errmsg_default_with_oids.patch
application/octet-stream
Filename: errmsg_default_with_oids.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/utils/misc/guc.c | 30 | 0 |
| src/test/regress/expected/guc.out | 5 | 0 |
| src/test/regress/sql/guc.sql | 4 | 0 |
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 6fe1939..78c18f3 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -209,6 +209,7 @@ static void assign_recovery_target_name(const char *newval, void *extra);
static bool check_recovery_target_lsn(char **newval, void **extra, GucSource source);
static void assign_recovery_target_lsn(const char *newval, void *extra);
static bool check_primary_slot_name(char **newval, void **extra, GucSource source);
+static bool check_default_with_oids(bool *newval, void **extra, GucSource source);
/* Private functions in guc-file.l that need to be called from guc.c */
static ConfigVariable *ProcessConfigFileInternal(GucContext context,
@@ -479,6 +480,7 @@ char *event_source;
bool row_security;
bool check_function_bodies = true;
+bool default_with_oids = false;
bool session_auth_is_superuser;
int log_min_error_statement = ERROR;
@@ -1539,6 +1541,18 @@ static struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL
},
{
+ {"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
+ gettext_noop("Create new tables with OIDs by default (deprecated)."),
+ gettext_noop("This parameter cannot be turned on since OIDS cannot"
+ " be added to user tables; it is retained only to emit"
+ " a user-friendly error message while restoring from"
+ " old dump files."),
+ },
+ &default_with_oids,
+ false,
+ check_default_with_oids, NULL, NULL
+ },
+ {
{"logging_collector", PGC_POSTMASTER, LOGGING_WHERE,
gettext_noop("Start a subprocess to capture stderr output and/or csvlogs into log files."),
NULL
@@ -11310,4 +11324,20 @@ check_primary_slot_name(char **newval, void **extra, GucSource source)
return true;
}
+static bool
+check_default_with_oids(bool *newval, void **extra, GucSource source)
+{
+ if (*newval)
+ {
+ /* For the reason for this error message, see the guc definition */
+ GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
+ GUC_check_errmsg("cannot set this parameter to true");
+ GUC_check_errhint("OIDs cannot be added to user tables.");
+
+ return false;
+ }
+
+ return true;
+}
+
#include "guc-file.c"
diff --git a/src/test/regress/expected/guc.out b/src/test/regress/expected/guc.out
index 43ac5f5..fec84dc 100644
--- a/src/test/regress/expected/guc.out
+++ b/src/test/regress/expected/guc.out
@@ -767,3 +767,8 @@ NOTICE: text search configuration "no_such_config" does not exist
select func_with_bad_set();
ERROR: invalid value for parameter "default_text_search_config": "no_such_config"
reset check_function_bodies;
+set default_with_oids to f;
+-- Should not allow to set it to true.
+set default_with_oids to t;
+ERROR: cannot set this parameter to true
+HINT: OIDs cannot be added to user tables.
diff --git a/src/test/regress/sql/guc.sql b/src/test/regress/sql/guc.sql
index 23e5029..3b854ac 100644
--- a/src/test/regress/sql/guc.sql
+++ b/src/test/regress/sql/guc.sql
@@ -288,3 +288,7 @@ set default_text_search_config = no_such_config;
select func_with_bad_set();
reset check_function_bodies;
+
+set default_with_oids to f;
+-- Should not allow to set it to true.
+set default_with_oids to t;