Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
4e064c05
Commit
4e064c05
authored
Dec 06, 1996
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
_bt_updateitem is returned in code, but works only if sizes of keys
are equal.
parent
c3e10a4c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
50 deletions
+76
-50
src/backend/access/nbtree/nbtinsert.c
src/backend/access/nbtree/nbtinsert.c
+76
-50
No files found.
src/backend/access/nbtree/nbtinsert.c
View file @
4e064c05
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.
7 1996/11/13 20:47:11 scrappy
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.
8 1996/12/06 09:45:30 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -31,10 +31,7 @@ static OffsetNumber _bt_findsplitloc(Relation rel, Page page, OffsetNumber start
static
void
_bt_newroot
(
Relation
rel
,
Buffer
lbuf
,
Buffer
rbuf
);
static
OffsetNumber
_bt_pgaddtup
(
Relation
rel
,
Buffer
buf
,
int
keysz
,
ScanKey
itup_scankey
,
Size
itemsize
,
BTItem
btitem
,
BTItem
afteritem
);
static
bool
_bt_goesonpg
(
Relation
rel
,
Buffer
buf
,
Size
keysz
,
ScanKey
scankey
,
BTItem
afteritem
);
#if 0
static
void
_bt_updateitem
(
Relation
rel
,
Size
keysz
,
Buffer
buf
,
Oid
bti_oid
,
BTItem
newItem
);
#endif
/*
* _bt_doinsert() -- Handle insertion of a single btitem in the tree.
...
...
@@ -265,6 +262,8 @@ _bt_insertonpg(Relation rel,
if
(
_bt_itemcmp
(
rel
,
keysz
,
stack
->
bts_btitem
,
new_item
,
BTGreaterStrategyNumber
))
{
ppageop
=
(
BTPageOpaque
)
PageGetSpecialPointer
(
page
);
Assert
(
P_LEFTMOST
(
ppageop
));
lowLeftItem
=
(
BTItem
)
PageGetItem
(
page
,
PageGetItemId
(
page
,
P_FIRSTKEY
));
...
...
@@ -278,56 +277,80 @@ _bt_insertonpg(Relation rel,
/* because it's bigger than what was there before). */
/* --djm 8/21/96 */
/* _bt_updateitem(rel, keysz, pbuf, stack->bts_btitem->bti_oid,
lowLeftItem); */
/* get the parent page */
ppage
=
BufferGetPage
(
pbuf
);
ppageop
=
(
BTPageOpaque
)
PageGetSpecialPointer
(
ppage
);
/*
* but it works for items with the same size and so why don't
* use it for them ? - vadim 12/05/96
*/
if
(
DOUBLEALIGN
(
IndexTupleDSize
(
lowLeftItem
->
bti_itup
))
==
DOUBLEALIGN
(
IndexTupleDSize
(
stack
->
bts_btitem
->
bti_itup
))
)
{
_bt_updateitem
(
rel
,
keysz
,
pbuf
,
stack
->
bts_btitem
->
bti_oid
,
lowLeftItem
);
_bt_relbuf
(
rel
,
buf
,
BT_WRITE
);
_bt_relbuf
(
rel
,
rbuf
,
BT_WRITE
);
}
else
{
/* get the parent page */
ppage
=
BufferGetPage
(
pbuf
);
ppageop
=
(
BTPageOpaque
)
PageGetSpecialPointer
(
ppage
);
/* figure out which key is leftmost (if the parent page */
/* is rightmost, too, it must be the root) */
if
(
P_RIGHTMOST
(
ppageop
))
{
leftmost_offset
=
P_HIKEY
;
}
else
{
leftmost_offset
=
P_FIRSTKEY
;
}
PageIndexTupleDelete
(
ppage
,
leftmost_offset
);
/*
* figure out which key is leftmost (if the parent page
* is rightmost, too, it must be the root)
*/
if
(
P_RIGHTMOST
(
ppageop
))
{
leftmost_offset
=
P_HIKEY
;
}
else
{
leftmost_offset
=
P_FIRSTKEY
;
}
PageIndexTupleDelete
(
ppage
,
leftmost_offset
);
/* don't write anything out yet--we still have the write */
/* lock, and now we call another _bt_insertonpg to */
/* insert the correct leftmost key */
/*
* don't write anything out yet--we still have the write
* lock, and now we call another _bt_insertonpg to
* insert the correct leftmost key
*/
/* make a new leftmost item, using the tuple data from */
/* lowLeftItem. point it to the left child. */
/* update it on the stack at the same time. */
bknum
=
BufferGetBlockNumber
(
buf
);
pfree
(
stack
->
bts_btitem
);
stack
->
bts_btitem
=
_bt_formitem
(
&
(
lowLeftItem
->
bti_itup
));
ItemPointerSet
(
&
(
stack
->
bts_btitem
->
bti_itup
.
t_tid
),
/*
* make a new leftmost item, using the tuple data from
* lowLeftItem. point it to the left child.
* update it on the stack at the same time.
*/
bknum
=
BufferGetBlockNumber
(
buf
);
pfree
(
stack
->
bts_btitem
);
stack
->
bts_btitem
=
_bt_formitem
(
&
(
lowLeftItem
->
bti_itup
));
ItemPointerSet
(
&
(
stack
->
bts_btitem
->
bti_itup
.
t_tid
),
bknum
,
P_HIKEY
);
/* unlock the children before doing this */
_bt_relbuf
(
rel
,
buf
,
BT_WRITE
);
_bt_relbuf
(
rel
,
rbuf
,
BT_WRITE
);
/* unlock the children before doing this */
_bt_relbuf
(
rel
,
buf
,
BT_WRITE
);
_bt_relbuf
(
rel
,
rbuf
,
BT_WRITE
);
/* a regular _bt_binsrch should find the right place to */
/* put the new entry, since it should be lower than any */
/* other key on the page, therefore set afteritem to NULL */
newskey
=
_bt_mkscankey
(
rel
,
&
(
stack
->
bts_btitem
->
bti_itup
));
newres
=
_bt_insertonpg
(
rel
,
pbuf
,
stack
->
bts_parent
,
/*
* a regular _bt_binsrch should find the right place to
* put the new entry, since it should be lower than any
* other key on the page, therefore set afteritem to NULL
*/
newskey
=
_bt_mkscankey
(
rel
,
&
(
stack
->
bts_btitem
->
bti_itup
));
newres
=
_bt_insertonpg
(
rel
,
pbuf
,
stack
->
bts_parent
,
keysz
,
newskey
,
stack
->
bts_btitem
,
NULL
);
pfree
(
newres
);
pfree
(
newskey
);
pfree
(
newres
);
pfree
(
newskey
);
/* we have now lost our lock on the parent buffer, and */
/* need to get it back. */
pbuf
=
_bt_getstackbuf
(
rel
,
stack
,
BT_WRITE
);
}
else
{
_bt_relbuf
(
rel
,
buf
,
BT_WRITE
);
_bt_relbuf
(
rel
,
rbuf
,
BT_WRITE
);
/*
* we have now lost our lock on the parent buffer, and
* need to get it back.
*/
pbuf
=
_bt_getstackbuf
(
rel
,
stack
,
BT_WRITE
);
}
}
else
{
_bt_relbuf
(
rel
,
buf
,
BT_WRITE
);
_bt_relbuf
(
rel
,
rbuf
,
BT_WRITE
);
}
newskey
=
_bt_mkscankey
(
rel
,
&
(
new_item
->
bti_itup
));
...
...
@@ -872,8 +895,6 @@ _bt_itemcmp(Relation rel,
return
(
true
);
}
#if 0
/* gone since updating in place doesn't work in general --djm 11/13/96 */
/*
* _bt_updateitem() -- updates the key of the item identified by the
* oid with the key of newItem (done in place if
...
...
@@ -912,18 +933,23 @@ _bt_updateitem(Relation rel,
elog
(
FATAL
,
"_bt_getstackbuf was lying!!"
);
}
/*
* It's defined by caller (_bt_insertonpg)
*/
/*
if(IndexTupleDSize(newItem->bti_itup) >
IndexTupleDSize(item->bti_itup)) {
elog(NOTICE, "trying to overwrite a smaller value with a bigger one in _bt_updateitem");
elog(WARN, "this is not good.");
}
*/
oldIndexTuple
=
&
(
item
->
bti_itup
);
newIndexTuple
=
&
(
newItem
->
bti_itup
);
/* keep the original item pointer */
ItemPointerCopy(&(oldIndexTuple->t_tid), &itemPtrData);
CopyIndexTuple(newIndexTuple, &oldIndexTuple);
ItemPointerCopy(&itemPtrData, &(oldIndexTuple->t_tid));
ItemPointerCopy
(
&
(
oldIndexTuple
->
t_tid
),
&
itemPtrData
);
CopyIndexTuple
(
newIndexTuple
,
&
oldIndexTuple
);
ItemPointerCopy
(
&
itemPtrData
,
&
(
oldIndexTuple
->
t_tid
));
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment