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
b3364fc8
Commit
b3364fc8
authored
Sep 22, 2005
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pgindent new GIST index code, per request from Tom.
parent
08817bdb
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1542 additions
and
1205 deletions
+1542
-1205
src/backend/access/gist/gist.c
src/backend/access/gist/gist.c
+468
-352
src/backend/access/gist/gistget.c
src/backend/access/gist/gistget.c
+133
-117
src/backend/access/gist/gistproc.c
src/backend/access/gist/gistproc.c
+36
-36
src/backend/access/gist/gistscan.c
src/backend/access/gist/gistscan.c
+18
-17
src/backend/access/gist/gistutil.c
src/backend/access/gist/gistutil.c
+67
-58
src/backend/access/gist/gistvacuum.c
src/backend/access/gist/gistvacuum.c
+319
-229
src/backend/access/gist/gistxlog.c
src/backend/access/gist/gistxlog.c
+501
-396
No files found.
src/backend/access/gist/gist.c
View file @
b3364fc8
This diff is collapsed.
Click to expand it.
src/backend/access/gist/gistget.c
View file @
b3364fc8
This diff is collapsed.
Click to expand it.
src/backend/access/gist/gistproc.c
View file @
b3364fc8
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gist/gistproc.c,v 1.
1 2005/07/01 19:19:02 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/access/gist/gistproc.c,v 1.
2 2005/09/22 20:44:36 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -30,10 +30,10 @@ typedef struct
...
@@ -30,10 +30,10 @@ typedef struct
static
int
compare_KB
(
const
void
*
a
,
const
void
*
b
);
static
int
compare_KB
(
const
void
*
a
,
const
void
*
b
);
static
bool
gist_box_leaf_consistent
(
BOX
*
key
,
BOX
*
query
,
static
bool
gist_box_leaf_consistent
(
BOX
*
key
,
BOX
*
query
,
StrategyNumber
strategy
);
StrategyNumber
strategy
);
static
double
size_box
(
Datum
dbox
);
static
double
size_box
(
Datum
dbox
);
static
bool
rtree_internal_consistent
(
BOX
*
key
,
BOX
*
query
,
static
bool
rtree_internal_consistent
(
BOX
*
key
,
BOX
*
query
,
StrategyNumber
strategy
);
StrategyNumber
strategy
);
/**************************************************
/**************************************************
...
@@ -268,11 +268,11 @@ gist_box_picksplit(PG_FUNCTION_ARGS)
...
@@ -268,11 +268,11 @@ gist_box_picksplit(PG_FUNCTION_ARGS)
#define ADDLIST( list, unionD, pos, num ) do { \
#define ADDLIST( list, unionD, pos, num ) do { \
if ( pos ) { \
if ( pos ) { \
if ( (unionD)->high.x < cur->high.x ) (unionD)->high.x = cur->high.x; \
if ( (unionD)->high.x < cur->high.x ) (unionD)->high.x = cur->high.x; \
if ( (unionD)->low.x > cur->low.x
) (unionD)->low.x = cur->low.x; \
if ( (unionD)->low.x > cur->low.x
) (unionD)->low.x = cur->low.x; \
if ( (unionD)->high.y < cur->high.y ) (unionD)->high.y = cur->high.y; \
if ( (unionD)->high.y < cur->high.y ) (unionD)->high.y = cur->high.y; \
if ( (unionD)->low.y > cur->low.y
) (unionD)->low.y = cur->low.y; \
if ( (unionD)->low.y > cur->low.y
) (unionD)->low.y = cur->low.y; \
} else { \
} else { \
memcpy( (void*)(unionD), (void*) cur, sizeof( BOX ) );
\
memcpy( (void*)(unionD), (void*) cur, sizeof( BOX ) );
\
} \
} \
(list)[pos] = num; \
(list)[pos] = num; \
(pos)++; \
(pos)++; \
...
@@ -411,62 +411,62 @@ gist_box_leaf_consistent(BOX *key, BOX *query, StrategyNumber strategy)
...
@@ -411,62 +411,62 @@ gist_box_leaf_consistent(BOX *key, BOX *query, StrategyNumber strategy)
case
RTLeftStrategyNumber
:
case
RTLeftStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_left
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_left
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTOverLeftStrategyNumber
:
case
RTOverLeftStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overleft
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overleft
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTOverlapStrategyNumber
:
case
RTOverlapStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overlap
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overlap
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTOverRightStrategyNumber
:
case
RTOverRightStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overright
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overright
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTRightStrategyNumber
:
case
RTRightStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_right
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_right
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTSameStrategyNumber
:
case
RTSameStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_same
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_same
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTContainsStrategyNumber
:
case
RTContainsStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_contain
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_contain
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTContainedByStrategyNumber
:
case
RTContainedByStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_contained
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_contained
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTOverBelowStrategyNumber
:
case
RTOverBelowStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overbelow
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overbelow
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTBelowStrategyNumber
:
case
RTBelowStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_below
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_below
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTAboveStrategyNumber
:
case
RTAboveStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_above
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_above
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTOverAboveStrategyNumber
:
case
RTOverAboveStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overabove
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overabove
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
default:
default:
retval
=
FALSE
;
retval
=
FALSE
;
...
@@ -477,7 +477,7 @@ gist_box_leaf_consistent(BOX *key, BOX *query, StrategyNumber strategy)
...
@@ -477,7 +477,7 @@ gist_box_leaf_consistent(BOX *key, BOX *query, StrategyNumber strategy)
static
double
static
double
size_box
(
Datum
dbox
)
size_box
(
Datum
dbox
)
{
{
BOX
*
box
=
DatumGetBoxP
(
dbox
);
BOX
*
box
=
DatumGetBoxP
(
dbox
);
if
(
box
==
NULL
||
box
->
high
.
x
<=
box
->
low
.
x
||
box
->
high
.
y
<=
box
->
low
.
y
)
if
(
box
==
NULL
||
box
->
high
.
x
<=
box
->
low
.
x
||
box
->
high
.
y
<=
box
->
low
.
y
)
return
0
.
0
;
return
0
.
0
;
...
@@ -506,58 +506,58 @@ rtree_internal_consistent(BOX *key, BOX *query, StrategyNumber strategy)
...
@@ -506,58 +506,58 @@ rtree_internal_consistent(BOX *key, BOX *query, StrategyNumber strategy)
case
RTLeftStrategyNumber
:
case
RTLeftStrategyNumber
:
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_overright
,
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_overright
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTOverLeftStrategyNumber
:
case
RTOverLeftStrategyNumber
:
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_right
,
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_right
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTOverlapStrategyNumber
:
case
RTOverlapStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overlap
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overlap
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTOverRightStrategyNumber
:
case
RTOverRightStrategyNumber
:
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_left
,
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_left
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTRightStrategyNumber
:
case
RTRightStrategyNumber
:
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_overleft
,
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_overleft
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTSameStrategyNumber
:
case
RTSameStrategyNumber
:
case
RTContainsStrategyNumber
:
case
RTContainsStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_contain
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_contain
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTContainedByStrategyNumber
:
case
RTContainedByStrategyNumber
:
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overlap
,
retval
=
DatumGetBool
(
DirectFunctionCall2
(
box_overlap
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTOverBelowStrategyNumber
:
case
RTOverBelowStrategyNumber
:
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_above
,
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_above
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTBelowStrategyNumber
:
case
RTBelowStrategyNumber
:
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_overabove
,
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_overabove
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTAboveStrategyNumber
:
case
RTAboveStrategyNumber
:
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_overbelow
,
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_overbelow
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
case
RTOverAboveStrategyNumber
:
case
RTOverAboveStrategyNumber
:
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_below
,
retval
=
!
DatumGetBool
(
DirectFunctionCall2
(
box_below
,
PointerGetDatum
(
key
),
PointerGetDatum
(
key
),
PointerGetDatum
(
query
)));
PointerGetDatum
(
query
)));
break
;
break
;
default:
default:
retval
=
FALSE
;
retval
=
FALSE
;
...
@@ -621,8 +621,8 @@ gist_poly_consistent(PG_FUNCTION_ARGS)
...
@@ -621,8 +621,8 @@ gist_poly_consistent(PG_FUNCTION_ARGS)
/*
/*
* Since the operators are marked lossy anyway, we can just use
* Since the operators are marked lossy anyway, we can just use
* rtree_internal_consistent even at leaf nodes. (This works
* rtree_internal_consistent even at leaf nodes. (This works
in part
*
in part
because the index entries are bounding boxes not polygons.)
* because the index entries are bounding boxes not polygons.)
*/
*/
result
=
rtree_internal_consistent
(
DatumGetBoxP
(
entry
->
key
),
result
=
rtree_internal_consistent
(
DatumGetBoxP
(
entry
->
key
),
&
(
query
->
boundbox
),
strategy
);
&
(
query
->
boundbox
),
strategy
);
...
@@ -651,7 +651,7 @@ gist_circle_compress(PG_FUNCTION_ARGS)
...
@@ -651,7 +651,7 @@ gist_circle_compress(PG_FUNCTION_ARGS)
retval
=
palloc
(
sizeof
(
GISTENTRY
));
retval
=
palloc
(
sizeof
(
GISTENTRY
));
if
(
DatumGetCircleP
(
entry
->
key
)
!=
NULL
)
if
(
DatumGetCircleP
(
entry
->
key
)
!=
NULL
)
{
{
CIRCLE
*
in
=
DatumGetCircleP
(
entry
->
key
);
CIRCLE
*
in
=
DatumGetCircleP
(
entry
->
key
);
BOX
*
r
;
BOX
*
r
;
r
=
(
BOX
*
)
palloc
(
sizeof
(
BOX
));
r
=
(
BOX
*
)
palloc
(
sizeof
(
BOX
));
...
@@ -683,7 +683,7 @@ Datum
...
@@ -683,7 +683,7 @@ Datum
gist_circle_consistent
(
PG_FUNCTION_ARGS
)
gist_circle_consistent
(
PG_FUNCTION_ARGS
)
{
{
GISTENTRY
*
entry
=
(
GISTENTRY
*
)
PG_GETARG_POINTER
(
0
);
GISTENTRY
*
entry
=
(
GISTENTRY
*
)
PG_GETARG_POINTER
(
0
);
CIRCLE
*
query
=
PG_GETARG_CIRCLE_P
(
1
);
CIRCLE
*
query
=
PG_GETARG_CIRCLE_P
(
1
);
StrategyNumber
strategy
=
(
StrategyNumber
)
PG_GETARG_UINT16
(
2
);
StrategyNumber
strategy
=
(
StrategyNumber
)
PG_GETARG_UINT16
(
2
);
BOX
bbox
;
BOX
bbox
;
bool
result
;
bool
result
;
...
@@ -693,8 +693,8 @@ gist_circle_consistent(PG_FUNCTION_ARGS)
...
@@ -693,8 +693,8 @@ gist_circle_consistent(PG_FUNCTION_ARGS)
/*
/*
* Since the operators are marked lossy anyway, we can just use
* Since the operators are marked lossy anyway, we can just use
* rtree_internal_consistent even at leaf nodes. (This works
* rtree_internal_consistent even at leaf nodes. (This works
in part
*
in part
because the index entries are bounding boxes not circles.)
* because the index entries are bounding boxes not circles.)
*/
*/
bbox
.
high
.
x
=
query
->
center
.
x
+
query
->
radius
;
bbox
.
high
.
x
=
query
->
center
.
x
+
query
->
radius
;
bbox
.
low
.
x
=
query
->
center
.
x
-
query
->
radius
;
bbox
.
low
.
x
=
query
->
center
.
x
-
query
->
radius
;
...
...
src/backend/access/gist/gistscan.c
View file @
b3364fc8
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.6
0 2005/09/22 18:49:45 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.6
1 2005/09/22 20:44:36 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -120,11 +120,11 @@ gistrescan(PG_FUNCTION_ARGS)
...
@@ -120,11 +120,11 @@ gistrescan(PG_FUNCTION_ARGS)
scan
->
numberOfKeys
*
sizeof
(
ScanKeyData
));
scan
->
numberOfKeys
*
sizeof
(
ScanKeyData
));
/*
/*
* Modify the scan key so that all the Consistent method is
* Modify the scan key so that all the Consistent method is
called for
*
called for all comparisons. The original operator is passed
*
all comparisons. The original operator is passed to the Consistent
*
to the Consistent function in the form of its strategy
*
function in the form of its strategy number, which is available
*
number, which is available from the sk_strategy field, and
*
from the sk_strategy field, and its subtype from the sk_subtype
*
its subtype from the sk_subtype
field.
* field.
*/
*/
for
(
i
=
0
;
i
<
scan
->
numberOfKeys
;
i
++
)
for
(
i
=
0
;
i
<
scan
->
numberOfKeys
;
i
++
)
scan
->
keyData
[
i
].
sk_func
=
so
->
giststate
->
consistentFn
[
scan
->
keyData
[
i
].
sk_attno
-
1
];
scan
->
keyData
[
i
].
sk_func
=
so
->
giststate
->
consistentFn
[
scan
->
keyData
[
i
].
sk_attno
-
1
];
...
@@ -138,7 +138,7 @@ gistmarkpos(PG_FUNCTION_ARGS)
...
@@ -138,7 +138,7 @@ gistmarkpos(PG_FUNCTION_ARGS)
{
{
IndexScanDesc
scan
=
(
IndexScanDesc
)
PG_GETARG_POINTER
(
0
);
IndexScanDesc
scan
=
(
IndexScanDesc
)
PG_GETARG_POINTER
(
0
);
GISTScanOpaque
so
;
GISTScanOpaque
so
;
GISTSearchStack
*
o
,
GISTSearchStack
*
o
,
*
n
,
*
n
,
*
tmp
;
*
tmp
;
...
@@ -187,7 +187,7 @@ gistrestrpos(PG_FUNCTION_ARGS)
...
@@ -187,7 +187,7 @@ gistrestrpos(PG_FUNCTION_ARGS)
{
{
IndexScanDesc
scan
=
(
IndexScanDesc
)
PG_GETARG_POINTER
(
0
);
IndexScanDesc
scan
=
(
IndexScanDesc
)
PG_GETARG_POINTER
(
0
);
GISTScanOpaque
so
;
GISTScanOpaque
so
;
GISTSearchStack
*
o
,
GISTSearchStack
*
o
,
*
n
,
*
n
,
*
tmp
;
*
tmp
;
...
@@ -308,9 +308,9 @@ ReleaseResources_gist(void)
...
@@ -308,9 +308,9 @@ ReleaseResources_gist(void)
GISTScanList
next
;
GISTScanList
next
;
/*
/*
* Note: this should be a no-op during normal query shutdown. However,
* Note: this should be a no-op during normal query shutdown. However,
in
*
in an abort situation ExecutorEnd is not called and so there may be
*
an abort situation ExecutorEnd is not called and so there may be open
*
open
index scans to clean up.
* index scans to clean up.
*/
*/
prev
=
NULL
;
prev
=
NULL
;
...
@@ -338,8 +338,8 @@ gistadjscans(Relation rel, int op, BlockNumber blkno, OffsetNumber offnum, XLogR
...
@@ -338,8 +338,8 @@ gistadjscans(Relation rel, int op, BlockNumber blkno, OffsetNumber offnum, XLogR
GISTScanList
l
;
GISTScanList
l
;
Oid
relid
;
Oid
relid
;
if
(
XLogRecPtrIsInvalid
(
newlsn
)
||
XLogRecPtrIsInvalid
(
oldlsn
)
)
if
(
XLogRecPtrIsInvalid
(
newlsn
)
||
XLogRecPtrIsInvalid
(
oldlsn
)
)
return
;
return
;
relid
=
RelationGetRelid
(
rel
);
relid
=
RelationGetRelid
(
rel
);
for
(
l
=
GISTScans
;
l
!=
NULL
;
l
=
l
->
gsl_next
)
for
(
l
=
GISTScans
;
l
!=
NULL
;
l
=
l
->
gsl_next
)
...
@@ -365,7 +365,7 @@ gistadjone(IndexScanDesc scan,
...
@@ -365,7 +365,7 @@ gistadjone(IndexScanDesc scan,
BlockNumber
blkno
,
BlockNumber
blkno
,
OffsetNumber
offnum
,
XLogRecPtr
newlsn
,
XLogRecPtr
oldlsn
)
OffsetNumber
offnum
,
XLogRecPtr
newlsn
,
XLogRecPtr
oldlsn
)
{
{
GISTScanOpaque
so
=
(
GISTScanOpaque
)
scan
->
opaque
;
GISTScanOpaque
so
=
(
GISTScanOpaque
)
scan
->
opaque
;
adjustiptr
(
scan
,
&
(
scan
->
currentItemData
),
so
->
stack
,
op
,
blkno
,
offnum
,
newlsn
,
oldlsn
);
adjustiptr
(
scan
,
&
(
scan
->
currentItemData
),
so
->
stack
,
op
,
blkno
,
offnum
,
newlsn
,
oldlsn
);
adjustiptr
(
scan
,
&
(
scan
->
currentMarkData
),
so
->
markstk
,
op
,
blkno
,
offnum
,
newlsn
,
oldlsn
);
adjustiptr
(
scan
,
&
(
scan
->
currentMarkData
),
so
->
markstk
,
op
,
blkno
,
offnum
,
newlsn
,
oldlsn
);
...
@@ -399,7 +399,8 @@ adjustiptr(IndexScanDesc scan,
...
@@ -399,7 +399,8 @@ adjustiptr(IndexScanDesc scan,
{
{
case
GISTOP_DEL
:
case
GISTOP_DEL
:
/* back up one if we need to */
/* back up one if we need to */
if
(
curoff
>=
offnum
&&
XLByteEQ
(
stk
->
lsn
,
oldlsn
)
)
/* the same vesrion of page */
if
(
curoff
>=
offnum
&&
XLByteEQ
(
stk
->
lsn
,
oldlsn
))
/* the same vesrion of
* page */
{
{
if
(
curoff
>
FirstOffsetNumber
)
if
(
curoff
>
FirstOffsetNumber
)
{
{
...
@@ -409,8 +410,7 @@ adjustiptr(IndexScanDesc scan,
...
@@ -409,8 +410,7 @@ adjustiptr(IndexScanDesc scan,
else
else
{
{
/*
/*
* remember that we're before the current
* remember that we're before the current tuple
* tuple
*/
*/
ItemPointerSet
(
iptr
,
blkno
,
FirstOffsetNumber
);
ItemPointerSet
(
iptr
,
blkno
,
FirstOffsetNumber
);
if
(
iptr
==
&
(
scan
->
currentItemData
))
if
(
iptr
==
&
(
scan
->
currentItemData
))
...
@@ -435,6 +435,7 @@ gistfreestack(GISTSearchStack *s)
...
@@ -435,6 +435,7 @@ gistfreestack(GISTSearchStack *s)
while
(
s
!=
NULL
)
while
(
s
!=
NULL
)
{
{
GISTSearchStack
*
p
=
s
->
next
;
GISTSearchStack
*
p
=
s
->
next
;
pfree
(
s
);
pfree
(
s
);
s
=
p
;
s
=
p
;
}
}
...
...
src/backend/access/gist/gistutil.c
View file @
b3364fc8
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
*
$PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.6 2005/09/22 18:49:45 tgl
Exp $
*
$PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.7 2005/09/22 20:44:36 momjian
Exp $
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
#include "postgres.h"
#include "postgres.h"
...
@@ -22,9 +22,9 @@
...
@@ -22,9 +22,9 @@
#include "storage/freespace.h"
#include "storage/freespace.h"
/* group flags ( in gistadjsubkey ) */
/* group flags ( in gistadjsubkey ) */
#define LEFT_ADDED
0x01
#define LEFT_ADDED
0x01
#define RIGHT_ADDED 0x02
#define RIGHT_ADDED 0x02
#define BOTH_ADDED
( LEFT_ADDED | RIGHT_ADDED )
#define BOTH_ADDED
( LEFT_ADDED | RIGHT_ADDED )
/*
/*
...
@@ -47,8 +47,7 @@
...
@@ -47,8 +47,7 @@
} while(0);
} while(0);
static
void
static
void
gistpenalty
(
GISTSTATE
*
giststate
,
int
attno
,
gistpenalty
(
GISTSTATE
*
giststate
,
int
attno
,
GISTENTRY
*
key1
,
bool
isNull1
,
GISTENTRY
*
key1
,
bool
isNull1
,
GISTENTRY
*
key2
,
bool
isNull2
,
float
*
penalty
);
GISTENTRY
*
key2
,
bool
isNull2
,
float
*
penalty
);
...
@@ -57,13 +56,13 @@ gistpenalty(GISTSTATE *giststate, int attno,
...
@@ -57,13 +56,13 @@ gistpenalty(GISTSTATE *giststate, int attno,
*/
*/
OffsetNumber
OffsetNumber
gistfillbuffer
(
Relation
r
,
Page
page
,
IndexTuple
*
itup
,
gistfillbuffer
(
Relation
r
,
Page
page
,
IndexTuple
*
itup
,
int
len
,
OffsetNumber
off
)
int
len
,
OffsetNumber
off
)
{
{
OffsetNumber
l
=
InvalidOffsetNumber
;
OffsetNumber
l
=
InvalidOffsetNumber
;
int
i
;
int
i
;
if
(
off
==
InvalidOffsetNumber
)
if
(
off
==
InvalidOffsetNumber
)
off
=
(
PageIsEmpty
(
page
)
)
?
FirstOffsetNumber
:
off
=
(
PageIsEmpty
(
page
))
?
FirstOffsetNumber
:
OffsetNumberNext
(
PageGetMaxOffsetNumber
(
page
));
OffsetNumberNext
(
PageGetMaxOffsetNumber
(
page
));
for
(
i
=
0
;
i
<
len
;
i
++
)
for
(
i
=
0
;
i
<
len
;
i
++
)
...
@@ -137,13 +136,13 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
...
@@ -137,13 +136,13 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
GistEntryVector
*
evec
;
GistEntryVector
*
evec
;
int
i
;
int
i
;
GISTENTRY
centry
[
INDEX_MAX_KEYS
];
GISTENTRY
centry
[
INDEX_MAX_KEYS
];
IndexTuple
res
;
IndexTuple
res
;
evec
=
(
GistEntryVector
*
)
palloc
(((
len
==
1
)
?
2
:
len
)
*
sizeof
(
GISTENTRY
)
+
GEVHDRSZ
);
evec
=
(
GistEntryVector
*
)
palloc
(((
len
==
1
)
?
2
:
len
)
*
sizeof
(
GISTENTRY
)
+
GEVHDRSZ
);
for
(
i
=
0
;
i
<
len
;
i
++
)
for
(
i
=
0
;
i
<
len
;
i
++
)
if
(
GistTupleIsInvalid
(
itvec
[
i
]
)
)
if
(
GistTupleIsInvalid
(
itvec
[
i
])
)
return
gist_form_invalid_tuple
(
InvalidBlockNumber
);
return
gist_form_invalid_tuple
(
InvalidBlockNumber
);
for
(
i
=
0
;
i
<
r
->
rd_att
->
natts
;
i
++
)
for
(
i
=
0
;
i
<
r
->
rd_att
->
natts
;
i
++
)
{
{
...
@@ -155,6 +154,7 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
...
@@ -155,6 +154,7 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
for
(
j
=
0
;
j
<
len
;
j
++
)
for
(
j
=
0
;
j
<
len
;
j
++
)
{
{
bool
IsNull
;
bool
IsNull
;
datum
=
index_getattr
(
itvec
[
j
],
i
+
1
,
giststate
->
tupdesc
,
&
IsNull
);
datum
=
index_getattr
(
itvec
[
j
],
i
+
1
,
giststate
->
tupdesc
,
&
IsNull
);
if
(
IsNull
)
if
(
IsNull
)
continue
;
continue
;
...
@@ -176,7 +176,7 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
...
@@ -176,7 +176,7 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
}
}
else
else
{
{
int
datumsize
;
int
datumsize
;
if
(
real_len
==
1
)
if
(
real_len
==
1
)
{
{
...
@@ -202,7 +202,7 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
...
@@ -202,7 +202,7 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
}
}
res
=
index_form_tuple
(
giststate
->
tupdesc
,
attr
,
isnull
);
res
=
index_form_tuple
(
giststate
->
tupdesc
,
attr
,
isnull
);
GistTupleSetValid
(
res
);
GistTupleSetValid
(
res
);
return
res
;
return
res
;
}
}
...
@@ -227,9 +227,9 @@ gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *gis
...
@@ -227,9 +227,9 @@ gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *gis
IndexTuple
newtup
=
NULL
;
IndexTuple
newtup
=
NULL
;
int
i
;
int
i
;
if
(
GistTupleIsInvalid
(
oldtup
)
||
GistTupleIsInvalid
(
addtup
)
)
if
(
GistTupleIsInvalid
(
oldtup
)
||
GistTupleIsInvalid
(
addtup
)
)
return
gist_form_invalid_tuple
(
ItemPointerGetBlockNumber
(
&
(
oldtup
->
t_tid
)
)
);
return
gist_form_invalid_tuple
(
ItemPointerGetBlockNumber
(
&
(
oldtup
->
t_tid
)));
evec
=
palloc
(
2
*
sizeof
(
GISTENTRY
)
+
GEVHDRSZ
);
evec
=
palloc
(
2
*
sizeof
(
GISTENTRY
)
+
GEVHDRSZ
);
evec
->
n
=
2
;
evec
->
n
=
2
;
ev0p
=
&
(
evec
->
vector
[
0
]);
ev0p
=
&
(
evec
->
vector
[
0
]);
...
@@ -268,7 +268,7 @@ gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *gis
...
@@ -268,7 +268,7 @@ gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *gis
}
}
else
else
{
{
bool
result
;
bool
result
;
FunctionCall3
(
&
giststate
->
equalFn
[
i
],
FunctionCall3
(
&
giststate
->
equalFn
[
i
],
ev0p
->
key
,
ev0p
->
key
,
...
@@ -301,7 +301,7 @@ gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *gis
...
@@ -301,7 +301,7 @@ gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *gis
void
void
gistunionsubkey
(
Relation
r
,
GISTSTATE
*
giststate
,
IndexTuple
*
itvec
,
GIST_SPLITVEC
*
spl
,
bool
isall
)
gistunionsubkey
(
Relation
r
,
GISTSTATE
*
giststate
,
IndexTuple
*
itvec
,
GIST_SPLITVEC
*
spl
,
bool
isall
)
{
{
int
lr
;
int
lr
;
for
(
lr
=
0
;
lr
<
2
;
lr
++
)
for
(
lr
=
0
;
lr
<
2
;
lr
++
)
{
{
...
@@ -309,7 +309,7 @@ gistunionsubkey(Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLITV
...
@@ -309,7 +309,7 @@ gistunionsubkey(Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLITV
int
i
;
int
i
;
Datum
*
attr
;
Datum
*
attr
;
int
len
,
int
len
,
*
attrsize
;
*
attrsize
;
bool
*
isnull
;
bool
*
isnull
;
GistEntryVector
*
evec
;
GistEntryVector
*
evec
;
...
@@ -354,7 +354,7 @@ gistunionsubkey(Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLITV
...
@@ -354,7 +354,7 @@ gistunionsubkey(Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLITV
&
(
evec
->
vector
[
real_len
]),
&
(
evec
->
vector
[
real_len
]),
datum
,
datum
,
NULL
,
NULL
,
(
OffsetNumber
)
0
,
NULL
,
NULL
,
(
OffsetNumber
)
0
,
ATTSIZE
(
datum
,
giststate
->
tupdesc
,
i
+
1
,
IsNull
),
ATTSIZE
(
datum
,
giststate
->
tupdesc
,
i
+
1
,
IsNull
),
FALSE
,
IsNull
);
FALSE
,
IsNull
);
real_len
++
;
real_len
++
;
...
@@ -402,14 +402,14 @@ gistfindgroup(GISTSTATE *giststate, GISTENTRY *valvec, GIST_SPLITVEC *spl)
...
@@ -402,14 +402,14 @@ gistfindgroup(GISTSTATE *giststate, GISTENTRY *valvec, GIST_SPLITVEC *spl)
int
curid
=
1
;
int
curid
=
1
;
/*
/*
* first key is always not null (see gistinsert), so we may not check
* first key is always not null (see gistinsert), so we may not check
for
*
for
nulls
* nulls
*/
*/
for
(
i
=
0
;
i
<
spl
->
spl_nleft
;
i
++
)
for
(
i
=
0
;
i
<
spl
->
spl_nleft
;
i
++
)
{
{
int
j
;
int
j
;
int
len
;
int
len
;
bool
result
;
bool
result
;
if
(
spl
->
spl_idgrp
[
spl
->
spl_left
[
i
]])
if
(
spl
->
spl_idgrp
[
spl
->
spl_left
[
i
]])
continue
;
continue
;
...
@@ -540,12 +540,12 @@ gistadjsubkey(Relation r,
...
@@ -540,12 +540,12 @@ gistadjsubkey(Relation r,
for
(
j
=
1
;
j
<
r
->
rd_att
->
natts
;
j
++
)
for
(
j
=
1
;
j
<
r
->
rd_att
->
natts
;
j
++
)
{
{
gistentryinit
(
entry
,
v
->
spl_lattr
[
j
],
r
,
NULL
,
gistentryinit
(
entry
,
v
->
spl_lattr
[
j
],
r
,
NULL
,
(
OffsetNumber
)
0
,
v
->
spl_lattrsize
[
j
],
FALSE
);
(
OffsetNumber
)
0
,
v
->
spl_lattrsize
[
j
],
FALSE
);
gistpenalty
(
giststate
,
j
,
&
entry
,
v
->
spl_lisnull
[
j
],
gistpenalty
(
giststate
,
j
,
&
entry
,
v
->
spl_lisnull
[
j
],
&
identry
[
j
],
isnull
[
j
],
&
lpenalty
);
&
identry
[
j
],
isnull
[
j
],
&
lpenalty
);
gistentryinit
(
entry
,
v
->
spl_rattr
[
j
],
r
,
NULL
,
gistentryinit
(
entry
,
v
->
spl_rattr
[
j
],
r
,
NULL
,
(
OffsetNumber
)
0
,
v
->
spl_rattrsize
[
j
],
FALSE
);
(
OffsetNumber
)
0
,
v
->
spl_rattrsize
[
j
],
FALSE
);
gistpenalty
(
giststate
,
j
,
&
entry
,
v
->
spl_risnull
[
j
],
gistpenalty
(
giststate
,
j
,
&
entry
,
v
->
spl_risnull
[
j
],
&
identry
[
j
],
isnull
[
j
],
&
rpenalty
);
&
identry
[
j
],
isnull
[
j
],
&
rpenalty
);
...
@@ -555,8 +555,7 @@ gistadjsubkey(Relation r,
...
@@ -555,8 +555,7 @@ gistadjsubkey(Relation r,
}
}
/*
/*
* add
* add XXX: refactor this to avoid duplicating code
* XXX: refactor this to avoid duplicating code
*/
*/
if
(
lpenalty
<
rpenalty
)
if
(
lpenalty
<
rpenalty
)
{
{
...
@@ -643,12 +642,13 @@ gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */
...
@@ -643,12 +642,13 @@ gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */
{
{
int
j
;
int
j
;
IndexTuple
itup
=
(
IndexTuple
)
PageGetItem
(
p
,
PageGetItemId
(
p
,
i
));
IndexTuple
itup
=
(
IndexTuple
)
PageGetItem
(
p
,
PageGetItemId
(
p
,
i
));
if
(
!
GistPageIsLeaf
(
p
)
&&
GistTupleIsInvalid
(
itup
)
)
{
if
(
!
GistPageIsLeaf
(
p
)
&&
GistTupleIsInvalid
(
itup
))
{
ereport
(
LOG
,
ereport
(
LOG
,
(
errmsg
(
"index
\"
%s
\"
needs VACUUM or REINDEX to finish crash recovery"
,
(
errmsg
(
"index
\"
%s
\"
needs VACUUM or REINDEX to finish crash recovery"
,
RelationGetRelationName
(
r
))));
RelationGetRelationName
(
r
))));
continue
;
continue
;
}
}
sum_grow
=
0
;
sum_grow
=
0
;
...
@@ -683,7 +683,7 @@ gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */
...
@@ -683,7 +683,7 @@ gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */
}
}
}
}
if
(
which
==
InvalidOffsetNumber
)
if
(
which
==
InvalidOffsetNumber
)
which
=
FirstOffsetNumber
;
which
=
FirstOffsetNumber
;
return
which
;
return
which
;
...
@@ -775,7 +775,8 @@ gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
...
@@ -775,7 +775,8 @@ gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
for
(
i
=
0
;
i
<
r
->
rd_att
->
natts
;
i
++
)
for
(
i
=
0
;
i
<
r
->
rd_att
->
natts
;
i
++
)
{
{
Datum
datum
=
index_getattr
(
tuple
,
i
+
1
,
giststate
->
tupdesc
,
&
isnull
[
i
]);
Datum
datum
=
index_getattr
(
tuple
,
i
+
1
,
giststate
->
tupdesc
,
&
isnull
[
i
]);
gistdentryinit
(
giststate
,
i
,
&
attdata
[
i
],
gistdentryinit
(
giststate
,
i
,
&
attdata
[
i
],
datum
,
r
,
p
,
o
,
datum
,
r
,
p
,
o
,
ATTSIZE
(
datum
,
giststate
->
tupdesc
,
i
+
1
,
isnull
[
i
]),
ATTSIZE
(
datum
,
giststate
->
tupdesc
,
i
+
1
,
isnull
[
i
]),
...
@@ -801,8 +802,8 @@ void
...
@@ -801,8 +802,8 @@ void
GISTInitBuffer
(
Buffer
b
,
uint32
f
)
GISTInitBuffer
(
Buffer
b
,
uint32
f
)
{
{
GISTPageOpaque
opaque
;
GISTPageOpaque
opaque
;
Page
page
;
Page
page
;
Size
pageSize
;
Size
pageSize
;
pageSize
=
BufferGetPageSize
(
b
);
pageSize
=
BufferGetPageSize
(
b
);
page
=
BufferGetPage
(
b
);
page
=
BufferGetPage
(
b
);
...
@@ -811,15 +812,16 @@ GISTInitBuffer(Buffer b, uint32 f)
...
@@ -811,15 +812,16 @@ GISTInitBuffer(Buffer b, uint32 f)
opaque
=
GistPageGetOpaque
(
page
);
opaque
=
GistPageGetOpaque
(
page
);
opaque
->
flags
=
f
;
opaque
->
flags
=
f
;
opaque
->
rightlink
=
InvalidBlockNumber
;
opaque
->
rightlink
=
InvalidBlockNumber
;
memset
(
&
(
opaque
->
nsn
),
0
,
sizeof
(
GistNSN
)
);
memset
(
&
(
opaque
->
nsn
),
0
,
sizeof
(
GistNSN
)
);
}
}
void
void
gistUserPicksplit
(
Relation
r
,
GistEntryVector
*
entryvec
,
GIST_SPLITVEC
*
v
,
gistUserPicksplit
(
Relation
r
,
GistEntryVector
*
entryvec
,
GIST_SPLITVEC
*
v
,
IndexTuple
*
itup
,
int
len
,
GISTSTATE
*
giststate
)
{
IndexTuple
*
itup
,
int
len
,
GISTSTATE
*
giststate
)
{
/*
/*
* now let the user-defined picksplit function set up the split
* now let the user-defined picksplit function set up the split
vector; in
*
vector; in
entryvec have no null value!!
* entryvec have no null value!!
*/
*/
FunctionCall2
(
&
giststate
->
picksplitFn
[
0
],
FunctionCall2
(
&
giststate
->
picksplitFn
[
0
],
PointerGetDatum
(
entryvec
),
PointerGetDatum
(
entryvec
),
...
@@ -837,8 +839,8 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, GIST_SPLITVEC *v,
...
@@ -837,8 +839,8 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, GIST_SPLITVEC *v,
v
->
spl_risnull
[
0
]
=
false
;
v
->
spl_risnull
[
0
]
=
false
;
/*
/*
* if index is multikey, then we must to try get smaller bounding box
* if index is multikey, then we must to try get smaller bounding box
for
*
for
subkey(s)
* subkey(s)
*/
*/
if
(
r
->
rd_att
->
natts
>
1
)
if
(
r
->
rd_att
->
natts
>
1
)
{
{
...
@@ -854,35 +856,42 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, GIST_SPLITVEC *v,
...
@@ -854,35 +856,42 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, GIST_SPLITVEC *v,
gistunionsubkey
(
r
,
giststate
,
itup
,
v
,
false
);
gistunionsubkey
(
r
,
giststate
,
itup
,
v
,
false
);
/*
/*
* if possible, we insert equivalent tuples with control by
* if possible, we insert equivalent tuples with control by
penalty
*
penalty
for a subkey(s)
* for a subkey(s)
*/
*/
if
(
MaxGrpId
>
1
)
if
(
MaxGrpId
>
1
)
gistadjsubkey
(
r
,
itup
,
len
,
v
,
giststate
);
gistadjsubkey
(
r
,
itup
,
len
,
v
,
giststate
);
}
}
}
}
Buffer
Buffer
gistNewBuffer
(
Relation
r
)
{
gistNewBuffer
(
Relation
r
)
Buffer
buffer
=
InvalidBuffer
;
{
bool
needLock
;
Buffer
buffer
=
InvalidBuffer
;
bool
needLock
;
while
(
true
)
{
while
(
true
)
{
BlockNumber
blkno
=
GetFreeIndexPage
(
&
r
->
rd_node
);
BlockNumber
blkno
=
GetFreeIndexPage
(
&
r
->
rd_node
);
if
(
blkno
==
InvalidBlockNumber
)
if
(
blkno
==
InvalidBlockNumber
)
break
;
break
;
buffer
=
ReadBuffer
(
r
,
blkno
);
buffer
=
ReadBuffer
(
r
,
blkno
);
if
(
ConditionalLockBuffer
(
buffer
)
)
{
if
(
ConditionalLockBuffer
(
buffer
))
Page
page
=
BufferGetPage
(
buffer
);
{
if
(
GistPageIsDeleted
(
page
)
)
{
Page
page
=
BufferGetPage
(
buffer
);
GistPageSetNonDeleted
(
page
);
if
(
GistPageIsDeleted
(
page
))
{
GistPageSetNonDeleted
(
page
);
return
buffer
;
return
buffer
;
}
else
}
else
LockBuffer
(
buffer
,
GIST_UNLOCK
);
LockBuffer
(
buffer
,
GIST_UNLOCK
);
}
}
ReleaseBuffer
(
buffer
);
ReleaseBuffer
(
buffer
);
}
}
needLock
=
!
RELATION_IS_LOCAL
(
r
);
needLock
=
!
RELATION_IS_LOCAL
(
r
);
...
@@ -895,6 +904,6 @@ gistNewBuffer(Relation r) {
...
@@ -895,6 +904,6 @@ gistNewBuffer(Relation r) {
if
(
needLock
)
if
(
needLock
)
UnlockRelationForExtension
(
r
,
ExclusiveLock
);
UnlockRelationForExtension
(
r
,
ExclusiveLock
);
return
buffer
;
return
buffer
;
}
}
src/backend/access/gist/gistvacuum.c
View file @
b3364fc8
This diff is collapsed.
Click to expand it.
src/backend/access/gist/gistxlog.c
View file @
b3364fc8
This diff is collapsed.
Click to expand it.
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