diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c index ff584909e2d02bff1992c0505197a90513b6afc6..8ed6d06bb2370a54349f2a86ee13e08a381eacf2 100644 --- a/src/backend/commands/tablespace.c +++ b/src/backend/commands/tablespace.c @@ -1031,9 +1031,27 @@ check_default_tablespace(char **newval, void **extra, GucSource source) if (**newval != '\0' && !OidIsValid(get_tablespace_oid(*newval, true))) { - GUC_check_errdetail("Tablespace \"%s\" does not exist.", - *newval); - return false; + /* + * When source == PGC_S_TEST, we are checking the argument of an + * ALTER DATABASE SET or ALTER USER SET command. pg_dumpall dumps + * all roles before tablespaces, so if we're restoring a + * pg_dumpall script the tablespace might not yet exist, but will + * be created later. Because of that, issue a NOTICE if source == + * PGC_S_TEST, but accept the value anyway. + */ + if (source == PGC_S_TEST) + { + ereport(NOTICE, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("tablespace \"%s\" does not exist", + *newval))); + } + else + { + GUC_check_errdetail("Tablespace \"%s\" does not exist.", + *newval); + return false; + } } } @@ -1148,12 +1166,25 @@ check_temp_tablespaces(char **newval, void **extra, GucSource source) } /* - * In an interactive SET command, we ereport for bad info. - * Otherwise, silently ignore any bad list elements. + * In an interactive SET command, we ereport for bad info. When + * source == PGC_S_TEST, we are checking the argument of an ALTER + * DATABASE SET or ALTER USER SET command. pg_dumpall dumps all + * roles before tablespaces, so if we're restoring a pg_dumpall + * script the tablespace might not yet exist, but will be created + * later. Because of that, issue a NOTICE if source == PGC_S_TEST, + * but accept the value anyway. Otherwise, silently ignore any + * bad list elements. */ - curoid = get_tablespace_oid(curname, source < PGC_S_INTERACTIVE); + curoid = get_tablespace_oid(curname, source <= PGC_S_TEST); if (curoid == InvalidOid) + { + if (source == PGC_S_TEST) + ereport(NOTICE, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("tablespace \"%s\" does not exist", + curname))); continue; + } /* * Allow explicit specification of database's default tablespace diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c index c84c58006230eb64284cb53a0e7a39ba8f717a43..4ad5e7fc0b0642398adaaea27f5b8466798d7ef1 100644 --- a/src/backend/utils/cache/ts_cache.c +++ b/src/backend/utils/cache/ts_cache.c @@ -601,8 +601,25 @@ check_TSCurrentConfig(char **newval, void **extra, GucSource source) cfgId = get_ts_config_oid(stringToQualifiedNameList(*newval), true); + /* + * When source == PGC_S_TEST, we are checking the argument of an + * ALTER DATABASE SET or ALTER USER SET command. It could be that + * the intended use of the setting is for some other database, so + * we should not error out if the text search configuration is not + * present in the current database. We issue a NOTICE instead. + */ if (!OidIsValid(cfgId)) - return false; + { + if (source == PGC_S_TEST) + { + ereport(NOTICE, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("text search configuration \"%s\" does not exist", *newval))); + return true; + } + else + return false; + } /* * Modify the actually stored value to be fully qualified, to ensure