Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc891e05

Browse files
author
Neil Conway
committed
Cleanup GiST header files. Since GiST extensions are often written as
external projects, we should be careful about what parts of the GiSTAPI are considered implementation details, and which are part of thepublic API. Therefore, I've moved internal-only declarations intogist_private.h -- future backward-incompatible changes to gist.h shouldbe made with care, to avoid needlessly breaking external GiST extensions.Also did some related header cleanup: remove some unnecessary #includesfrom gist.h, and remove some unused definitions: isAttByVal(), _gistdump(),and GISTNStrategies.
1 parenteda6dd3 commitc891e05

File tree

7 files changed

+137
-127
lines changed

7 files changed

+137
-127
lines changed

‎contrib/cube/cube.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include"postgres.h"
88

9+
#include<float.h>
910
#include<math.h>
1011

1112
#include"access/gist.h"

‎src/backend/access/gist/gist.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.116 2005/05/1700:59:30 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.117 2005/05/1703:34:18 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515
#include"postgres.h"
1616

1717
#include"access/genam.h"
18-
#include"access/gist.h"
18+
#include"access/gist_private.h"
1919
#include"access/gistscan.h"
2020
#include"access/heapam.h"
2121
#include"catalog/index.h"
@@ -26,10 +26,10 @@
2626

2727
#undef GIST_PAGEADDITEM
2828

29-
#defineATTSIZE(datum,TupDesc,i,isnull) \
29+
#defineATTSIZE(datum,tupdesc,i,isnull) \
3030
( \
3131
(isnull) ? 0 : \
32-
att_addlength(0, (TupDesc)->attrs[(i)-1]->attlen, (datum)) \
32+
att_addlength(0, (tupdesc)->attrs[(i)-1]->attlen, (datum)) \
3333
)
3434

3535
/* result's status */

‎src/backend/access/gist/gistget.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.46 2005/05/1700:59:30 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.47 2005/05/1703:34:18 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515
#include"postgres.h"
1616

17-
#include"access/gist.h"
17+
#include"access/gist_private.h"
18+
#include"access/itup.h"
1819
#include"executor/execdebug.h"
1920
#include"utils/memutils.h"
2021

‎src/backend/access/gist/gistscan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.57 2005/05/1700:59:30 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.58 2005/05/1703:34:18 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515
#include"postgres.h"
1616

1717
#include"access/genam.h"
18-
#include"access/gist.h"
18+
#include"access/gist_private.h"
1919
#include"access/gistscan.h"
2020
#include"utils/memutils.h"
2121
#include"utils/resowner.h"

‎src/backend/access/transam/rmgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
*
44
* Resource managers definition
55
*
6-
* $PostgreSQL: pgsql/src/backend/access/transam/rmgr.c,v 1.16 2004/08/29 21:08:47 tgl Exp $
6+
* $PostgreSQL: pgsql/src/backend/access/transam/rmgr.c,v 1.17 2005/05/17 03:34:18 neilc Exp $
77
*/
88
#include"postgres.h"
99

1010
#include"access/clog.h"
11-
#include"access/gist.h"
11+
#include"access/gist_private.h"
1212
#include"access/hash.h"
1313
#include"access/heapam.h"
1414
#include"access/nbtree.h"

‎src/include/access/gist.h

Lines changed: 15 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
/*-------------------------------------------------------------------------
22
*
33
* gist.h
4-
* common declarations for the GiST access method code.
4+
* The public API for GiST indexes. This API is exposed to
5+
* individuals implementing GiST indexes, so backward-incompatible
6+
* changes should be made with care.
57
*
68
*
79
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
810
* Portions Copyright (c) 1994, Regents of the University of California
911
*
10-
* $PostgreSQL: pgsql/src/include/access/gist.h,v 1.45 2005/05/1700:59:30 neilc Exp $
12+
* $PostgreSQL: pgsql/src/include/access/gist.h,v 1.46 2005/05/1703:34:18 neilc Exp $
1113
*
1214
*-------------------------------------------------------------------------
1315
*/
1416
#ifndefGIST_H
1517
#defineGIST_H
1618

17-
#include"access/itup.h"
18-
#include"access/relscan.h"
19-
#include"access/sdir.h"
20-
#include"access/xlog.h"
21-
22-
/*
23-
* You can have as many strategies as you please in GiSTs,
24-
* as long as your consistent method can handle them.
25-
* The system doesn't really care what they are.
26-
*/
27-
#defineGISTNStrategies100
19+
#include"storage/bufpage.h"
20+
#include"storage/off.h"
21+
#include"utils/rel.h"
2822

2923
/*
3024
* amproc indexes for GiST indexes.
@@ -38,7 +32,6 @@
3832
#defineGIST_EQUAL_PROC7
3933
#defineGISTNProcs7
4034

41-
4235
/*
4336
* Page opaque data in a GiST index page.
4437
*/
@@ -51,81 +44,6 @@ typedef struct GISTPageOpaqueData
5144

5245
typedefGISTPageOpaqueData*GISTPageOpaque;
5346

54-
#defineGIST_LEAF(entry) (((GISTPageOpaque) PageGetSpecialPointer((entry)->page))->flags & F_LEAF)
55-
56-
/*
57-
*When we descend a tree, we keep a stack of parent pointers. This
58-
*allows us to follow a chain of internal node points until we reach
59-
*a leaf node, and then back up the stack to re-examine the internal
60-
*nodes.
61-
*
62-
* 'parent' is the previous stack entry -- i.e. the node we arrived
63-
* from. 'block' is the node's block number. 'offset' is the offset in
64-
* the node's page that we stopped at (i.e. we followed the child
65-
* pointer located at the specified offset).
66-
*/
67-
typedefstructGISTSTACK
68-
{
69-
structGISTSTACK*parent;
70-
OffsetNumberoffset;
71-
BlockNumberblock;
72-
}GISTSTACK;
73-
74-
typedefstructGISTSTATE
75-
{
76-
FmgrInfoconsistentFn[INDEX_MAX_KEYS];
77-
FmgrInfounionFn[INDEX_MAX_KEYS];
78-
FmgrInfocompressFn[INDEX_MAX_KEYS];
79-
FmgrInfodecompressFn[INDEX_MAX_KEYS];
80-
FmgrInfopenaltyFn[INDEX_MAX_KEYS];
81-
FmgrInfopicksplitFn[INDEX_MAX_KEYS];
82-
FmgrInfoequalFn[INDEX_MAX_KEYS];
83-
84-
TupleDesctupdesc;
85-
}GISTSTATE;
86-
87-
#defineisAttByVal(gs,anum ) (gs)->tupdesc->attrs[anum]->attbyval
88-
89-
/*
90-
*When we're doing a scan, we need to keep track of the parent stack
91-
*for the marked and current items.
92-
*/
93-
typedefstructGISTScanOpaqueData
94-
{
95-
GISTSTACK*stack;
96-
GISTSTACK*markstk;
97-
uint16flags;
98-
GISTSTATE*giststate;
99-
MemoryContexttempCxt;
100-
Buffercurbuf;
101-
Buffermarkbuf;
102-
}GISTScanOpaqueData;
103-
104-
typedefGISTScanOpaqueData*GISTScanOpaque;
105-
106-
/*
107-
*When we're doing a scan and updating a tree at the same time, the
108-
*updates may affect the scan. We use the flags entry of the scan's
109-
*opaque space to record our actual position in response to updates
110-
*that we can't handle simply by adjusting pointers.
111-
*/
112-
#defineGS_CURBEFORE((uint16) (1 << 0))
113-
#defineGS_MRKBEFORE((uint16) (1 << 1))
114-
115-
/* root page of a gist index */
116-
#defineGIST_ROOT_BLKNO0
117-
118-
/*
119-
*When we update a relation on which we're doing a scan, we need to
120-
*check the scan and fix it if the update affected any of the pages it
121-
*touches. Otherwise, we can miss records that we should see. The only
122-
*times we need to do this are for deletions and splits.See the code in
123-
*gistscan.c for how the scan is fixed. These two constants tell us what sort
124-
*of operation changed the index.
125-
*/
126-
#defineGISTOP_DEL0
127-
#defineGISTOP_SPLIT1
128-
12947
/*
13048
* This is the Split Vector to be returned by the PickSplit method.
13149
*/
@@ -153,10 +71,10 @@ typedef struct GIST_SPLITVEC
15371
}GIST_SPLITVEC;
15472

15573
/*
156-
* An entry on a GiST node. Contains the key, as well as
157-
*its ownlocation (rel,page,offset) which can supply the matching
158-
*pointer.The size of the key is in bytes, and leafkey is a flag to
159-
*tell usif the entry is in a leaf node.
74+
* An entry on a GiST node. Contains the key, as well as its own
75+
* location (rel,page,offset) which can supply the matching pointer.
76+
* The size of the key is in bytes, and leafkey is a flag to tell us
77+
* if the entry is in a leaf node.
16078
*/
16179
typedefstructGISTENTRY
16280
{
@@ -168,19 +86,19 @@ typedef struct GISTENTRY
16886
boolleafkey;
16987
}GISTENTRY;
17088

89+
#defineGIST_LEAF(entry) (((GISTPageOpaque) PageGetSpecialPointer((entry)->page))->flags & F_LEAF)
17190

17291
/*
173-
* Vector of GISTENTRYstruct's, user-defined
174-
*methods union andpicksplit takes it as one ofargs
92+
* Vector of GISTENTRYstructs; user-defined methods union and pick
93+
* split takes it as one oftheir arguments
17594
*/
176-
17795
typedefstruct
17896
{
17997
int32n;/* number of elements */
18098
GISTENTRYvector[1];
18199
}GistEntryVector;
182100

183-
#defineGEVHDRSZ(offsetof(GistEntryVector, vector[0]))
101+
#defineGEVHDRSZ(offsetof(GistEntryVector, vector[0]))
184102

185103
/*
186104
* macro to initialize a GISTENTRY
@@ -189,24 +107,4 @@ typedef struct
189107
do { (e).key = (k); (e).rel = (r); (e).page = (pg); \
190108
(e).offset = (o); (e).bytes = (b); (e).leafkey = (l); } while (0)
191109

192-
/* gist.c */
193-
externDatumgistbuild(PG_FUNCTION_ARGS);
194-
externDatumgistinsert(PG_FUNCTION_ARGS);
195-
externDatumgistbulkdelete(PG_FUNCTION_ARGS);
196-
externvoid_gistdump(Relationr);
197-
externvoidinitGISTstate(GISTSTATE*giststate,Relationindex);
198-
externvoidfreeGISTstate(GISTSTATE*giststate);
199-
externvoidgistdentryinit(GISTSTATE*giststate,intnkey,GISTENTRY*e,
200-
Datumk,Relationr,Pagepg,OffsetNumbero,
201-
intb,booll,boolisNull);
202-
203-
externvoidgist_redo(XLogRecPtrlsn,XLogRecord*record);
204-
externvoidgist_undo(XLogRecPtrlsn,XLogRecord*record);
205-
externvoidgist_desc(char*buf,uint8xl_info,char*rec);
206-
externMemoryContextcreateTempGistContext(void);
207-
208-
/* gistget.c */
209-
externDatumgistgettuple(PG_FUNCTION_ARGS);
210-
externDatumgistgetmulti(PG_FUNCTION_ARGS);
211-
212110
#endif/* GIST_H */

