diff options
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/cluster.c | 21 | ||||
-rw-r--r-- | src/backend/commands/command.c | 30 | ||||
-rw-r--r-- | src/backend/commands/creatinh.c | 10 | ||||
-rw-r--r-- | src/backend/commands/indexcmds.c | 6 | ||||
-rw-r--r-- | src/backend/commands/rename.c | 10 | ||||
-rw-r--r-- | src/backend/commands/trigger.c | 4 | ||||
-rw-r--r-- | src/backend/commands/vacuum.c | 13 |
7 files changed, 38 insertions, 56 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 0d0cbbe7881..c801c53f406 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.75 2002/03/29 22:10:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.76 2002/03/31 06:26:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -35,12 +35,10 @@ #include "utils/builtins.h" #include "utils/lsyscache.h" #include "utils/syscache.h" -#include "utils/temprel.h" -static Oid copy_heap(Oid OIDOldHeap, char *NewName, bool istemp); -static void copy_index(Oid OIDOldIndex, Oid OIDNewHeap, char *NewIndexName, - bool istemp); +static Oid copy_heap(Oid OIDOldHeap, char *NewName); +static void copy_index(Oid OIDOldIndex, Oid OIDNewHeap, char *NewIndexName); static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex); /* @@ -63,7 +61,6 @@ cluster(RangeVar *oldrelation, char *oldindexname) OIDNewHeap; Relation OldHeap, OldIndex; - bool istemp; char NewHeapName[NAMEDATALEN]; char NewIndexName[NAMEDATALEN]; RangeVar *NewHeap; @@ -76,8 +73,6 @@ cluster(RangeVar *oldrelation, char *oldindexname) OldHeap = heap_openrv(oldrelation, AccessExclusiveLock); OIDOldHeap = RelationGetRelid(OldHeap); - istemp = is_temp_rel_name(oldrelation->relname); - /* * The index is expected to be in the same namespace as the relation. */ @@ -105,7 +100,7 @@ cluster(RangeVar *oldrelation, char *oldindexname) */ snprintf(NewHeapName, NAMEDATALEN, "temp_%u", OIDOldHeap); - OIDNewHeap = copy_heap(OIDOldHeap, NewHeapName, istemp); + OIDNewHeap = copy_heap(OIDOldHeap, NewHeapName); /* We do not need CommandCounterIncrement() because copy_heap did it. */ @@ -120,7 +115,7 @@ cluster(RangeVar *oldrelation, char *oldindexname) /* Create new index over the tuples of the new heap. */ snprintf(NewIndexName, NAMEDATALEN, "temp_%u", OIDOldIndex); - copy_index(OIDOldIndex, OIDNewHeap, NewIndexName, istemp); + copy_index(OIDOldIndex, OIDNewHeap, NewIndexName); CommandCounterIncrement(); @@ -145,7 +140,7 @@ cluster(RangeVar *oldrelation, char *oldindexname) } static Oid -copy_heap(Oid OIDOldHeap, char *NewName, bool istemp) +copy_heap(Oid OIDOldHeap, char *NewName) { TupleDesc OldHeapDesc, tupdesc; @@ -166,7 +161,6 @@ copy_heap(Oid OIDOldHeap, char *NewName, bool istemp) tupdesc, OldHeap->rd_rel->relkind, OldHeap->rd_rel->relhasoids, - istemp, allowSystemTableMods); /* @@ -188,7 +182,7 @@ copy_heap(Oid OIDOldHeap, char *NewName, bool istemp) } static void -copy_index(Oid OIDOldIndex, Oid OIDNewHeap, char *NewIndexName, bool istemp) +copy_index(Oid OIDOldIndex, Oid OIDNewHeap, char *NewIndexName) { Relation OldIndex, NewHeap; @@ -209,7 +203,6 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap, char *NewIndexName, bool istemp) indexInfo, OldIndex->rd_rel->relam, OldIndex->rd_index->indclass, - istemp, OldIndex->rd_index->indisprimary, allowSystemTableMods); diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index 2c029fa2ae9..b79e65960f7 100644 --- a/src/backend/commands/command.c +++ b/src/backend/commands/command.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.168 2002/03/30 01:02:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.169 2002/03/31 06:26:30 tgl Exp $ * * NOTES * The PerformAddAttribute() code, like most of the relation @@ -55,7 +55,7 @@ #include "utils/lsyscache.h" #include "utils/syscache.h" #include "utils/relcache.h" -#include "utils/temprel.h" + static void drop_default(Oid relid, int16 attnum); static bool needs_toast_table(Relation rel); @@ -1344,20 +1344,27 @@ AlterTableAddConstraint(Oid myrelid, List *list; int count; - if (is_temp_rel_name(fkconstraint->pktable->relname) && - !is_temp_rel_name(RelationGetRelationName(rel))) - elog(ERROR, "ALTER TABLE / ADD CONSTRAINT: Unable to reference temporary table from permanent table constraint."); - /* * Grab an exclusive lock on the pk table, so that * someone doesn't delete rows out from under us. + * + * XXX wouldn't a lesser lock be sufficient? */ - pkrel = heap_openrv(fkconstraint->pktable, AccessExclusiveLock); + + /* + * Validity checks + */ if (pkrel->rd_rel->relkind != RELKIND_RELATION) elog(ERROR, "referenced table \"%s\" not a relation", fkconstraint->pktable->relname); + + if (isTempNamespace(RelationGetNamespace(pkrel)) && + !isTempNamespace(RelationGetNamespace(rel))) + elog(ERROR, "ALTER TABLE / ADD CONSTRAINT: Unable to reference temporary table from permanent table constraint."); + + /* Don't need pkrel open anymore, but hold lock */ heap_close(pkrel, NoLock); /* @@ -1763,8 +1770,9 @@ AlterTableCreateToastTable(Oid relOid, bool silent) toast_relid = heap_create_with_catalog(toast_relname, PG_TOAST_NAMESPACE, tupdesc, - RELKIND_TOASTVALUE, false, - false, true); + RELKIND_TOASTVALUE, + false, + true); /* make the toast relation visible, else index creation will fail */ CommandCounterIncrement(); @@ -1794,7 +1802,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent) toast_idxid = index_create(toast_relid, toast_idxname, indexInfo, BTREE_AM_OID, classObjectId, - false, true, true); + true, true); /* * Update toast rel's pg_class entry to show that it has an index. The @@ -1971,7 +1979,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt) } /* Create the schema's namespace */ - NamespaceCreate(schemaName); + NamespaceCreate(schemaName, owner_userid); /* Let commands in the schema-element-list know about the schema */ CommandCounterIncrement(); diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c index f85814cc0f4..4a76e0c11ec 100644 --- a/src/backend/commands/creatinh.c +++ b/src/backend/commands/creatinh.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.94 2002/03/29 22:10:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.95 2002/03/31 06:26:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,7 @@ #include "parser/parse_type.h" #include "utils/acl.h" #include "utils/syscache.h" -#include "utils/temprel.h" + /* ---------------- * local stuff @@ -157,11 +157,11 @@ DefineRelation(CreateStmt *stmt, char relkind) } } - relationId = heap_create_with_catalog(relname, namespaceId, + relationId = heap_create_with_catalog(relname, + namespaceId, descriptor, relkind, stmt->hasoids || parentHasOids, - stmt->relation->istemp, allowSystemTableMods); StoreCatalogInheritance(relationId, inheritOids); @@ -447,7 +447,7 @@ MergeAttributes(List *schema, List *supers, bool istemp, elog(ERROR, "CREATE TABLE: inherited relation \"%s\" is not a table", parent->relname); /* Permanent rels cannot inherit from temporary ones */ - if (!istemp && is_temp_rel_name(parent->relname)) + if (!istemp && isTempNamespace(RelationGetNamespace(relation))) elog(ERROR, "CREATE TABLE: cannot inherit from temp relation \"%s\"", parent->relname); diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ae3476efb24..c931ab19278 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.65 2002/03/26 19:15:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.66 2002/03/31 06:26:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,6 @@ #include "utils/fmgroids.h" #include "utils/lsyscache.h" #include "utils/syscache.h" -#include "utils/temprel.h" #define IsFuncIndex(ATTR_LIST) (((IndexElem*)lfirst(ATTR_LIST))->args != NIL) @@ -74,7 +73,6 @@ DefineIndex(RangeVar *heapRelation, Oid *classObjectId; Oid accessMethodId; Oid relationId; - bool istemp = is_temp_rel_name(heapRelation->relname); Relation rel; HeapTuple tuple; Form_pg_am accessMethodForm; @@ -191,7 +189,7 @@ DefineIndex(RangeVar *heapRelation, index_create(relationId, indexRelationName, indexInfo, accessMethodId, classObjectId, - istemp, primary, allowSystemTableMods); + primary, allowSystemTableMods); /* * We update the relation's pg_class tuple even if it already has diff --git a/src/backend/commands/rename.c b/src/backend/commands/rename.c index 0f4c83fbebf..7e08dade24d 100644 --- a/src/backend/commands/rename.c +++ b/src/backend/commands/rename.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.66 2002/03/29 19:06:07 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.67 2002/03/31 06:26:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -39,7 +39,6 @@ #include "utils/lsyscache.h" #include "utils/relcache.h" #include "utils/syscache.h" -#include "utils/temprel.h" #define RI_TRIGGER_PK 1 /* is a trigger on the PK relation */ @@ -271,13 +270,6 @@ renamerel(const RangeVar *relation, const char *newrelname) newrelname); /* - * Check for renaming a temp table, which only requires altering the - * temp-table mapping, not the underlying table. - */ - if (rename_temp_relation(relation->relname, newrelname)) - return; /* all done... */ - - /* * Grab an exclusive lock on the target table or index, which we will * NOT release until end of transaction. */ diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 36229b158e2..c20c2637178 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.109 2002/03/29 22:10:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.110 2002/03/31 06:26:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -471,7 +471,7 @@ RelationRemoveTriggers(Relation rel) Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(tup); elog(NOTICE, "DROP TABLE implicitly drops referential integrity trigger from table \"%s\"", - get_temp_rel_by_physicalname(get_rel_name(pg_trigger->tgrelid))); + get_rel_name(pg_trigger->tgrelid)); DropTrigger(pg_trigger->tgrelid, NameStr(pg_trigger->tgname)); diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 41405f3654a..6553529cdcf 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.219 2002/03/21 23:27:22 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.220 2002/03/31 06:26:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -42,8 +42,6 @@ #include "utils/inval.h" #include "utils/relcache.h" #include "utils/syscache.h" -#include "utils/temprel.h" - #include "pgstat.h" @@ -351,16 +349,9 @@ getrels(Name VacRelP, const char *stmttype) * we could use the cache here, but it is clearer to use scankeys * for both vacuum cases, bjm 2000/01/19 */ - char *nontemp_relname; - - /* We must re-map temp table names bjm 2000-04-06 */ - nontemp_relname = get_temp_rel_by_username(NameStr(*VacRelP)); - if (nontemp_relname == NULL) - nontemp_relname = NameStr(*VacRelP); - ScanKeyEntryInitialize(&key, 0x0, Anum_pg_class_relname, F_NAMEEQ, - PointerGetDatum(nontemp_relname)); + PointerGetDatum(NameStr(*VacRelP))); } else { |