#
#
# 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
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 \
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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);
*
* 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.
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);
*
*
* 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.
* 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);
res = _hash_doinsert(rel, hitem);
pfree(hitem);
+ pfree(itup);
return (res);
}
*
*
* 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
*/
InsertIndexResult
index_insert(Relation relation,
- IndexTuple indexTuple)
+ Datum *datum,
+ char *nulls,
+ ItemPointer heap_t_ctid)
{
RegProcedure procedure;
InsertIndexResult specificResult;
* ----------------
*/
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
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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);
*
*
* 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.
* 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);
res = _bt_doinsert(rel, btitem);
pfree(btitem);
+ pfree(itup);
return (res);
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
* 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);
*
*
* 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
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);
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,
static TupleDesc
ConstructTupleDescriptor(Oid heapoid,
Relation heapRelation,
+ TypeName *IndexKeyType,
int numatts,
AttrNumber attNums[])
{
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
int natts,
AttrNumber attNums[],
Oid classOids[],
- Node *predicate)
+ Node *predicate,
+ TypeName *indexKeyType,
+ bool islossy)
{
IndexTupleForm indexForm;
char *predString;
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);
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;
else
indexTupDesc = ConstructTupleDescriptor(heapoid,
heapRelation,
+ IndexKeyType,
numatts,
attNums);
* ----------------
*/
UpdateIndexRelation(indexoid, heapoid, funcInfo,
- numatts, attNums, classObjectId, predicate);
+ numatts, attNums, classObjectId, predicate,
+ IndexKeyType, islossy);
predInfo = (PredInfo*)palloc(sizeof(PredInfo));
predInfo->pred = predicate;
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);
*
* 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 $
*
*-------------------------------------------------------------------------
*/
#include "access/funcindex.h"
#include "access/itup.h"
#include "nodes/execnodes.h"
+#include "nodes/parsenodes.h"
extern Form_pg_am
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);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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);
}
}
*
* 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
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
*
* 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
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 */
* 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
#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 */
*
* 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
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 ));
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 ));
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 ));
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));
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
&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);
}
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
Datum *parameterA = NULL;
FuncIndexInfo fInfo;
List *cnfPred = NULL;
-
-
+ bool lossy = FALSE;
+ List *pl;
+
/*
* Handle attributes
*/
/*
* 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;
+ }
+
/*
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 *
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);
}
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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;
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);
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
* ----------------
*/
if (result) pfree(result);
- pfree(indexTuple);
}
if (econtext != NULL) pfree(econtext);
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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?
case T_Expr:
retval = _equalExpr(a, b);
break;
+ case T_TargetEntry:
+ retval = _equalTargetEntry(a,b);
+ break;
case T_Iter:
retval = _equalIter(a, b);
break;
*
* 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 $
*
*-------------------------------------------------------------------------
*/
Node *whereClause; /* qualifications */
List *rangetable; /* range table, filled in
by transformStmt() */
+ bool *lossy; /* is index lossy? */
} IndexStmt;
/* ----------------------
char *name; /* name of index */
List *args; /* if not NULL, function index */
char *class;
+ TypeName *tname; /* type of index's keys (optional) */
} IndexElem;
/*
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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
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);
*
*
* 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
%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,
*****************************************************************************/
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 */
n->relname = $5;
n->accessMethod = $6;
n->indexParams = $8;
- n->withClause = NIL;
+ n->withClause = $11;
n->whereClause = NULL;
$$ = (Node *)n;
}
{ $$ = 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; }
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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();
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);
}
/*
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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));
+}