Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54bb91c

Browse files
committed
Further tweaking of pg_dump's handling of default_toast_compression.
As committed in bbe0a81, 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/[email protected]
1 parent ed934d4 commit 54bb91c

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,18 +3333,28 @@ dumpSearchPath(Archive *AH)
33333333
static void
33343334
dumpToastCompression(Archive *AH)
33353335
{
3336-
const char *toast_compression;
3336+
char *toast_compression;
33373337
PQExpBuffer qry;
3338-
PGresult *res;
33393338

3340-
if (AH->remoteVersion < 140000 || AH->dopt->no_toast_compression)
3339+
if (AH->dopt->no_toast_compression)
33413340
{
3342-
/* server doesn't support compression, or we don't care */
3341+
/* we don't intend to dump the info, so no need to fetch it either */
33433342
return;
33443343
}
33453344

3346-
res = ExecuteSqlQueryForSingleRow(AH, "SHOW default_toast_compression");
3347-
toast_compression = PQgetvalue(res, 0, 0);
3345+
if (AH->remoteVersion < 140000)
3346+
{
3347+
/* pre-v14, the only method was pglz */
3348+
toast_compression = pg_strdup("pglz");
3349+
}
3350+
else
3351+
{
3352+
PGresult *res;
3353+
3354+
res = ExecuteSqlQueryForSingleRow(AH, "SHOW default_toast_compression");
3355+
toast_compression = pg_strdup(PQgetvalue(res, 0, 0));
3356+
PQclear(res);
3357+
}
33483358

33493359
qry = createPQExpBuffer();
33503360
appendPQExpBufferStr(qry, "SET default_toast_compression = ");
@@ -3363,9 +3373,8 @@ dumpToastCompression(Archive *AH)
33633373
* Also save it in AH->default_toast_compression, in case we're doing
33643374
* plain text dump.
33653375
*/
3366-
AH->default_toast_compression = pg_strdup(toast_compression);
3376+
AH->default_toast_compression = toast_compression;
33673377

3368-
PQclear(res);
33693378
destroyPQExpBuffer(qry);
33703379
}
33713380

0 commit comments

Comments
 (0)