aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-04-27 21:24:34 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-04-27 21:24:34 +0000
commitc06f6a6bc2bce09df9b945ac29de152daec0dcf7 (patch)
tree5cdd87954051c99eda2d2cf86526f73be8e3eb18 /src/backend/commands/tablecmds.c
parent108871f4fcb24ed333c226f470f2fe30296b9b35 (diff)
downloadpostgresql-c06f6a6bc2bce09df9b945ac29de152daec0dcf7.tar.gz
postgresql-c06f6a6bc2bce09df9b945ac29de152daec0dcf7.zip
Support toasting of shared system relations, and provide toast tables for
pg_database, pg_shadow, pg_group, all of which now have potentially-long fields. Along the way, get rid of SharedSystemRelationNames list: shared rels are now identified in their include/pg_catalog/*.h files by a BKI_SHARED_RELATION macro, while indexes and toast rels inherit sharedness automatically from their parent table. Fix some bugs with failure to detoast pg_group.grolist during ALTER GROUP.
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 32930710c6e..79b54aa7a5a 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.11 2002/04/27 03:45:01 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.12 2002/04/27 21:24:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -200,6 +200,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
namespaceId,
descriptor,
relkind,
+ false,
stmt->hasoids || parentHasOids,
allowSystemTableMods);
@@ -2840,6 +2841,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
HeapTuple reltup;
HeapTupleData classtuple;
TupleDesc tupdesc;
+ bool shared_relation;
Relation class_rel;
Buffer buffer;
Relation ridescs[Num_pg_class_indices];
@@ -2856,6 +2858,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
*/
rel = heap_open(relOid, AccessExclusiveLock);
+ /* Check permissions */
if (rel->rd_rel->relkind != RELKIND_RELATION)
elog(ERROR, "ALTER TABLE: relation \"%s\" is not a table",
RelationGetRelationName(rel));
@@ -2864,6 +2867,19 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
aclcheck_error(ACLCHECK_NOT_OWNER, RelationGetRelationName(rel));
/*
+ * Toast table is shared if and only if its parent is.
+ *
+ * We cannot allow toasting a shared relation after initdb (because
+ * there's no way to mark it toasted in other databases' pg_class).
+ * Unfortunately we can't distinguish initdb from a manually started
+ * standalone backend. However, we can at least prevent this mistake
+ * under normal multi-user operation.
+ */
+ shared_relation = rel->rd_rel->relisshared;
+ if (shared_relation && IsUnderPostmaster)
+ elog(ERROR, "Shared relations cannot be toasted after initdb");
+
+ /*
* lock the pg_class tuple for update (is that really needed?)
*/
class_rel = heap_openr(RelationRelationName, RowExclusiveLock);
@@ -2962,6 +2978,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
PG_TOAST_NAMESPACE,
tupdesc,
RELKIND_TOASTVALUE,
+ shared_relation,
false,
true);