From 07a65b22554d54455de5bc791a48fb0542f48791 Mon Sep 17 00:00:00 2001 From: "Marc G. Fournier" Date: Wed, 13 Nov 1996 20:56:15 +0000 Subject: Commit of a *MAJOR* patch from Dan McGuirk Changes: * Unique index capability works using the syntax 'create unique index'. * Duplicate OID's in the system tables are removed. I put little scripts called 'duplicate_oids' and 'find_oid' in include/catalog that help to find and remove duplicate OID's. I also moved 'unused_oids' from backend/catalog to include/catalog, since it has to be in the same directory as the include files in order to work. * The backend tries converting the name of a function or aggregate to all lowercase if the original name given doesn't work (mostly for compatibility with ODBC). * You can 'SELECT NULL' to your heart's content. * I put my _bt_updateitem fix in instead, which uses _bt_insertonpg so that even if the new key is so big that the page has to be split, everything still works. * All literal references to system catalog OID's have been replaced with references to define'd constants from the catalog header files. * I added a couple of node copy functions. I think this was a preliminary attempt to get rules to work. --- src/backend/access/nbtree/nbtree.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/backend/access/nbtree/nbtree.c') diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index b5248b23eb..1aa75f4027 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); -- cgit v1.2.1