From de66987adb8a3414724b99540d324407bfad697a Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Mon, 14 Jan 2019 15:30:24 -0800 Subject: [PATCH] Re-add default_with_oids GUC to avoid breaking old dump files. After 578b229718 / the removal of WITH OIDS support, older dump files containing SET default_with_oids = false; either report unnecessary errors (as the subsequent tables have no oids) or even fail to restore entirely (when using transaction mode). To avoid that, re-add the GUC, but don't allow setting it to true. Per complaint from Tom Lane. Author: Amit Khandekar, editorialized by me Discussion: https://postgr.es/m/CAJ3gD9dZyxrtL0rJfoNoOj6v7fJSDaXBngi9wy5XU8m-ioXhAA@mail.gmail.com --- src/backend/utils/misc/guc.c | 37 +++++++++++++++++++++++++++++++ src/test/regress/expected/guc.out | 4 ++++ src/test/regress/sql/guc.sql | 4 ++++ 3 files changed, 45 insertions(+) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index ae925c1650..c216ed0922 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,12 @@ char *event_source; bool row_security; bool check_function_bodies = true; + +/* + * This GUC exists solely for backward compatibility, check its definition for + * details. + */ +bool default_with_oids = false; bool session_auth_is_superuser; int log_min_error_statement = ERROR; @@ -1538,6 +1545,21 @@ static struct config_bool ConfigureNamesBool[] = true, NULL, NULL, NULL }, + /* + * WITH OIDS support, and consequently default_with_oids, was removed in + * PostgreSQL 12, but we tolerate the parameter being set to false to + * avoid unnecessarily breaking older dump files. + */ + { + {"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS, + gettext_noop("WITH OIDS is no longer supported; this can only be false."), + NULL, + GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE + }, + &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."), @@ -11311,4 +11333,19 @@ 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) + { + /* check the GUC's definition for an explanation */ + GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED); + GUC_check_errmsg("tables declared WITH OIDS are not supported"); + + 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 43ac5f5f11..b0d7351145 100644 --- a/src/test/regress/expected/guc.out +++ b/src/test/regress/expected/guc.out @@ -767,3 +767,7 @@ 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: tables declared WITH OIDS are not supported diff --git a/src/test/regress/sql/guc.sql b/src/test/regress/sql/guc.sql index 23e5029780..3b854ac496 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; -- 2.40.0