‎src/include/access/gist_private.h

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* gist_private.h
4+
* private declarations for GiST -- declarations related to the
5+
* internal implementation of GiST, not the public API
6+
*
7+
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
8+
* Portions Copyright (c) 1994, Regents of the University of California
9+
*
10+
* $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.1 2005/05/17 03:34:18 neilc Exp $
11+
*
12+
*-------------------------------------------------------------------------
13+
*/
14+
#ifndefGIST_PRIVATE_H
15+
#defineGIST_PRIVATE_H
16+
17+
#include"access/gist.h"
18+
#include"access/xlog.h"
19+
#include"fmgr.h"
20+
21+
/*
22+
* When we descend a tree, we keep a stack of parent pointers. This
23+
* allows us to follow a chain of internal node points until we reach
24+
* a leaf node, and then back up the stack to re-examine the internal
25+
* nodes.
26+
*
27+
* 'parent' is the previous stack entry -- i.e. the node we arrived
28+
* from. 'block' is the node's block number. 'offset' is the offset in
29+
* the node's page that we stopped at (i.e. we followed the child
30+
* pointer located at the specified offset).
31+
*/
32+
typedefstructGISTSTACK
33+
{
34+
structGISTSTACK*parent;
35+
OffsetNumberoffset;
36+
BlockNumberblock;
37+
}GISTSTACK;
38+
39+
typedefstructGISTSTATE
40+
{
41+
FmgrInfoconsistentFn[INDEX_MAX_KEYS];
42+
FmgrInfounionFn[INDEX_MAX_KEYS];
43+
FmgrInfocompressFn[INDEX_MAX_KEYS];
44+
FmgrInfodecompressFn[INDEX_MAX_KEYS];
45+
FmgrInfopenaltyFn[INDEX_MAX_KEYS];
46+
FmgrInfopicksplitFn[INDEX_MAX_KEYS];
47+
FmgrInfoequalFn[INDEX_MAX_KEYS];
48+
49+
TupleDesctupdesc;
50+
}GISTSTATE;
51+
52+
/*
53+
*When we're doing a scan, we need to keep track of the parent stack
54+
*for the marked and current items.
55+
*/
56+
typedefstructGISTScanOpaqueData
57+
{
58+
GISTSTACK*stack;
59+
GISTSTACK*markstk;
60+
uint16flags;
61+
GISTSTATE*giststate;
62+
MemoryContexttempCxt;
63+
Buffercurbuf;
64+
Buffermarkbuf;
65+
}GISTScanOpaqueData;
66+
67+
typedefGISTScanOpaqueData*GISTScanOpaque;
68+
69+
/*
70+
* When we're doing a scan and updating a tree at the same time, the
71+
* updates may affect the scan. We use the flags entry of the scan's
72+
* opaque space to record our actual position in response to updates
73+
* that we can't handle simply by adjusting pointers.
74+
*/
75+
#defineGS_CURBEFORE((uint16) (1 << 0))
76+
#defineGS_MRKBEFORE((uint16) (1 << 1))
77+
78+
/* root page of a gist index */
79+
#defineGIST_ROOT_BLKNO0
80+
81+
/*
82+
* When we update a relation on which we're doing a scan, we need to
83+
* check the scan and fix it if the update affected any of the pages
84+
* it touches. Otherwise, we can miss records that we should see.
85+
* The only times we need to do this are for deletions and splits. See
86+
* the code in gistscan.c for how the scan is fixed. These two
87+
* constants tell us what sort of operation changed the index.
88+
*/
89+
#defineGISTOP_DEL0
90+
#defineGISTOP_SPLIT1
91+
92+
/* gist.c */
93+
externDatumgistbuild(PG_FUNCTION_ARGS);
94+
externDatumgistinsert(PG_FUNCTION_ARGS);
95+
externDatumgistbulkdelete(PG_FUNCTION_ARGS);
96+
externMemoryContextcreateTempGistContext(void);
97+
externvoidinitGISTstate(GISTSTATE*giststate,Relationindex);
98+
externvoidfreeGISTstate(GISTSTATE*giststate);
99+
externvoidgistdentryinit(GISTSTATE*giststate,intnkey,GISTENTRY*e,
100+
Datumk,Relationr,Pagepg,OffsetNumbero,
101+
intb,booll,boolisNull);
102+
externvoidgist_redo(XLogRecPtrlsn,XLogRecord*record);
103+
externvoidgist_undo(XLogRecPtrlsn,XLogRecord*record);
104+
externvoidgist_desc(char*buf,uint8xl_info,char*rec);
105+
106+
/* gistget.c */
107+
externDatumgistgettuple(PG_FUNCTION_ARGS);
108+
externDatumgistgetmulti(PG_FUNCTION_ARGS);
109+
110+
#endif/* GIST_PRIVATE_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp