Commit edf0b5f0 authored by Tom Lane's avatar Tom Lane

Get rid of IndexIsUniqueNoCache() kluge by the simple expedient of

passing the index-is-unique flag to index build routines (duh! ...
why wasn't it done this way to begin with?).  Aside from eliminating
an eyesore, this should save a few milliseconds in btree index creation
because a full scan of pg_index is not needed any more.
parent d03a933e
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.58 2000/06/15 03:31:53 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.59 2000/06/17 23:41:12 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -67,13 +67,12 @@ gistbuild(PG_FUNCTION_ARGS) ...@@ -67,13 +67,12 @@ gistbuild(PG_FUNCTION_ARGS)
Relation index = (Relation) PG_GETARG_POINTER(1); Relation index = (Relation) PG_GETARG_POINTER(1);
int32 natts = PG_GETARG_INT32(2); int32 natts = PG_GETARG_INT32(2);
AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3); AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3);
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(4);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(5);
#ifdef NOT_USED #ifdef NOT_USED
IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(4); bool unique = PG_GETARG_BOOL(6);
uint16 pcount = PG_GETARG_UINT16(5); IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(7);
Datum *params = (Datum *) PG_GETARG_POINTER(6);
#endif #endif
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(7);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(8);
HeapScanDesc scan; HeapScanDesc scan;
AttrNumber i; AttrNumber i;
HeapTuple htup; HeapTuple htup;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.39 2000/06/14 05:24:35 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.40 2000/06/17 23:41:13 tgl Exp $
* *
* NOTES * NOTES
* This file contains only the public interface routines. * This file contains only the public interface routines.
...@@ -43,13 +43,12 @@ hashbuild(PG_FUNCTION_ARGS) ...@@ -43,13 +43,12 @@ hashbuild(PG_FUNCTION_ARGS)
Relation index = (Relation) PG_GETARG_POINTER(1); Relation index = (Relation) PG_GETARG_POINTER(1);
int32 natts = PG_GETARG_INT32(2); int32 natts = PG_GETARG_INT32(2);
AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3); AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3);
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(4);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(5);
#ifdef NOT_USED #ifdef NOT_USED
IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(4); bool unique = PG_GETARG_BOOL(6);
uint16 pcount = PG_GETARG_UINT16(5); IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(7);
Datum *params = (Datum *) PG_GETARG_POINTER(6);
#endif #endif
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(7);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(8);
HeapScanDesc hscan; HeapScanDesc hscan;
HeapTuple htup; HeapTuple htup;
IndexTuple itup; IndexTuple itup;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.58 2000/06/15 04:09:36 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.59 2000/06/17 23:41:16 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -47,13 +47,12 @@ btbuild(PG_FUNCTION_ARGS) ...@@ -47,13 +47,12 @@ btbuild(PG_FUNCTION_ARGS)
Relation index = (Relation) PG_GETARG_POINTER(1); Relation index = (Relation) PG_GETARG_POINTER(1);
int32 natts = PG_GETARG_INT32(2); int32 natts = PG_GETARG_INT32(2);
AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3); AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3);
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(4);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(5);
bool unique = PG_GETARG_BOOL(6);
#ifdef NOT_USED #ifdef NOT_USED
IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(4); IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(7);
uint16 pcount = PG_GETARG_UINT16(5);
Datum *params = (Datum *) PG_GETARG_POINTER(6);
#endif #endif
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(7);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(8);
HeapScanDesc hscan; HeapScanDesc hscan;
HeapTuple htup; HeapTuple htup;
IndexTuple itup; IndexTuple itup;
...@@ -76,7 +75,6 @@ btbuild(PG_FUNCTION_ARGS) ...@@ -76,7 +75,6 @@ btbuild(PG_FUNCTION_ARGS)
Node *pred, Node *pred,
*oldPred; *oldPred;
BTSpool *spool = NULL; BTSpool *spool = NULL;
bool isunique;
bool usefast; bool usefast;
/* note that this is a new btree */ /* note that this is a new btree */
...@@ -98,9 +96,6 @@ btbuild(PG_FUNCTION_ARGS) ...@@ -98,9 +96,6 @@ btbuild(PG_FUNCTION_ARGS)
ResetUsage(); ResetUsage();
#endif /* BTREE_BUILD_STATS */ #endif /* BTREE_BUILD_STATS */
/* see if index is unique */
isunique = IndexIsUniqueNoCache(RelationGetRelid(index));
/* initialize the btree index metadata page (if this is a new index) */ /* initialize the btree index metadata page (if this is a new index) */
if (oldPred == NULL) if (oldPred == NULL)
_bt_metapinit(index); _bt_metapinit(index);
...@@ -146,7 +141,7 @@ btbuild(PG_FUNCTION_ARGS) ...@@ -146,7 +141,7 @@ btbuild(PG_FUNCTION_ARGS)
if (usefast) if (usefast)
{ {
spool = _bt_spoolinit(index, isunique); spool = _bt_spoolinit(index, unique);
res = (InsertIndexResult) NULL; res = (InsertIndexResult) NULL;
} }
...@@ -254,7 +249,7 @@ btbuild(PG_FUNCTION_ARGS) ...@@ -254,7 +249,7 @@ btbuild(PG_FUNCTION_ARGS)
if (usefast) if (usefast)
_bt_spool(btitem, spool); _bt_spool(btitem, spool);
else else
res = _bt_doinsert(index, btitem, isunique, heap); res = _bt_doinsert(index, btitem, unique, heap);
pfree(btitem); pfree(btitem);
pfree(itup); pfree(itup);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.49 2000/06/14 05:24:43 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.50 2000/06/17 23:41:22 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -66,13 +66,12 @@ rtbuild(PG_FUNCTION_ARGS) ...@@ -66,13 +66,12 @@ rtbuild(PG_FUNCTION_ARGS)
Relation index = (Relation) PG_GETARG_POINTER(1); Relation index = (Relation) PG_GETARG_POINTER(1);
int32 natts = PG_GETARG_INT32(2); int32 natts = PG_GETARG_INT32(2);
AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3); AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3);
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(4);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(5);
#ifdef NOT_USED #ifdef NOT_USED
IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(4); bool unique = PG_GETARG_BOOL(6);
uint16 pcount = PG_GETARG_UINT16(5); IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(7);
Datum *params = (Datum *) PG_GETARG_POINTER(6);
#endif #endif
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(7);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(8);
HeapScanDesc scan; HeapScanDesc scan;
AttrNumber i; AttrNumber i;
HeapTuple htup; HeapTuple htup;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.85 2000/06/05 07:28:40 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.86 2000/06/17 23:41:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -161,10 +161,9 @@ typedef struct _IndexList ...@@ -161,10 +161,9 @@ typedef struct _IndexList
char *il_ind; char *il_ind;
int il_natts; int il_natts;
AttrNumber *il_attnos; AttrNumber *il_attnos;
uint16 il_nparams;
Datum *il_params;
FuncIndexInfo *il_finfo; FuncIndexInfo *il_finfo;
PredInfo *il_predInfo; PredInfo *il_predInfo;
bool il_unique;
struct _IndexList *il_next; struct _IndexList *il_next;
} IndexList; } IndexList;
...@@ -1071,12 +1070,10 @@ index_register(char *heap, ...@@ -1071,12 +1070,10 @@ index_register(char *heap,
char *ind, char *ind,
int natts, int natts,
AttrNumber *attnos, AttrNumber *attnos,
uint16 nparams,
Datum *params,
FuncIndexInfo *finfo, FuncIndexInfo *finfo,
PredInfo *predInfo) PredInfo *predInfo,
bool unique)
{ {
Datum *v;
IndexList *newind; IndexList *newind;
int len; int len;
MemoryContext oldcxt; MemoryContext oldcxt;
...@@ -1103,25 +1100,12 @@ index_register(char *heap, ...@@ -1103,25 +1100,12 @@ index_register(char *heap,
len = natts * sizeof(AttrNumber); len = natts * sizeof(AttrNumber);
newind->il_attnos = (AttrNumber *) palloc(len); newind->il_attnos = (AttrNumber *) palloc(len);
memmove(newind->il_attnos, attnos, len); memcpy(newind->il_attnos, attnos, len);
if ((newind->il_nparams = nparams) > 0) if (PointerIsValid(finfo))
{
v = newind->il_params = (Datum *) palloc(2 * nparams * sizeof(Datum));
nparams *= 2;
while (nparams-- > 0)
{
*v = (Datum) palloc(strlen((char *) (*params)) + 1);
strcpy((char *) *v++, (char *) *params++);
}
}
else
newind->il_params = (Datum *) NULL;
if (finfo != (FuncIndexInfo *) NULL)
{ {
newind->il_finfo = (FuncIndexInfo *) palloc(sizeof(FuncIndexInfo)); newind->il_finfo = (FuncIndexInfo *) palloc(sizeof(FuncIndexInfo));
memmove(newind->il_finfo, finfo, sizeof(FuncIndexInfo)); memcpy(newind->il_finfo, finfo, sizeof(FuncIndexInfo));
} }
else else
newind->il_finfo = (FuncIndexInfo *) NULL; newind->il_finfo = (FuncIndexInfo *) NULL;
...@@ -1135,6 +1119,8 @@ index_register(char *heap, ...@@ -1135,6 +1119,8 @@ index_register(char *heap,
else else
newind->il_predInfo = NULL; newind->il_predInfo = NULL;
newind->il_unique = unique;
newind->il_next = ILHead; newind->il_next = ILHead;
ILHead = newind; ILHead = newind;
...@@ -1155,8 +1141,8 @@ build_indices() ...@@ -1155,8 +1141,8 @@ build_indices()
ind = index_openr(ILHead->il_ind); ind = index_openr(ILHead->il_ind);
Assert(ind); Assert(ind);
index_build(heap, ind, ILHead->il_natts, ILHead->il_attnos, index_build(heap, ind, ILHead->il_natts, ILHead->il_attnos,
ILHead->il_nparams, ILHead->il_params, ILHead->il_finfo, ILHead->il_finfo, ILHead->il_predInfo,
ILHead->il_predInfo); ILHead->il_unique);
/* /*
* In normal processing mode, index_build would close the heap and * In normal processing mode, index_build would close the heap and
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.131 2000/06/15 03:32:01 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.132 2000/06/17 23:41:31 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -1112,6 +1112,7 @@ RelationTruncateIndexes(Relation heapRelation) ...@@ -1112,6 +1112,7 @@ RelationTruncateIndexes(Relation heapRelation)
AttrNumber *attributeNumberA; AttrNumber *attributeNumberA;
FuncIndexInfo fInfo, FuncIndexInfo fInfo,
*funcInfo = NULL; *funcInfo = NULL;
bool unique;
int i, int i,
numberOfAttributes; numberOfAttributes;
char *predString; char *predString;
...@@ -1134,6 +1135,7 @@ RelationTruncateIndexes(Relation heapRelation) ...@@ -1134,6 +1135,7 @@ RelationTruncateIndexes(Relation heapRelation)
index = (Form_pg_index) GETSTRUCT(indexTuple); index = (Form_pg_index) GETSTRUCT(indexTuple);
indexId = index->indexrelid; indexId = index->indexrelid;
procId = index->indproc; procId = index->indproc;
unique = index->indisunique;
for (i = 0; i < INDEX_MAX_KEYS; i++) for (i = 0; i < INDEX_MAX_KEYS; i++)
{ {
...@@ -1201,7 +1203,7 @@ RelationTruncateIndexes(Relation heapRelation) ...@@ -1201,7 +1203,7 @@ RelationTruncateIndexes(Relation heapRelation)
/* Initialize the index and rebuild */ /* Initialize the index and rebuild */
InitIndexStrategy(numberOfAttributes, currentIndex, accessMethodId); InitIndexStrategy(numberOfAttributes, currentIndex, accessMethodId);
index_build(heapRelation, currentIndex, numberOfAttributes, index_build(heapRelation, currentIndex, numberOfAttributes,
attributeNumberA, 0, NULL, funcInfo, predInfo); attributeNumberA, funcInfo, predInfo, unique);
/* /*
* index_build will close both the heap and index relations (but * index_build will close both the heap and index relations (but
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.117 2000/06/17 21:48:39 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.118 2000/06/17 23:41:34 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -72,9 +72,9 @@ static void UpdateIndexRelation(Oid indexoid, Oid heapoid, ...@@ -72,9 +72,9 @@ static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
AttrNumber *attNums, Oid *classOids, Node *predicate, AttrNumber *attNums, Oid *classOids, Node *predicate,
List *attributeList, bool islossy, bool unique, bool primary); List *attributeList, bool islossy, bool unique, bool primary);
static void DefaultBuild(Relation heapRelation, Relation indexRelation, static void DefaultBuild(Relation heapRelation, Relation indexRelation,
int numberOfAttributes, AttrNumber *attributeNumber, int numberOfAttributes, AttrNumber *attributeNumber,
IndexStrategy indexStrategy, uint16 parameterCount, FuncIndexInfoPtr funcInfo, PredInfo *predInfo,
Datum *parameter, FuncIndexInfoPtr funcInfo, PredInfo *predInfo); bool unique, IndexStrategy indexStrategy);
static Oid IndexGetRelation(Oid indexId); static Oid IndexGetRelation(Oid indexId);
static bool activate_index(Oid indexId, bool activate); static bool activate_index(Oid indexId, bool activate);
...@@ -952,8 +952,6 @@ index_create(char *heapRelationName, ...@@ -952,8 +952,6 @@ index_create(char *heapRelationName,
int numatts, int numatts,
AttrNumber *attNums, AttrNumber *attNums,
Oid *classObjectId, Oid *classObjectId,
uint16 parameterCount,
Datum *parameter,
Node *predicate, Node *predicate,
bool islossy, bool islossy,
bool unique, bool unique,
...@@ -1086,13 +1084,13 @@ index_create(char *heapRelationName, ...@@ -1086,13 +1084,13 @@ index_create(char *heapRelationName,
if (IsBootstrapProcessingMode()) if (IsBootstrapProcessingMode())
{ {
index_register(heapRelationName, indexRelationName, numatts, attNums, index_register(heapRelationName, indexRelationName, numatts, attNums,
parameterCount, parameter, funcInfo, predInfo); funcInfo, predInfo, unique);
/* XXX shouldn't we close the heap and index rels here? */ /* XXX shouldn't we close the heap and index rels here? */
} }
else else
{ {
index_build(heapRelation, indexRelation, numatts, attNums, index_build(heapRelation, indexRelation, numatts, attNums,
parameterCount, parameter, funcInfo, predInfo); funcInfo, predInfo, unique);
} }
} }
...@@ -1706,6 +1704,11 @@ FillDummyExprContext(ExprContext *econtext, ...@@ -1706,6 +1704,11 @@ FillDummyExprContext(ExprContext *econtext,
/* ---------------- /* ----------------
* DefaultBuild * DefaultBuild
*
* NB: this routine is dead code, and likely always has been, because
* there are no access methods that don't supply their own ambuild procedure.
*
* Anyone want to wager whether it would actually work if executed?
* ---------------- * ----------------
*/ */
static void static void
...@@ -1713,11 +1716,10 @@ DefaultBuild(Relation heapRelation, ...@@ -1713,11 +1716,10 @@ DefaultBuild(Relation heapRelation,
Relation indexRelation, Relation indexRelation,
int numberOfAttributes, int numberOfAttributes,
AttrNumber *attributeNumber, AttrNumber *attributeNumber,
IndexStrategy indexStrategy, /* not used */
uint16 parameterCount, /* not used */
Datum *parameter, /* not used */
FuncIndexInfoPtr funcInfo, FuncIndexInfoPtr funcInfo,
PredInfo *predInfo) PredInfo *predInfo,
bool unique, /* not used */
IndexStrategy indexStrategy) /* not used */
{ {
HeapScanDesc scan; HeapScanDesc scan;
HeapTuple heapTuple; HeapTuple heapTuple;
...@@ -1925,10 +1927,9 @@ index_build(Relation heapRelation, ...@@ -1925,10 +1927,9 @@ index_build(Relation heapRelation,
Relation indexRelation, Relation indexRelation,
int numberOfAttributes, int numberOfAttributes,
AttrNumber *attributeNumber, AttrNumber *attributeNumber,
uint16 parameterCount,
Datum *parameter,
FuncIndexInfo *funcInfo, FuncIndexInfo *funcInfo,
PredInfo *predInfo) PredInfo *predInfo,
bool unique)
{ {
RegProcedure procedure; RegProcedure procedure;
...@@ -1942,30 +1943,28 @@ index_build(Relation heapRelation, ...@@ -1942,30 +1943,28 @@ index_build(Relation heapRelation,
procedure = indexRelation->rd_am->ambuild; procedure = indexRelation->rd_am->ambuild;
/* ---------------- /* ----------------
* use the access method build procedure if supplied.. * use the access method build procedure if supplied, else default.
* ---------------- * ----------------
*/ */
if (RegProcedureIsValid(procedure)) if (RegProcedureIsValid(procedure))
OidFunctionCall9(procedure, OidFunctionCall8(procedure,
PointerGetDatum(heapRelation), PointerGetDatum(heapRelation),
PointerGetDatum(indexRelation), PointerGetDatum(indexRelation),
Int32GetDatum(numberOfAttributes), Int32GetDatum(numberOfAttributes),
PointerGetDatum(attributeNumber), PointerGetDatum(attributeNumber),
PointerGetDatum(RelationGetIndexStrategy(indexRelation)),
UInt16GetDatum(parameterCount),
PointerGetDatum(parameter),
PointerGetDatum(funcInfo), PointerGetDatum(funcInfo),
PointerGetDatum(predInfo)); PointerGetDatum(predInfo),
BoolGetDatum(unique),
PointerGetDatum(RelationGetIndexStrategy(indexRelation)));
else else
DefaultBuild(heapRelation, DefaultBuild(heapRelation,
indexRelation, indexRelation,
numberOfAttributes, numberOfAttributes,
attributeNumber, attributeNumber,
RelationGetIndexStrategy(indexRelation),
parameterCount,
parameter,
funcInfo, funcInfo,
predInfo); predInfo,
unique,
RelationGetIndexStrategy(indexRelation));
} }
/* /*
...@@ -2016,51 +2015,6 @@ IndexIsUnique(Oid indexId) ...@@ -2016,51 +2015,6 @@ IndexIsUnique(Oid indexId)
return index->indisunique; return index->indisunique;
} }
/*
* IndexIsUniqueNoCache: same as above function, but don't use the
* system cache. if we are called from btbuild, the transaction
* that is adding the entry to pg_index has not been committed yet.
* the system cache functions will do a heap scan, but only with
* NowTimeQual, not SelfTimeQual, so it won't find tuples added
* by the current transaction (which is good, because if the transaction
* is aborted, you don't want the tuples sitting around in the cache).
* so anyway, we have to do our own scan with SelfTimeQual.
* this is only called when a new index is created, so it's OK
* if it's slow.
*/
bool
IndexIsUniqueNoCache(Oid indexId)
{
Relation pg_index;
ScanKeyData skey[1];
HeapScanDesc scandesc;
HeapTuple tuple;
Form_pg_index index;
bool isunique;
pg_index = heap_openr(IndexRelationName, AccessShareLock);
ScanKeyEntryInitialize(&skey[0], (bits16) 0x0,
Anum_pg_index_indexrelid,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(indexId));
scandesc = heap_beginscan(pg_index, 0, SnapshotSelf, 1, skey);
/* NO CACHE */
tuple = heap_getnext(scandesc, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "IndexIsUniqueNoCache: can't find index id %u", indexId);
index = (Form_pg_index) GETSTRUCT(tuple);
Assert(index->indexrelid == indexId);
isunique = index->indisunique;
heap_endscan(scandesc);
heap_close(pg_index, AccessShareLock);
return isunique;
}
/* --------------------------------- /* ---------------------------------
* activate_index -- activate/deactivate the specified index. * activate_index -- activate/deactivate the specified index.
...@@ -2102,6 +2056,7 @@ reindex_index(Oid indexId, bool force) ...@@ -2102,6 +2056,7 @@ reindex_index(Oid indexId, bool force)
*funcInfo = NULL; *funcInfo = NULL;
int i, int i,
numberOfAttributes; numberOfAttributes;
bool unique;
char *predString; char *predString;
bool old; bool old;
...@@ -2121,6 +2076,7 @@ reindex_index(Oid indexId, bool force) ...@@ -2121,6 +2076,7 @@ reindex_index(Oid indexId, bool force)
index = (Form_pg_index) GETSTRUCT(indexTuple); index = (Form_pg_index) GETSTRUCT(indexTuple);
heapId = index->indrelid; heapId = index->indrelid;
procId = index->indproc; procId = index->indproc;
unique = index->indisunique;
for (i = 0; i < INDEX_MAX_KEYS; i++) for (i = 0; i < INDEX_MAX_KEYS; i++)
{ {
...@@ -2189,7 +2145,7 @@ reindex_index(Oid indexId, bool force) ...@@ -2189,7 +2145,7 @@ reindex_index(Oid indexId, bool force)
/* Initialize the index and rebuild */ /* Initialize the index and rebuild */
InitIndexStrategy(numberOfAttributes, iRel, accessMethodId); InitIndexStrategy(numberOfAttributes, iRel, accessMethodId);
index_build(heapRelation, iRel, numberOfAttributes, index_build(heapRelation, iRel, numberOfAttributes,
attributeNumberA, 0, NULL, funcInfo, predInfo); attributeNumberA, funcInfo, predInfo, unique);
/* /*
* index_build will close both the heap and index relations (but not * index_build will close both the heap and index relations (but not
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.55 2000/06/15 03:32:07 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.56 2000/06/17 23:41:36 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -273,7 +273,6 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap) ...@@ -273,7 +273,6 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
natts, natts,
Old_pg_index_Form->indkey, Old_pg_index_Form->indkey,
Old_pg_index_Form->indclass, Old_pg_index_Form->indclass,
(uint16) 0, (Datum *) NULL,
(Node *) NULL, /* XXX where's the predicate? */ (Node *) NULL, /* XXX where's the predicate? */
Old_pg_index_Form->indislossy, Old_pg_index_Form->indislossy,
Old_pg_index_Form->indisunique, Old_pg_index_Form->indisunique,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.30 2000/06/17 21:48:42 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.31 2000/06/17 23:41:36 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -90,11 +90,9 @@ DefineIndex(char *heapRelationName, ...@@ -90,11 +90,9 @@ DefineIndex(char *heapRelationName,
int numberOfAttributes; int numberOfAttributes;
AttrNumber *attributeNumberA; AttrNumber *attributeNumberA;
HeapTuple tuple; HeapTuple tuple;
uint16 parameterCount = 0;
Datum *parameterA = NULL;
FuncIndexInfo fInfo; FuncIndexInfo fInfo;
List *cnfPred = NULL; List *cnfPred = NULL;
bool lossy = FALSE; bool lossy = false;
List *pl; List *pl;
/* /*
...@@ -198,7 +196,7 @@ DefineIndex(char *heapRelationName, ...@@ -198,7 +196,7 @@ DefineIndex(char *heapRelationName,
index_create(heapRelationName, indexRelationName, index_create(heapRelationName, indexRelationName,
&fInfo, NULL, &fInfo, NULL,
accessMethodId, numberOfAttributes, attributeNumberA, accessMethodId, numberOfAttributes, attributeNumberA,
classObjectId, parameterCount, parameterA, classObjectId,
(Node *) cnfPred, (Node *) cnfPred,
lossy, unique, primary); lossy, unique, primary);
} }
...@@ -216,7 +214,7 @@ DefineIndex(char *heapRelationName, ...@@ -216,7 +214,7 @@ DefineIndex(char *heapRelationName,
index_create(heapRelationName, indexRelationName, index_create(heapRelationName, indexRelationName,
NULL, attributeList, NULL, attributeList,
accessMethodId, numberOfAttributes, attributeNumberA, accessMethodId, numberOfAttributes, attributeNumberA,
classObjectId, parameterCount, parameterA, classObjectId,
(Node *) cnfPred, (Node *) cnfPred,
lossy, unique, primary); lossy, unique, primary);
} }
...@@ -252,6 +250,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable) ...@@ -252,6 +250,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
HeapTuple tuple; HeapTuple tuple;
FuncIndexInfo fInfo; FuncIndexInfo fInfo;
FuncIndexInfo *funcInfo = NULL; FuncIndexInfo *funcInfo = NULL;
bool unique;
Form_pg_index index; Form_pg_index index;
Node *oldPred = NULL; Node *oldPred = NULL;
List *cnfPred = NULL; List *cnfPred = NULL;
...@@ -293,6 +292,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable) ...@@ -293,6 +292,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
Assert(index->indexrelid == indexId); Assert(index->indexrelid == indexId);
relationId = index->indrelid; relationId = index->indrelid;
indproc = index->indproc; indproc = index->indproc;
unique = index->indisunique;
for (i = 0; i < INDEX_MAX_KEYS; i++) for (i = 0; i < INDEX_MAX_KEYS; i++)
{ {
...@@ -366,7 +366,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable) ...@@ -366,7 +366,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
InitIndexStrategy(numberOfAttributes, indexRelation, accessMethodId); InitIndexStrategy(numberOfAttributes, indexRelation, accessMethodId);
index_build(heapRelation, indexRelation, numberOfAttributes, index_build(heapRelation, indexRelation, numberOfAttributes,
attributeNumberA, 0, NULL, funcInfo, predInfo); attributeNumberA, funcInfo, predInfo, unique);
/* heap and index rels are closed as a side-effect of index_build */ /* heap and index rels are closed as a side-effect of index_build */
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.70 2000/06/15 06:07:34 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.71 2000/06/17 23:41:39 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -165,7 +165,7 @@ inv_create(int flags) ...@@ -165,7 +165,7 @@ inv_create(int flags)
classObjectId[0] = INT4_OPS_OID; classObjectId[0] = INT4_OPS_OID;
index_create(objname, indname, NULL, NULL, BTREE_AM_OID, index_create(objname, indname, NULL, NULL, BTREE_AM_OID,
1, &attNums[0], &classObjectId[0], 1, &attNums[0], &classObjectId[0],
0, (Datum) NULL, NULL, FALSE, FALSE, FALSE); (Node *) NULL, false, false, false);
/* make the index visible in this transaction */ /* make the index visible in this transaction */
CommandCounterIncrement(); CommandCounterIncrement();
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: bootstrap.h,v 1.17 2000/01/26 05:57:53 momjian Exp $ * $Id: bootstrap.h,v 1.18 2000/06/17 23:41:49 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -34,14 +34,11 @@ extern int numattr; ...@@ -34,14 +34,11 @@ extern int numattr;
extern int DebugMode; extern int DebugMode;
extern int BootstrapMain(int ac, char *av[]); extern int BootstrapMain(int ac, char *av[]);
extern void index_register(char *heap,
char *ind, extern void index_register(char *heap, char *ind,
int natts, int natts, AttrNumber *attnos,
AttrNumber *attnos, FuncIndexInfo *finfo, PredInfo *predInfo,
uint16 nparams, bool unique);
Datum *params,
FuncIndexInfo *finfo,
PredInfo *predInfo);
extern void err_out(void); extern void err_out(void);
extern void InsertOneTuple(Oid objectid); extern void InsertOneTuple(Oid objectid);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: index.h,v 1.24 2000/06/08 22:37:39 momjian Exp $ * $Id: index.h,v 1.25 2000/06/17 23:41:51 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -33,8 +33,6 @@ extern void index_create(char *heapRelationName, ...@@ -33,8 +33,6 @@ extern void index_create(char *heapRelationName,
int numatts, int numatts,
AttrNumber *attNums, AttrNumber *attNums,
Oid *classObjectId, Oid *classObjectId,
uint16 parameterCount,
Datum *parameter,
Node *predicate, Node *predicate,
bool islossy, bool islossy,
bool unique, bool unique,
...@@ -57,12 +55,11 @@ extern void FillDummyExprContext(ExprContext *econtext, TupleTableSlot *slot, ...@@ -57,12 +55,11 @@ extern void FillDummyExprContext(ExprContext *econtext, TupleTableSlot *slot,
TupleDesc tupdesc, Buffer buffer); TupleDesc tupdesc, Buffer buffer);
extern void index_build(Relation heapRelation, Relation indexRelation, extern void index_build(Relation heapRelation, Relation indexRelation,
int numberOfAttributes, AttrNumber *attributeNumber, int numberOfAttributes, AttrNumber *attributeNumber,
uint16 parameterCount, Datum *parameter, FuncIndexInfo *funcInfo, FuncIndexInfo *funcInfo, PredInfo *predInfo,
PredInfo *predInfo); bool unique);
extern bool IndexIsUnique(Oid indexId); extern bool IndexIsUnique(Oid indexId);
extern bool IndexIsUniqueNoCache(Oid indexId);
extern bool reindex_index(Oid indexId, bool force); extern bool reindex_index(Oid indexId, bool force);
extern bool activate_indexes_of_a_table(Oid relid, bool activate); extern bool activate_indexes_of_a_table(Oid relid, bool activate);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_proc.h,v 1.139 2000/06/13 07:35:19 tgl Exp $ * $Id: pg_proc.h,v 1.140 2000/06/17 23:41:51 tgl Exp $
* *
* NOTES * NOTES
* The script catalog/genbki.sh reads this file and generates .bki * The script catalog/genbki.sh reads this file and generates .bki
...@@ -677,7 +677,7 @@ DATA(insert OID = 321 ( rtdelete PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 ...@@ -677,7 +677,7 @@ DATA(insert OID = 321 ( rtdelete PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
DATA(insert OID = 322 ( rtgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 rtgettuple - )); DATA(insert OID = 322 ( rtgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 rtgettuple - ));
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
DATA(insert OID = 323 ( rtbuild PGUID 12 f t f t 9 f 23 "0 0 0 0 0 0 0 0 0" 100 0 0 100 rtbuild - )); DATA(insert OID = 323 ( rtbuild PGUID 12 f t f t 8 f 23 "0 0 0 0 0 0 0 0" 100 0 0 100 rtbuild - ));
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
DATA(insert OID = 324 ( rtbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 rtbeginscan - )); DATA(insert OID = 324 ( rtbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 rtbeginscan - ));
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
...@@ -706,7 +706,7 @@ DATA(insert OID = 336 ( btmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 ...@@ -706,7 +706,7 @@ DATA(insert OID = 336 ( btmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100
DESCR("btree(internal)"); DESCR("btree(internal)");
DATA(insert OID = 337 ( btrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btrestrpos - )); DATA(insert OID = 337 ( btrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btrestrpos - ));
DESCR("btree(internal)"); DESCR("btree(internal)");
DATA(insert OID = 338 ( btbuild PGUID 12 f t f t 9 f 23 "0 0 0 0 0 0 0 0 0" 100 0 0 100 btbuild - )); DATA(insert OID = 338 ( btbuild PGUID 12 f t f t 8 f 23 "0 0 0 0 0 0 0 0" 100 0 0 100 btbuild - ));
DESCR("btree(internal)"); DESCR("btree(internal)");
DATA(insert OID = 339 ( poly_same PGUID 11 f t t t 2 f 16 "604 604" 100 0 1 0 poly_same - )); DATA(insert OID = 339 ( poly_same PGUID 11 f t t t 2 f 16 "604 604" 100 0 1 0 poly_same - ));
...@@ -814,7 +814,7 @@ DATA(insert OID = 446 ( hashmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 ...@@ -814,7 +814,7 @@ DATA(insert OID = 446 ( hashmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100
DESCR("hash(internal)"); DESCR("hash(internal)");
DATA(insert OID = 447 ( hashrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashrestrpos - )); DATA(insert OID = 447 ( hashrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashrestrpos - ));
DESCR("hash(internal)"); DESCR("hash(internal)");
DATA(insert OID = 448 ( hashbuild PGUID 12 f t f t 9 f 23 "0 0 0 0 0 0 0 0 0" 100 0 0 100 hashbuild - )); DATA(insert OID = 448 ( hashbuild PGUID 12 f t f t 8 f 23 "0 0 0 0 0 0 0 0" 100 0 0 100 hashbuild - ));
DESCR("hash(internal)"); DESCR("hash(internal)");
DATA(insert OID = 449 ( hashint2 PGUID 12 f t t t 1 f 23 "21" 100 0 0 100 hashint2 - )); DATA(insert OID = 449 ( hashint2 PGUID 12 f t t t 1 f 23 "21" 100 0 0 100 hashint2 - ));
DESCR("hash"); DESCR("hash");
...@@ -1040,7 +1040,7 @@ DATA(insert OID = 780 ( gistmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 ...@@ -1040,7 +1040,7 @@ DATA(insert OID = 780 ( gistmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100
DESCR("gist(internal)"); DESCR("gist(internal)");
DATA(insert OID = 781 ( gistrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistrestrpos - )); DATA(insert OID = 781 ( gistrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistrestrpos - ));
DESCR("gist(internal)"); DESCR("gist(internal)");
DATA(insert OID = 782 ( gistbuild PGUID 12 f t f t 9 f 23 "0 0 0 0 0 0 0 0 0" 100 0 0 100 gistbuild - )); DATA(insert OID = 782 ( gistbuild PGUID 12 f t f t 8 f 23 "0 0 0 0 0 0 0 0" 100 0 0 100 gistbuild - ));
DESCR("gist(internal)"); DESCR("gist(internal)");
DATA(insert OID = 784 ( tintervaleq PGUID 12 f t f t 2 f 16 "704 704" 100 0 0 100 tintervaleq - )); DATA(insert OID = 784 ( tintervaleq PGUID 12 f t f t 2 f 16 "704 704" 100 0 0 100 tintervaleq - ));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment