From 0c66a223774dec62edb5281a47e72fe480a8f7aa Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 3 Sep 2013 18:56:22 -0400 Subject: [PATCH] Update comments concerning PGC_S_TEST. This GUC context value was once only used by ALTER DATABASE SET and ALTER USER SET. That's not true anymore, though, so rewrite the comments to be a bit more general. Patch in HEAD only, since this is just an internal documentation issue. --- src/backend/commands/tablespace.c | 19 +++++-------------- src/backend/utils/cache/ts_cache.c | 7 ++----- src/include/utils/guc.h | 14 +++++++++----- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c index ba9cb1f8f1..155eb7c248 100644 --- a/src/backend/commands/tablespace.c +++ b/src/backend/commands/tablespace.c @@ -977,12 +977,8 @@ check_default_tablespace(char **newval, void **extra, GucSource source) !OidIsValid(get_tablespace_oid(*newval, true))) { /* - * 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. + * When source == PGC_S_TEST, don't throw a hard error for a + * nonexistent tablespace, only a NOTICE. See comments in guc.h. */ if (source == PGC_S_TEST) { @@ -1111,14 +1107,9 @@ check_temp_tablespaces(char **newval, void **extra, 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. + * In an interactive SET command, we ereport for bad info. When + * source == PGC_S_TEST, don't throw a hard error for a + * nonexistent tablespace, only a NOTICE. See comments in guc.h. */ curoid = get_tablespace_oid(curname, source <= PGC_S_TEST); if (curoid == InvalidOid) diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c index 4e79247218..e61b329130 100644 --- a/src/backend/utils/cache/ts_cache.c +++ b/src/backend/utils/cache/ts_cache.c @@ -604,11 +604,8 @@ 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. + * When source == PGC_S_TEST, don't throw a hard error for a + * nonexistent configuration, only a NOTICE. See comments in guc.h. */ if (!OidIsValid(cfgId)) { diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index d497b1f654..99211c1f6c 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -72,11 +72,15 @@ typedef enum * dividing line between "interactive" and "non-interactive" sources for * error reporting purposes. * - * PGC_S_TEST is used when testing values to be stored as per-database or - * per-user defaults ("doit" will always be false, so this never gets stored - * as the actual source of any value). This is an interactive case, but - * it needs its own source value because some assign hooks need to make - * different validity checks in this case. + * PGC_S_TEST is used when testing values to be used later ("doit" will always + * be false, so this never gets stored as the actual source of any value). + * For example, ALTER DATABASE/ROLE tests proposed per-database or per-user + * defaults this way, and CREATE FUNCTION tests proposed function SET clauses + * this way. This is an interactive case, but it needs its own source value + * because some assign hooks need to make different validity checks in this + * case. In particular, references to nonexistent database objects generally + * shouldn't throw hard errors in this case, at most NOTICEs, since the + * objects might exist by the time the setting is used for real. * * NB: see GucSource_Names in guc.c if you change this. */