diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/bootstrap/bootparse.y | 3 | ||||
-rw-r--r-- | src/backend/catalog/heap.c | 18 | ||||
-rw-r--r-- | src/backend/catalog/index.c | 3 | ||||
-rw-r--r-- | src/include/catalog/heap.h | 3 |
4 files changed, 22 insertions, 5 deletions
diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y index d40fd6827c0..cee72c186b0 100644 --- a/src/backend/bootstrap/bootparse.y +++ b/src/backend/bootstrap/bootparse.y @@ -222,7 +222,8 @@ Boot_CreateStmt: RELKIND_RELATION, RELPERSISTENCE_PERMANENT, shared_relation, - mapped_relation); + mapped_relation, + true); elog(DEBUG4, "bootstrap relation created"); } else diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 7622a9655ea..45a84e44a1d 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -246,7 +246,8 @@ heap_create(const char *relname, char relkind, char relpersistence, bool shared_relation, - bool mapped_relation) + bool mapped_relation, + bool allow_system_table_mods) { bool create_storage; Relation rel; @@ -255,6 +256,18 @@ heap_create(const char *relname, 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 * cases for particular relkinds. */ @@ -1132,7 +1145,8 @@ heap_create_with_catalog(const char *relname, relkind, relpersistence, shared_relation, - mapped_relation); + mapped_relation, + allow_system_table_mods); Assert(relid == RelationGetRelid(new_rel_desc)); diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 7966558218f..5f61ecbfdf3 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -825,7 +825,8 @@ index_create(Relation heapRelation, RELKIND_INDEX, relpersistence, shared_relation, - mapped_relation); + mapped_relation, + allow_system_table_mods); Assert(indexRelationId == RelationGetRelid(indexRelation)); diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h index 26266e17d58..b43765b026a 100644 --- a/src/include/catalog/heap.h +++ b/src/include/catalog/heap.h @@ -46,7 +46,8 @@ extern Relation heap_create(const char *relname, char relkind, char relpersistence, bool shared_relation, - bool mapped_relation); + bool mapped_relation, + bool allow_system_table_mods); extern Oid heap_create_with_catalog(const char *relname, Oid relnamespace, |