mirror of
https://github.com/postgres/postgres.git
synced 2025-10-16 17:07:43 +03:00
Rethink definition of pg_attribute.attcompression.
Redefine '\0' (InvalidCompressionMethod) as meaning "if we need to compress, use the current setting of default_toast_compression". This allows '\0' to be a suitable default choice regardless of datatype, greatly simplifying code paths that initialize tupledescs and the like. It seems like a more user-friendly approach as well, because now the default compression choice doesn't migrate into table definitions, meaning that changing default_toast_compression is usually sufficient to flip an installation's behavior; one needn't tediously issue per-column ALTER SET COMPRESSION commands. Along the way, fix a few minor bugs and documentation issues with the per-column-compression feature. Adopt more robust APIs for SetIndexStorageProperties and GetAttributeCompression. Bump catversion because typical contents of attcompression will now be different. We could get away without doing that, but it seems better to ensure v14 installations all agree on this. (We already forced initdb for beta2, anyway.) Discussion: https://postgr.es/m/626613.1621787110@sss.pgh.pa.us
This commit is contained in:
@@ -86,7 +86,6 @@ 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);
|
||||
@@ -2638,8 +2637,6 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2697,29 +2694,6 @@ 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)
|
||||
{
|
||||
@@ -2779,8 +2753,7 @@ _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, "TOASTCOMPRESSION") == 0)
|
||||
strcmp(te->desc, "SEARCHPATH") == 0)
|
||||
return REQ_SPECIAL;
|
||||
|
||||
/*
|
||||
@@ -3103,11 +3076,6 @@ _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