Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
716d506a
Commit
716d506a
authored
28 years ago
by
Marc G. Fournier
Browse files
Options
Downloads
Patches
Plain Diff
Make sure the btree patch gets into 2.0 as well...
Still submitted by: Massimo Dal Zotto <dz@cs.unitn.it>
parent
e18d49d8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/access/nbtree/nbtinsert.c
+50
-9
50 additions, 9 deletions
src/backend/access/nbtree/nbtinsert.c
with
50 additions
and
9 deletions
src/backend/access/nbtree/nbtinsert.c
+
50
−
9
View file @
716d506a
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.
3
1996/10/2
3
0
7:39:00
scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.
4
1996/10/2
5
0
9:55:36
scrappy Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -815,7 +815,8 @@ _bt_itemcmp(Relation rel,
...
@@ -815,7 +815,8 @@ _bt_itemcmp(Relation rel,
/*
/*
* _bt_updateitem() -- updates the key of the item identified by the
* _bt_updateitem() -- updates the key of the item identified by the
* oid with the key of newItem (done in place)
* oid with the key of newItem (done in place if
* possible)
*
*
*/
*/
static
void
static
void
...
@@ -829,14 +830,17 @@ _bt_updateitem(Relation rel,
...
@@ -829,14 +830,17 @@ _bt_updateitem(Relation rel,
OffsetNumber
maxoff
;
OffsetNumber
maxoff
;
OffsetNumber
i
;
OffsetNumber
i
;
ItemPointerData
itemPtrData
;
ItemPointerData
itemPtrData
;
BTItem
item
;
BTItem
item
,
itemCopy
;
IndexTuple
oldIndexTuple
,
newIndexTuple
;
IndexTuple
oldIndexTuple
,
newIndexTuple
;
int
newSize
,
oldSize
,
first
;
page
=
BufferGetPage
(
buf
);
page
=
BufferGetPage
(
buf
);
maxoff
=
PageGetMaxOffsetNumber
(
page
);
maxoff
=
PageGetMaxOffsetNumber
(
page
);
/* locate item on the page */
/* locate item on the page */
i
=
P_HIKEY
;
first
=
P_RIGHTMOST
((
BTPageOpaque
)
PageGetSpecialPointer
(
page
))
\
?
P_HIKEY
:
P_FIRSTKEY
;
i
=
first
;
do
{
do
{
item
=
(
BTItem
)
PageGetItem
(
page
,
PageGetItemId
(
page
,
i
));
item
=
(
BTItem
)
PageGetItem
(
page
,
PageGetItemId
(
page
,
i
));
i
=
OffsetNumberNext
(
i
);
i
=
OffsetNumberNext
(
i
);
...
@@ -849,9 +853,46 @@ _bt_updateitem(Relation rel,
...
@@ -849,9 +853,46 @@ _bt_updateitem(Relation rel,
oldIndexTuple
=
&
(
item
->
bti_itup
);
oldIndexTuple
=
&
(
item
->
bti_itup
);
newIndexTuple
=
&
(
newItem
->
bti_itup
);
newIndexTuple
=
&
(
newItem
->
bti_itup
);
oldSize
=
DOUBLEALIGN
(
IndexTupleSize
(
oldIndexTuple
));
/* keep the original item pointer */
newSize
=
DOUBLEALIGN
(
IndexTupleSize
(
newIndexTuple
));
ItemPointerCopy
(
&
(
oldIndexTuple
->
t_tid
),
&
itemPtrData
);
#ifdef NBTINSERT_PATCH_DEBUG
CopyIndexTuple
(
newIndexTuple
,
&
oldIndexTuple
);
printf
(
"_bt_updateitem: newSize=%d, oldSize=%d
\n
"
,
newSize
,
oldSize
);
ItemPointerCopy
(
&
itemPtrData
,
&
(
oldIndexTuple
->
t_tid
));
#endif
/*
* If new and old item have the same size do the update in place
* and return.
*/
if
(
oldSize
==
newSize
)
{
/* keep the original item pointer */
ItemPointerCopy
(
&
(
oldIndexTuple
->
t_tid
),
&
itemPtrData
);
CopyIndexTuple
(
newIndexTuple
,
&
oldIndexTuple
);
ItemPointerCopy
(
&
itemPtrData
,
&
(
oldIndexTuple
->
t_tid
));
return
;
}
/*
* If new and old items have different size the update in place
* is not possible. In this case the old item is deleted and the
* new one is inserted.
* The new insertion should be done using _bt_insertonpg which
* would also takes care of the page splitting if needed, but
* unfortunately it doesn't work, so PageAddItem is used instead.
* There is the possibility that there is not enough space in the
* page and the item is not inserted.
*/
itemCopy
=
palloc
(
newSize
);
memmove
((
char
*
)
itemCopy
,
(
char
*
)
newItem
,
newSize
);
itemCopy
->
bti_oid
=
item
->
bti_oid
;
newIndexTuple
=
&
(
itemCopy
->
bti_itup
);
ItemPointerCopy
(
&
(
oldIndexTuple
->
t_tid
),
&
(
newIndexTuple
->
t_tid
));
/*
* Get the offset number of the item then delete it and insert
* the new item in the same place.
*/
i
=
OffsetNumberPrev
(
i
);
PageIndexTupleDelete
(
page
,
i
);
PageAddItem
(
page
,
(
Item
)
itemCopy
,
newSize
,
i
,
LP_USED
);
pfree
(
itemCopy
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment