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

Commita2740a4

Browse files
committed
There, now we support GiST...now what? :)
1 parentfe87dbb commita2740a4

File tree

24 files changed

+279
-99
lines changed

24 files changed

+279
-99
lines changed

‎src/backend/access/Makefile.inc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/backend/access/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:08 scrappy Exp $
10+
# $Header: /cvsroot/pgsql/src/backend/access/Attic/Makefile.inc,v 1.2 1996/08/26 06:26:37 scrappy Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

1414
accdir=$(CURDIR)/access
1515
VPATH:=$(VPATH):$(accdir):\
16-
$(accdir)/common:$(accdir)/hash:$(accdir)/heap:$(accdir)/index:\
17-
$(accdir)/rtree:$(accdir)/nbtree:$(accdir)/transam
16+
$(accdir)/common:$(accdir)/gist:$(accdir)/hash:$(accdir)/heap:\
17+
$(accdir)/index:$(accdir)/rtree:$(accdir)/nbtree:$(accdir)/transam
1818

1919

2020
SUBSRCS=
2121
include$(accdir)/common/Makefile.inc
22+
include$(accdir)/gist/Makefile.inc
2223
include$(accdir)/hash/Makefile.inc
2324
include$(accdir)/heap/Makefile.inc
2425
include$(accdir)/index/Makefile.inc
@@ -27,7 +28,7 @@ include $(accdir)/nbtree/Makefile.inc
2728
include$(accdir)/transam/Makefile.inc
2829
SRCS_ACCESS:=$(SUBSRCS)
2930

30-
HEADERS+= attnum.h funcindex.h genam.h hash.h\
31+
HEADERS+= attnum.h funcindex.h genam.hgist.hhash.h\
3132
heapam.h hio.h htup.h ibit.h iqual.h istrat.h\
3233
itup.h nbtree.h printtup.h relscan.h rtree.h\
3334
sdir.h skey.h strat.h transam.h tupdesc.h tupmacs.h\

‎src/backend/access/genam.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: genam.h,v 1.1.1.1 1996/07/09 06:21:08 scrappy Exp $
9+
* $Id: genam.h,v 1.2 1996/08/26 06:26:40 scrappy Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -32,7 +32,8 @@ extern Relation index_open(Oid relationId);
3232
externRelationindex_openr(char*relationName);
3333
externvoidindex_close(Relationrelation);
3434
externInsertIndexResultindex_insert(Relationrelation,
35-
IndexTupleindexTuple);
35+
Datum*datum,char*nulls,
36+
ItemPointerheap_t_ctid);
3637
externvoidindex_delete(Relationrelation,ItemPointerindexItem);
3738
externIndexScanDescindex_beginscan(Relationrelation,boolscanFromEnd,
3839
uint16numberOfKeys,ScanKeykey);

‎src/backend/access/hash.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: hash.h,v 1.1.1.1 1996/07/09 06:21:08 scrappy Exp $
9+
* $Id: hash.h,v 1.2 1996/08/26 06:26:42 scrappy Exp $
1010
*
1111
* NOTES
1212
*modeled after Margo Seltzer's hash implementation for unix.
@@ -250,7 +250,8 @@ typedef HashItemData *HashItem;
250250
externvoidhashbuild(Relationheap,Relationindex,intnatts,
251251
AttrNumber*attnum,IndexStrategyistrat,uint16pcount,
252252
Datum*params,FuncIndexInfo*finfo,PredInfo*predInfo);
253-
externInsertIndexResulthashinsert(Relationrel,IndexTupleitup);
253+
externInsertIndexResulthashinsert(Relationrel,Datum*datum,char*nulls,
254+
ItemPointerht_ctid);
254255
externchar*hashgettuple(IndexScanDescscan,ScanDirectiondir);
255256
externchar*hashbeginscan(Relationrel,boolfromEnd,uint16keysz,
256257
ScanKeyscankey);

