Fix pg_dump assertion failure when dumping pg_catalog.
Commit 396d348b04 did not account for the default collation. Also, use pg_log_warning() instead of Assert(). Discussion: https://postgr.es/m/ce071503fee88334aa70f360e6e4ea14d48305ee.camel%40j-davis.com Reviewed-by: Michael Paquier Backpatch-through: 15
This commit is contained in:
parent
a684581085
commit
37188cea0c
@ -13415,6 +13415,18 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
|
|||||||
else
|
else
|
||||||
collctype = NULL;
|
collctype = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Before version 15, collcollate and collctype were of type NAME and
|
||||||
|
* non-nullable. Treat empty strings as NULL for consistency.
|
||||||
|
*/
|
||||||
|
if (fout->remoteVersion < 150000)
|
||||||
|
{
|
||||||
|
if (collcollate[0] == '\0')
|
||||||
|
collcollate = NULL;
|
||||||
|
if (collctype[0] == '\0')
|
||||||
|
collctype = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!PQgetisnull(res, 0, i_colliculocale))
|
if (!PQgetisnull(res, 0, i_colliculocale))
|
||||||
colliculocale = PQgetvalue(res, 0, i_colliculocale);
|
colliculocale = PQgetvalue(res, 0, i_colliculocale);
|
||||||
else
|
else
|
||||||
@ -13446,35 +13458,60 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
|
|||||||
if (strcmp(PQgetvalue(res, 0, i_collisdeterministic), "f") == 0)
|
if (strcmp(PQgetvalue(res, 0, i_collisdeterministic), "f") == 0)
|
||||||
appendPQExpBufferStr(q, ", deterministic = false");
|
appendPQExpBufferStr(q, ", deterministic = false");
|
||||||
|
|
||||||
if (colliculocale != NULL)
|
if (collprovider[0] == 'd')
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(q, ", locale = ");
|
if (collcollate || collctype || colliculocale || collicurules)
|
||||||
appendStringLiteralAH(q, colliculocale, fout);
|
pg_log_warning("invalid collation \"%s\"", qcollname);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Assert(collcollate != NULL);
|
|
||||||
Assert(collctype != NULL);
|
|
||||||
|
|
||||||
if (strcmp(collcollate, collctype) == 0)
|
/* no locale -- the default collation cannot be reloaded anyway */
|
||||||
|
}
|
||||||
|
else if (collprovider[0] == 'i')
|
||||||
{
|
{
|
||||||
|
if (fout->remoteVersion >= 150000)
|
||||||
|
{
|
||||||
|
if (collcollate || collctype || !colliculocale)
|
||||||
|
pg_log_warning("invalid collation \"%s\"", qcollname);
|
||||||
|
|
||||||
appendPQExpBufferStr(q, ", locale = ");
|
appendPQExpBufferStr(q, ", locale = ");
|
||||||
appendStringLiteralAH(q, collcollate, fout);
|
appendStringLiteralAH(q, colliculocale ? colliculocale : "",
|
||||||
|
fout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(q, ", lc_collate = ");
|
if (!collcollate || !collctype || colliculocale ||
|
||||||
appendStringLiteralAH(q, collcollate, fout);
|
strcmp(collcollate, collctype) != 0)
|
||||||
appendPQExpBufferStr(q, ", lc_ctype = ");
|
pg_log_warning("invalid collation \"%s\"", qcollname);
|
||||||
appendStringLiteralAH(q, collctype, fout);
|
|
||||||
}
|
appendPQExpBufferStr(q, ", locale = ");
|
||||||
|
appendStringLiteralAH(q, collcollate ? collcollate : "", fout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collicurules)
|
if (collicurules)
|
||||||
{
|
{
|
||||||
appendPQExpBufferStr(q, ", rules = ");
|
appendPQExpBufferStr(q, ", rules = ");
|
||||||
appendStringLiteralAH(q, collicurules, fout);
|
appendStringLiteralAH(q, collicurules ? collicurules : "", fout);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (collprovider[0] == 'c')
|
||||||
|
{
|
||||||
|
if (colliculocale || collicurules || !collcollate || !collctype)
|
||||||
|
pg_log_warning("invalid collation \"%s\"", qcollname);
|
||||||
|
|
||||||
|
if (collcollate && collctype && strcmp(collcollate, collctype) == 0)
|
||||||
|
{
|
||||||
|
appendPQExpBufferStr(q, ", locale = ");
|
||||||
|
appendStringLiteralAH(q, collcollate ? collcollate : "", fout);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
appendPQExpBufferStr(q, ", lc_collate = ");
|
||||||
|
appendStringLiteralAH(q, collcollate ? collcollate : "", fout);
|
||||||
|
appendPQExpBufferStr(q, ", lc_ctype = ");
|
||||||
|
appendStringLiteralAH(q, collctype ? collctype : "", fout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pg_fatal("unrecognized collation provider '%c'", collprovider[0]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For binary upgrade, carry over the collation version. For normal
|
* For binary upgrade, carry over the collation version. For normal
|
||||||
|
@ -4769,6 +4769,14 @@ $node->command_fails_like(
|
|||||||
qr/pg_dumpall: error: improper qualified name \(too many dotted names\): myhost\.mydb/,
|
qr/pg_dumpall: error: improper qualified name \(too many dotted names\): myhost\.mydb/,
|
||||||
'pg_dumpall: option --exclude-database rejects multipart database names');
|
'pg_dumpall: option --exclude-database rejects multipart database names');
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
# Test dumping pg_catalog (for research -- cannot be reloaded)
|
||||||
|
|
||||||
|
$node->command_ok(
|
||||||
|
[ 'pg_dump', '-p', "$port", '-n', 'pg_catalog' ],
|
||||||
|
'pg_dump: option -n pg_catalog'
|
||||||
|
);
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# Test valid database exclusion patterns
|
# Test valid database exclusion patterns
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user