From c06f6a6bc2bce09df9b945ac29de152daec0dcf7 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 27 Apr 2002 21:24:34 +0000 Subject: 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. --- src/backend/commands/tablecmds.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/backend/commands/tablecmds.c') 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)); @@ -2863,6 +2866,19 @@ AlterTableCreateToastTable(Oid relOid, bool silent) if (!pg_class_ownercheck(relOid, GetUserId())) 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?) */ @@ -2962,6 +2978,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent) PG_TOAST_NAMESPACE, tupdesc, RELKIND_TOASTVALUE, + shared_relation, false, true); -- cgit v1.2.3