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

Commit1d9976d

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 parent75f323a commit1d9976d

File tree

2 files changed

+55
-10
lines changed

2 files changed

+55
-10
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13258,6 +13258,18 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
1325813258
else
1325913259
collctype = NULL;
1326013260

13261+
/*
13262+
* Before version 15, collcollate and collctype were of type NAME and
13263+
* non-nullable. Treat empty strings as NULL for consistency.
13264+
*/
13265+
if (fout->remoteVersion < 150000)
13266+
{
13267+
if (collcollate[0] == '\0')
13268+
collcollate = NULL;
13269+
if (collctype[0] == '\0')
13270+
collctype = NULL;
13271+
}
13272+
1326113273
if (!PQgetisnull(res, 0, i_colliculocale))
1326213274
colliculocale = PQgetvalue(res, 0, i_colliculocale);
1326313275
else
@@ -13284,29 +13296,54 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
1328413296
if (strcmp(PQgetvalue(res, 0, i_collisdeterministic), "f") == 0)
1328513297
appendPQExpBufferStr(q, ", deterministic = false");
1328613298

13287-
if (colliculocale != NULL)
13299+
if (collprovider[0] == 'd')
1328813300
{
13289-
appendPQExpBufferStr(q, ", locale = ");
13290-
appendStringLiteralAH(q, colliculocale, fout);
13301+
if (collcollate || collctype || colliculocale)
13302+
pg_log_warning("invalid collation \"%s\"", qcollname);
13303+
13304+
/* no locale -- the default collation cannot be reloaded anyway */
1329113305
}
13292-
else
13306+
else if (collprovider[0] == 'i')
1329313307
{
13294-
Assert(collcollate != NULL);
13295-
Assert(collctype != NULL);
13308+
if (fout->remoteVersion >= 150000)
13309+
{
13310+
if (collcollate || collctype || !colliculocale)
13311+
pg_log_warning("invalid collation \"%s\"", qcollname);
1329613312

13297-
if (strcmp(collcollate, collctype) == 0)
13313+
appendPQExpBufferStr(q, ", locale = ");
13314+
appendStringLiteralAH(q, colliculocale ? colliculocale : "",
13315+
fout);
13316+
}
13317+
else
13318+
{
13319+
if (!collcollate || !collctype || colliculocale ||
13320+
strcmp(collcollate, collctype) != 0)
13321+
pg_log_warning("invalid collation \"%s\"", qcollname);
13322+
13323+
appendPQExpBufferStr(q, ", locale = ");
13324+
appendStringLiteralAH(q, collcollate ? collcollate : "", fout);
13325+
}
13326+
}
13327+
else if (collprovider[0] == 'c')
13328+
{
13329+
if (colliculocale || !collcollate || !collctype)
13330+
pg_log_warning("invalid collation \"%s\"", qcollname);
13331+
13332+
if (collcollate && collctype && strcmp(collcollate, collctype) == 0)
1329813333
{
1329913334
appendPQExpBufferStr(q, ", locale = ");
13300-
appendStringLiteralAH(q, collcollate, fout);
13335+
appendStringLiteralAH(q, collcollate ? collcollate : "", fout);
1330113336
}
1330213337
else
1330313338
{
1330413339
appendPQExpBufferStr(q, ", lc_collate = ");
13305-
appendStringLiteralAH(q, collcollate, fout);
13340+
appendStringLiteralAH(q, collcollate ? collcollate : "", fout);
1330613341
appendPQExpBufferStr(q, ", lc_ctype = ");
13307-
appendStringLiteralAH(q, collctype, fout);
13342+
appendStringLiteralAH(q, collctype ? collctype : "", fout);
1330813343
}
1330913344
}
13345+
else
13346+
pg_fatal("unrecognized collation provider '%c'", collprovider[0]);
1331013347

1331113348
/*
1331213349
* 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
@@ -4091,6 +4091,14 @@
40914091
qr/pg_dumpall: error: improper qualified name\(too many dotted names\): myhost\.mydb/,
40924092
'pg_dumpall: option --exclude-database rejects multipart database names');
40934093
4094+
##############################################################
4095+
# Test dumping pg_catalog (for research -- cannot be reloaded)
4096+
4097+
$node->command_ok(
4098+
[ 'pg_dump', '-p', "$port", '-n', 'pg_catalog' ],
4099+
'pg_dump: option -n pg_catalog'
4100+
);
4101+
40944102
#########################################
40954103
# Test valid database exclusion patterns
40964104

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp