Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 303d1f6

Browse files
committed
Merge branch 'PGPRO10' into PGPROEE10
2 parents 8465d36 + 178a3d1 commit 303d1f6

File tree

6 files changed

+86
-20
lines changed

6 files changed

+86
-20
lines changed

doc/src/sgml/ref/pg_dump.sgml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,27 @@ doc/src/sgml/ref/pg_dump.sgml
638638
</listitem>
639639
</varlistentry>
640640

641+
<varlistentry>
642+
<term><option>--add-collprovider</option></term>
643+
<listitem>
644+
<para>
645+
This option is recommended when upgrading with
646+
<application>pg_dump</application> and
647+
<application>pg_restore</application> from previous versions of
648+
<productname>&project;</> as well as from all versions of
649+
<productname>PostgreSQL</> (it's automatically used in case of a binary
650+
upgrade; and it actually does nothing for the current version of
651+
<productname>&project;</>). If you do not want to manually fix the
652+
scripts (or do not know how to do it correctly) this helps to avoid mess
653+
when the templated database and the created database actually use
654+
different collation providers that are ommitted (see <xref
655+
linkend="collation-managing">). In this case the check constrains that
656+
use the default collation of the database may change and the
657+
<command>COPY</command> command may end with fail.
658+
</para>
659+
</listitem>
660+
</varlistentry>
661+
641662
<varlistentry>
642663
<term><option>--binary-upgrade</option></term>
643664
<listitem>

doc/src/sgml/ref/pg_dumpall.sgml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,27 @@ doc/src/sgml/ref/pg_dumpall.sgml
231231
</listitem>
232232
</varlistentry>
233233

234+
<varlistentry>
235+
<term><option>--add-collprovider</option></term>
236+
<listitem>
237+
<para>
238+
This option is recommended when upgrading with
239+
<application>pg_dumpall</application> and
240+
<application>pg_restore</application> from previous versions of
241+
<productname>&project;</> as well as from all versions of
242+
<productname>PostgreSQL</> (it's automatically used in case of a binary
243+
upgrade; and it actually does nothing for the current version of
244+
<productname>&project;</>). If you do not want to manually fix the
245+
scripts (or do not know how to do it correctly) this helps to avoid mess
246+
when the templated database and the created database actually use
247+
different collation providers that are ommitted (see <xref
248+
linkend="collation-managing">). In this case the check constrains that
249+
use the default collation of the database may change and the
250+
<command>COPY</command> command may end with fail.
251+
</para>
252+
</listitem>
253+
</varlistentry>
254+
234255
<varlistentry>
235256
<term><option>--binary-upgrade</option></term>
236257
<listitem>

src/bin/pg_dump/pg_dump.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ char g_comment_end[10];
135135

136136
static const CatalogId nilCatalogId = {0, 0};
137137

138+
/*
139+
* Whether to add the collation provider to the non-empty LC_COLLATE settings in
140+
* the database creation; always true for binary upgrade.
141+
*/
142+
static bool add_collprovider = false;
143+
138144
/*
139145
* Macro for producing quoted, schema-qualified name of a dumpable object.
140146
* Note implicit dependence on "fout"; we should get rid of that argument.
@@ -376,6 +382,7 @@ main(int argc, char **argv)
376382
{"no-sync", no_argument, NULL, 7},
377383
{"transfer-dir", required_argument, NULL, 8},
378384
{"copy-mode-transfer", no_argument, &dopt.copy_mode_transfer, 1},
385+
{"add-collprovider", no_argument, NULL, 9},
379386

380387
{NULL, 0, NULL, 0}
381388
};
@@ -563,6 +570,9 @@ main(int argc, char **argv)
563570
case 8:
564571
dopt.transfer_dir = pg_strdup(optarg);
565572
break;
573+
case 9:
574+
add_collprovider = true;
575+
break;
566576

567577
default:
568578
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
@@ -591,14 +601,18 @@ main(int argc, char **argv)
591601
if (dopt.column_inserts)
592602
dopt.dump_inserts = 1;
593603

594-
/*
595-
* Binary upgrade mode implies dumping sequence data even in schema-only
596-
* mode. This is not exposed as a separate option, but kept separate
597-
* internally for clarity.
598-
*/
599604
if (dopt.binary_upgrade)
605+
{
606+
/*
607+
* Binary upgrade mode implies dumping sequence data even in schema-only
608+
* mode. This is not exposed as a separate option, but kept separate
609+
* internally for clarity.
610+
*/
600611
dopt.sequence_data = 1;
601612

613+
add_collprovider = true;
614+
}
615+
602616
if (dopt.dataOnly && dopt.schemaOnly)
603617
{
604618
write_msg(NULL, "options -s/--schema-only and -a/--data-only cannot be used together\n");
@@ -981,6 +995,7 @@ help(const char *progname)
981995
printf(_(" -t, --table=TABLE dump the named table(s) only\n"));
982996
printf(_(" -T, --exclude-table=TABLE do NOT dump the named table(s)\n"));
983997
printf(_(" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
998+
printf(_(" --add-collprovider add provider for database LC_COLLATE settings\n"));
984999
printf(_(" --binary-upgrade for use by upgrade utilities only\n"));
9851000
printf(_(" --column-inserts dump data as INSERT commands with column names\n"));
9861001
printf(_(" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n"));
@@ -2696,11 +2711,11 @@ dumpDatabase(Archive *fout)
26962711
char *dbcollate;
26972712
appendPQExpBufferStr(creaQry, " LC_COLLATE = ");
26982713
dbcollate = pg_strdup(collate);
2699-
if (dopt->binary_upgrade)
2714+
if (add_collprovider)
27002715
dbcollate = addCollProvider(dbcollate,
27012716
fout->remoteVersion,
27022717
fout->remoteEdition,
2703-
i_encoding);
2718+
pg_char_to_encoding(encoding));
27042719
appendStringLiteralAH(creaQry, dbcollate, fout);
27052720
free(dbcollate);
27062721
}

src/bin/pg_dump/pg_dumpall.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ static char role_catalog[10];
9292
static FILE *OPF;
9393
static char *filename = NULL;
9494

95+
static int add_collprovider = 0;
96+
9597
#define exit_nicely(code) exit(code)
9698

9799
int
@@ -140,6 +142,7 @@ main(int argc, char *argv[])
140142
{"no-subscriptions", no_argument, &no_subscriptions, 1},
141143
{"no-sync", no_argument, NULL, 4},
142144
{"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1},
145+
{"add-collprovider", no_argument, &add_collprovider, 1},
143146

144147
{NULL, 0, NULL, 0}
145148
};
@@ -364,6 +367,10 @@ main(int argc, char *argv[])
364367
exit_nicely(1);
365368
}
366369

370+
/* Always add the collation provider in the binary upgrade */
371+
if (binary_upgrade)
372+
add_collprovider++;
373+
367374
/*
368375
* If password values are not required in the dump, switch to using
369376
* pg_roles which is equally useful, just more likely to have unrestricted
@@ -399,6 +406,8 @@ main(int argc, char *argv[])
399406
appendPQExpBufferStr(pgdumpopts, " --no-subscriptions");
400407
if (no_unlogged_table_data)
401408
appendPQExpBufferStr(pgdumpopts, " --no-unlogged-table-data");
409+
if (add_collprovider)
410+
appendPQExpBufferStr(pgdumpopts, " --add-collprovider");
402411

403412
/*
404413
* If there was a database specified on the command line, use that,
@@ -596,6 +605,7 @@ help(void)
596605
printf(_(" -S, --superuser=NAME superuser user name to use in the dump\n"));
597606
printf(_(" -t, --tablespaces-only dump only tablespaces, no databases or roles\n"));
598607
printf(_(" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
608+
printf(_(" --add-collprovider add provider for database LC_COLLATE settings\n"));
599609
printf(_(" --binary-upgrade for use by upgrade utilities only\n"));
600610
printf(_(" --column-inserts dump data as INSERT commands with column names\n"));
601611
printf(_(" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n"));
@@ -1461,18 +1471,21 @@ dumpCreateDB(PGconn *conn)
14611471
appendStringLiteralConn(buf, dbencoding, conn);
14621472
}
14631473

1464-
if (default_collate && strcmp(dbcollate, default_collate) != 0)
1474+
if (default_collate && strlen(dbcollate) > 0)
14651475
{
1466-
char *dbcollate_full_name;
1467-
appendPQExpBufferStr(buf, " LC_COLLATE = ");
1468-
dbcollate_full_name = pg_strdup(dbcollate);
1469-
if (binary_upgrade)
1476+
char *dbcollate_full_name = pg_strdup(dbcollate);
1477+
1478+
if (add_collprovider)
14701479
dbcollate_full_name = addCollProvider(
14711480
dbcollate_full_name,
14721481
server_version,
14731482
server_edition,
14741483
pg_char_to_encoding(dbencoding));
1475-
appendStringLiteralConn(buf, dbcollate_full_name, conn);
1484+
if (strcmp(dbcollate_full_name, default_collate) != 0)
1485+
{
1486+
appendPQExpBufferStr(buf, " LC_COLLATE = ");
1487+
appendStringLiteralConn(buf, dbcollate_full_name, conn);
1488+
}
14761489
free(dbcollate_full_name);
14771490
}
14781491

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"--file=$tempdir/createdb.sql",
8181
'-C',
8282
'-R', # no-op, just for testing
83+
'--add-collprovider', # no-op, just for testing
8384
'-v',
8485
'postgres', ], },
8586
data_only => {
@@ -182,7 +183,8 @@
182183
pg_dumpall_dbprivs => {
183184
dump_cmd => [
184185
'pg_dumpall', '--no-sync',
185-
"--file=$tempdir/pg_dumpall_dbprivs.sql", ], },
186+
"--file=$tempdir/pg_dumpall_dbprivs.sql",
187+
'--add-collprovider', ], }, # no-op, just for testing
186188
no_blobs => {
187189
dump_cmd => [
188190
'pg_dump', '--no-sync',

src/tools/msvc/Solution.pm

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,12 +644,6 @@ sub AddProject
644644
$proj->AddIncludeDir($self->{options}->{uuid} . '\include');
645645
$proj->AddLibrary($self->{options}->{uuid} . '\lib\uuid.lib');
646646
}
647-
if ($self->{options}->{libedit})
648-
{
649-
$proj->AddIncludeDir($self->{options}->{libedit} . '\include');
650-
$proj->AddLibrary($self->{options}->{libedit} . "\\" .
651-
($self->{platform} eq 'x64'? 'lib64': 'lib32').'\edit.lib');
652-
}
653647
if ($self->{options}->{zstd})
654648
{
655649
$proj->AddIncludeDir($self->{options}->{zstd});

0 commit comments

Comments
 (0)