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
598a1272
Commit
598a1272
authored
Jan 29, 2001
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call _bt_fixroot() from _bt_insertonpg.
parent
72401a44
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
5 deletions
+60
-5
src/backend/access/nbtree/nbtinsert.c
src/backend/access/nbtree/nbtinsert.c
+58
-4
src/backend/access/nbtree/nbtpage.c
src/backend/access/nbtree/nbtpage.c
+2
-1
No files found.
src/backend/access/nbtree/nbtinsert.c
View file @
598a1272
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.7
7 2001/01/26 01:24:31
vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.7
8 2001/01/29 07:28:16
vadim Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -34,7 +34,10 @@ typedef struct
...
@@ -34,7 +34,10 @@ typedef struct
int
best_delta
;
/* best size delta so far */
int
best_delta
;
/* best size delta so far */
}
FindSplitData
;
}
FindSplitData
;
extern
bool
FixBTree
;
Buffer
_bt_fixroot
(
Relation
rel
,
Buffer
oldrootbuf
,
bool
release
);
Buffer
_bt_fixroot
(
Relation
rel
,
Buffer
oldrootbuf
,
bool
release
);
static
void
_bt_fixtree
(
Relation
rel
,
BlockNumber
blkno
,
BTStack
stack
);
static
Buffer
_bt_newroot
(
Relation
rel
,
Buffer
lbuf
,
Buffer
rbuf
);
static
Buffer
_bt_newroot
(
Relation
rel
,
Buffer
lbuf
,
Buffer
rbuf
);
...
@@ -477,10 +480,55 @@ _bt_insertonpg(Relation rel,
...
@@ -477,10 +480,55 @@ _bt_insertonpg(Relation rel,
BTItem
ritem
;
BTItem
ritem
;
Buffer
pbuf
;
Buffer
pbuf
;
/*
Set up a phony stack entry if we haven't got a real one
*/
/*
If root page was splitted
*/
if
(
stack
==
(
BTStack
)
NULL
)
if
(
stack
==
(
BTStack
)
NULL
)
{
{
elog
(
DEBUG
,
"btree: concurrent ROOT page split"
);
elog
(
DEBUG
,
"btree: concurrent ROOT page split"
);
/*
* If root page splitter failed to create new root page
* then old root' btpo_parent still points to metapage.
* We have to fix root page in this case.
*/
if
(
lpageop
->
btpo_parent
==
BTREE_METAPAGE
)
{
if
(
!
FixBTree
)
elog
(
ERROR
,
"bt_insertonpg: no root page found"
);
_bt_wrtbuf
(
rel
,
rbuf
);
_bt_wrtnorelbuf
(
rel
,
buf
);
while
(
!
P_LEFTMOST
(
lpageop
))
{
BlockNumber
blkno
=
lpageop
->
btpo_prev
;
LockBuffer
(
buf
,
BUFFER_LOCK_UNLOCK
);
ReleaseBuffer
(
buf
);
buf
=
_bt_getbuf
(
rel
,
blkno
,
BT_WRITE
);
page
=
BufferGetPage
(
buf
);
lpageop
=
(
BTPageOpaque
)
PageGetSpecialPointer
(
page
);
/*
* If someone else already created parent pages
* then it's time for _bt_fixtree() to check upper
* levels and fix them, if required.
*/
if
(
lpageop
->
btpo_parent
!=
BTREE_METAPAGE
)
{
blkno
=
lpageop
->
btpo_parent
;
_bt_relbuf
(
rel
,
buf
,
BT_WRITE
);
_bt_fixtree
(
rel
,
blkno
,
NULL
);
goto
formres
;
}
}
/*
* Ok, we are on the leftmost page, it's write locked
* by us and its btpo_parent points to meta page - time
* for _bt_fixroot().
*/
buf
=
_bt_fixroot
(
rel
,
buf
,
true
);
_bt_relbuf
(
rel
,
buf
,
BT_WRITE
);
goto
formres
;
}
/*
* Set up a phony stack entry if we haven't got a real one
*/
stack
=
&
fakestack
;
stack
=
&
fakestack
;
stack
->
bts_blkno
=
lpageop
->
btpo_parent
;
stack
->
bts_blkno
=
lpageop
->
btpo_parent
;
stack
->
bts_offset
=
InvalidOffsetNumber
;
stack
->
bts_offset
=
InvalidOffsetNumber
;
...
@@ -537,6 +585,7 @@ _bt_insertonpg(Relation rel,
...
@@ -537,6 +585,7 @@ _bt_insertonpg(Relation rel,
_bt_wrtbuf
(
rel
,
buf
);
_bt_wrtbuf
(
rel
,
buf
);
}
}
formres:
;
/* by here, the new tuple is inserted at itup_blkno/itup_off */
/* by here, the new tuple is inserted at itup_blkno/itup_off */
res
=
(
InsertIndexResult
)
palloc
(
sizeof
(
InsertIndexResultData
));
res
=
(
InsertIndexResult
)
palloc
(
sizeof
(
InsertIndexResultData
));
ItemPointerSet
(
&
(
res
->
pointerData
),
itup_blkno
,
itup_off
);
ItemPointerSet
(
&
(
res
->
pointerData
),
itup_blkno
,
itup_off
);
...
@@ -1414,8 +1463,7 @@ _bt_fixroot(Relation rel, Buffer oldrootbuf, bool release)
...
@@ -1414,8 +1463,7 @@ _bt_fixroot(Relation rel, Buffer oldrootbuf, bool release)
* created with _bt_newroot() - rootbuf, - and buf we've used
* created with _bt_newroot() - rootbuf, - and buf we've used
* for last insert ops - buf. If rootbuf != buf then we have to
* for last insert ops - buf. If rootbuf != buf then we have to
* create at least one more level. And if "release" is TRUE
* create at least one more level. And if "release" is TRUE
* (ie we've already created some levels) then we give up
* then we give up oldrootbuf.
* oldrootbuf.
*/
*/
if
(
release
)
if
(
release
)
_bt_relbuf
(
rel
,
oldrootbuf
,
BT_WRITE
);
_bt_relbuf
(
rel
,
oldrootbuf
,
BT_WRITE
);
...
@@ -1429,6 +1477,12 @@ _bt_fixroot(Relation rel, Buffer oldrootbuf, bool release)
...
@@ -1429,6 +1477,12 @@ _bt_fixroot(Relation rel, Buffer oldrootbuf, bool release)
return
(
rootbuf
);
return
(
rootbuf
);
}
}
static
void
_bt_fixtree
(
Relation
rel
,
BlockNumber
blkno
,
BTStack
stack
)
{
elog
(
ERROR
,
"bt_fixtree: unimplemented , yet"
);
}
/*
/*
* _bt_pgaddtup() -- add a tuple to a particular page in the index.
* _bt_pgaddtup() -- add a tuple to a particular page in the index.
*
*
...
...
src/backend/access/nbtree/nbtpage.c
View file @
598a1272
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.4
8 2001/01/26 01:24:31
vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.4
9 2001/01/29 07:28:17
vadim Exp $
*
*
* NOTES
* NOTES
* Postgres btree pages look like ordinary relation pages. The opaque
* Postgres btree pages look like ordinary relation pages. The opaque
...
@@ -257,6 +257,7 @@ check_parent:;
...
@@ -257,6 +257,7 @@ check_parent:;
/* handle concurrent fix of root page */
/* handle concurrent fix of root page */
if
(
rootopaque
->
btpo_parent
==
BTREE_METAPAGE
)
/* unupdated! */
if
(
rootopaque
->
btpo_parent
==
BTREE_METAPAGE
)
/* unupdated! */
{
{
elog
(
NOTICE
,
"bt_getroot: fixing root page"
);
newrootbuf
=
_bt_fixroot
(
rel
,
rootbuf
,
true
);
newrootbuf
=
_bt_fixroot
(
rel
,
rootbuf
,
true
);
LockBuffer
(
newrootbuf
,
BUFFER_LOCK_UNLOCK
);
LockBuffer
(
newrootbuf
,
BUFFER_LOCK_UNLOCK
);
LockBuffer
(
newrootbuf
,
BT_READ
);
LockBuffer
(
newrootbuf
,
BT_READ
);
...
...
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