‎src/backend/access/hash/hash.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.1.1.1 1996/07/09 06:21:10 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.2 1996/08/26 06:27:28 scrappy Exp $
1111
*
1212
* NOTES
1313
* This file contains only the public interface routines.
@@ -252,11 +252,17 @@ hashbuild(Relation heap,
252252
* to the caller.
253253
*/
254254
InsertIndexResult
255-
hashinsert(Relationrel,IndexTupleitup)
255+
hashinsert(Relationrel,Datum*datum,char*nulls,ItemPointerht_ctid)
256256
{
257257
HashItemhitem;
258+
IndexTupleitup;
258259
InsertIndexResultres;
259260

261+
262+
/* generate an index tuple */
263+
itup=index_formtuple(RelationGetTupleDescriptor(rel),datum,nulls);
264+
itup->t_tid=*ht_ctid;
265+
260266
if (itup->t_info&INDEX_NULL_MASK)
261267
return ((InsertIndexResult)NULL);
262268

@@ -265,6 +271,7 @@ hashinsert(Relation rel, IndexTuple itup)
265271
res=_hash_doinsert(rel,hitem);
266272

267273
pfree(hitem);
274+
pfree(itup);
268275

269276
return (res);
270277
}

‎src/backend/access/index/indexam.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.1.1.1 1996/07/09 06:21:11 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.2 1996/08/26 06:27:48 scrappy Exp $
1111
*
1212
* INTERFACE ROUTINES
1313
*index_open - open an index relation by relationId
@@ -179,7 +179,9 @@ index_close(Relation relation)
179179
*/
180180
InsertIndexResult
181181
index_insert(Relationrelation,
182-
IndexTupleindexTuple)
182+
Datum*datum,
183+
char*nulls,
184+
ItemPointerheap_t_ctid)
183185
{
184186
RegProcedureprocedure;
185187
InsertIndexResultspecificResult;
@@ -192,7 +194,7 @@ index_insert(Relation relation,
192194
* ----------------
193195
*/
194196
specificResult= (InsertIndexResult)
195-
fmgr(procedure,relation,indexTuple,NULL);
197+
fmgr(procedure,relation,datum,nulls,heap_t_ctid,NULL);
196198

197199
/* ----------------
198200
*the insert proc is supposed to return a "specific result" and

‎src/backend/access/nbtree.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: nbtree.h,v 1.2 1996/07/30 07:55:10 scrappy Exp $
9+
* $Id: nbtree.h,v 1.3 1996/08/26 06:26:44 scrappy Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -201,7 +201,8 @@ extern bool BuildingBtree;/* in nbtree.c */
201201
externvoidbtbuild(Relationheap,Relationindex,intnatts,
202202
AttrNumber*attnum,IndexStrategyistrat,uint16pcount,
203203
Datum*params,FuncIndexInfo*finfo,PredInfo*predInfo);
204-
externInsertIndexResultbtinsert(Relationrel,IndexTupleitup);
204+
externInsertIndexResultbtinsert(Relationrel,Datum*datum,char*nulls,
205+
ItemPointerht_ctid);
205206
externchar*btgettuple(IndexScanDescscan,ScanDirectiondir);
206207
externchar*btbeginscan(Relationrel,boolfromEnd,uint16keysz,
207208
ScanKeyscankey);

‎src/backend/access/nbtree/nbtree.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.2 1996/07/30 07:56:00 scrappy Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.3 1996/08/26 06:28:21 scrappy Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -285,18 +285,24 @@ btbuild(Relation heap,
285285
*return an InsertIndexResult to the caller.
286286
*/
287287
InsertIndexResult
288-
btinsert(Relationrel,IndexTupleitup)
288+
btinsert(Relationrel,Datum*datum,char*nulls,ItemPointerht_ctid)
289289
{
290290
BTItembtitem;
291+
IndexTupleitup;
291292
InsertIndexResultres;
292293

294+
/* generate an index tuple */
295+
itup=index_formtuple(RelationGetTupleDescriptor(rel),datum,nulls);
296+
itup->t_tid=*ht_ctid;
297+
293298
if (itup->t_info&INDEX_NULL_MASK)
294299
return ((InsertIndexResult)NULL);
295300

296301
btitem=_bt_formitem(itup);
297302

298303
res=_bt_doinsert(rel,btitem);
299304
pfree(btitem);
305+
pfree(itup);
300306

301307
return (res);
302308
}

‎src/backend/access/rtree/rtree.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.1.1.1 1996/07/09 06:21:13 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.2 1996/08/26 06:29:10 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -273,11 +273,15 @@ rtbuild(Relation heap,
273273
* It doesn't do any work; just locks the relation and passes the buck.
274274
*/
275275
InsertIndexResult
276-
rtinsert(Relationr,IndexTupleitup)
276+
rtinsert(Relationr,Datum*datum,char*nulls,ItemPointerht_ctid)
277277
{
278278
InsertIndexResultres;
279+
IndexTupleitup;
279280
RTSTATErtState;
280281

282+
/* generate an index tuple */
283+
itup=index_formtuple(RelationGetTupleDescriptor(r),datum,nulls);
284+
itup->t_tid=*ht_ctid;
281285
initRtstate(&rtState,r);
282286

283287
RelationSetLockForWrite(r);

‎src/backend/catalog/index.c

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.2 1996/08/19 13:32:07 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.3 1996/08/26 06:29:32 scrappy Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -86,6 +86,7 @@ static Oid RelationNameGetObjectId(char *relationName, Relation pg_class,
8686
staticOidGetHeapRelationOid(char*heapRelationName,char*indexRelationName);
8787
staticTupleDescBuildFuncTupleDesc(FuncIndexInfo*funcInfo);
8888
staticTupleDescConstructTupleDescriptor(Oidheapoid,RelationheapRelation,
89+
TypeName*IndexKeyType,
8990
intnumatts,AttrNumberattNums[]);
9091

9192
staticvoidConstructIndexReldesc(RelationindexRelation,Oidamoid);
@@ -97,7 +98,8 @@ static void
9798
AppendAttributeTuples(RelationindexRelation,intnumatts);
9899
staticvoidUpdateIndexRelation(Oidindexoid,Oidheapoid,
99100
FuncIndexInfo*funcInfo,intnatts,
100-
AttrNumberattNums[],OidclassOids[],Node*predicate);
101+
AttrNumberattNums[],OidclassOids[],Node*predicate,
102+
TypeName*indexKeyType,boolislossy);
101103
staticvoidDefaultBuild(RelationheapRelation,RelationindexRelation,
102104
intnumberOfAttributes,AttrNumberattributeNumber[],
103105
IndexStrategyindexStrategy,uint16parameterCount,
@@ -341,6 +343,7 @@ BuildFuncTupleDesc(FuncIndexInfo *funcInfo)
341343
staticTupleDesc
342344
ConstructTupleDescriptor(Oidheapoid,
343345
RelationheapRelation,
346+
TypeName*IndexKeyType,
344347
intnumatts,
345348
AttrNumberattNums[])
346349
{
@@ -424,7 +427,28 @@ ConstructTupleDescriptor(Oid heapoid,
424427

425428
to= (char*) (indexTupDesc->attrs[i ]);
426429
memcpy(to,from,ATTRIBUTE_TUPLE_SIZE);
427-
430+
431+
/* if the keytype is defined, we need to change the tuple form's
432+
atttypid & attlen field to match that of the key's type */
433+
if (IndexKeyType!=NULL) {
434+
HeapTupletup;
435+
436+
tup=SearchSysCacheTuple(TYPNAME,
437+
PointerGetDatum(IndexKeyType->name),
438+
0,0,0);
439+
if(!HeapTupleIsValid(tup))
440+
elog(WARN,"create index: type '%s' undefined",
441+
IndexKeyType->name);
442+
((AttributeTupleForm)to)->atttypid=tup->t_oid;
443+
((AttributeTupleForm)to)->attbyval=
444+
((TypeTupleForm) ((char*)tup+tup->t_hoff))->typbyval;
445+
if (IndexKeyType->typlen>0)
446+
((AttributeTupleForm)to)->attlen=IndexKeyType->typlen;
447+
else ((AttributeTupleForm)to)->attlen=
448+
((TypeTupleForm) ((char*)tup+tup->t_hoff))->typlen;
449+
}
450+
451+
428452
/* ----------------
429453
* now we have to drop in the proper relation descriptor
430454
* into the copied tuple form's attrelid and we should be
@@ -734,7 +758,9 @@ UpdateIndexRelation(Oid indexoid,
734758
intnatts,
735759
AttrNumberattNums[],
736760
OidclassOids[],
737-
Node*predicate)
761+
Node*predicate,
762+
TypeName*indexKeyType,
763+
boolislossy)
738764
{
739765
IndexTupleFormindexForm;
740766
char*predString;
@@ -770,6 +796,11 @@ UpdateIndexRelation(Oid indexoid,
770796
indexForm->indexrelid=indexoid;
771797
indexForm->indproc= (PointerIsValid(funcInfo)) ?
772798
FIgetProcOid(funcInfo) :InvalidOid;
799+
indexForm->indislossy=islossy;
800+
if (indexKeyType!=NULL)
801+
indexForm->indhaskeytype=1;
802+
else
803+
indexForm->indhaskeytype=0;
773804

774805
memset((char*)&indexForm->indkey[0],0,sizeofindexForm->indkey);
775806
memset((char*)&indexForm->indclass[0],0,sizeofindexForm->indclass);
@@ -987,13 +1018,15 @@ void
9871018
index_create(char*heapRelationName,
9881019
char*indexRelationName,
9891020
FuncIndexInfo*funcInfo,
1021+
TypeName*IndexKeyType,
9901022
OidaccessMethodObjectId,
9911023
intnumatts,
9921024
AttrNumberattNums[],
9931025
OidclassObjectId[],
9941026
uint16parameterCount,
9951027
Datum*parameter,
996-
Node*predicate)
1028+
Node*predicate,
1029+
boolislossy)
9971030
{
9981031
RelationheapRelation;
9991032
RelationindexRelation;
@@ -1034,6 +1067,7 @@ index_create(char *heapRelationName,
10341067
else
10351068
indexTupDesc=ConstructTupleDescriptor(heapoid,
10361069
heapRelation,
1070+
IndexKeyType,
10371071
numatts,
10381072
attNums);
10391073

@@ -1105,7 +1139,8 @@ index_create(char *heapRelationName,
11051139
* ----------------
11061140
*/
11071141
UpdateIndexRelation(indexoid,heapoid,funcInfo,
1108-
numatts,attNums,classObjectId,predicate);
1142+
numatts,attNums,classObjectId,predicate,
1143+
IndexKeyType,islossy);
11091144

11101145
predInfo= (PredInfo*)palloc(sizeof(PredInfo));
11111146
predInfo->pred=predicate;
@@ -1568,7 +1603,8 @@ DefaultBuild(Relation heapRelation,
15681603

15691604
indexTuple->t_tid=heapTuple->t_ctid;
15701605

1571-
insertResult=index_insert(indexRelation,indexTuple);
1606+
insertResult=index_insert(indexRelation,datum,nullv,
1607+
&(heapTuple->t_ctid));
15721608

15731609
if (insertResult)pfree(insertResult);
15741610
pfree(indexTuple);

‎src/backend/catalog/index.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: index.h,v 1.2 1996/08/19 13:32:08 scrappy Exp $
9+
* $Id: index.h,v 1.3 1996/08/26 06:29:36 scrappy Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -16,6 +16,7 @@
1616
#include"access/funcindex.h"
1717
#include"access/itup.h"
1818
#include"nodes/execnodes.h"
19+
#include"nodes/parsenodes.h"
1920

2021

2122
externForm_pg_am
@@ -31,13 +32,15 @@ extern void InitIndexStrategy(int numatts,
3132
externvoidindex_create(char*heapRelationName,
3233
char*indexRelationName,
3334
FuncIndexInfo*funcInfo,
35+
TypeName*IndexKeyType,
3436
OidaccessMethodObjectId,
3537
intnumatts,
3638
AttrNumberattNums[],
3739
OidclassObjectId[],
3840
uint16parameterCount,
3941
Datum*parameter,
40-
Node*predicate);
42+
Node*predicate,
43+
boolislossy);
4144

4245
externvoidindex_destroy(OidindexId);
4346

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp