Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1538628

Browse files
committed
Put back allow_system_table_mods check in heap_create().
This reverts commita475c60.Erik Rijkers reported back in January 2013 that after the patch, if you do"pg_dump -t myschema.mytable" to dump a single table, and restore that ina database where myschema does not exist, the table is silently created inpg_catalog instead. That is because pg_dump uses"SET search_path=myschema, pg_catalog" to set schema the table is createdin. While allow_system_table_mods is not a very elegant solution to this,we can't leave it as it is, so for now, revert it back to the way it waspreviously.
1 parentf129615 commit1538628

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

‎src/backend/bootstrap/bootparse.y

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

‎src/backend/catalog/heap.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,27 @@ heap_create(const char *relname,
246246
charrelkind,
247247
charrelpersistence,
248248
boolshared_relation,
249-
boolmapped_relation)
249+
boolmapped_relation,
250+
boolallow_system_table_mods)
250251
{
251252
boolcreate_storage;
252253
Relationrel;
253254

254255
/* The caller must have provided an OID for the relation. */
255256
Assert(OidIsValid(relid));
256257

258+
/*
259+
* sanity checks
260+
*/
261+
if (!allow_system_table_mods&&
262+
(IsSystemNamespace(relnamespace)||IsToastNamespace(relnamespace))&&
263+
IsNormalProcessingMode())
264+
ereport(ERROR,
265+
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
266+
errmsg("permission denied to create \"%s.%s\"",
267+
get_namespace_name(relnamespace),relname),
268+
errdetail("System catalog modifications are currently disallowed.")));
269+
257270
/*
258271
* Decide if we need storage or not, and handle a couple other special
259272
* cases for particular relkinds.
@@ -1132,7 +1145,8 @@ heap_create_with_catalog(const char *relname,
11321145
relkind,
11331146
relpersistence,
11341147
shared_relation,
1135-
mapped_relation);
1148+
mapped_relation,
1149+
allow_system_table_mods);
11361150

11371151
Assert(relid==RelationGetRelid(new_rel_desc));
11381152

‎src/backend/catalog/index.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,8 @@ index_create(Relation heapRelation,
825825
RELKIND_INDEX,
826826
relpersistence,
827827
shared_relation,
828-
mapped_relation);
828+
mapped_relation,
829+
allow_system_table_mods);
829830

830831
Assert(indexRelationId==RelationGetRelid(indexRelation));
831832

‎src/include/catalog/heap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ extern Relation heap_create(const char *relname,
4646
charrelkind,
4747
charrelpersistence,
4848
boolshared_relation,
49-
boolmapped_relation);
49+
boolmapped_relation,
50+
boolallow_system_table_mods);
5051

5152
externOidheap_create_with_catalog(constchar*relname,
5253
Oidrelnamespace,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp