Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a475c60

Browse files
committed
Remove misplaced sanity check from heap_create().
Even when allow_system_table_mods is not set, we allow creation of any type of SQL object in pg_catalog, except for relations. And you can get relations into pg_catalog, too, by initially creating them in some other schema and then moving them with ALTER .. SET SCHEMA. So this restriction, which prevents relations (only) from being created in pg_catalog directly, is fairly pointless. If we need a safety mechanism for this, it should be placed further upstream, so that it affects all SQL objects uniformly, and picks up both CREATE and SET SCHEMA. For now, just rip it out, per discussion with Tom Lane.
1 parent d2c86a1 commit a475c60

File tree

4 files changed

+5
-22
lines changed

4 files changed

+5
-22
lines changed

src/backend/bootstrap/bootparse.y

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,7 @@ Boot_CreateStmt:
222222
RELKIND_RELATION,
223223
RELPERSISTENCE_PERMANENT,
224224
shared_relation,
225-
mapped_relation,
226-
true);
225+
mapped_relation);
227226
elog(DEBUG4, "bootstrap relation created");
228227
}
229228
else

src/backend/catalog/heap.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -242,27 +242,14 @@ heap_create(const char *relname,
242242
char relkind,
243243
char relpersistence,
244244
bool shared_relation,
245-
bool mapped_relation,
246-
bool allow_system_table_mods)
245+
bool mapped_relation)
247246
{
248247
bool create_storage;
249248
Relation rel;
250249

251250
/* The caller must have provided an OID for the relation. */
252251
Assert(OidIsValid(relid));
253252

254-
/*
255-
* sanity checks
256-
*/
257-
if (!allow_system_table_mods &&
258-
(IsSystemNamespace(relnamespace) || IsToastNamespace(relnamespace)) &&
259-
IsNormalProcessingMode())
260-
ereport(ERROR,
261-
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
262-
errmsg("permission denied to create \"%s.%s\"",
263-
get_namespace_name(relnamespace), relname),
264-
errdetail("System catalog modifications are currently disallowed.")));
265-
266253
/*
267254
* Decide if we need storage or not, and handle a couple other special
268255
* cases for particular relkinds.
@@ -1124,8 +1111,7 @@ heap_create_with_catalog(const char *relname,
11241111
relkind,
11251112
relpersistence,
11261113
shared_relation,
1127-
mapped_relation,
1128-
allow_system_table_mods);
1114+
mapped_relation);
11291115

11301116
Assert(relid == RelationGetRelid(new_rel_desc));
11311117

src/backend/catalog/index.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,7 @@ index_create(Relation heapRelation,
816816
RELKIND_INDEX,
817817
relpersistence,
818818
shared_relation,
819-
mapped_relation,
820-
allow_system_table_mods);
819+
mapped_relation);
821820

822821
Assert(indexRelationId == RelationGetRelid(indexRelation));
823822

src/include/catalog/heap.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ extern Relation heap_create(const char *relname,
4646
char relkind,
4747
char relpersistence,
4848
bool shared_relation,
49-
bool mapped_relation,
50-
bool allow_system_table_mods);
49+
bool mapped_relation);
5150

5251
extern Oid heap_create_with_catalog(const char *relname,
5352
Oid relnamespace,

0 commit comments

Comments
 (0)