diff options
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 19 |
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); |