summaryrefslogtreecommitdiff
path: root/src/backend/catalog
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-07-04 06:11:54 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-07-04 06:11:54 +0000
commitcdeca5f590cc3c336c9c217831d68a2ca7f15265 (patch)
treef233f7ae62023950d1c169530b83f705c63ceed0 /src/backend/catalog
parent9cf327790d978fc4ec6dba1c7f456e0a7596e4e2 (diff)
downloadpostgresql-cdeca5f590cc3c336c9c217831d68a2ca7f15265.tar.gz
Make toast-table creation and deletion work somewhat reliably.
Don't go through pg_exec_query_dest(), but directly to the execution routines. Also, extend parameter lists so that there's no need to change the global setting of allowSystemTableMods, a hack that was certain to cause trouble in the event of any error.
Diffstat (limited to 'src/backend/catalog')
-rw-r--r--src/backend/catalog/heap.c30
-rw-r--r--src/backend/catalog/index.c15
2 files changed, 22 insertions, 23 deletions
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 2187b8db44..bd330b5d1e 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.137 2000/07/03 23:09:27 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.138 2000/07/04 06:11:23 tgl Exp $
*
*
* INTERFACE ROUTINES
@@ -172,7 +172,8 @@ Relation
heap_create(char *relname,
TupleDesc tupDesc,
bool istemp,
- bool storage_create)
+ bool storage_create,
+ bool allow_system_table_mods)
{
static unsigned int uniqueId = 0;
@@ -189,7 +190,7 @@ heap_create(char *relname,
*/
AssertArg(natts > 0);
- if (relname && !allowSystemTableMods &&
+ if (relname && !allow_system_table_mods &&
IsSystemRelationName(relname) && IsNormalProcessingMode())
{
elog(ERROR, "Illegal class name '%s'"
@@ -744,7 +745,8 @@ Oid
heap_create_with_catalog(char *relname,
TupleDesc tupdesc,
char relkind,
- bool istemp)
+ bool istemp,
+ bool allow_system_table_mods)
{
Relation pg_class_desc;
Relation new_rel_desc;
@@ -769,9 +771,9 @@ heap_create_with_catalog(char *relname,
(istemp && get_temp_rel_by_username(relname) != NULL))
elog(ERROR, "Relation '%s' already exists", relname);
- /* save user relation name because heap_create changes it */
if (istemp)
{
+ /* save user relation name because heap_create changes it */
temp_relname = pstrdup(relname); /* save original value */
relname = palloc(NAMEDATALEN);
strcpy(relname, temp_relname); /* heap_create will change this */
@@ -797,7 +799,8 @@ heap_create_with_catalog(char *relname,
* work of creating the disk file for the relation.
* ----------------
*/
- new_rel_desc = heap_create(relname, tupdesc, istemp, false);
+ new_rel_desc = heap_create(relname, tupdesc, istemp, false,
+ allow_system_table_mods);
new_rel_oid = new_rel_desc->rd_att->attrs[0]->attrelid;
@@ -1419,7 +1422,8 @@ DeleteTypeTuple(Relation rel)
* --------------------------------
*/
void
-heap_drop_with_catalog(const char *relname)
+heap_drop_with_catalog(const char *relname,
+ bool allow_system_table_mods)
{
Relation rel;
Oid rid;
@@ -1438,7 +1442,7 @@ heap_drop_with_catalog(const char *relname)
* ----------------
*/
/* allow temp of pg_class? Guess so. */
- if (!istemp && !allowSystemTableMods &&
+ if (!istemp && !allow_system_table_mods &&
IsSystemRelationName(RelationGetRelationName(rel)))
elog(ERROR, "System relation '%s' cannot be destroyed",
RelationGetRelationName(rel));
@@ -1546,15 +1550,9 @@ heap_drop_with_catalog(const char *relname)
if (has_toasttable)
{
char toast_relname[NAMEDATALEN];
- bool old_allow;
- old_allow = allowSystemTableMods;
- allowSystemTableMods = true;
-
- sprintf(toast_relname, "pg_toast_%d", rid);
- heap_drop_with_catalog(toast_relname);
-
- allowSystemTableMods = old_allow;
+ sprintf(toast_relname, "pg_toast_%u", rid);
+ heap_drop_with_catalog(toast_relname, true);
}
}
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 2c5ff64dab..a78f0fa3db 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.121 2000/06/30 07:04:17 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.122 2000/07/04 06:11:23 tgl Exp $
*
*
* INTERFACE ROUTINES
@@ -946,7 +946,8 @@ index_create(char *heapRelationName,
Node *predicate,
bool islossy,
bool unique,
- bool primary)
+ bool primary,
+ bool allow_system_table_mods)
{
Relation heapRelation;
Relation indexRelation;
@@ -989,13 +990,13 @@ index_create(char *heapRelationName,
numatts,
attNums);
- /* save user relation name because heap_create changes it */
if (istemp)
{
- temp_relname = pstrdup(indexRelationName); /* save original value */
+ /* save user relation name because heap_create changes it */
+ temp_relname = pstrdup(indexRelationName); /* save original value */
indexRelationName = palloc(NAMEDATALEN);
- strcpy(indexRelationName, temp_relname); /* heap_create will
- * change this */
+ strcpy(indexRelationName, temp_relname); /* heap_create will
+ * change this */
}
/* ----------------
@@ -1003,7 +1004,7 @@ index_create(char *heapRelationName,
* ----------------
*/
indexRelation = heap_create(indexRelationName, indexTupDesc,
- istemp, false);
+ istemp, false, allow_system_table_mods);
/* ----------------
* construct the index relation descriptor