There, now we support GiST...now what? :)

This commit is contained in:
Marc G. Fournier 1996-08-26 06:32:06 +00:00
parent fe87dbb140
commit a2740a455f
24 changed files with 279 additions and 99 deletions

View File

@ -7,18 +7,19 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/access/Attic/Makefile.inc,v 1.1.1.1 1996/07/09 06:21:08 scrappy Exp $
# $Header: /cvsroot/pgsql/src/backend/access/Attic/Makefile.inc,v 1.2 1996/08/26 06:26:37 scrappy Exp $
#
#-------------------------------------------------------------------------
accdir=$(CURDIR)/access
VPATH:=$(VPATH):$(accdir):\
$(accdir)/common:$(accdir)/hash:$(accdir)/heap:$(accdir)/index:\
$(accdir)/rtree:$(accdir)/nbtree:$(accdir)/transam
$(accdir)/common:$(accdir)/gist:$(accdir)/hash:$(accdir)/heap:\
$(accdir)/index:$(accdir)/rtree:$(accdir)/nbtree:$(accdir)/transam
SUBSRCS=
include $(accdir)/common/Makefile.inc
include $(accdir)/gist/Makefile.inc
include $(accdir)/hash/Makefile.inc
include $(accdir)/heap/Makefile.inc
include $(accdir)/index/Makefile.inc
@ -27,7 +28,7 @@ include $(accdir)/nbtree/Makefile.inc
include $(accdir)/transam/Makefile.inc
SRCS_ACCESS:= $(SUBSRCS)
HEADERS+= attnum.h funcindex.h genam.h hash.h \
HEADERS+= attnum.h funcindex.h genam.h gist.h hash.h \
heapam.h hio.h htup.h ibit.h iqual.h istrat.h \
itup.h nbtree.h printtup.h relscan.h rtree.h \
sdir.h skey.h strat.h transam.h tupdesc.h tupmacs.h \

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: genam.h,v 1.1.1.1 1996/07/09 06:21:08 scrappy Exp $
* $Id: genam.h,v 1.2 1996/08/26 06:26:40 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -32,7 +32,8 @@ extern Relation index_open(Oid relationId);
extern Relation index_openr(char *relationName);
extern void index_close(Relation relation);
extern InsertIndexResult index_insert(Relation relation,
IndexTuple indexTuple);
Datum *datum, char *nulls,
ItemPointer heap_t_ctid);
extern void index_delete(Relation relation, ItemPointer indexItem);
extern IndexScanDesc index_beginscan(Relation relation, bool scanFromEnd,
uint16 numberOfKeys, ScanKey key);

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: hash.h,v 1.1.1.1 1996/07/09 06:21:08 scrappy Exp $
* $Id: hash.h,v 1.2 1996/08/26 06:26:42 scrappy Exp $
*
* NOTES
* modeled after Margo Seltzer's hash implementation for unix.
@ -250,7 +250,8 @@ typedef HashItemData *HashItem;
extern void hashbuild(Relation heap, Relation index, int natts,
AttrNumber *attnum, IndexStrategy istrat, uint16 pcount,
Datum *params, FuncIndexInfo *finfo, PredInfo *predInfo);
extern InsertIndexResult hashinsert(Relation rel, IndexTuple itup);
extern InsertIndexResult hashinsert(Relation rel, Datum *datum, char *nulls,
ItemPointer ht_ctid);
extern char *hashgettuple(IndexScanDesc scan, ScanDirection dir);
extern char *hashbeginscan(Relation rel, bool fromEnd, uint16 keysz,
ScanKey scankey);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.1.1.1 1996/07/09 06:21:10 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.2 1996/08/26 06:27:28 scrappy Exp $
*
* NOTES
* This file contains only the public interface routines.
@ -252,11 +252,17 @@ hashbuild(Relation heap,
* to the caller.
*/
InsertIndexResult
hashinsert(Relation rel, IndexTuple itup)
hashinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid)
{
HashItem hitem;
IndexTuple itup;
InsertIndexResult res;
/* generate an index tuple */
itup = index_formtuple(RelationGetTupleDescriptor(rel), datum, nulls);
itup->t_tid = *ht_ctid;
if (itup->t_info & INDEX_NULL_MASK)
return ((InsertIndexResult) NULL);
@ -265,6 +271,7 @@ hashinsert(Relation rel, IndexTuple itup)
res = _hash_doinsert(rel, hitem);
pfree(hitem);
pfree(itup);
return (res);
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.1.1.1 1996/07/09 06:21:11 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.2 1996/08/26 06:27:48 scrappy Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relationId
@ -179,7 +179,9 @@ index_close(Relation relation)
*/
InsertIndexResult
index_insert(Relation relation,
IndexTuple indexTuple)
Datum *datum,
char *nulls,
ItemPointer heap_t_ctid)
{
RegProcedure procedure;
InsertIndexResult specificResult;
@ -192,7 +194,7 @@ index_insert(Relation relation,
* ----------------
*/
specificResult = (InsertIndexResult)
fmgr(procedure, relation, indexTuple, NULL);
fmgr(procedure, relation, datum, nulls, heap_t_ctid, NULL);
/* ----------------
* the insert proc is supposed to return a "specific result" and

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nbtree.h,v 1.2 1996/07/30 07:55:10 scrappy Exp $
* $Id: nbtree.h,v 1.3 1996/08/26 06:26:44 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -201,7 +201,8 @@ extern bool BuildingBtree; /* in nbtree.c */
extern void btbuild(Relation heap, Relation index, int natts,
AttrNumber *attnum, IndexStrategy istrat, uint16 pcount,
Datum *params, FuncIndexInfo *finfo, PredInfo *predInfo);
extern InsertIndexResult btinsert(Relation rel, IndexTuple itup);
extern InsertIndexResult btinsert(Relation rel, Datum *datum, char *nulls,
ItemPointer ht_ctid);
extern char *btgettuple(IndexScanDesc scan, ScanDirection dir);
extern char *btbeginscan(Relation rel, bool fromEnd, uint16 keysz,
ScanKey scankey);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.2 1996/07/30 07:56:00 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.3 1996/08/26 06:28:21 scrappy Exp $
*
* NOTES
* This file contains only the public interface routines.
@ -285,11 +285,16 @@ btbuild(Relation heap,
* return an InsertIndexResult to the caller.
*/
InsertIndexResult
btinsert(Relation rel, IndexTuple itup)
btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid)
{
BTItem btitem;
IndexTuple itup;
InsertIndexResult res;
/* generate an index tuple */
itup = index_formtuple(RelationGetTupleDescriptor(rel), datum, nulls);
itup->t_tid = *ht_ctid;
if (itup->t_info & INDEX_NULL_MASK)
return ((InsertIndexResult) NULL);
@ -297,6 +302,7 @@ btinsert(Relation rel, IndexTuple itup)
res = _bt_doinsert(rel, btitem);
pfree(btitem);
pfree(itup);
return (res);
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.1.1.1 1996/07/09 06:21:13 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.2 1996/08/26 06:29:10 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -273,11 +273,15 @@ rtbuild(Relation heap,
* It doesn't do any work; just locks the relation and passes the buck.
*/
InsertIndexResult
rtinsert(Relation r, IndexTuple itup)
rtinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid)
{
InsertIndexResult res;
IndexTuple itup;
RTSTATE rtState;
/* generate an index tuple */
itup = index_formtuple(RelationGetTupleDescriptor(r), datum, nulls);
itup->t_tid = *ht_ctid;
initRtstate(&rtState, r);
RelationSetLockForWrite(r);

View File

@ -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);

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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

View File

@ -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 */

View File

@ -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));

View File

@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.2 1996/08/15 07:39:24 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.3 1996/08/26 06:30:19 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -316,11 +316,12 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
index_create((NewHeap->rd_rel->relname).data,
NewIndexName,
finfo,
- NULL, /* type info is in the old index */
Old_pg_index_relation_Form->relam,
natts,
Old_pg_index_Form->indkey,
Old_pg_index_Form->indclass,
(uint16)0, (Datum) NULL, NULL);
(uint16)0, (Datum) NULL, NULL, Old_pg_index_Form->indislossy);
heap_close(OldIndex);
heap_close(NewHeap);

