summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/commands/tablespace.c23
-rw-r--r--src/backend/utils/cache/ts_cache.c20
2 files changed, 39 insertions, 4 deletions
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index b81381a6ea8..069b456d0d5 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -926,11 +926,22 @@ assign_default_tablespace(const char *newval, bool doit, GucSource source)
if (newval[0] != '\0' &&
!OidIsValid(get_tablespace_oid(newval)))
{
- ereport(GUC_complaint_elevel(source),
+ /*
+ * 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.
+ */
+ ereport((source == PGC_S_TEST) ? NOTICE : GUC_complaint_elevel(source),
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("tablespace \"%s\" does not exist",
newval)));
- return NULL;
+ if (source == PGC_S_TEST)
+ return newval;
+ else
+ return NULL;
}
}
@@ -1047,10 +1058,16 @@ assign_temp_tablespaces(const char *newval, bool doit, GucSource source)
{
/*
* 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.
*/
if (source >= PGC_S_INTERACTIVE)
- ereport(ERROR,
+ ereport((source == PGC_S_TEST) ? NOTICE : ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("tablespace \"%s\" does not exist",
curname)));
diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c
index 9c4e72f24e9..e895a990315 100644
--- a/src/backend/utils/cache/ts_cache.c
+++ b/src/backend/utils/cache/ts_cache.c
@@ -608,8 +608,26 @@ assignTSCurrentConfig(const char *newval, bool doit, GucSource source)
cfgId = TSConfigGetCfgid(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 NULL;
+ {
+ if (source == PGC_S_TEST && !doit)
+ {
+ ereport(NOTICE,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("text search configuration \"%s\" does not exist",
+ newval)));
+ return newval;
+ }
+ else
+ return NULL;
+ }
/*
* Modify the actually stored value to be fully qualified, to ensure