mirror of
https://github.com/postgres/postgres.git
synced 2025-10-16 17:07:43 +03:00
Fix up pg_dump's handling of per-attribute compression options.
The approach used in commitbbe0a81db
would've been disastrous for portability of dumps. Instead handle non-default compression options in separate ALTER TABLE commands. This reduces chatter for the common case where most columns are compressed the same way, and it makes it possible to restore the dump to a server that lacks any knowledge of per-attribute compression options (so long as you're willing to ignore syntax errors from the ALTER TABLE commands). There's a whole lot left to do to mop up afterbbe0a81db
, but I'm fast-tracking this part because we need to see if it's enough to make the buildfarm's cross-version-upgrade tests happy. Justin Pryzby and Tom Lane Discussion: https://postgr.es/m/20210119190720.GL8560@telsasoft.com
This commit is contained in:
@@ -86,6 +86,7 @@ static void _selectTableAccessMethod(ArchiveHandle *AH, const char *tableam);
|
||||
static void processEncodingEntry(ArchiveHandle *AH, TocEntry *te);
|
||||
static void processStdStringsEntry(ArchiveHandle *AH, TocEntry *te);
|
||||
static void processSearchPathEntry(ArchiveHandle *AH, TocEntry *te);
|
||||
static void processToastCompressionEntry(ArchiveHandle *AH, TocEntry *te);
|
||||
static int _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH);
|
||||
static RestorePass _tocEntryRestorePass(TocEntry *te);
|
||||
static bool _tocEntryIsACL(TocEntry *te);
|
||||
@@ -2696,6 +2697,8 @@ ReadToc(ArchiveHandle *AH)
|
||||
processStdStringsEntry(AH, te);
|
||||
else if (strcmp(te->desc, "SEARCHPATH") == 0)
|
||||
processSearchPathEntry(AH, te);
|
||||
else if (strcmp(te->desc, "TOASTCOMPRESSION") == 0)
|
||||
processToastCompressionEntry(AH, te);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2753,6 +2756,29 @@ processSearchPathEntry(ArchiveHandle *AH, TocEntry *te)
|
||||
AH->public.searchpath = pg_strdup(te->defn);
|
||||
}
|
||||
|
||||
static void
|
||||
processToastCompressionEntry(ArchiveHandle *AH, TocEntry *te)
|
||||
{
|
||||
/* te->defn should have the form SET default_toast_compression = 'x'; */
|
||||
char *defn = pg_strdup(te->defn);
|
||||
char *ptr1;
|
||||
char *ptr2 = NULL;
|
||||
|
||||
ptr1 = strchr(defn, '\'');
|
||||
if (ptr1)
|
||||
ptr2 = strchr(++ptr1, '\'');
|
||||
if (ptr2)
|
||||
{
|
||||
*ptr2 = '\0';
|
||||
AH->public.default_toast_compression = pg_strdup(ptr1);
|
||||
}
|
||||
else
|
||||
fatal("invalid TOASTCOMPRESSION item: %s",
|
||||
te->defn);
|
||||
|
||||
free(defn);
|
||||
}
|
||||
|
||||
static void
|
||||
StrictNamesCheck(RestoreOptions *ropt)
|
||||
{
|
||||
@@ -2812,7 +2838,8 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH)
|
||||
/* These items are treated specially */
|
||||
if (strcmp(te->desc, "ENCODING") == 0 ||
|
||||
strcmp(te->desc, "STDSTRINGS") == 0 ||
|
||||
strcmp(te->desc, "SEARCHPATH") == 0)
|
||||
strcmp(te->desc, "SEARCHPATH") == 0 ||
|
||||
strcmp(te->desc, "TOASTCOMPRESSION") == 0)
|
||||
return REQ_SPECIAL;
|
||||
|
||||
/*
|
||||
@@ -3135,6 +3162,11 @@ _doSetFixedOutputState(ArchiveHandle *AH)
|
||||
if (AH->public.searchpath)
|
||||
ahprintf(AH, "%s", AH->public.searchpath);
|
||||
|
||||
/* Select the dump-time default_toast_compression */
|
||||
if (AH->public.default_toast_compression)
|
||||
ahprintf(AH, "SET default_toast_compression = '%s';\n",
|
||||
AH->public.default_toast_compression);
|
||||
|
||||
/* Make sure function checking is disabled */
|
||||
ahprintf(AH, "SET check_function_bodies = false;\n");
|
||||
|
||||
|
Reference in New Issue
Block a user