View File

@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.4 1996/08/24 20:48:14 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.5 1996/08/26 06:30:21 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -527,11 +527,9 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
&idatum,
index_nulls,
finfoP[i]);
ituple = index_formtuple(itupdescArr[i], &idatum, index_nulls);
ituple->t_tid = tuple->t_ctid;
indexRes = index_insert(index_rels[i], ituple);
indexRes = index_insert(index_rels[i], &idatum, index_nulls,
&(tuple->t_ctid));
if (indexRes) pfree(indexRes);
pfree(ituple);
}
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.3 1996/08/19 01:53:38 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.4 1996/08/26 06:30:23 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -86,8 +86,9 @@ DefineIndex(char *heapRelationName,
Datum *parameterA = NULL;
FuncIndexInfo fInfo;
List *cnfPred = NULL;
bool lossy = FALSE;
List *pl;
/*
* Handle attributes
*/
@ -123,7 +124,19 @@ DefineIndex(char *heapRelationName,
/*
* Handle parameters
* [param list is now different (NOT USED, really) - ay 10/94]
*
* WITH clause reinstated to handle lossy indices.
* -- JMH, 7/22/96
*/
foreach(pl, parameterList) {
int count;
char *ptr;
ParamString *param = (ParamString*)lfirst(pl);
if (!strcasecmp(param->name, "islossy"))
lossy = TRUE;
}
/*
@ -167,9 +180,10 @@ DefineIndex(char *heapRelationName,
index_create(heapRelationName,
indexRelationName,
&fInfo, accessMethodId,
&fInfo, NULL, accessMethodId,
numberOfAttributes, attributeNumberA,
classObjectId, parameterCount, parameterA, (Node*)cnfPred);
classObjectId, parameterCount, parameterA, (Node*)cnfPred,
lossy);
}else {
attributeNumberA =
(AttrNumber *)palloc(numberOfAttributes *
@ -182,8 +196,10 @@ DefineIndex(char *heapRelationName,
classObjectId, relationId);
index_create(heapRelationName, indexRelationName, NULL,
((IndexElem*)lfirst(attributeList))->tname,
accessMethodId, numberOfAttributes, attributeNumberA,
classObjectId, parameterCount, parameterA, (Node*)cnfPred);
classObjectId, parameterCount, parameterA, (Node*)cnfPred,
lossy);
}
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.1.1.1 1996/07/09 06:21:25 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.2 1996/08/26 06:30:33 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -1025,11 +1025,17 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
RelationPtr relationDescs;
Relation heapRelation;
IndexInfo **indexInfoArray;
IndexInfo *indexInfo;
Node *predicate;
bool satisfied;
ExprContext *econtext;
IndexTuple indexTuple;
InsertIndexResult result;
int numberOfAttributes;
AttrNumber *keyAttributeNumbers;
FuncIndexInfoPtr fInfoP;
TupleDesc heapDescriptor;
Datum *datum;
char *nulls;
heapTuple = slot->val;
@ -1050,8 +1056,9 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
econtext = NULL;
for (i=0; i<numIndices; i++) {
if (relationDescs[i] == NULL) continue;
predicate = indexInfoArray[i]->ii_Predicate;
indexInfo = indexInfoArray[i];
predicate = indexInfo->ii_Predicate;
if (predicate != NULL) {
if (econtext == NULL) {
econtext = makeNode(ExprContext);
@ -1063,16 +1070,32 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
if (satisfied == false)
continue;
}
/* ----------------
* get information from index info structure
* ----------------
*/
numberOfAttributes = indexInfo->ii_NumKeyAttributes;
keyAttributeNumbers = indexInfo->ii_KeyAttributeNumbers;
fInfoP = indexInfo->ii_FuncIndexInfo;
datum = (Datum *) palloc(numberOfAttributes * sizeof *datum);
nulls = (char *) palloc(numberOfAttributes * sizeof *nulls);
heapDescriptor = (TupleDesc)RelationGetTupleDescriptor(heapRelation);
FormIndexDatum(numberOfAttributes, /* num attributes */
keyAttributeNumbers, /* array of att nums to extract */
heapTuple, /* tuple from base relation */
heapDescriptor, /* heap tuple's descriptor */
InvalidBuffer, /* buffer associated with heap tuple */
datum, /* return: array of attributes */
nulls, /* return: array of char's */
fInfoP); /* functional index information */
indexTuple = ExecFormIndexTuple(heapTuple,
heapRelation,
relationDescs[i],
indexInfoArray[i]);
indexTuple->t_tid = (*tupleid); /* structure assignment */
result = index_insert(relationDescs[i], /* index relation */
indexTuple); /* index tuple */
datum, /* array of heaptuple Datums */
nulls, /* info on nulls */
&(heapTuple->t_ctid)); /* oid of heap tuple */
/* ----------------
* keep track of index inserts for debugging
@ -1085,7 +1108,6 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
* ----------------
*/
if (result) pfree(result);
pfree(indexTuple);
}
if (econtext != NULL) pfree(econtext);
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.1.1.1 1996/07/09 06:21:32 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.2 1996/08/26 06:30:51 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -523,6 +523,19 @@ _equalEState(EState *a, EState *b)
return (true);
}
static bool
_equalTargetEntry(TargetEntry *a, TargetEntry *b)
{
if (!equal(a->resdom,b->resdom))
return(false);
if (!equal(a->fjoin,b->fjoin))
return(false);
if (!equal(a->expr,b->expr))
return(false);
return(true);
}
/*
* equal -- are two lists equal?
@ -582,6 +595,9 @@ equal(void *a, void *b)
case T_Expr:
retval = _equalExpr(a, b);
break;
case T_TargetEntry:
retval = _equalTargetEntry(a,b);
break;
case T_Iter:
retval = _equalIter(a, b);
break;

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.4 1996/08/24 20:48:31 scrappy Exp $
* $Id: parsenodes.h,v 1.5 1996/08/26 06:30:54 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -218,6 +218,7 @@ typedef struct IndexStmt {
Node *whereClause; /* qualifications */
List *rangetable; /* range table, filled in
by transformStmt() */
bool *lossy; /* is index lossy? */
} IndexStmt;
/* ----------------------
@ -655,6 +656,7 @@ typedef struct IndexElem {
char *name; /* name of index */
List *args; /* if not NULL, function index */
char *class;
TypeName *tname; /* type of index's keys (optional) */
} IndexElem;
/*

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.1.1.1 1996/07/09 06:21:37 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.2 1996/08/26 06:31:15 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -316,8 +316,11 @@ create_indexscan_node(IndexPath *best_path,
List *indxqual = NIL;
List *qpqual = NIL;
List *fixed_indxqual = NIL;
List *ixid;
IndexScan *scan_node = (IndexScan*)NULL;
bool lossy = FALSE;
HeapTuple indexTuple;
IndexTupleForm index;
/*
* If an 'or' clause is to be used with this index, the indxqual
@ -340,15 +343,42 @@ create_indexscan_node(IndexPath *best_path,
NIL);
}
/* check and see if any indices are lossy */
foreach (ixid, best_path->indexid) {
indexTuple = SearchSysCacheTuple(INDEXRELID,
ObjectIdGetDatum(lfirsti(ixid)),
0,0,0);
if (!HeapTupleIsValid(indexTuple))
elog(WARN, "create_plan: index %d not found",
lfirsti(ixid));
index = (IndexTupleForm)GETSTRUCT(indexTuple);
if (index->indislossy)
lossy = TRUE;
}
/*
* The qpqual field contains all restrictions except the indxqual.
* The qpqual field contains all restrictions not automatically handled
* by the index. Note that for non-lossy indices, the predicates
* in the indxqual are handled by the index, while for lossy indices
* the indxqual predicates need to be double-checked after the
* index fetches the best-guess tuples.
*/
if(or_clause((Node*)index_clause))
if(or_clause((Node*)index_clause)) {
qpqual = set_difference(scan_clauses,
lcons(index_clause,NIL));
else
if (lossy)
qpqual = nconc(qpqual,
lcons((List *)copyObject(index_clause),NIL));
}
else {
qpqual = set_difference(scan_clauses, lfirst(indxqual));
if (lossy)
qpqual = nconc(qpqual,
(List *)copyObject(lfirst(indxqual)));
}
fixed_indxqual =
(List*)fix_indxqual_references((Node*)indxqual,(Path*)best_path);

