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

Commit396d348

Browse files
committed
pg_dump: Dump colliculocale
This was forgotten when the new column was introduced.Author: Marina Polyakova <m.polyakova@postgrespro.ru>Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>Discussion:https://www.postgresql.org/message-id/7ad26354e75259f59c4a6c6997b8ee32%40postgrespro.ru
1 parentf25bed3 commit396d348

File tree

3 files changed

+70
-9
lines changed

3 files changed

+70
-9
lines changed

‎src/bin/pg_dump/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ top_builddir = ../../..
1717
include$(top_builddir)/src/Makefile.global
1818

1919
exportGZIP_PROGRAM=$(GZIP)
20+
exportwith_icu
2021

2122
overrideCPPFLAGS := -I$(libpq_srcdir)$(CPPFLAGS)
2223
LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils$(libpq_pgport)

‎src/bin/pg_dump/pg_dump.c

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13083,9 +13083,11 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
1308313083
inti_collisdeterministic;
1308413084
inti_collcollate;
1308513085
inti_collctype;
13086+
inti_colliculocale;
1308613087
const char *collprovider;
1308713088
const char *collcollate;
1308813089
const char *collctype;
13090+
const char *colliculocale;
1308913091

1309013092
/* Do nothing in data-only dump */
1309113093
if (dopt->dataOnly)
@@ -13116,6 +13118,13 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
1311613118
appendPQExpBufferStr(query,
1311713119
"true AS collisdeterministic, ");
1311813120

13121+
if (fout->remoteVersion >= 150000)
13122+
appendPQExpBufferStr(query,
13123+
"colliculocale, ");
13124+
else
13125+
appendPQExpBufferStr(query,
13126+
"NULL AS colliculocale, ");
13127+
1311913128
appendPQExpBuffer(query,
1312013129
"collcollate, "
1312113130
"collctype "
@@ -13129,10 +13138,24 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
1312913138
i_collisdeterministic = PQfnumber(res, "collisdeterministic");
1313013139
i_collcollate = PQfnumber(res, "collcollate");
1313113140
i_collctype = PQfnumber(res, "collctype");
13141+
i_colliculocale = PQfnumber(res, "colliculocale");
1313213142

1313313143
collprovider = PQgetvalue(res, 0, i_collprovider);
13134-
collcollate = PQgetvalue(res, 0, i_collcollate);
13135-
collctype = PQgetvalue(res, 0, i_collctype);
13144+
13145+
if (!PQgetisnull(res, 0, i_collcollate))
13146+
collcollate = PQgetvalue(res, 0, i_collcollate);
13147+
else
13148+
collcollate = NULL;
13149+
13150+
if (!PQgetisnull(res, 0, i_collctype))
13151+
collctype = PQgetvalue(res, 0, i_collctype);
13152+
else
13153+
collctype = NULL;
13154+
13155+
if (!PQgetisnull(res, 0, i_colliculocale))
13156+
colliculocale = PQgetvalue(res, 0, i_colliculocale);
13157+
else
13158+
colliculocale = NULL;
1313613159

1313713160
appendPQExpBuffer(delq, "DROP COLLATION %s;\n",
1313813161
fmtQualifiedDumpable(collinfo));
@@ -13155,17 +13178,28 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
1315513178
if (strcmp(PQgetvalue(res, 0, i_collisdeterministic), "f") == 0)
1315613179
appendPQExpBufferStr(q, ", deterministic = false");
1315713180

13158-
if (strcmp(collcollate, collctype) == 0)
13181+
if (colliculocale != NULL)
1315913182
{
1316013183
appendPQExpBufferStr(q, ", locale = ");
13161-
appendStringLiteralAH(q,collcollate, fout);
13184+
appendStringLiteralAH(q,colliculocale, fout);
1316213185
}
1316313186
else
1316413187
{
13165-
appendPQExpBufferStr(q, ", lc_collate = ");
13166-
appendStringLiteralAH(q, collcollate, fout);
13167-
appendPQExpBufferStr(q, ", lc_ctype = ");
13168-
appendStringLiteralAH(q, collctype, fout);
13188+
Assert(collcollate != NULL);
13189+
Assert(collctype != NULL);
13190+
13191+
if (strcmp(collcollate, collctype) == 0)
13192+
{
13193+
appendPQExpBufferStr(q, ", locale = ");
13194+
appendStringLiteralAH(q, collcollate, fout);
13195+
}
13196+
else
13197+
{
13198+
appendPQExpBufferStr(q, ", lc_collate = ");
13199+
appendStringLiteralAH(q, collcollate, fout);
13200+
appendPQExpBufferStr(q, ", lc_ctype = ");
13201+
appendStringLiteralAH(q, collctype, fout);
13202+
}
1316913203
}
1317013204

1317113205
/*

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,15 @@
15931593
like=> {%full_runs,section_pre_data=> 1, },
15941594
},
15951595

1596+
'CREATE COLLATION icu_collation'=> {
1597+
create_order=> 76,
1598+
create_sql=>"CREATE COLLATION icu_collation (PROVIDER = icu, LOCALE = 'C');",
1599+
regexp=>
1600+
qr/CREATE COLLATION public.icu_collation\(provider = icu, locale = 'C'(, version = '[^']*')?\);/m,
1601+
icu=> 1,
1602+
like=> {%full_runs,section_pre_data=> 1, },
1603+
},
1604+
15961605
'CREATE CAST FOR timestamptz'=> {
15971606
create_order=> 51,
15981607
create_sql=>
@@ -3890,7 +3899,7 @@
38903899
$collation_support = 1;
38913900
}
38923901
3893-
# Determine whether build supports LZ4 and gzip.
3902+
my$supports_icu = ($ENV{with_icu} eq 'yes');
38943903
my$supports_lz4 = check_pg_config("#define USE_LZ4 1");
38953904
my$supports_gzip = check_pg_config("#define HAVE_LIBZ 1");
38963905
@@ -3931,6 +3940,11 @@
39313940
$test_db =$tests{$test}->{database};
39323941
}
39333942
3943+
if (defined($tests{$test}->{icu}))
3944+
{
3945+
$tests{$test}->{collation} = 1;
3946+
}
3947+
39343948
if ($tests{$test}->{create_sql})
39353949
{
39363950
@@ -3940,6 +3954,12 @@
39403954
next;
39413955
}
39423956
3957+
# Skip any icu-related collation commands if build was without icu
3958+
if (!$supports_icu && defined($tests{$test}->{icu}))
3959+
{
3960+
next;
3961+
}
3962+
39433963
# Skip tests specific to LZ4 if this build does not support
39443964
# this option.
39453965
if (!$supports_lz4 && defined($tests{$test}->{lz4}))
@@ -4141,6 +4161,12 @@
41414161
next;
41424162
}
41434163
4164+
# Skip any icu-related collation commands if build was without icu
4165+
if (!$supports_icu && defined($tests{$test}->{icu}))
4166+
{
4167+
next;
4168+
}
4169+
41444170
# Skip tests specific to LZ4 if this build does not support
41454171
# this option.
41464172
if (!$supports_lz4 && defined($tests{$test}->{lz4}))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp