Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit de66987

Browse files
committed
Re-add default_with_oids GUC to avoid breaking old dump files.
After 578b229 / 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
1 parent 0ad41cf commit de66987

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

src/backend/utils/misc/guc.c

+37
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ static void assign_recovery_target_name(const char *newval, void *extra);
209209
static bool check_recovery_target_lsn(char **newval, void **extra, GucSource source);
210210
static void assign_recovery_target_lsn(const char *newval, void *extra);
211211
static bool check_primary_slot_name(char **newval, void **extra, GucSource source);
212+
static bool check_default_with_oids(bool *newval, void **extra, GucSource source);
212213

213214
/* Private functions in guc-file.l that need to be called from guc.c */
214215
static ConfigVariable *ProcessConfigFileInternal(GucContext context,
@@ -479,6 +480,12 @@ char *event_source;
479480

480481
bool row_security;
481482
bool check_function_bodies = true;
483+
484+
/*
485+
* This GUC exists solely for backward compatibility, check its definition for
486+
* details.
487+
*/
488+
bool default_with_oids = false;
482489
bool session_auth_is_superuser;
483490

484491
int log_min_error_statement = ERROR;
@@ -1538,6 +1545,21 @@ static struct config_bool ConfigureNamesBool[] =
15381545
true,
15391546
NULL, NULL, NULL
15401547
},
1548+
/*
1549+
* WITH OIDS support, and consequently default_with_oids, was removed in
1550+
* PostgreSQL 12, but we tolerate the parameter being set to false to
1551+
* avoid unnecessarily breaking older dump files.
1552+
*/
1553+
{
1554+
{"default_with_oids", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
1555+
gettext_noop("WITH OIDS is no longer supported; this can only be false."),
1556+
NULL,
1557+
GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE
1558+
},
1559+
&default_with_oids,
1560+
false,
1561+
check_default_with_oids, NULL, NULL
1562+
},
15411563
{
15421564
{"logging_collector", PGC_POSTMASTER, LOGGING_WHERE,
15431565
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)
1131111333
return true;
1131211334
}
1131311335

11336+
static bool
11337+
check_default_with_oids(bool *newval, void **extra, GucSource source)
11338+
{
11339+
if (*newval)
11340+
{
11341+
/* check the GUC's definition for an explanation */
11342+
GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
11343+
GUC_check_errmsg("tables declared WITH OIDS are not supported");
11344+
11345+
return false;
11346+
}
11347+
11348+
return true;
11349+
}
11350+
1131411351
#include "guc-file.c"

src/test/regress/expected/guc.out

+4
Original file line numberDiff line numberDiff line change
@@ -767,3 +767,7 @@ NOTICE: text search configuration "no_such_config" does not exist
767767
select func_with_bad_set();
768768
ERROR: invalid value for parameter "default_text_search_config": "no_such_config"
769769
reset check_function_bodies;
770+
set default_with_oids to f;
771+
-- Should not allow to set it to true.
772+
set default_with_oids to t;
773+
ERROR: tables declared WITH OIDS are not supported

src/test/regress/sql/guc.sql

+4
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,7 @@ set default_text_search_config = no_such_config;
288288
select func_with_bad_set();
289289

290290
reset check_function_bodies;
291+
292+
set default_with_oids to f;
293+
-- Should not allow to set it to true.
294+
set default_with_oids to t;

0 commit comments

Comments
 (0)