1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-22 21:53:06 +03:00

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.
This commit is contained in:
Tom Lane
2002-04-27 21:24:34 +00:00
parent 108871f4fc
commit c06f6a6bc2
27 changed files with 403 additions and 531 deletions

View File

@@ -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);