postgresql/src/bin
Tom Lane 9e5f1f21ad Rethink recent fix for pg_dump's handling of extension config tables.
Commit 3eb3d3e78 was a few bricks shy of a load: while it correctly
set the table's "interesting" flag when deciding to dump the data of
an extension config table, it was not correct to clear that flag
if we concluded we shouldn't dump the data.  This led to the crash
reported in bug #16655, because in fact we'll traverse dumpTableSchema
anyway for all extension tables (to see if they have user-added
seclabels or RLS policies).

The right thing to do is to force "interesting" true in makeTableDataInfo,
and otherwise leave the flag alone.  (Doing it there is more future-proof
in case additional calls are added, and it also avoids setting the flag
unnecessarily if that function decides the table is non-dumpable.)

This investigation also showed that while only the --inserts code path
had an obvious failure in the case considered by 3eb3d3e78, the COPY
code path also has a problem with not having loaded table subsidiary
data.  That causes fmtCopyColumnList to silently return an empty string
instead of the correct column list.  That accidentally mostly works,
which perhaps is why we didn't notice this before.  It would only fail
if the restore column order is different from the dump column order,
which only happens in weird inheritance cases, so it's not surprising
nobody had hit the case with an extension config table.  Nonetheless,
it's a bug, and it goes a long way back, not just to v12 where the
--inserts code path started to have a problem with this.

In hopes of catching such cases a bit sooner in future, add some
Asserts that "interesting" has been set in both dumpTableData and
dumpTableSchema.  Adjust the test case added by 3eb3d3e78 so that it
checks the COPY rather than INSERT form of that bug, allowing it to
detect the longer-standing symptom.

Per bug #16655 from Cameron Daniel.  Back-patch to all supported
branches.

Discussion: https://postgr.es/m/16655-5c92d6b3a9438137@postgresql.org
Discussion: https://postgr.es/m/18048b44-3414-b983-8c7c-9165b177900d@2ndQuadrant.com
2020-10-07 12:51:02 -04:00
..
initdb Make postgres.bki use the same literal-string syntax as postgresql.conf. 2020-10-04 16:09:55 -04:00
pg_archivecleanup Improve common/logging.c's support for multiple verbosity levels. 2020-09-17 12:52:18 -04:00
pg_basebackup Standardize the printf format for st_size 2020-09-24 21:04:21 +02:00
pg_checksums Avoid non-constant format string argument to fprintf(). 2020-08-18 13:13:09 +03:00
pg_config Translation updates 2020-05-18 12:49:30 +02:00
pg_controldata Rename VariableCacheData.nextFullXid to nextXid. 2020-08-11 12:07:14 -07:00
pg_ctl Remove non-fast promotion. 2020-07-29 21:24:26 +09:00
pg_dump Rethink recent fix for pg_dump's handling of extension config tables. 2020-10-07 12:51:02 -04:00
pg_resetwal Rename VariableCacheData.nextFullXid to nextXid. 2020-08-11 12:07:14 -07:00
pg_rewind Improve common/logging.c's support for multiple verbosity levels. 2020-09-17 12:52:18 -04:00
pg_test_fsync Improve range checks of options for pg_test_fsync and pg_test_timing 2020-09-28 10:13:59 +09:00
pg_test_timing Improve range checks of options for pg_test_fsync and pg_test_timing 2020-09-28 10:13:59 +09:00
pg_upgrade pg_upgrade: remove pre-8.4 code and >= 8.4 check 2020-10-06 14:31:22 -04:00
pg_verifybackup Standardize the printf format for st_size 2020-09-24 21:04:21 +02:00
pg_waldump Correct several behavior descriptions in comments. 2020-08-15 20:21:52 -07:00
pgbench pgbench: Use PQExpBuffer to simplify code that constructs SQL. 2020-09-30 10:58:09 +03:00
pgevent Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
psql Improve tab-completion for DEALLOCATE. 2020-09-28 11:23:15 +09:00
scripts Message fixes and style improvements 2020-09-14 06:42:30 +02:00
Makefile Rename pg_validatebackup to pg_verifybackup. 2020-04-12 11:26:05 -04:00