aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/access/gist/gist.c2
-rw-r--r--src/backend/access/hash/hash.c4
-rw-r--r--src/backend/access/index/indexam.c7
-rw-r--r--src/backend/access/nbtree/nbtinsert.c147
-rw-r--r--src/backend/access/nbtree/nbtree.c14
-rw-r--r--src/backend/access/nbtree/nbtsearch.c6
-rw-r--r--src/backend/access/rtree/rtree.c4
-rw-r--r--src/backend/bootstrap/bootparse.y4
-rw-r--r--src/backend/catalog/index.c81
-rw-r--r--src/backend/catalog/indexing.c4
-rw-r--r--src/backend/catalog/unused_oids41
-rw-r--r--src/backend/commands/cluster.c6
-rw-r--r--src/backend/commands/copy.c4
-rw-r--r--src/backend/commands/defind.c7
-rw-r--r--src/backend/executor/execMain.c7
-rw-r--r--src/backend/executor/execUtils.c9
-rw-r--r--src/backend/nodes/copyfuncs.c44
-rw-r--r--src/backend/parser/analyze.c50
-rw-r--r--src/backend/parser/catalog_utils.c48
-rw-r--r--src/backend/parser/gram.y32
-rw-r--r--src/backend/parser/keywords.c3
-rw-r--r--src/backend/parser/parse_query.c6
-rw-r--r--src/backend/parser/parser.c28
-rw-r--r--src/backend/storage/large_object/inv_api.c6
-rw-r--r--src/backend/storage/page/bufpage.c10
-rw-r--r--src/backend/tcop/utility.c3
-rw-r--r--src/backend/utils/cache/catcache.c3
27 files changed, 413 insertions, 167 deletions
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index 7fbf0ef07d3..5188c8bf90a 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -292,7 +292,7 @@ gistbuild(Relation heap,
* It doesn't do any work; just locks the relation and passes the buck.
*/
InsertIndexResult
-gistinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid)
+gistinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, bool is_update)
{
InsertIndexResult res;
IndexTuple itup;
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index 0ab47a5cd8c..973902c85cc 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.10 1996/11/05 09:40:17 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.11 1996/11/13 20:46:48 scrappy Exp $
*
* NOTES
* This file contains only the public interface routines.
@@ -257,7 +257,7 @@ hashbuild(Relation heap,
* to the caller.
*/
InsertIndexResult
-hashinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid)
+hashinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, bool is_update)
{
HashItem hitem;
IndexTuple itup;
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index dc354bdfaaf..92b7d4236ef 100644
--- a/src/backend/access/index/indexam.c
+++ b/src/backend/access/index/indexam.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.7 1996/11/05 10:02:03 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.8 1996/11/13 20:46:59 scrappy Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relationId
@@ -164,7 +164,8 @@ InsertIndexResult
index_insert(Relation relation,
Datum *datum,
char *nulls,
- ItemPointer heap_t_ctid)
+ ItemPointer heap_t_ctid,
+ bool is_update)
{
RegProcedure procedure;
InsertIndexResult specificResult;
@@ -177,7 +178,7 @@ index_insert(Relation relation,
* ----------------
*/
specificResult = (InsertIndexResult)
- fmgr(procedure, relation, datum, nulls, heap_t_ctid, NULL);
+ fmgr(procedure, relation, datum, nulls, heap_t_ctid, is_update, NULL);
/* ----------------
* the insert proc is supposed to return a "specific result" and
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c
index 63e06f8e1e3..c1cedd33bda 100644
--- a/src/backend/access/nbtree/nbtinsert.c
+++ b/src/backend/access/nbtree/nbtinsert.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.6 1996/11/05 10:35:29 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.7 1996/11/13 20:47:11 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -31,7 +31,10 @@ static OffsetNumber _bt_findsplitloc(Relation rel, Page page, OffsetNumber start
static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf);
static OffsetNumber _bt_pgaddtup(Relation rel, Buffer buf, int keysz, ScanKey itup_scankey, Size itemsize, BTItem btitem, BTItem afteritem);
static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem);
+
+#if 0
static void _bt_updateitem(Relation rel, Size keysz, Buffer buf, Oid bti_oid, BTItem newItem);
+#endif
/*
* _bt_doinsert() -- Handle insertion of a single btitem in the tree.
@@ -41,7 +44,7 @@ static void _bt_updateitem(Relation rel, Size keysz, Buffer buf, Oid bti_oid, BT
* (xid, seqno) pair.
*/
InsertIndexResult
-_bt_doinsert(Relation rel, BTItem btitem)
+_bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, bool is_update)
{
ScanKey itup_scankey;
IndexTuple itup;
@@ -59,6 +62,31 @@ _bt_doinsert(Relation rel, BTItem btitem)
/* find the page containing this key */
stack = _bt_search(rel, natts, itup_scankey, &buf);
+
+ /* if we're not allowing duplicates, make sure the key isn't */
+ /* already in the node */
+ if(index_is_unique && !is_update) {
+ OffsetNumber offset;
+ TupleDesc itupdesc;
+ Page page;
+
+ itupdesc = RelationGetTupleDescriptor(rel);
+ page = BufferGetPage(buf);
+
+ offset = _bt_binsrch(rel, buf, natts, itup_scankey, BT_DESCENT);
+
+ /* make sure the offset we're given points to an actual */
+ /* key on the page before trying to compare it */
+ if(!PageIsEmpty(page) &&
+ offset <= PageGetMaxOffsetNumber(page)) {
+ if(!_bt_compare(rel, itupdesc, page,
+ natts, itup_scankey, offset)) {
+ /* it is a duplicate */
+ elog(WARN, "Cannot insert a duplicate key into a unique index.");
+ }
+ }
+ }
+
blkno = BufferGetBlockNumber(buf);
/* trade in our read lock for a write lock */
@@ -137,6 +165,10 @@ _bt_insertonpg(Relation rel,
InsertIndexResult newres;
BTItem new_item = (BTItem) NULL;
BTItem lowLeftItem;
+ OffsetNumber leftmost_offset;
+ Page ppage;
+ BTPageOpaque ppageop;
+ BlockNumber bknum;
page = BufferGetPage(buf);
itemsz = IndexTupleDSize(btitem->bti_itup)
@@ -236,14 +268,67 @@ _bt_insertonpg(Relation rel,
lowLeftItem =
(BTItem) PageGetItem(page,
PageGetItemId(page, P_FIRSTKEY));
- /* page must have right pointer after split */
- _bt_updateitem(rel, keysz, pbuf, stack->bts_btitem->bti_oid,
- lowLeftItem);
+
+ /* this method does not work--_bt_updateitem tries to */
+ /* overwrite an entry with another entry that might be */
+ /* bigger. if lowLeftItem is bigger, it corrupts the */
+ /* parent page. instead, we have to delete the original */
+ /* leftmost item from the parent, and insert the new one */
+ /* with a regular _bt_insertonpg (it could cause a split */
+ /* because it's bigger than what was there before). */
+ /* --djm 8/21/96 */
+
+ /* _bt_updateitem(rel, keysz, pbuf, stack->bts_btitem->bti_oid,
+ lowLeftItem); */
+
+ /* get the parent page */
+ ppage = BufferGetPage(pbuf);
+ ppageop = (BTPageOpaque) PageGetSpecialPointer(ppage);
+
+ /* figure out which key is leftmost (if the parent page */
+ /* is rightmost, too, it must be the root) */
+ if(P_RIGHTMOST(ppageop)) {
+ leftmost_offset = P_HIKEY;
+ } else {
+ leftmost_offset = P_FIRSTKEY;
}
+ PageIndexTupleDelete(ppage, leftmost_offset);
+
+ /* don't write anything out yet--we still have the write */
+ /* lock, and now we call another _bt_insertonpg to */
+ /* insert the correct leftmost key */
+
+ /* make a new leftmost item, using the tuple data from */
+ /* lowLeftItem. point it to the left child. */
+ /* update it on the stack at the same time. */
+ bknum = BufferGetBlockNumber(buf);
+ pfree(stack->bts_btitem);
+ stack->bts_btitem = _bt_formitem(&(lowLeftItem->bti_itup));
+ ItemPointerSet(&(stack->bts_btitem->bti_itup.t_tid),
+ bknum, P_HIKEY);
+
+ /* unlock the children before doing this */
+ _bt_relbuf(rel, buf, BT_WRITE);
+ _bt_relbuf(rel, rbuf, BT_WRITE);
+
+ /* a regular _bt_binsrch should find the right place to */
+ /* put the new entry, since it should be lower than any */
+ /* other key on the page, therefore set afteritem to NULL */
+ newskey = _bt_mkscankey(rel, &(stack->bts_btitem->bti_itup));
+ newres = _bt_insertonpg(rel, pbuf, stack->bts_parent,
+ keysz, newskey, stack->bts_btitem,
+ NULL);
+
+ pfree(newres);
+ pfree(newskey);
- /* don't need the children anymore */
+ /* we have now lost our lock on the parent buffer, and */
+ /* need to get it back. */
+ pbuf = _bt_getstackbuf(rel, stack, BT_WRITE);
+ } else {
_bt_relbuf(rel, buf, BT_WRITE);
_bt_relbuf(rel, rbuf, BT_WRITE);
+ }
newskey = _bt_mkscankey(rel, &(new_item->bti_itup));
newres = _bt_insertonpg(rel, pbuf, stack->bts_parent,
@@ -787,6 +872,8 @@ _bt_itemcmp(Relation rel,
return (true);
}
+#if 0
+/* gone since updating in place doesn't work in general --djm 11/13/96 */
/*
* _bt_updateitem() -- updates the key of the item identified by the
* oid with the key of newItem (done in place if
@@ -804,9 +891,9 @@ _bt_updateitem(Relation rel,
OffsetNumber maxoff;
OffsetNumber i;
ItemPointerData itemPtrData;
- BTItem item, itemCopy;
+ BTItem item;
IndexTuple oldIndexTuple, newIndexTuple;
- int newSize, oldSize, first;
+ int first;
page = BufferGetPage(buf);
maxoff = PageGetMaxOffsetNumber(page);
@@ -825,48 +912,18 @@ _bt_updateitem(Relation rel,
elog(FATAL, "_bt_getstackbuf was lying!!");
}
+ if(IndexTupleDSize(newItem->bti_itup) >
+ IndexTupleDSize(item->bti_itup)) {
+ elog(NOTICE, "trying to overwrite a smaller value with a bigger one in _bt_updateitem");
+ elog(WARN, "this is not good.");
+ }
+
oldIndexTuple = &(item->bti_itup);
newIndexTuple = &(newItem->bti_itup);
- oldSize = DOUBLEALIGN(IndexTupleSize(oldIndexTuple));
- newSize = DOUBLEALIGN(IndexTupleSize(newIndexTuple));
-#ifdef NBTINSERT_PATCH_DEBUG
- printf("_bt_updateitem: newSize=%d, oldSize=%d\n", newSize, oldSize);
-#endif
- /*
- * If new and old item have the same size do the update in place
- * and return.
- */
- if (oldSize == newSize) {
/* keep the original item pointer */
ItemPointerCopy(&(oldIndexTuple->t_tid), &itemPtrData);
CopyIndexTuple(newIndexTuple, &oldIndexTuple);
ItemPointerCopy(&itemPtrData, &(oldIndexTuple->t_tid));
- return;
- }
-
- /*
- * If new and old items have different size the update in place
- * is not possible. In this case the old item is deleted and the
- * new one is inserted.
- * The new insertion should be done using _bt_insertonpg which
- * would also takes care of the page splitting if needed, but
- * unfortunately it doesn't work, so PageAddItem is used instead.
- * There is the possibility that there is not enough space in the
- * page and the item is not inserted.
- */
- itemCopy = palloc(newSize);
- memmove((char *) itemCopy, (char *) newItem, newSize);
- itemCopy->bti_oid = item->bti_oid;
- newIndexTuple = &(itemCopy->bti_itup);
- ItemPointerCopy(&(oldIndexTuple->t_tid), &(newIndexTuple->t_tid));
-
- /*
- * Get the offset number of the item then delete it and insert
- * the new item in the same place.
- */
- i = OffsetNumberPrev(i);
- PageIndexTupleDelete(page, i);
- PageAddItem(page, (Item) itemCopy, newSize, i, LP_USED);
- pfree(itemCopy);
}
+#endif
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index b5248b23eb3..1aa75f40271 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.9 1996/11/05 10:35:32 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.10 1996/11/13 20:47:18 scrappy Exp $
*
* NOTES
* This file contains only the public interface routines.
@@ -74,6 +74,7 @@ btbuild(Relation heap,
Oid hrelid, irelid;
Node *pred, *oldPred;
void *spool;
+ bool isunique;
/* note that this is a new btree */
BuildingBtree = true;
@@ -81,6 +82,9 @@ btbuild(Relation heap,
pred = predInfo->pred;
oldPred = predInfo->oldPred;
+ /* see if index is unique */
+ isunique = IndexIsUniqueNoCache(RelationGetRelationId(index));
+
/* initialize the btree index metadata page (if this is a new index) */
if (oldPred == NULL)
_bt_metapinit(index);
@@ -218,7 +222,7 @@ btbuild(Relation heap,
if (FastBuild) {
_bt_spool(index, btitem, spool);
} else {
- res = _bt_doinsert(index, btitem);
+ res = _bt_doinsert(index, btitem, isunique, false);
}
pfree(btitem);
@@ -289,7 +293,7 @@ btbuild(Relation heap,
* return an InsertIndexResult to the caller.
*/
InsertIndexResult
-btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid)
+btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, bool is_update)
{
BTItem btitem;
IndexTuple itup;
@@ -304,7 +308,9 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid)
btitem = _bt_formitem(itup);
- res = _bt_doinsert(rel, btitem);
+ res = _bt_doinsert(rel, btitem,
+ IndexIsUnique(RelationGetRelationId(rel)), is_update);
+
pfree(btitem);
pfree(itup);
diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c
index 2866e026475..d6658ea701e 100644
--- a/src/backend/access/nbtree/nbtsearch.c
+++ b/src/backend/access/nbtree/nbtsearch.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.8 1996/11/05 10:35:34 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.9 1996/11/13 20:47:20 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -29,7 +29,7 @@
static BTStack _bt_searchr(Relation rel, int keysz, ScanKey scankey, Buffer *bufP, BTStack stack_in);
static OffsetNumber _bt_firsteq(Relation rel, TupleDesc itupdesc, Page page, Size keysz, ScanKey scankey, OffsetNumber offnum);
-static int _bt_compare(Relation rel, TupleDesc itupdesc, Page page, int keysz, ScanKey scankey, OffsetNumber offnum);
+int _bt_compare(Relation rel, TupleDesc itupdesc, Page page, int keysz, ScanKey scankey, OffsetNumber offnum);
static bool _bt_twostep(IndexScanDesc scan, Buffer *bufP, ScanDirection dir);
static RetrieveIndexResult _bt_endpoint(IndexScanDesc scan, ScanDirection dir);
@@ -413,7 +413,7 @@ _bt_firsteq(Relation rel,
* a new minimal key is inserted, the leftmost entry on the leftmost
* page is less than all possible keys, by definition.
*/
-static int
+int
_bt_compare(Relation rel,
TupleDesc itupdesc,
Page page,
diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c
index 6dfe3b7f37f..b851323d107 100644
--- a/src/backend/access/rtree/rtree.c
+++ b/src/backend/access/rtree/rtree.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.9 1996/11/05 10:54:18 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.10 1996/11/13 20:47:35 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -277,7 +277,7 @@ rtbuild(Relation heap,
* It doesn't do any work; just locks the relation and passes the buck.
*/
InsertIndexResult
-rtinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid)
+rtinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, bool is_update)
{
InsertIndexResult res;
IndexTuple itup;
diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y
index 43c75abee11..c27eabe969f 100644
--- a/src/backend/bootstrap/bootparse.y
+++ b/src/backend/bootstrap/bootparse.y
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.3 1996/10/21 08:31:18 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.4 1996/11/13 20:47:45 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -231,7 +231,7 @@ DeclareIndexStmt:
DefineIndex(LexIDStr($5),
LexIDStr($3),
LexIDStr($7),
- params, NIL, 0, NIL);
+ params, NIL, 0, 0, NIL);
DO_END;
}
;
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index eefa44c7297..14fc47700e5 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.8 1996/11/08 00:44:30 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.9 1996/11/13 20:47:53 scrappy Exp $
*
*
* INTERFACE ROUTINES
@@ -81,7 +81,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts);
static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
FuncIndexInfo *funcInfo, int natts,
AttrNumber attNums[], Oid classOids[], Node *predicate,
- TypeName *indexKeyType, bool islossy);
+ TypeName *indexKeyType, bool islossy, bool unique);
static void DefaultBuild(Relation heapRelation, Relation indexRelation,
int numberOfAttributes, AttrNumber attributeNumber[],
IndexStrategy indexStrategy, uint16 parameterCount,
@@ -742,7 +742,8 @@ UpdateIndexRelation(Oid indexoid,
Oid classOids[],
Node *predicate,
TypeName *indexKeyType,
- bool islossy)
+ bool islossy,
+ bool unique)
{
IndexTupleForm indexForm;
char *predString;
@@ -779,6 +780,7 @@ UpdateIndexRelation(Oid indexoid,
indexForm->indproc = (PointerIsValid(funcInfo)) ?
FIgetProcOid(funcInfo) : InvalidOid;
indexForm->indislossy = islossy;
+ indexForm->indisunique = unique;
if (indexKeyType != NULL)
indexForm->indhaskeytype = 1;
else
@@ -1008,7 +1010,8 @@ index_create(char *heapRelationName,
uint16 parameterCount,
Datum *parameter,
Node *predicate,
- bool islossy)
+ bool islossy,
+ bool unique)
{
Relation heapRelation;
Relation indexRelation;
@@ -1122,7 +1125,7 @@ index_create(char *heapRelationName,
*/
UpdateIndexRelation(indexoid, heapoid, funcInfo,
numatts, attNums, classObjectId, predicate,
- IndexKeyType, islossy);
+ IndexKeyType, islossy, unique);
predInfo = (PredInfo*)palloc(sizeof(PredInfo));
predInfo->pred = predicate;
@@ -1594,7 +1597,7 @@ DefaultBuild(Relation heapRelation,
indexTuple->t_tid = heapTuple->t_ctid;
insertResult = index_insert(indexRelation, datum, nullv,
- &(heapTuple->t_ctid));
+ &(heapTuple->t_ctid), false);
if (insertResult) pfree(insertResult);
pfree(indexTuple);
@@ -1678,4 +1681,70 @@ index_build(Relation heapRelation,
predInfo);
}
+/*
+ * IndexIsUnique: given an index's relation OID, see if it
+ * is unique using the system cache.
+ */
+bool
+IndexIsUnique(Oid indexId)
+{
+ HeapTuple tuple;
+ IndexTupleForm index;
+
+ tuple = SearchSysCacheTuple(INDEXRELID,
+ ObjectIdGetDatum(indexId),
+ 0,0,0);
+ if(!HeapTupleIsValid(tuple)) {
+ elog(WARN, "Can't find index id %d in IndexIsUnique",
+ indexId);
+ }
+ index = (IndexTupleForm)GETSTRUCT(tuple);
+ Assert(index->indexrelid == indexId);
+
+ 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;
+ Buffer b;
+ IndexTupleForm index;
+ bool isunique;
+
+ pg_index = heap_openr(IndexRelationName);
+
+ ScanKeyEntryInitialize(&skey[0], (bits16)0x0,
+ Anum_pg_index_indexrelid,
+ (RegProcedure)ObjectIdEqualRegProcedure,
+ ObjectIdGetDatum(indexId));
+
+ scandesc = heap_beginscan(pg_index, 0, SelfTimeQual, 1, skey);
+
+ tuple = heap_getnext(scandesc, 0, &b);
+ if(!HeapTupleIsValid(tuple)) {
+ elog(WARN, "Can't find index id %d in IndexIsUniqueNoCache",
+ indexId);
+ }
+ index = (IndexTupleForm)GETSTRUCT(tuple);
+ Assert(index->indexrelid == indexId);
+ isunique = index->indisunique;
+
+ ReleaseBuffer(b);
+ return isunique;
+}
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index 34603cb155b..a27496528c7 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.5 1996/11/11 14:02:10 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.6 1996/11/13 20:47:57 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -184,7 +184,7 @@ CatalogIndexInsert(Relation *idescs,
finfoP);
indexRes = index_insert(idescs[i], &datum, nulls,
- &(heapTuple->t_ctid));
+ &(heapTuple->t_ctid), false);
if (indexRes) pfree(indexRes);
}
}
diff --git a/src/backend/catalog/unused_oids b/src/backend/catalog/unused_oids
index 9608204f495..e69de29bb2d 100644
--- a/src/backend/catalog/unused_oids
+++ b/src/backend/catalog/unused_oids
@@ -1,41 +0,0 @@
-#!/bin/sh
-# unused_oids
-#
-# $Header: /cvsroot/pgsql/src/backend/catalog/Attic/unused_oids,v 1.1.1.1 1996/07/09 06:21:18 scrappy Exp $
-#
-# finds blocks of oids that have not already been claimed by
-# post_hackers for internal purposes. primarily useful for
-# finding valid oids for new internal function oids. the numbers
-# printed are inclusive ranges of valid (unused) oids.
-#
-# before using a large empty block, make sure you aren't about
-# to take over what was intended as expansion space for something
-# else. also, before using a number, do a "grepsrc" to make sure
-# that someone isn't using a literal numeric constant somewhere..
-#
-# non-berkeley post_hackers should probably not try to use oids
-# less than the highest one that comes with the distributed source.
-#
-# run this script in src/backend/catalog.
-#
-egrep '^DATA' pg_*.h | \
- sed -e 's/^.*OID[^=]*=[^0-9]*//' -e 's/[^0-9].*$//' | \
- sort -n | \
- uniq | \
- awk '
-BEGIN {
- last = 0;
-}
-/^[0-9]/ {
- if ($1 > last + 1) {
- if ($1 > last + 2) {
- print last + 1, "-", $1 - 1;
- } else {
- print last + 1;
- }
- }
- last = $1;
-}
-END {
- print last + 1, "-";
-}'
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 4d82e2c8645..3e8dcd549d2 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.8 1996/11/06 08:21:29 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.9 1996/11/13 20:48:12 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -298,7 +298,9 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
natts,
Old_pg_index_Form->indkey,
Old_pg_index_Form->indclass,
- (uint16)0, (Datum) NULL, NULL, Old_pg_index_Form->indislossy);
+ (uint16)0, (Datum) NULL, NULL,
+ Old_pg_index_Form->indislossy,
+ Old_pg_index_Form->indisunique);
heap_close(OldIndex);
heap_close(NewHeap);
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 258376ee8ba..6777455be9f 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.16 1996/11/10 02:59:34 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.17 1996/11/13 20:48:18 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -578,7 +578,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
index_nulls,
finfoP[i]);
indexRes = index_insert(index_rels[i], &idatum, index_nulls,
- &(tuple->t_ctid));
+ &(tuple->t_ctid), false);
if (indexRes) pfree(indexRes);
}
}
diff --git a/src/backend/commands/defind.c b/src/backend/commands/defind.c
index cd1bbc14747..0618be3e20a 100644
--- a/src/backend/commands/defind.c
+++ b/src/backend/commands/defind.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.8 1996/11/06 08:21:33 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.9 1996/11/13 20:48:22 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -69,6 +69,7 @@ DefineIndex(char *heapRelationName,
char *accessMethodName,
List *attributeList,
List *parameterList,
+ bool unique,
Expr *predicate,
List *rangetable)
{
@@ -176,7 +177,7 @@ DefineIndex(char *heapRelationName,
&fInfo, NULL, accessMethodId,
numberOfAttributes, attributeNumberA,
classObjectId, parameterCount, parameterA, (Node*)cnfPred,
- lossy);
+ lossy, unique);
}else {
attributeNumberA =
(AttrNumber *)palloc(numberOfAttributes *
@@ -192,7 +193,7 @@ DefineIndex(char *heapRelationName,
((IndexElem*)lfirst(attributeList))->tname,
accessMethodId, numberOfAttributes, attributeNumberA,
classObjectId, parameterCount, parameterA, (Node*)cnfPred,
- lossy);
+ lossy, unique);
}
}
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index c5e26186087..6a562f8eaa5 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -26,7 +26,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.8 1996/11/06 06:47:32 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.9 1996/11/13 20:48:28 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -918,7 +918,7 @@ ExecAppend(TupleTableSlot *slot,
*/
numIndices = resultRelationInfo->ri_NumIndices;
if (numIndices > 0) {
- ExecInsertIndexTuples(slot, &(tuple->t_ctid), estate);
+ ExecInsertIndexTuples(slot, &(tuple->t_ctid), estate, false);
}
}
@@ -1056,8 +1056,9 @@ ExecReplace(TupleTableSlot *slot,
* the new tupleid stored there.
* ----------------
*/
+
numIndices = resultRelationInfo->ri_NumIndices;
if (numIndices > 0) {
- ExecInsertIndexTuples(slot, &(tuple->t_ctid), estate);
+ ExecInsertIndexTuples(slot, &(tuple->t_ctid), estate, true);
}
}
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index bd1e7968c91..94e3a118a30 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.5 1996/11/10 02:59:49 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.6 1996/11/13 20:48:34 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1025,7 +1025,8 @@ ExecFormIndexTuple(HeapTuple heapTuple,
void
ExecInsertIndexTuples(TupleTableSlot *slot,
ItemPointer tupleid,
- EState *estate)
+ EState *estate,
+ bool is_update)
{
HeapTuple heapTuple;
RelationInfo *resultRelationInfo;
@@ -1104,7 +1105,8 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
result = index_insert(relationDescs[i], /* index relation */
datum, /* array of heaptuple Datums */
nulls, /* info on nulls */
- &(heapTuple->t_ctid)); /* oid of heap tuple */
+ &(heapTuple->t_ctid),
+ is_update); /* oid of heap tuple */
/* ----------------
* keep track of index inserts for debugging
@@ -1120,4 +1122,3 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
}
if (econtext != NULL) pfree(econtext);
}
-
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index e61a13eab04..94e03a776d4 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.3 1996/11/08 05:56:35 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.4 1996/11/13 20:48:46 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1407,6 +1407,34 @@ _copySortClause(SortClause *from)
return newnode;
}
+static A_Const *
+_copyAConst(A_Const *from)
+{
+ A_Const *newnode = makeNode(A_Const);
+
+ newnode->val = *((Value *)(copyObject(&(from->val))));
+ Node_Copy(from, newnode, typename);
+
+ return newnode;
+}
+
+static TypeName *
+_copyTypeName(TypeName *from)
+{
+ TypeName *newnode = makeNode(TypeName);
+
+ if(from->name) {
+ newnode->name = pstrdup(from->name);
+ } else {
+ from->name = (char *)0;
+ }
+ newnode->setof = from->setof;
+ Node_Copy(from, newnode, arrayBounds);
+ newnode->typlen = from->typlen;
+
+ return newnode;
+}
+
static Query *
_copyQuery(Query *from)
{
@@ -1414,7 +1442,13 @@ _copyQuery(Query *from)
newnode->commandType = from->commandType;
newnode->resultRelation = from->resultRelation;
- newnode->into = from->into;
+ /* probably should dup this string instead of just pointing */
+ /* to the old one --djm */
+ if(from->into) {
+ newnode->into = pstrdup(from->into);
+ } else {
+ newnode->into = (char *)0;
+ }
newnode->isPortal = from->isPortal;
Node_Copy(from, newnode, rtable);
if (from->utilityStmt && nodeTag(from->utilityStmt) == T_NotifyStmt) {
@@ -1643,6 +1677,12 @@ copyObject(void *from)
case T_SortClause:
retval = _copySortClause(from);
break;
+ case T_A_Const:
+ retval = _copyAConst(from);
+ break;
+ case T_TypeName:
+ retval = _copyTypeName(from);
+ break;
/*
* VALUE NODES
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index b9c13dd7b95..874023c1872 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.14 1996/11/10 03:01:10 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.15 1996/11/13 20:48:55 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -77,6 +77,9 @@ static void AddAggToParseState(ParseState *pstate, Aggreg *aggreg);
static void finalizeAggregates(ParseState *pstate, Query *qry);
static void parseCheckAggregates(ParseState *pstate, Query *qry);
+static bool is_lowercase(char *string);
+static void make_lowercase(char *string);
+
/*****************************************************************************
*
*****************************************************************************/
@@ -1869,6 +1872,30 @@ ParseComplexProjection(ParseState *pstate,
return NULL;
}
+static bool is_lowercase(char *string)
+{
+ int i;
+
+ for(i = 0; i < strlen(string); i++) {
+ if(string[i] >= 'A' && string[i] <= 'Z') {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static void make_lowercase(char *string)
+{
+ int i;
+
+ for(i = 0; i < strlen(string); i++) {
+ if(string[i] >= 'A' && string[i] <= 'Z') {
+ string[i] = (string[i] - 'A') + 'a';
+ }
+ }
+}
+
static Node *
ParseFunc(ParseState *pstate, char *funcname, List *fargs, int *curr_resno)
{
@@ -1987,6 +2014,27 @@ ParseFunc(ParseState *pstate, char *funcname, List *fargs, int *curr_resno)
AddAggToParseState(pstate, aggreg);
return (Node*)aggreg;
+ } else {
+ /* try one more time with lowercase --djm 8/17/96 */
+ if(!is_lowercase(funcname)) {
+ char *lowercase_funcname = strdup(funcname);
+
+ make_lowercase(lowercase_funcname);
+ if (strcmp(lowercase_funcname, "count") == 0)
+ basetype = 0;
+ else
+ basetype = exprType(lfirst(fargs));
+ if (SearchSysCacheTuple(AGGNAME,
+ PointerGetDatum(lowercase_funcname),
+ ObjectIdGetDatum(basetype),
+ 0, 0)) {
+ Aggreg *aggreg = ParseAgg(lowercase_funcname,
+ basetype, lfirst(fargs));
+
+ AddAggToParseState(pstate, aggreg);
+ return (Node*)aggreg;
+ }
+ }
}
}
}
diff --git a/src/backend/parser/catalog_utils.c b/src/backend/parser/catalog_utils.c
index dcc754c12ba..20206e01341 100644
--- a/src/backend/parser/catalog_utils.c
+++ b/src/backend/parser/catalog_utils.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.9 1996/11/10 03:01:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.10 1996/11/13 20:48:58 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -108,6 +108,9 @@ static Oid **argtype_inherit(int nargs, Oid *oid_array);
static Oid **genxprod(InhPaths *arginh, int nargs);
static int findsupers(Oid relid, Oid **supervec);
+static bool is_lowercase(char *string);
+static void make_lowercase(char *string);
+
/* check to see if a type id is valid,
* returns true if it is. By using this call before calling
* get_id_type or get_id_typname, more meaningful error messages
@@ -1010,6 +1013,30 @@ func_select_candidate(int nargs,
return (NULL);
}
+static bool is_lowercase(char *string)
+{
+ int i;
+
+ for(i = 0; i < strlen(string); i++) {
+ if(string[i] >= 'A' && string[i] <= 'Z') {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static void make_lowercase(char *string)
+{
+ int i;
+
+ for(i = 0; i < strlen(string); i++) {
+ if(string[i] >= 'A' && string[i] <= 'Z') {
+ string[i] = (string[i] - 'A') + 'a';
+ }
+ }
+}
+
bool
func_get_detail(char *funcname,
int nargs,
@@ -1105,6 +1132,24 @@ func_get_detail(char *funcname,
if (!HeapTupleIsValid(ftup)) {
Type tp;
+ /*
+ * everything else has failed--try converting the function
+ * name to lowercase, and do everything one more time
+ * (if it's not already lowercase). so ODBC applications
+ * that expect uppercase names to work can work. --djm 8/17/96
+ */
+ if(!is_lowercase(funcname)) {
+ char *lowercase_funcname = strdup(funcname);
+ bool result;
+
+ make_lowercase(lowercase_funcname);
+ result = func_get_detail(lowercase_funcname, nargs, oid_array,
+ funcid, rettype, retset,
+ true_typeids);
+
+ free(lowercase_funcname);
+ return result;
+ } else {
if (nargs == 1) {
tp = get_id_type(oid_array[0]);
if (typetypetype(tp) == 'c')
@@ -1112,6 +1157,7 @@ func_get_detail(char *funcname,
funcname);
}
func_error("func_get_detail", funcname, nargs, (int*)oid_array);
+ }
} else {
pform = (Form_pg_proc) GETSTRUCT(ftup);
*funcid = ftup->t_oid;
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 1e599c9e65a..c3abd74e426 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.15 1996/11/11 12:14:09 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.16 1996/11/13 20:49:00 scrappy Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -114,7 +114,7 @@ static Node *makeA_Expr(int op, char *opname, Node *lexpr, Node *rexpr);
class, index_name, var_name, name, file_name, recipe_name
%type <str> opt_id, opt_portal_name,
- before_clause, after_clause, all_Op, MathOp, opt_name, opt_unique
+ before_clause, after_clause, all_Op, MathOp, opt_name, opt_unique,
result, OptUseOp, opt_class, opt_range_start, opt_range_end,
SpecialRuleRelation
@@ -123,14 +123,14 @@ static Node *makeA_Expr(int op, char *opname, Node *lexpr, Node *rexpr);
%type <list> queryblock, relation_name_list, OptTableElementList,
tableElementList, OptInherit, definition,
- opt_with_func, def_args, def_name_list, func_argtypes,
+ opt_with, def_args, def_name_list, func_argtypes,
oper_argtypes, OptStmtList, OptStmtBlock, opt_column_list, columnList,
sort_clause, sortby_list, index_params,
name_list, from_clause, from_list, opt_array_bounds, nest_array_bounds,
expr_list, attrs, res_target_list, res_target_list2, def_list,
opt_indirection, group_clause, groupby_list, explain_options
-%type <boolean> opt_inh_star, opt_binary, opt_instead, opt_with_copy
+%type <boolean> opt_inh_star, opt_binary, opt_instead, opt_with_copy, index_opt_unique
%type <ival> copy_dirn, archive_type, OptArchiveType, OptArchiveLocation,
def_type, opt_direction, remove_type, opt_column, event
@@ -658,17 +658,18 @@ opt_portal_name: IN name { $$ = $2;}
* [where <qual>] is not supported anymore
*****************************************************************************/
-IndexStmt: CREATE INDEX index_name ON relation_name
- access_method_clause '(' index_params ')' opt_with_func
+IndexStmt: CREATE index_opt_unique INDEX index_name ON relation_name
+ access_method_clause '(' index_params ')' opt_with
{
/* should check that access_method is valid,
etc ... but doesn't */
IndexStmt *n = makeNode(IndexStmt);
- n->idxname = $3;
- n->relname = $5;
- n->accessMethod = $6;
- n->indexParams = $8;
- n->withClause = $10;
+ n->unique = $2;
+ n->idxname = $4;
+ n->relname = $6;
+ n->accessMethod = $7;
+ n->indexParams = $9;
+ n->withClause = $11;
n->whereClause = NULL;
$$ = (Node *)n;
}
@@ -677,6 +678,11 @@ IndexStmt: CREATE INDEX index_name ON relation_name
access_method_clause: USING access_method { $$ = $2; }
| /* empty -- 'btree' is default access method */
{ $$ = "btree"; }
+ ;
+
+index_opt_unique: UNIQUE { $$ = TRUE; }
+ | /*empty*/ { $$ = FALSE; }
+ ;
/*****************************************************************************
*
@@ -731,7 +737,7 @@ RecipeStmt: EXECUTE RECIPE recipe_name
*****************************************************************************/
ProcedureStmt: CREATE FUNCTION def_name def_args
- RETURNS def_arg opt_with_func AS Sconst LANGUAGE Sconst
+ RETURNS def_arg opt_with AS Sconst LANGUAGE Sconst
{
ProcedureStmt *n = makeNode(ProcedureStmt);
n->funcname = $3;
@@ -743,7 +749,7 @@ ProcedureStmt: CREATE FUNCTION def_name def_args
$$ = (Node *)n;
};
-opt_with_func: WITH definition { $$ = $2; }
+opt_with: WITH definition { $$ = $2; }
| /* EMPTY */ { $$ = NIL; }
;
diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c
index 31c035d42a5..8c90f12fd82 100644
--- a/src/backend/parser/keywords.c
+++ b/src/backend/parser/keywords.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.3 1996/08/24 20:48:46 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.4 1996/11/13 20:49:04 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -130,6 +130,7 @@ static ScanKeyword ScanKeywords[] = {
{ "to", TO },
{ "transaction", TRANSACTION },
{ "type", P_TYPE },
+ { "unique", UNIQUE },
{ "update", UPDATE },
{ "using", USING },
{ "vacuum", VACUUM },
diff --git a/src/backend/parser/parse_query.c b/src/backend/parser/parse_query.c
index d92cb195c7f..26769191484 100644
--- a/src/backend/parser/parse_query.c
+++ b/src/backend/parser/parse_query.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.7 1996/11/08 00:56:17 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.8 1996/11/13 20:49:05 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -651,7 +651,9 @@ make_const(Value *value)
elog(NOTICE,"unknown type : %d\n", nodeTag(value));
/* null const */
- con = makeConst(0, 0, (Datum)NULL, TRUE, 0, FALSE);
+ /* if we don't set a type here, things will break. */
+ /* so set it to type 'unknown'. */
+ con = makeConst(UNKNOWNOID, 0, (Datum)NULL, TRUE, 0, FALSE);
return con;
}
}
diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c
index 57e25a68632..89bd5b56a70 100644
--- a/src/backend/parser/parser.c
+++ b/src/backend/parser/parser.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.10 1996/11/10 03:30:46 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.11 1996/11/13 20:49:07 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -216,36 +216,36 @@ parser_typecast(Value *expr, TypeName *typename, int typlen)
#if 0 /* fix me */
switch ( CInteger(lfirst(expr)) ) {
- case 23: /* int4 */
+ case INT4OID: /* int4 */
const_string = (char *) palloc(256);
string_palloced = true;
sprintf(const_string,"%d", ((Const*)lnext(expr))->constvalue);
break;
- case 19: /* char16 */
+ case NAMEOID: /* char16 */
const_string = (char *) palloc(256);
string_palloced = true;
sprintf(const_string,"%s", ((Const*)lnext(expr))->constvalue);
break;
- case 18: /* char */
+ case CHAROID: /* char */
const_string = (char *) palloc(256);
string_palloced = true;
sprintf(const_string,"%c", ((Const)lnext(expr))->constvalue);
break;
- case 701:/* float8 */
+ case FLOAT8OID:/* float8 */
const_string = (char *) palloc(256);
string_palloced = true;
sprintf(const_string,"%f", ((Const)lnext(expr))->constvalue);
break;
- case 25: /* text */
+ case TEXTOID: /* text */
const_string = DatumGetPointer(((Const)lnext(expr))->constvalue);
const_string = (char *) textout((struct varlena *)const_string);
break;
- case 705: /* unknown */
+ case UNKNOWNOID: /* unknown */
const_string = DatumGetPointer(((Const)lnext(expr))->constvalue);
const_string = (char *) textout((struct varlena *)const_string);
break;
@@ -312,25 +312,25 @@ parser_typecast2(Node *expr, int exprType, Type tp, int typlen)
switch (exprType) {
case 0: /* NULL */
break;
- case 23: /* int4 */
+ case INT4OID: /* int4 */
const_string = (char *) palloc(256);
string_palloced = true;
sprintf(const_string,"%d",
(int) ((Const*)expr)->constvalue);
break;
- case 19: /* char16 */
+ case NAMEOID: /* char16 */
const_string = (char *) palloc(256);
string_palloced = true;
sprintf(const_string,"%s",
(char*) ((Const*)expr)->constvalue);
break;
- case 18: /* char */
+ case CHAROID: /* char */
const_string = (char *) palloc(256);
string_palloced = true;
sprintf(const_string,"%c",
(char) ((Const*)expr)->constvalue);
break;
- case 700: /* float4 */
+ case FLOAT4OID: /* float4 */
{
float32 floatVal =
DatumGetFloat32(((Const*)expr)->constvalue);
@@ -339,7 +339,7 @@ parser_typecast2(Node *expr, int exprType, Type tp, int typlen)
sprintf(const_string,"%f", *floatVal);
break;
}
- case 701:/* float8 */
+ case FLOAT8OID:/* float8 */
{
float64 floatVal =
DatumGetFloat64(((Const*)expr)->constvalue);
@@ -348,12 +348,12 @@ parser_typecast2(Node *expr, int exprType, Type tp, int typlen)
sprintf(const_string,"%f", *floatVal);
break;
}
- case 25: /* text */
+ case TEXTOID: /* text */
const_string =
DatumGetPointer(((Const*)expr)->constvalue );
const_string = (char *) textout((struct varlena *)const_string);
break;
- case 705: /* unknown */
+ case UNKNOWNOID: /* unknown */
const_string =
DatumGetPointer(((Const*)expr)->constvalue );
const_string = (char *) textout((struct varlena *)const_string);
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
index bb649996010..243bdc28a35 100644
--- a/src/backend/storage/large_object/inv_api.c
+++ b/src/backend/storage/large_object/inv_api.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.6 1996/11/10 03:02:36 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.7 1996/11/13 20:49:18 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -165,7 +165,7 @@ inv_create(int flags)
classObjectId[0] = INT4_OPS_OID;
index_create(objname, indname, NULL, NULL, BTREE_AM_OID,
1, &attNums[0], &classObjectId[0],
- 0, (Datum) NULL, NULL, FALSE);
+ 0, (Datum) NULL, NULL, FALSE, FALSE);
/* make the index visible in this transaction */
CommandCounterIncrement();
@@ -1008,7 +1008,7 @@ inv_indextup(LargeObjectDesc *obj_desc, HeapTuple htup)
n[0] = ' ';
v[0] = Int32GetDatum(obj_desc->highbyte);
- res = index_insert(obj_desc->index_r, &v[0], &n[0], &(htup->t_ctid));
+ res = index_insert(obj_desc->index_r, &v[0], &n[0], &(htup->t_ctid), false);
if (res)
pfree(res);
diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c
index 2cfc21f5c17..55ef66afc57 100644
--- a/src/backend/storage/page/bufpage.c
+++ b/src/backend/storage/page/bufpage.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.3 1996/11/08 05:59:03 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.4 1996/11/13 20:49:29 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -105,9 +105,13 @@ PageGetItem(Page page, ItemId itemId)
Item item;
Assert(PageIsValid(page));
- Assert((*itemId).lp_flags & LP_USED);
+/* Assert(itemId->lp_flags & LP_USED); */
+ if(!(itemId->lp_flags & LP_USED)) {
+ elog(NOTICE, "LP_USED assertion failed. dumping core.");
+ abort();
+ }
- item = (Item)(((char *)page) + (*itemId).lp_off);
+ item = (Item)(((char *)page) + itemId->lp_off);
return (item);
}
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index f7890deb7e9..26bb04d751e 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.8 1996/11/11 04:54:54 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.9 1996/11/13 20:49:50 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -372,6 +372,7 @@ ProcessUtility(Node *parsetree,
stmt->accessMethod, /* am name */
stmt->indexParams, /* parameters */
stmt->withClause,
+ stmt->unique,
(Expr*)stmt->whereClause,
stmt->rangetable);
}
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index 9aefc80f9ab..aa3616390c4 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.4 1996/11/08 05:59:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.5 1996/11/13 20:50:04 scrappy Exp $
*
* Notes:
* XXX This needs to use exception.h to handle recovery when
@@ -901,6 +901,7 @@ SearchSysCache(struct catcache *cache,
sd = heap_beginscan(relation, 0, NowTimeQual,
cache->cc_nkeys, cache->cc_skey);
+ /* should this buffer be ReleaseBuffer'd? --djm 8/20/96 */
ntp = heap_getnext(sd, 0, &buffer);
MemoryContextSwitchTo((MemoryContext)CacheCxt);