]> granicus.if.org Git - postgresql/commitdiff
Re-add default_with_oids GUC to avoid breaking old dump files.
authorAndres Freund <andres@anarazel.de>
Mon, 14 Jan 2019 23:30:24 +0000 (15:30 -0800)
committerAndres Freund <andres@anarazel.de>
Mon, 14 Jan 2019 23:30:24 +0000 (15:30 -0800)
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
src/test/regress/expected/guc.out
src/test/regress/sql/guc.sql

index ae925c16509f25889640ff73fafa6dc41aaa70af..c216ed0922a5b2300218a0f7b741b544a7dda7ad 100644 (file)
@@ -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"
index 43ac5f5f11ccf27cf348e4d154b1391dcac5a592..b0d735114511a7374689e49dcd44b08f14d5ce91 100644 (file)
@@ -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
index 23e50297800f9164ced75d6f7e8c457f41c21821..3b854ac4963f8ca404218c38574768db6f3621b8 100644 (file)
@@ -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;