View File

@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.8 1996/08/24 20:48:44 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.9 1996/08/26 06:31:31 scrappy Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -140,7 +140,7 @@ static Node *makeA_Expr(int op, char *opname, Node *lexpr, Node *rexpr);
%type <pstmt> purge_quals
%type <astmt> insert_rest
%type <typnam> Typename, typname
%type <typnam> Typename, typname, opt_type
%type <coldef> columnDef
%type <defelt> def_elem
%type <node> def_arg, columnElem, exprElem, where_clause,
@ -658,7 +658,7 @@ opt_portal_name: IN name { $$ = $2;}
*****************************************************************************/
IndexStmt: CREATE INDEX index_name ON relation_name
access_method_clause '(' index_params ')'
access_method_clause '(' index_params ')' opt_with
{
/* should check that access_method is valid,
etc ... but doesn't */
@ -667,7 +667,7 @@ IndexStmt: CREATE INDEX index_name ON relation_name
n->relname = $5;
n->accessMethod = $6;
n->indexParams = $8;
n->withClause = NIL;
n->withClause = $11;
n->whereClause = NULL;
$$ = (Node *)n;
}
@ -1473,24 +1473,30 @@ index_params: index_elem { $$ = lcons($1,NIL); }
{ $$ = lcons($1, NIL); }
;*/
func_index: name '(' name_list ')' opt_class
func_index: name '(' name_list ')' opt_type opt_class
{
$$ = makeNode(IndexElem);
$$->name = $1;
$$->args = $3;
$$->class = $5;
$$->class = $6;
$$->tname = $5;
}
;
index_elem: attr_name opt_class
index_elem: attr_name opt_type opt_class
{
$$ = makeNode(IndexElem);
$$->name = $1;
$$->args = NIL;
$$->class = $2;
$$->class = $3;
$$->tname = $2;
}
;
opt_type: ':' Typename { $$ = $2;}
| /*EMPTY*/ { $$ = NULL;}
;
opt_class: class
| WITH class { $$ = $2; }
| /*EMPTY*/ { $$ = NULL; }

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.1.1.1 1996/07/09 06:21:55 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.2 1996/08/26 06:31:45 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -157,9 +157,9 @@ inv_create(int flags)
attNums[0] = 1;
classObjectId[0] = INT4_OPS_OID;
index_create(objname, indname, NULL, BTREE_AM_OID,
index_create(objname, indname, NULL, NULL, BTREE_AM_OID,
1, &attNums[0], &classObjectId[0],
0, (Datum) NULL, NULL);
0, (Datum) NULL, NULL, FALSE);
/* make the index visible in this transaction */
CommandCounterIncrement();
@ -996,23 +996,16 @@ inv_newtuple(LargeObjectDesc *obj_desc,
static void
inv_indextup(LargeObjectDesc *obj_desc, HeapTuple htup)
{
IndexTuple itup;
InsertIndexResult res;
Datum v[1];
char n[1];
n[0] = ' ';
v[0] = Int32GetDatum(obj_desc->highbyte);
itup = index_formtuple(obj_desc->idesc, &v[0], &n[0]);
memmove((char *)&(itup->t_tid),
(char *)&(htup->t_ctid),
sizeof(ItemPointerData));
res = index_insert(obj_desc->index_r, itup);
res = index_insert(obj_desc->index_r, &v[0], &n[0], &(htup->t_ctid));
if (res)
pfree(res);
pfree(itup);
}
/*

View File

@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.2 1996/07/31 18:48:16 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.3 1996/08/26 06:32:06 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -583,3 +583,29 @@ rtnpage(Oid operatorObjectId,
return (btreenpage(operatorObjectId, indrelid, attributeNumber,
constValue, constFlag, nIndexKeys, indexrelid));
}
float64
gistsel(Oid operatorObjectId,
Oid indrelid,
AttrNumber attributeNumber,
char *constValue,
int32 constFlag,
int32 nIndexKeys,
Oid indexrelid)
{
return (btreesel(operatorObjectId, indrelid, attributeNumber,
constValue, constFlag, nIndexKeys, indexrelid));
}
float64
gistnpage(Oid operatorObjectId,
Oid indrelid,
AttrNumber attributeNumber,
char *constValue,
int32 constFlag,
int32 nIndexKeys,
Oid indexrelid)
{
return (btreenpage(operatorObjectId, indrelid, attributeNumber,
constValue, constFlag, nIndexKeys, indexrelid));
}