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

Commit72b6828

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 parent3d3c05c commit72b6828

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
@@ -13077,9 +13077,11 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
1307713077
inti_collisdeterministic;
1307813078
inti_collcollate;
1307913079
inti_collctype;
13080+
inti_colliculocale;
1308013081
const char *collprovider;
1308113082
const char *collcollate;
1308213083
const char *collctype;
13084+
const char *colliculocale;
1308313085

1308413086
/* Do nothing in data-only dump */
1308513087
if (dopt->dataOnly)
@@ -13110,6 +13112,13 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
1311013112
appendPQExpBufferStr(query,
1311113113
"true AS collisdeterministic, ");
1311213114

13115+
if (fout->remoteVersion >= 150000)
13116+
appendPQExpBufferStr(query,
13117+
"colliculocale, ");
13118+
else
13119+
appendPQExpBufferStr(query,
13120+
"NULL AS colliculocale, ");
13121+
1311313122
appendPQExpBuffer(query,
1311413123
"collcollate, "
1311513124
"collctype "
@@ -13123,10 +13132,24 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
1312313132
i_collisdeterministic = PQfnumber(res, "collisdeterministic");
1312413133
i_collcollate = PQfnumber(res, "collcollate");
1312513134
i_collctype = PQfnumber(res, "collctype");
13135+
i_colliculocale = PQfnumber(res, "colliculocale");
1312613136

1312713137
collprovider = PQgetvalue(res, 0, i_collprovider);
13128-
collcollate = PQgetvalue(res, 0, i_collcollate);
13129-
collctype = PQgetvalue(res, 0, i_collctype);
13138+
13139+
if (!PQgetisnull(res, 0, i_collcollate))
13140+
collcollate = PQgetvalue(res, 0, i_collcollate);
13141+
else
13142+
collcollate = NULL;
13143+
13144+
if (!PQgetisnull(res, 0, i_collctype))
13145+
collctype = PQgetvalue(res, 0, i_collctype);
13146+
else
13147+
collctype = NULL;
13148+
13149+
if (!PQgetisnull(res, 0, i_colliculocale))
13150+
colliculocale = PQgetvalue(res, 0, i_colliculocale);
13151+
else
13152+
colliculocale = NULL;
1313013153

1313113154
appendPQExpBuffer(delq, "DROP COLLATION %s;\n",
1313213155
fmtQualifiedDumpable(collinfo));
@@ -13149,17 +13172,28 @@ dumpCollation(Archive *fout, const CollInfo *collinfo)
1314913172
if (strcmp(PQgetvalue(res, 0, i_collisdeterministic), "f") == 0)
1315013173
appendPQExpBufferStr(q, ", deterministic = false");
1315113174

13152-
if (strcmp(collcollate, collctype) == 0)
13175+
if (colliculocale != NULL)
1315313176
{
1315413177
appendPQExpBufferStr(q, ", locale = ");
13155-
appendStringLiteralAH(q,collcollate, fout);
13178+
appendStringLiteralAH(q,colliculocale, fout);
1315613179
}
1315713180
else
1315813181
{
13159-
appendPQExpBufferStr(q, ", lc_collate = ");
13160-
appendStringLiteralAH(q, collcollate, fout);
13161-
appendPQExpBufferStr(q, ", lc_ctype = ");
13162-
appendStringLiteralAH(q, collctype, fout);
13182+
Assert(collcollate != NULL);
13183+
Assert(collctype != NULL);
13184+
13185+
if (strcmp(collcollate, collctype) == 0)
13186+
{
13187+
appendPQExpBufferStr(q, ", locale = ");
13188+
appendStringLiteralAH(q, collcollate, fout);
13189+
}
13190+
else
13191+
{
13192+
appendPQExpBufferStr(q, ", lc_collate = ");
13193+
appendStringLiteralAH(q, collcollate, fout);
13194+
appendPQExpBufferStr(q, ", lc_ctype = ");
13195+
appendStringLiteralAH(q, collctype, fout);
13196+
}
1316313197
}
1316413198

1316513199
/*

‎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=>
@@ -3868,7 +3877,7 @@
38683877
$collation_support = 1;
38693878
}
38703879
3871-
# Determine whether build supports LZ4 and gzip.
3880+
my$supports_icu = ($ENV{with_icu} eq 'yes');
38723881
my$supports_lz4 = check_pg_config("#define USE_LZ4 1");
38733882
my$supports_gzip = check_pg_config("#define HAVE_LIBZ 1");
38743883
@@ -3909,6 +3918,11 @@
39093918
$test_db =$tests{$test}->{database};
39103919
}
39113920
3921+
if (defined($tests{$test}->{icu}))
3922+
{
3923+
$tests{$test}->{collation} = 1;
3924+
}
3925+
39123926
if ($tests{$test}->{create_sql})
39133927
{
39143928
@@ -3918,6 +3932,12 @@
39183932
next;
39193933
}
39203934
3935+
# Skip any icu-related collation commands if build was without icu
3936+
if (!$supports_icu && defined($tests{$test}->{icu}))
3937+
{
3938+
next;
3939+
}
3940+
39213941
# Skip tests specific to LZ4 if this build does not support
39223942
# this option.
39233943
if (!$supports_lz4 && defined($tests{$test}->{lz4}))
@@ -4119,6 +4139,12 @@
41194139
next;
41204140
}
41214141
4142+
# Skip any icu-related collation commands if build was without icu
4143+
if (!$supports_icu && defined($tests{$test}->{icu}))
4144+
{
4145+
next;
4146+
}
4147+
41224148
# Skip tests specific to LZ4 if this build does not support
41234149
# this option.
41244150
if (!$supports_lz4 && defined($tests{$test}->{lz4}))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp