mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
There, now we support GiST...now what? :)
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.2 1996/08/19 13:32:07 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.3 1996/08/26 06:29:32 scrappy Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -86,6 +86,7 @@ static Oid RelationNameGetObjectId(char *relationName, Relation pg_class,
|
||||
static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName);
|
||||
static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo);
|
||||
static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation,
|
||||
TypeName *IndexKeyType,
|
||||
int numatts, AttrNumber attNums[]);
|
||||
|
||||
static void ConstructIndexReldesc(Relation indexRelation, Oid amoid);
|
||||
@@ -97,7 +98,8 @@ static void
|
||||
AppendAttributeTuples(Relation indexRelation, int numatts);
|
||||
static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
|
||||
FuncIndexInfo *funcInfo, int natts,
|
||||
AttrNumber attNums[], Oid classOids[], Node *predicate);
|
||||
AttrNumber attNums[], Oid classOids[], Node *predicate,
|
||||
TypeName *indexKeyType, bool islossy);
|
||||
static void DefaultBuild(Relation heapRelation, Relation indexRelation,
|
||||
int numberOfAttributes, AttrNumber attributeNumber[],
|
||||
IndexStrategy indexStrategy, uint16 parameterCount,
|
||||
@@ -341,6 +343,7 @@ BuildFuncTupleDesc(FuncIndexInfo *funcInfo)
|
||||
static TupleDesc
|
||||
ConstructTupleDescriptor(Oid heapoid,
|
||||
Relation heapRelation,
|
||||
TypeName *IndexKeyType,
|
||||
int numatts,
|
||||
AttrNumber attNums[])
|
||||
{
|
||||
@@ -424,7 +427,28 @@ ConstructTupleDescriptor(Oid heapoid,
|
||||
|
||||
to = (char *) (indexTupDesc->attrs[ i ]);
|
||||
memcpy(to, from, ATTRIBUTE_TUPLE_SIZE);
|
||||
|
||||
|
||||
/* if the keytype is defined, we need to change the tuple form's
|
||||
atttypid & attlen field to match that of the key's type */
|
||||
if (IndexKeyType != NULL) {
|
||||
HeapTuple tup;
|
||||
|
||||
tup = SearchSysCacheTuple(TYPNAME,
|
||||
PointerGetDatum(IndexKeyType->name),
|
||||
0,0,0);
|
||||
if(!HeapTupleIsValid(tup))
|
||||
elog(WARN, "create index: type '%s' undefined",
|
||||
IndexKeyType->name);
|
||||
((AttributeTupleForm) to)->atttypid = tup->t_oid;
|
||||
((AttributeTupleForm) to)->attbyval =
|
||||
((TypeTupleForm) ((char *)tup + tup->t_hoff))->typbyval;
|
||||
if (IndexKeyType->typlen > 0)
|
||||
((AttributeTupleForm) to)->attlen = IndexKeyType->typlen;
|
||||
else ((AttributeTupleForm) to)->attlen =
|
||||
((TypeTupleForm) ((char *)tup + tup->t_hoff))->typlen;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------
|
||||
* now we have to drop in the proper relation descriptor
|
||||
* into the copied tuple form's attrelid and we should be
|
||||
@@ -734,7 +758,9 @@ UpdateIndexRelation(Oid indexoid,
|
||||
int natts,
|
||||
AttrNumber attNums[],
|
||||
Oid classOids[],
|
||||
Node *predicate)
|
||||
Node *predicate,
|
||||
TypeName *indexKeyType,
|
||||
bool islossy)
|
||||
{
|
||||
IndexTupleForm indexForm;
|
||||
char *predString;
|
||||
@@ -770,6 +796,11 @@ UpdateIndexRelation(Oid indexoid,
|
||||
indexForm->indexrelid = indexoid;
|
||||
indexForm->indproc = (PointerIsValid(funcInfo)) ?
|
||||
FIgetProcOid(funcInfo) : InvalidOid;
|
||||
indexForm->indislossy = islossy;
|
||||
if (indexKeyType != NULL)
|
||||
indexForm->indhaskeytype = 1;
|
||||
else
|
||||
indexForm->indhaskeytype = 0;
|
||||
|
||||
memset((char *)& indexForm->indkey[0], 0, sizeof indexForm->indkey);
|
||||
memset((char *)& indexForm->indclass[0], 0, sizeof indexForm->indclass);
|
||||
@@ -987,13 +1018,15 @@ void
|
||||
index_create(char *heapRelationName,
|
||||
char *indexRelationName,
|
||||
FuncIndexInfo *funcInfo,
|
||||
TypeName *IndexKeyType,
|
||||
Oid accessMethodObjectId,
|
||||
int numatts,
|
||||
AttrNumber attNums[],
|
||||
Oid classObjectId[],
|
||||
uint16 parameterCount,
|
||||
Datum *parameter,
|
||||
Node *predicate)
|
||||
Node *predicate,
|
||||
bool islossy)
|
||||
{
|
||||
Relation heapRelation;
|
||||
Relation indexRelation;
|
||||
@@ -1034,6 +1067,7 @@ index_create(char *heapRelationName,
|
||||
else
|
||||
indexTupDesc = ConstructTupleDescriptor(heapoid,
|
||||
heapRelation,
|
||||
IndexKeyType,
|
||||
numatts,
|
||||
attNums);
|
||||
|
||||
@@ -1105,7 +1139,8 @@ index_create(char *heapRelationName,
|
||||
* ----------------
|
||||
*/
|
||||
UpdateIndexRelation(indexoid, heapoid, funcInfo,
|
||||
numatts, attNums, classObjectId, predicate);
|
||||
numatts, attNums, classObjectId, predicate,
|
||||
IndexKeyType, islossy);
|
||||
|
||||
predInfo = (PredInfo*)palloc(sizeof(PredInfo));
|
||||
predInfo->pred = predicate;
|
||||
@@ -1568,7 +1603,8 @@ DefaultBuild(Relation heapRelation,
|
||||
|
||||
indexTuple->t_tid = heapTuple->t_ctid;
|
||||
|
||||
insertResult = index_insert(indexRelation, indexTuple);
|
||||
insertResult = index_insert(indexRelation, datum, nullv,
|
||||
&(heapTuple->t_ctid));
|
||||
|
||||
if (insertResult) pfree(insertResult);
|
||||
pfree(indexTuple);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: index.h,v 1.2 1996/08/19 13:32:08 scrappy Exp $
|
||||
* $Id: index.h,v 1.3 1996/08/26 06:29:36 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "access/funcindex.h"
|
||||
#include "access/itup.h"
|
||||
#include "nodes/execnodes.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
|
||||
|
||||
extern Form_pg_am
|
||||
@@ -31,13 +32,15 @@ extern void InitIndexStrategy(int numatts,
|
||||
extern void index_create(char *heapRelationName,
|
||||
char* indexRelationName,
|
||||
FuncIndexInfo *funcInfo,
|
||||
TypeName *IndexKeyType,
|
||||
Oid accessMethodObjectId,
|
||||
int numatts,
|
||||
AttrNumber attNums[],
|
||||
Oid classObjectId[],
|
||||
uint16 parameterCount,
|
||||
Datum *parameter,
|
||||
Node *predicate);
|
||||
Node *predicate,
|
||||
bool islossy);
|
||||
|
||||
extern void index_destroy(Oid indexId);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.1.1.1 1996/07/09 06:21:15 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.2 1996/08/26 06:29:38 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -193,16 +193,8 @@ CatalogIndexInsert(Relation *idescs,
|
||||
nulls,
|
||||
finfoP);
|
||||
|
||||
newIndxTup = (IndexTuple)index_formtuple(indexDescriptor,
|
||||
&datum,nulls);
|
||||
Assert(newIndxTup);
|
||||
/*
|
||||
* Doing this structure assignment makes me quake in my boots when I
|
||||
* think about portability.
|
||||
*/
|
||||
newIndxTup->t_tid = heapTuple->t_ctid;
|
||||
|
||||
indexRes = index_insert(idescs[i], newIndxTup);
|
||||
indexRes = index_insert(idescs[i], &datum, nulls,
|
||||
&(heapTuple->t_ctid));
|
||||
if (indexRes) pfree(indexRes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pg_am.h,v 1.1.1.1 1996/07/09 06:21:16 scrappy Exp $
|
||||
* $Id: pg_am.h,v 1.2 1996/08/26 06:29:40 scrappy Exp $
|
||||
*
|
||||
* NOTES
|
||||
* the genbki.sh script reads this file and generates .bki
|
||||
@@ -103,6 +103,7 @@ DATA(insert OID = 405 ( hash PGUID "o" 1 1 hashgettuple hashinsert hashdelete
|
||||
DATA(insert OID = 402 ( rtree PGUID "o" 8 3 rtgettuple rtinsert rtdelete - - - - rtbeginscan rtrescan rtendscan rtmarkpos rtrestrpos - - rtbuild - - ));
|
||||
DATA(insert OID = 403 ( btree PGUID "o" 5 1 btgettuple btinsert btdelete - - - - btbeginscan btrescan btendscan btmarkpos btrestrpos - - btbuild - - ));
|
||||
#define BTREE_AM_OID 403
|
||||
DATA(insert OID = 783 ( gist PGUID "o" 100 7 gistgettuple gistinsert gistdelete - - - - gistbeginscan gistrescan gistendscan gistmarkpos gistrestrpos - - gistbuild - - ));
|
||||
|
||||
BKI_BEGIN
|
||||
#ifdef NOBTREE
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pg_index.h,v 1.1.1.1 1996/07/09 06:21:17 scrappy Exp $
|
||||
* $Id: pg_index.h,v 1.2 1996/08/26 06:29:43 scrappy Exp $
|
||||
*
|
||||
* NOTES
|
||||
* the genbki.sh script reads this file and generates .bki
|
||||
@@ -42,6 +42,8 @@ CATALOG(pg_index) {
|
||||
bool indisclustered;
|
||||
bool indisarchived;
|
||||
text indpred; /* query plan for partial index predicate */
|
||||
bool indislossy; /* do we fetch false tuples (lossy compression)? */
|
||||
bool indhaskeytype; /* does key type != attribute type? */
|
||||
} FormData_pg_index;
|
||||
|
||||
#define INDEX_MAX_KEYS 8 /* maximum number of keys in an index definition */
|
||||
@@ -57,7 +59,7 @@ typedef FormData_pg_index *IndexTupleForm;
|
||||
* compiler constants for pg_index
|
||||
* ----------------
|
||||
*/
|
||||
#define Natts_pg_index 8
|
||||
#define Natts_pg_index 10
|
||||
#define Anum_pg_index_indexrelid 1
|
||||
#define Anum_pg_index_indrelid 2
|
||||
#define Anum_pg_index_indproc 3
|
||||
@@ -66,6 +68,8 @@ typedef FormData_pg_index *IndexTupleForm;
|
||||
#define Anum_pg_index_indisclustered 6
|
||||
#define Anum_pg_index_indisarchived 7
|
||||
#define Anum_pg_index_indpred 8
|
||||
#define Anum_pg_index_indislossy 9
|
||||
#define Anum_pg_index_indhaskeytype 10
|
||||
|
||||
|
||||
#endif /* PG_INDEX_H */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pg_proc.h,v 1.1.1.1 1996/07/09 06:21:18 scrappy Exp $
|
||||
* $Id: pg_proc.h,v 1.2 1996/08/26 06:29:46 scrappy Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The script catalog/genbki.sh reads this file and generates .bki
|
||||
@@ -385,7 +385,7 @@ DATA(insert OID = 313 ( i2toi4 PGUID 11 f t f 2 f 23 "21" 100 0 0 10
|
||||
DATA(insert OID = 314 ( i4toi2 PGUID 11 f t f 2 f 21 "23" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 315 ( keyfirsteq PGUID 11 f t f 2 f 16 "0 21" 100 0 0 100 foo bar ));
|
||||
|
||||
DATA(insert OID = 320 ( rtinsert PGUID 11 f t f 2 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 320 ( rtinsert PGUID 11 f t f 4 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 321 ( rtdelete PGUID 11 f t f 2 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 322 ( rtgettuple PGUID 11 f t f 2 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 323 ( rtbuild PGUID 11 f t f 9 f 23 "0" 100 0 0 100 foo bar ));
|
||||
@@ -396,7 +396,7 @@ DATA(insert OID = 327 ( rtrestrpos PGUID 11 f t f 1 f 23 "0" 100 0 0 100
|
||||
DATA(insert OID = 328 ( rtrescan PGUID 11 f t f 3 f 23 "0" 100 0 0 100 foo bar ));
|
||||
|
||||
DATA(insert OID = 330 ( btgettuple PGUID 11 f t f 2 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 331 ( btinsert PGUID 11 f t f 2 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 331 ( btinsert PGUID 11 f t f 4 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 332 ( btdelete PGUID 11 f t f 2 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 333 ( btbeginscan PGUID 11 f t f 4 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 334 ( btrescan PGUID 11 f t f 3 f 23 "0" 100 0 0 100 foo bar ));
|
||||
@@ -448,7 +448,7 @@ DATA(insert OID = 438 ( hashsel PGUID 11 f t t 7 f 701 "26 26 21 0 23
|
||||
DATA(insert OID = 439 ( hashnpage PGUID 11 f t t 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100 foo bar ));
|
||||
|
||||
DATA(insert OID = 440 ( hashgettuple PGUID 11 f t f 2 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 441 ( hashinsert PGUID 11 f t f 2 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 441 ( hashinsert PGUID 11 f t f 4 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 442 ( hashdelete PGUID 11 f t f 2 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 443 ( hashbeginscan PGUID 11 f t f 4 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 444 ( hashrescan PGUID 11 f t f 3 f 23 "0" 100 0 0 100 foo bar ));
|
||||
@@ -574,6 +574,17 @@ DATA(insert OID = 768 ( int4larger PGUID 11 f t f 2 f 23 "23 23" 100 0 0
|
||||
DATA(insert OID = 769 ( int4smaller PGUID 11 f t f 2 f 23 "23 23" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 770 ( int2larger PGUID 11 f t f 2 f 23 "21 21" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 771 ( int2smaller PGUID 11 f t f 2 f 23 "21 21" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 772 ( gistsel PGUID 11 f t t 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 773 ( gistnpage PGUID 11 f t t 7 f 701 "26 26 21 0 23 23 26" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 774 ( gistgettuple PGUID 11 f t f 2 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 775 ( gistinsert PGUID 11 f t f 4 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 776 ( gistdelete PGUID 11 f t f 2 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 777 ( gistbeginscan PGUID 11 f t f 4 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 778 ( gistrescan PGUID 11 f t f 3 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 779 ( gistendscan PGUID 11 f t f 1 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 780 ( gistmarkpos PGUID 11 f t f 1 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 781 ( gistrestrpos PGUID 11 f t f 1 f 23 "0" 100 0 0 100 foo bar ));
|
||||
DATA(insert OID = 782 ( gistbuild PGUID 11 f t f 9 f 23 "0" 100 0 0 100 foo bar ));
|
||||
|
||||
/* OIDS 800 - 899 */
|
||||
DATA(insert OID = 820 ( oidint2in PGUID 11 f t f 1 f 810 "0" 100 0 0 100 foo bar));
|
||||
|
||||
Reference in New Issue
Block a user