mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
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.
This commit is contained in:
parent
d2c86a1ccd
commit
a475c60367
@ -222,8 +222,7 @@ Boot_CreateStmt:
|
|||||||
RELKIND_RELATION,
|
RELKIND_RELATION,
|
||||||
RELPERSISTENCE_PERMANENT,
|
RELPERSISTENCE_PERMANENT,
|
||||||
shared_relation,
|
shared_relation,
|
||||||
mapped_relation,
|
mapped_relation);
|
||||||
true);
|
|
||||||
elog(DEBUG4, "bootstrap relation created");
|
elog(DEBUG4, "bootstrap relation created");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -242,8 +242,7 @@ heap_create(const char *relname,
|
|||||||
char relkind,
|
char relkind,
|
||||||
char relpersistence,
|
char relpersistence,
|
||||||
bool shared_relation,
|
bool shared_relation,
|
||||||
bool mapped_relation,
|
bool mapped_relation)
|
||||||
bool allow_system_table_mods)
|
|
||||||
{
|
{
|
||||||
bool create_storage;
|
bool create_storage;
|
||||||
Relation rel;
|
Relation rel;
|
||||||
@ -251,18 +250,6 @@ heap_create(const char *relname,
|
|||||||
/* The caller must have provided an OID for the relation. */
|
/* The caller must have provided an OID for the relation. */
|
||||||
Assert(OidIsValid(relid));
|
Assert(OidIsValid(relid));
|
||||||
|
|
||||||
/*
|
|
||||||
* sanity checks
|
|
||||||
*/
|
|
||||||
if (!allow_system_table_mods &&
|
|
||||||
(IsSystemNamespace(relnamespace) || IsToastNamespace(relnamespace)) &&
|
|
||||||
IsNormalProcessingMode())
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
|
||||||
errmsg("permission denied to create \"%s.%s\"",
|
|
||||||
get_namespace_name(relnamespace), relname),
|
|
||||||
errdetail("System catalog modifications are currently disallowed.")));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Decide if we need storage or not, and handle a couple other special
|
* Decide if we need storage or not, and handle a couple other special
|
||||||
* cases for particular relkinds.
|
* cases for particular relkinds.
|
||||||
@ -1124,8 +1111,7 @@ heap_create_with_catalog(const char *relname,
|
|||||||
relkind,
|
relkind,
|
||||||
relpersistence,
|
relpersistence,
|
||||||
shared_relation,
|
shared_relation,
|
||||||
mapped_relation,
|
mapped_relation);
|
||||||
allow_system_table_mods);
|
|
||||||
|
|
||||||
Assert(relid == RelationGetRelid(new_rel_desc));
|
Assert(relid == RelationGetRelid(new_rel_desc));
|
||||||
|
|
||||||
|
@ -816,8 +816,7 @@ index_create(Relation heapRelation,
|
|||||||
RELKIND_INDEX,
|
RELKIND_INDEX,
|
||||||
relpersistence,
|
relpersistence,
|
||||||
shared_relation,
|
shared_relation,
|
||||||
mapped_relation,
|
mapped_relation);
|
||||||
allow_system_table_mods);
|
|
||||||
|
|
||||||
Assert(indexRelationId == RelationGetRelid(indexRelation));
|
Assert(indexRelationId == RelationGetRelid(indexRelation));
|
||||||
|
|
||||||
|
@ -46,8 +46,7 @@ extern Relation heap_create(const char *relname,
|
|||||||
char relkind,
|
char relkind,
|
||||||
char relpersistence,
|
char relpersistence,
|
||||||
bool shared_relation,
|
bool shared_relation,
|
||||||
bool mapped_relation,
|
bool mapped_relation);
|
||||||
bool allow_system_table_mods);
|
|
||||||
|
|
||||||
extern Oid heap_create_with_catalog(const char *relname,
|
extern Oid heap_create_with_catalog(const char *relname,
|
||||||
Oid relnamespace,
|
Oid relnamespace,
|
||||||
|
Loading…
Reference in New Issue
Block a user