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
2a0caefe
Commit
2a0caefe
authored
Dec 21, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Previous change exposed some opportunities for further simplification
in _bt_first().
parent
569659ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
37 deletions
+11
-37
src/backend/access/nbtree/nbtsearch.c
src/backend/access/nbtree/nbtsearch.c
+11
-37
No files found.
src/backend/access/nbtree/nbtsearch.c
View file @
2a0caefe
...
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.8
4 2003/12/21 01:23:06
tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.8
5 2003/12/21 03:00:04
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -495,10 +495,9 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
BlockNumber
blkno
;
StrategyNumber
strat
;
bool
res
;
int32
result
;
bool
nextkey
;
bool
continuescan
;
ScanKey
scankeys
=
NULL
;
ScanKey
scankeys
;
ScanKey
*
startKeys
=
NULL
;
int
keysCount
=
0
;
int
i
;
...
...
@@ -695,8 +694,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
pfree
(
startKeys
);
current
=
&
(
scan
->
currentItemData
);
/*
* We want to locate either the first item >= boundary point, or
* first item > boundary point, depending on the initial-positioning
...
...
@@ -746,6 +743,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
/* don't need to keep the stack around... */
_bt_freestack
(
stack
);
current
=
&
(
scan
->
currentItemData
);
if
(
!
BufferIsValid
(
buf
))
{
/* Only get here if index is completely empty */
...
...
@@ -765,6 +764,9 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
ItemPointerSet
(
current
,
blkno
,
offnum
);
/* done with manufactured scankey, now */
pfree
(
scankeys
);
/*
* It's now time to examine the initial-positioning strategy to find the
* exact place to start the scan.
...
...
@@ -802,10 +804,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
* that is always the correct starting position.)
*/
if
(
!
_bt_step
(
scan
,
&
buf
,
BackwardScanDirection
))
{
pfree
(
scankeys
);
return
false
;
}
break
;
case
BTLessEqualStrategyNumber
:
...
...
@@ -818,10 +817,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
* that is always the correct starting position.)
*/
if
(
!
_bt_step
(
scan
,
&
buf
,
BackwardScanDirection
))
{
pfree
(
scankeys
);
return
false
;
}
break
;
case
BTEqualStrategyNumber
:
...
...
@@ -834,14 +830,11 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
/*
* We are on first item > scankey.
*
* Back up one to arrive at last item <= scankey
, then
*
check
to see if it is equal to scankey.
* Back up one to arrive at last item <= scankey
.
*
We will check below
to see if it is equal to scankey.
*/
if
(
!
_bt_step
(
scan
,
&
buf
,
BackwardScanDirection
))
{
pfree
(
scankeys
);
return
false
;
}
}
else
{
...
...
@@ -849,25 +842,15 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
* We are on first item >= scankey.
*
* Make sure we are on a real item; might have to
* step forward if currently at end of page.
Then check
* to see if it is equal to scankey.
* step forward if currently at end of page.
*
We will check below
to see if it is equal to scankey.
*/
if
(
offnum
>
PageGetMaxOffsetNumber
(
page
))
{
if
(
!
_bt_step
(
scan
,
&
buf
,
ForwardScanDirection
))
{
pfree
(
scankeys
);
return
false
;
}
}
}
/* If we are not now on an equal item, then there ain't any. */
offnum
=
ItemPointerGetOffsetNumber
(
current
);
page
=
BufferGetPage
(
buf
);
result
=
_bt_compare
(
rel
,
keysCount
,
scankeys
,
page
,
offnum
);
if
(
result
!=
0
)
goto
nomatches
;
/* no equal items! */
break
;
case
BTGreaterEqualStrategyNumber
:
...
...
@@ -879,10 +862,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
if
(
offnum
>
PageGetMaxOffsetNumber
(
page
))
{
if
(
!
_bt_step
(
scan
,
&
buf
,
ForwardScanDirection
))
{
pfree
(
scankeys
);
return
false
;
}
}
break
;
...
...
@@ -895,10 +875,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
if
(
offnum
>
PageGetMaxOffsetNumber
(
page
))
{
if
(
!
_bt_step
(
scan
,
&
buf
,
ForwardScanDirection
))
{
pfree
(
scankeys
);
return
false
;
}
}
break
;
}
...
...
@@ -924,15 +901,12 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
else
{
/* no tuples in the index match this scan key */
nomatches:
ItemPointerSetInvalid
(
current
);
so
->
btso_curbuf
=
InvalidBuffer
;
_bt_relbuf
(
rel
,
buf
);
res
=
false
;
}
pfree
(
scankeys
);
return
res
;
}
...
...
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