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

Commit8bff640

Browse files
committed
Accept a non-existent value in "ALTER USER/DATABASE SET ..." command.
When default_text_search_config, default_tablespace, or temp_tablespacessetting is set per-user or per-database, with an "ALTER USER/DATABASE SET..." statement, don't throw an error if the text search configuration ortablespace does not exist. In case of text search configuration, even ifit doesn't exist in the current database, it might exist in anotherdatabase, where the setting is intended to have its effect. This behavioris now the same as search_path's.Tablespaces are cluster-wide, so the same argument doesn't hold fortablespaces, but there's a problem with pg_dumpall: it dumps "ALTER USERSET ..." statements before the "CREATE TABLESPACE" statements. Arguablythat's pg_dumpall's fault - it should dump the statements in such an orderthat the tablespace is created first and then the "ALTER USER SETdefault_tablespace ..." statements after that - but it seems better to beconsistent with search_path and default_text_search_config anyway. Besides,you could still create a dump that throws an error, by creating thetablespace, running "ALTER USER SET default_tablespace", then dropping thetablespace and running pg_dumpall on that.Backpatch to all supported versions.
1 parenta752952 commit8bff640

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

‎src/backend/commands/tablespace.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,11 +1031,22 @@ assign_default_tablespace(const char *newval, bool doit, GucSource source)
10311031
if (newval[0]!='\0'&&
10321032
!OidIsValid(get_tablespace_oid(newval)))
10331033
{
1034-
ereport(GUC_complaint_elevel(source),
1034+
/*
1035+
* When source == PGC_S_TEST, we are checking the argument of an
1036+
* ALTER DATABASE SET or ALTER USER SET command. pg_dumpall dumps
1037+
* all roles before tablespaces, so if we're restoring a
1038+
* pg_dumpall script the tablespace might not yet exist, but will
1039+
* be created later. Because of that, issue a NOTICE if source ==
1040+
* PGC_S_TEST, but accept the value anyway.
1041+
*/
1042+
ereport((source==PGC_S_TEST) ?NOTICE :GUC_complaint_elevel(source),
10351043
(errcode(ERRCODE_UNDEFINED_OBJECT),
10361044
errmsg("tablespace \"%s\" does not exist",
10371045
newval)));
1038-
returnNULL;
1046+
if (source==PGC_S_TEST)
1047+
returnnewval;
1048+
else
1049+
returnNULL;
10391050
}
10401051
}
10411052

@@ -1152,10 +1163,16 @@ assign_temp_tablespaces(const char *newval, bool doit, GucSource source)
11521163
{
11531164
/*
11541165
* In an interactive SET command, we ereport for bad info.
1166+
* When source == PGC_S_TEST, we are checking the argument of
1167+
* an ALTER DATABASE SET or ALTER USER SET command. pg_dumpall
1168+
* dumps all roles before tablespaces, so if we're restoring a
1169+
* pg_dumpall script the tablespace might not yet exist, but
1170+
* will be created later. Because of that, issue a NOTICE if
1171+
* source == PGC_S_TEST, but accept the value anyway.
11551172
* Otherwise, silently ignore any bad list elements.
11561173
*/
11571174
if (source >=PGC_S_INTERACTIVE)
1158-
ereport(ERROR,
1175+
ereport((source==PGC_S_TEST) ?NOTICE :ERROR,
11591176
(errcode(ERRCODE_UNDEFINED_OBJECT),
11601177
errmsg("tablespace \"%s\" does not exist",
11611178
curname)));

‎src/backend/utils/cache/ts_cache.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,26 @@ assignTSCurrentConfig(const char *newval, bool doit, GucSource source)
603603

604604
cfgId=TSConfigGetCfgid(stringToQualifiedNameList(newval), true);
605605

606+
/*
607+
* When source == PGC_S_TEST, we are checking the argument of an
608+
* ALTER DATABASE SET or ALTER USER SET command. It could be that
609+
* the intended use of the setting is for some other database, so
610+
* we should not error out if the text search configuration is not
611+
* present in the current database. We issue a NOTICE instead.
612+
*/
606613
if (!OidIsValid(cfgId))
607-
returnNULL;
614+
{
615+
if (source==PGC_S_TEST&& !doit)
616+
{
617+
ereport(NOTICE,
618+
(errcode(ERRCODE_UNDEFINED_OBJECT),
619+
errmsg("text search configuration \"%s\" does not exist",
620+
newval)));
621+
returnnewval;
622+
}
623+
else
624+
returnNULL;
625+
}
608626

609627
/*
610628
* Modify the actually stored value to be fully qualified, to ensure

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp