aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-03-30 10:57:57 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2021-03-30 10:57:57 -0400
commit54bb91c30e3964fd81059e6b02e377cc9dd2d64c (patch)
tree865b91ad06797ea01207f0f7db4f7e6f4487ad85 /src
parented934d4fa30f0f94e6f7125ad2154e6a58d1c7f7 (diff)
downloadpostgresql-54bb91c30e3964fd81059e6b02e377cc9dd2d64c.tar.gz
postgresql-54bb91c30e3964fd81059e6b02e377cc9dd2d64c.zip
Further tweaking of pg_dump's handling of default_toast_compression.
As committed in bbe0a81db, pg_dump from a pre-v14 server effectively acts as though you'd said --no-toast-compression. I think the right thing is for it to act as though default_toast_compression is set to "pglz", instead, so that the tables' toast compression behavior is preserved. You can always get the other behavior, if you want that, by giving the switch. Discussion: https://postgr.es/m/1112852.1616609702@sss.pgh.pa.us
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_dump.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index da6cc054b08..b72adcfbb8d 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3333,18 +3333,28 @@ dumpSearchPath(Archive *AH)
static void
dumpToastCompression(Archive *AH)
{
- const char *toast_compression;
+ char *toast_compression;
PQExpBuffer qry;
- PGresult *res;
- if (AH->remoteVersion < 140000 || AH->dopt->no_toast_compression)
+ if (AH->dopt->no_toast_compression)
{
- /* server doesn't support compression, or we don't care */
+ /* we don't intend to dump the info, so no need to fetch it either */
return;
}
- res = ExecuteSqlQueryForSingleRow(AH, "SHOW default_toast_compression");
- toast_compression = PQgetvalue(res, 0, 0);
+ if (AH->remoteVersion < 140000)
+ {
+ /* pre-v14, the only method was pglz */
+ toast_compression = pg_strdup("pglz");
+ }
+ else
+ {
+ PGresult *res;
+
+ res = ExecuteSqlQueryForSingleRow(AH, "SHOW default_toast_compression");
+ toast_compression = pg_strdup(PQgetvalue(res, 0, 0));
+ PQclear(res);
+ }
qry = createPQExpBuffer();
appendPQExpBufferStr(qry, "SET default_toast_compression = ");
@@ -3363,9 +3373,8 @@ dumpToastCompression(Archive *AH)
* Also save it in AH->default_toast_compression, in case we're doing
* plain text dump.
*/
- AH->default_toast_compression = pg_strdup(toast_compression);
+ AH->default_toast_compression = toast_compression;
- PQclear(res);
destroyPQExpBuffer(qry);
}