Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit37188ce

Browse files
committed
Fix pg_dump assertion failure when dumping pg_catalog.
Commit396d348 did not account for the default collation.Also, use pg_log_warning() instead of Assert().Discussion:https://postgr.es/m/ce071503fee88334aa70f360e6e4ea14d48305ee.camel%40j-davis.comReviewed-by: Michael PaquierBackpatch-through: 15
1 parenta684581 commit37188ce

File tree

2 files changed

+61
-16
lines changed

2 files changed

+61
-16
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13415,6 +13415,18 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
1341513415
else
1341613416
collctype = NULL;
1341713417

13418+
/*
13419+
* Before version 15, collcollate and collctype were of type NAME and
13420+
* non-nullable. Treat empty strings as NULL for consistency.
13421+
*/
13422+
if (fout->remoteVersion < 150000)
13423+
{
13424+
if (collcollate[0] == '\0')
13425+
collcollate = NULL;
13426+
if (collctype[0] == '\0')
13427+
collctype = NULL;
13428+
}
13429+
1341813430
if (!PQgetisnull(res, 0, i_colliculocale))
1341913431
colliculocale = PQgetvalue(res, 0, i_colliculocale);
1342013432
else
@@ -13446,35 +13458,60 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
1344613458
if (strcmp(PQgetvalue(res, 0, i_collisdeterministic), "f") == 0)
1344713459
appendPQExpBufferStr(q, ", deterministic = false");
1344813460

13449-
if (colliculocale != NULL)
13461+
if (collprovider[0] == 'd')
1345013462
{
13451-
appendPQExpBufferStr(q, ", locale = ");
13452-
appendStringLiteralAH(q, colliculocale, fout);
13463+
if (collcollate || collctype || colliculocale || collicurules)
13464+
pg_log_warning("invalid collation \"%s\"", qcollname);
13465+
13466+
/* no locale -- the default collation cannot be reloaded anyway */
1345313467
}
13454-
else
13468+
else if (collprovider[0] == 'i')
1345513469
{
13456-
Assert(collcollate != NULL);
13457-
Assert(collctype != NULL);
13470+
if (fout->remoteVersion >= 150000)
13471+
{
13472+
if (collcollate || collctype || !colliculocale)
13473+
pg_log_warning("invalid collation \"%s\"", qcollname);
1345813474

13459-
if (strcmp(collcollate, collctype) == 0)
13475+
appendPQExpBufferStr(q, ", locale = ");
13476+
appendStringLiteralAH(q, colliculocale ? colliculocale : "",
13477+
fout);
13478+
}
13479+
else
1346013480
{
13481+
if (!collcollate || !collctype || colliculocale ||
13482+
strcmp(collcollate, collctype) != 0)
13483+
pg_log_warning("invalid collation \"%s\"", qcollname);
13484+
1346113485
appendPQExpBufferStr(q, ", locale = ");
13462-
appendStringLiteralAH(q, collcollate, fout);
13486+
appendStringLiteralAH(q, collcollate ? collcollate : "", fout);
13487+
}
13488+
13489+
if (collicurules)
13490+
{
13491+
appendPQExpBufferStr(q, ", rules = ");
13492+
appendStringLiteralAH(q, collicurules ? collicurules : "", fout);
13493+
}
13494+
}
13495+
else if (collprovider[0] == 'c')
13496+
{
13497+
if (colliculocale || collicurules || !collcollate || !collctype)
13498+
pg_log_warning("invalid collation \"%s\"", qcollname);
13499+
13500+
if (collcollate && collctype && strcmp(collcollate, collctype) == 0)
13501+
{
13502+
appendPQExpBufferStr(q, ", locale = ");
13503+
appendStringLiteralAH(q, collcollate ? collcollate : "", fout);
1346313504
}
1346413505
else
1346513506
{
1346613507
appendPQExpBufferStr(q, ", lc_collate = ");
13467-
appendStringLiteralAH(q, collcollate, fout);
13508+
appendStringLiteralAH(q, collcollate ? collcollate : "", fout);
1346813509
appendPQExpBufferStr(q, ", lc_ctype = ");
13469-
appendStringLiteralAH(q, collctype, fout);
13510+
appendStringLiteralAH(q, collctype ? collctype : "", fout);
1347013511
}
1347113512
}
13472-
13473-
if (collicurules)
13474-
{
13475-
appendPQExpBufferStr(q, ", rules = ");
13476-
appendStringLiteralAH(q, collicurules, fout);
13477-
}
13513+
else
13514+
pg_fatal("unrecognized collation provider '%c'", collprovider[0]);
1347813515

1347913516
/*
1348013517
* For binary upgrade, carry over the collation version. For normal

‎src/bin/pg_dump/t/002_pg_dump.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4769,6 +4769,14 @@
47694769
qr/pg_dumpall: error: improper qualified name\(too many dotted names\): myhost\.mydb/,
47704770
'pg_dumpall: option --exclude-database rejects multipart database names');
47714771
4772+
##############################################################
4773+
# Test dumping pg_catalog (for research -- cannot be reloaded)
4774+
4775+
$node->command_ok(
4776+
[ 'pg_dump', '-p', "$port", '-n', 'pg_catalog' ],
4777+
'pg_dump: option -n pg_catalog'
4778+
);
4779+
47724780
#########################################
47734781
# Test valid database exclusion patterns
47744782

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp