=== Applying patches on top of PostgreSQL commit ID 331d829e62dbb08112bb3a2c5770cd10ba0ffccb === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Thu Apr 2 02:35:43 UTC 2026 On branch cf/6541 nothing to commit, working tree clean === using 'git am' to apply patch ./v02-pg_restore-add-no-globals-option-to-skip-globals.patch === Applying: pg_restore: add --no-globals option to skip globals Using index info to reconstruct a base tree... M doc/src/sgml/ref/pg_restore.sgml M src/bin/pg_dump/pg_restore.c M src/bin/pg_dump/t/001_basic.pl Falling back to patching base and 3-way merge... Auto-merging src/bin/pg_dump/t/001_basic.pl CONFLICT (content): Merge conflict in src/bin/pg_dump/t/001_basic.pl Auto-merging src/bin/pg_dump/pg_restore.c CONFLICT (content): Merge conflict in src/bin/pg_dump/pg_restore.c Auto-merging doc/src/sgml/ref/pg_restore.sgml CONFLICT (content): Merge conflict in doc/src/sgml/ref/pg_restore.sgml error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 pg_restore: add --no-globals option to skip globals When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./v02-pg_restore-add-no-globals-option-to-skip-globals.patch === patching file doc/src/sgml/ref/pg_restore.sgml Hunk #1 FAILED at 294. 1 out of 1 hunk FAILED -- saving rejects to file doc/src/sgml/ref/pg_restore.sgml.rej patching file src/bin/pg_dump/pg_restore.c Hunk #1 succeeded at 109 with fuzz 2 (offset 1 line). Hunk #2 succeeded at 174 (offset 2 lines). Hunk #3 succeeded at 517 with fuzz 2 (offset 26 lines). Hunk #4 FAILED at 620. Hunk #5 FAILED at 632. Hunk #6 succeeded at 803 with fuzz 1 (offset -34 lines). Hunk #7 FAILED at 1356. 3 out of 7 hunks FAILED -- saving rejects to file src/bin/pg_dump/pg_restore.c.rej patching file src/bin/pg_dump/t/001_basic.pl Hunk #1 FAILED at 299. 1 out of 1 hunk FAILED -- saving rejects to file src/bin/pg_dump/t/001_basic.pl.rej Unstaged changes after reset: M src/bin/pg_dump/pg_restore.c Removing doc/src/sgml/ref/pg_restore.sgml.rej Removing src/bin/pg_dump/pg_restore.c.rej Removing src/bin/pg_dump/t/001_basic.pl.rej === using 'git apply' to apply patch ./v02-pg_restore-add-no-globals-option-to-skip-globals.patch === Applied patch to 'doc/src/sgml/ref/pg_restore.sgml' with conflicts. Applied patch to 'src/bin/pg_dump/pg_restore.c' with conflicts. Applied patch to 'src/bin/pg_dump/t/001_basic.pl' with conflicts. U doc/src/sgml/ref/pg_restore.sgml U src/bin/pg_dump/pg_restore.c U src/bin/pg_dump/t/001_basic.pl diff --cc doc/src/sgml/ref/pg_restore.sgml index 6ae2cdcfc10,1921c97b725..00000000000 --- a/doc/src/sgml/ref/pg_restore.sgml +++ b/doc/src/sgml/ref/pg_restore.sgml @@@ -305,17 -300,15 +305,29 @@@ PostgreSQL documentatio ++<<<<<<< ours + + + + + Do not restore global objects (roles and tablespaces). When + / is not specified, + databases that do not already exist on the target server are skipped. + + + This option is only relevant when restoring from a non-plain-text + archive made using pg_dumpall. ++======= + + + + + Do not restore global objects (roles and tablespaces) and even don't create new database if + or is not specified. + + + This option is only relevant when restoring from a non-plain-text archive made using pg_dumpall. ++>>>>>>> theirs diff --cc src/bin/pg_dump/pg_restore.c index f016b336308,8810f9215d4..00000000000 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@@ -107,8 -107,8 +107,9 @@@ main(int argc, char **argv static int no_schema = 0; static int no_security_labels = 0; static int no_statistics = 0; + static int no_globals = 0; static int no_subscriptions = 0; + static int no_globals = 0; static int strict_names = 0; static int statistics_only = 0; static int with_statistics = 0; @@@ -409,48 -423,78 +411,52 @@@ pg_fatal("invalid restrict key"); } - /* reject conflicting "-only" options */ - if (data_only && schema_only) - pg_fatal("options %s and %s cannot be used together", - "-s/--schema-only", "-a/--data-only"); - if (schema_only && statistics_only) - pg_fatal("options %s and %s cannot be used together", - "-s/--schema-only", "--statistics-only"); - if (data_only && statistics_only) - pg_fatal("options %s and %s cannot be used together", - "-a/--data-only", "--statistics-only"); - - /* reject conflicting "-only" and "no-" options */ - if (data_only && no_data) - pg_fatal("options %s and %s cannot be used together", - "-a/--data-only", "--no-data"); - if (schema_only && no_schema) - pg_fatal("options %s and %s cannot be used together", - "-s/--schema-only", "--no-schema"); - if (statistics_only && no_statistics) - pg_fatal("options %s and %s cannot be used together", - "--statistics-only", "--no-statistics"); - - /* reject conflicting "no-" options */ - if (with_statistics && no_statistics) - pg_fatal("options %s and %s cannot be used together", - "--statistics", "--no-statistics"); - - /* reject conflicting "only-" options */ - if (data_only && with_statistics) - pg_fatal("options %s and %s cannot be used together", - "-a/--data-only", "--statistics"); - if (schema_only && with_statistics) - pg_fatal("options %s and %s cannot be used together", - "-s/--schema-only", "--statistics"); - - if (data_only && opts->dropSchema) - pg_fatal("options %s and %s cannot be used together", - "-c/--clean", "-a/--data-only"); - - if (opts->single_txn && opts->txn_size > 0) - pg_fatal("options %s and %s cannot be used together", - "-1/--single-transaction", "--transaction-size"); - - if (opts->single_txn && globals_only) - pg_fatal("options %s and %s cannot be used together when restoring an archive created by pg_dumpall", - "--single-transaction", "-g/--globals-only"); + /* *-only options are incompatible with each other */ + check_mut_excl_opts(data_only, "-a/--data-only", + globals_only, "-g/--globals-only", + schema_only, "-s/--schema-only", + statistics_only, "--statistics-only"); + + /* --no-* and *-only for same thing are incompatible */ + check_mut_excl_opts(data_only, "-a/--data-only", + no_data, "--no-data"); + check_mut_excl_opts(globals_only, "-g/--globals-only", + no_globals, "--no-globals"); + check_mut_excl_opts(schema_only, "-s/--schema-only", + no_schema, "--no-schema"); + check_mut_excl_opts(statistics_only, "--statistics-only", + no_statistics, "--no-statistics"); + + /* --statistics and --no-statistics are incompatible */ + check_mut_excl_opts(with_statistics, "--statistics", + no_statistics, "--no-statistics"); + + /* --statistics is incompatible with *-only (except --statistics-only) */ + check_mut_excl_opts(with_statistics, "--statistics", + data_only, "-a/--data-only", + globals_only, "-g/--globals-only", + schema_only, "-s/--schema-only"); + + /* --clean and --data-only are incompatible */ + check_mut_excl_opts(opts->dropSchema, "-c/--clean", + data_only, "-a/--data-only"); - if (opts->txn_size && globals_only) - pg_fatal("options %s and %s cannot be used together when restoring an archive created by pg_dumpall", - "--transaction-size", "-g/--globals-only"); - - if (opts->exit_on_error && globals_only) - pg_fatal("options %s and %s cannot be used together when restoring an archive created by pg_dumpall", - "--exit-on-error", "-g/--globals-only"); + /* + * --globals-only, --single-transaction, and --transaction-size are + * incompatible. + */ + check_mut_excl_opts(globals_only, "-g/--globals-only", + opts->single_txn, "-1/--single-transaction", + opts->txn_size, "--transaction-size"); - if (data_only && globals_only) - pg_fatal("options %s and %s cannot be used together", - "-a/--data-only", "-g/--globals-only"); - if (schema_only && globals_only) - pg_fatal("options %s and %s cannot be used together", - "-s/--schema-only", "-g/--globals-only"); - if (statistics_only && globals_only) - pg_fatal("options %s and %s cannot be used together", - "--statistics-only", "-g/--globals-only"); - if (with_statistics && globals_only) - pg_fatal("options %s and %s cannot be used together", - "--statistics", "-g/--globals-only"); + /* --exit-on-error and --globals-only are incompatible */ + check_mut_excl_opts(opts->exit_on_error, "--exit-on-error", + globals_only, "-g/--globals-only"); + if (no_globals && globals_only) + pg_fatal("options %s and %s cannot be used together", + "--no-globals", "-g/--globals-only"); + /* * -C is not compatible with -1, because we can't create a database inside * a transaction block. @@@ -576,7 -621,7 +582,11 @@@ /* * To restore from a pg_dumpall archive, -C (create database) option * must be specified unless we are only restoring globals or we are ++<<<<<<< ours + * skipping globals. ++======= + * skiping globals. ++>>>>>>> theirs */ if (!no_globals && !globals_only && opts->createDB != 1) { @@@ -588,16 -633,17 +598,27 @@@ } /* ++<<<<<<< ours + * Restore global objects, even if --exclude-database results in zero + * databases to process. If 'globals-only' is set, exit immediately. ++======= + * Restore global objects, even if --exclude-database results + * in zero databases to process. If 'globals-only' is set, exit + * immediately. ++>>>>>>> theirs */ snprintf(global_path, MAXPGPATH, "%s/toc.glo", inputFileSpec); if (!no_globals) n_errors = restore_global_objects(global_path, tmpopts); else ++<<<<<<< ours + pg_log_info("skipping restore of global objects because %s was specified", + "--no-globals"); ++======= + pg_log_info("toc.glo(globals) restoring skipped because option %s is specified", + "--no-globals"); ++>>>>>>> theirs if (globals_only) pg_log_info("database restoring skipped because option %s was specified", @@@ -794,9 -840,9 +815,10 @@@ usage(const char *progname printf(_(" --no-security-labels do not restore security labels\n")); printf(_(" --no-statistics do not restore statistics\n")); printf(_(" --no-subscriptions do not restore subscriptions\n")); + printf(_(" --no-globals do not restore global objects (roles and tablespaces)\n")); printf(_(" --no-table-access-method do not restore table access methods\n")); printf(_(" --no-tablespaces do not restore tablespace assignments\n")); + printf(_(" --no-globals do not restore global objects (roles and tablespaces)\n")); printf(_(" --restrict-key=RESTRICT_KEY use provided string as psql \\restrict key\n")); printf(_(" --section=SECTION restore named section (pre-data, data, or post-data)\n")); printf(_(" --statistics restore the statistics\n")); @@@ -1297,8 -1363,8 +1319,13 @@@ restore_all_databases(const char *input { if (!tmpopts->createDB) { ++<<<<<<< ours + pg_log_info("skipping restore of database \"%s\": database does not exist and %s was not specified", + dbidname->str, "-C/--create"); ++======= + pg_log_info("database %s restoring skipped because options %s and %s=false are specified with dump of pg_dumpall", + dbidname->str, "--no-globals", "-C/--create" ); ++>>>>>>> theirs continue; } diff --cc src/bin/pg_dump/t/001_basic.pl index 509f4f9ce7d,e2d6b30e437..00000000000 --- a/src/bin/pg_dump/t/001_basic.pl +++ b/src/bin/pg_dump/t/001_basic.pl @@@ -345,10 -301,8 +345,17 @@@ command_fails_like ); command_fails_like( ++<<<<<<< ours + [ + 'pg_restore', '--globals-only', '--no-globals', '-d', 'xxx', + 'dumpdir' + ], + qr/\Qpg_restore: error: options -g\/--globals-only and --no-globals cannot be used together\E/, + 'options --no-globals and --globals-only cannot be used together'); ++======= + [ 'pg_restore', '--globals-only', '--no-globals', '-d', 'xxx', 'dumpdir' ], + qr/\Qpg_restore: error: options --no-globals and -g\/--globals-only cannot be used together\E/, + 'pg_restore: error: options --no-globals and -g/--globals-only cannot be used together' + ); ++>>>>>>> theirs done_testing();