agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH 5/5] Improve find_em_expr_usable_for_sorting_rel comment 8+ messages / 2 participants [nested] [flat]
* [PATCH 5/5] Improve find_em_expr_usable_for_sorting_rel comment @ 2020-12-15 23:20 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 8+ messages in thread From: Tomas Vondra @ 2020-12-15 23:20 UTC (permalink / raw) Clarify the relationship between find_em_expr_usable_for_sorting_rel and prepare_sort_from_pathkeys, i.e. what restrictions need to be shared between those two places. Author: James Coleman Reviewed-by: Tomas Vondra Backpatch-through: 13 Discussion: https://postgr.es/m/CAAaqYe8cK3g5CfLC4w7bs%3DhC0mSksZC%3DH5M8LSchj5e5OxpTAg%40mail.gmail.com --- src/backend/optimizer/path/equivclass.c | 9 ++++++--- src/backend/optimizer/plan/createplan.c | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/backend/optimizer/path/equivclass.c b/src/backend/optimizer/path/equivclass.c index 70499af2cf..4466f880ee 100644 --- a/src/backend/optimizer/path/equivclass.c +++ b/src/backend/optimizer/path/equivclass.c @@ -798,9 +798,12 @@ find_em_expr_for_rel(EquivalenceClass *ec, RelOptInfo *rel) } /* - * Find an equivalence class member expression that can be safely used by a - * sort node on top of the provided relation. The rules here must match those - * applied in prepare_sort_from_pathkeys. + * Find an equivalence class member expression that can be safely used to build + * a sort node using the provided relation. The applied rules parallel those + * applied in prepare_sort_from_pathkeys but are a subset of that function since + * here we are concerned with proactive sorts while prepare_sort_from_pathkeys + * must deal with sorts that must be delayed until the last stages of query + * execution. */ Expr * find_em_expr_usable_for_sorting_rel(PlannerInfo *root, EquivalenceClass *ec, diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 5ecf9f4065..f7a8dae3c6 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -5850,6 +5850,9 @@ make_incrementalsort(Plan *lefttree, int numCols, int nPresortedCols, * * Returns the node which is to be the input to the Sort (either lefttree, * or a Result stacked atop lefttree). + * + * Note: Restrictions on what expressions are safely sortable may also need to + * be added to find_em_expr_usable_for_sorting_rel. */ static Plan * prepare_sort_from_pathkeys(Plan *lefttree, List *pathkeys, -- 2.26.2 --------------DB02ACD71E58FCC25F7488B7-- ^ permalink raw reply [nested|flat] 8+ messages in thread
* [PATCH v4 2/3] pg_dump: Add --sequence-data. @ 2025-02-19 17:25 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 8+ messages in thread From: Nathan Bossart @ 2025-02-19 17:25 UTC (permalink / raw) This new option instructs pg_dump to dump sequence data when the --no-data, --schema-only, or --statistics-only option is specified. This was originally considered for commit a7e5457db8, but it was left out at that time because there was no known use-case. A follow-up commit will use this to optimize pg_upgrade's file transfer step. Discussion: https://postgr.es/m/Zyvop-LxLXBLrZil%40nathan --- doc/src/sgml/ref/pg_dump.sgml | 11 +++++++++++ src/bin/pg_dump/pg_dump.c | 10 ++-------- src/bin/pg_dump/t/002_pg_dump.pl | 1 + src/bin/pg_upgrade/dump.c | 2 +- src/test/modules/test_pg_dump/t/001_base.pl | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 1975054d7bf..b05f16995c3 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -1289,6 +1289,17 @@ PostgreSQL documentation </listitem> </varlistentry> + <varlistentry> + <term><option>--sequence-data</option></term> + <listitem> + <para> + Include sequence data in the dump. This is the default behavior except + when <option>--no-data</option>, <option>--schema-only</option>, or + <option>--statistics-only</option> is specified. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>--serializable-deferrable</option></term> <listitem> diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 4f4ad2ee150..f63215eb3f9 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -517,6 +517,7 @@ main(int argc, char **argv) {"sync-method", required_argument, NULL, 15}, {"filter", required_argument, NULL, 16}, {"exclude-extension", required_argument, NULL, 17}, + {"sequence-data", no_argument, &dopt.sequence_data, 1}, {NULL, 0, NULL, 0} }; @@ -803,14 +804,6 @@ main(int argc, char **argv) if (dopt.column_inserts && dopt.dump_inserts == 0) dopt.dump_inserts = DUMP_DEFAULT_ROWS_PER_INSERT; - /* - * Binary upgrade mode implies dumping sequence data even in schema-only - * mode. This is not exposed as a separate option, but kept separate - * internally for clarity. - */ - if (dopt.binary_upgrade) - dopt.sequence_data = 1; - if (data_only && schema_only) pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together"); if (schema_only && statistics_only) @@ -1275,6 +1268,7 @@ help(const char *progname) printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n")); printf(_(" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n")); printf(_(" --section=SECTION dump named section (pre-data, data, or post-data)\n")); + printf(_(" --sequence-data include sequence data in dump\n")); printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n")); printf(_(" --snapshot=SNAPSHOT use given snapshot for the dump\n")); printf(_(" --statistics-only dump only the statistics, not schema or data\n")); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index c7bffc1b045..8ae6c5374fc 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -66,6 +66,7 @@ my %pgdump_runs = ( '--file' => "$tempdir/binary_upgrade.dump", '--no-password', '--no-data', + '--sequence-data', '--binary-upgrade', '--dbname' => 'postgres', # alternative way to specify database ], diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c index 23fe7280a16..b8fd0d0acee 100644 --- a/src/bin/pg_upgrade/dump.c +++ b/src/bin/pg_upgrade/dump.c @@ -52,7 +52,7 @@ generate_old_dump(void) snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid); parallel_exec_prog(log_file_name, NULL, - "\"%s/pg_dump\" %s --no-data %s --quote-all-identifiers " + "\"%s/pg_dump\" %s --no-data %s --sequence-data --quote-all-identifiers " "--binary-upgrade --format=custom %s --no-sync --file=\"%s/%s\" %s", new_cluster.bindir, cluster_conn_opts(&old_cluster), log_opts.verbose ? "--verbose" : "", diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index 9b2a90b0469..27c6c2ab0f3 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -48,7 +48,7 @@ my %pgdump_runs = ( dump_cmd => [ 'pg_dump', '--no-sync', "--file=$tempdir/binary_upgrade.sql", '--schema-only', - '--binary-upgrade', '--dbname=postgres', + '--sequence-data', '--binary-upgrade', '--dbname=postgres', ], }, clean => { -- 2.39.5 (Apple Git-154) --4+vVKu84k2Vx9Qwr Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v4-0003-pg_upgrade-Add-swap-for-faster-file-transfer.patch" ^ permalink raw reply [nested|flat] 8+ messages in thread
* [PATCH v5 2/3] pg_dump: Add --sequence-data. @ 2025-02-19 17:25 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 8+ messages in thread From: Nathan Bossart @ 2025-02-19 17:25 UTC (permalink / raw) This new option instructs pg_dump to dump sequence data when the --no-data, --schema-only, or --statistics-only option is specified. This was originally considered for commit a7e5457db8, but it was left out at that time because there was no known use-case. A follow-up commit will use this to optimize pg_upgrade's file transfer step. Discussion: https://postgr.es/m/Zyvop-LxLXBLrZil%40nathan --- doc/src/sgml/ref/pg_dump.sgml | 11 +++++++++++ src/bin/pg_dump/pg_dump.c | 10 ++-------- src/bin/pg_dump/t/002_pg_dump.pl | 1 + src/bin/pg_upgrade/dump.c | 2 +- src/test/modules/test_pg_dump/t/001_base.pl | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 0ae40f9be58..63cca18711a 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -1298,6 +1298,17 @@ PostgreSQL documentation </listitem> </varlistentry> + <varlistentry> + <term><option>--sequence-data</option></term> + <listitem> + <para> + Include sequence data in the dump. This is the default behavior except + when <option>--no-data</option>, <option>--schema-only</option>, or + <option>--statistics-only</option> is specified. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>--serializable-deferrable</option></term> <listitem> diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 428ed2d60fc..e6253331e27 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -518,6 +518,7 @@ main(int argc, char **argv) {"sync-method", required_argument, NULL, 15}, {"filter", required_argument, NULL, 16}, {"exclude-extension", required_argument, NULL, 17}, + {"sequence-data", no_argument, &dopt.sequence_data, 1}, {NULL, 0, NULL, 0} }; @@ -801,14 +802,6 @@ main(int argc, char **argv) if (dopt.column_inserts && dopt.dump_inserts == 0) dopt.dump_inserts = DUMP_DEFAULT_ROWS_PER_INSERT; - /* - * Binary upgrade mode implies dumping sequence data even in schema-only - * mode. This is not exposed as a separate option, but kept separate - * internally for clarity. - */ - if (dopt.binary_upgrade) - dopt.sequence_data = 1; - if (data_only && schema_only) pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together"); if (schema_only && statistics_only) @@ -1275,6 +1268,7 @@ help(const char *progname) printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n")); printf(_(" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n")); printf(_(" --section=SECTION dump named section (pre-data, data, or post-data)\n")); + printf(_(" --sequence-data include sequence data in dump\n")); printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n")); printf(_(" --snapshot=SNAPSHOT use given snapshot for the dump\n")); printf(_(" --statistics-only dump only the statistics, not schema or data\n")); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index d281e27aa67..ed379033da7 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -66,6 +66,7 @@ my %pgdump_runs = ( '--file' => "$tempdir/binary_upgrade.dump", '--no-password', '--no-data', + '--sequence-data', '--binary-upgrade', '--dbname' => 'postgres', # alternative way to specify database ], diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c index 23fe7280a16..b8fd0d0acee 100644 --- a/src/bin/pg_upgrade/dump.c +++ b/src/bin/pg_upgrade/dump.c @@ -52,7 +52,7 @@ generate_old_dump(void) snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid); parallel_exec_prog(log_file_name, NULL, - "\"%s/pg_dump\" %s --no-data %s --quote-all-identifiers " + "\"%s/pg_dump\" %s --no-data %s --sequence-data --quote-all-identifiers " "--binary-upgrade --format=custom %s --no-sync --file=\"%s/%s\" %s", new_cluster.bindir, cluster_conn_opts(&old_cluster), log_opts.verbose ? "--verbose" : "", diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index a9bcac4169d..adcaa419616 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -48,7 +48,7 @@ my %pgdump_runs = ( dump_cmd => [ 'pg_dump', '--no-sync', '--file' => "$tempdir/binary_upgrade.sql", - '--schema-only', '--binary-upgrade', + '--schema-only', '--sequence-data', '--binary-upgrade', '--dbname' => 'postgres', ], }, -- 2.39.5 (Apple Git-154) --X1/Y3tXYeEOfm9P0 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v5-0003-pg_upgrade-Add-swap-for-faster-file-transfer.patch" ^ permalink raw reply [nested|flat] 8+ messages in thread
* [PATCH v6 2/3] pg_dump: Add --sequence-data. @ 2025-02-19 17:25 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 8+ messages in thread From: Nathan Bossart @ 2025-02-19 17:25 UTC (permalink / raw) This new option instructs pg_dump to dump sequence data when the --no-data, --schema-only, or --statistics-only option is specified. This was originally considered for commit a7e5457db8, but it was left out at that time because there was no known use-case. A follow-up commit will use this to optimize pg_upgrade's file transfer step. Discussion: https://postgr.es/m/Zyvop-LxLXBLrZil%40nathan --- doc/src/sgml/ref/pg_dump.sgml | 11 +++++++++++ src/bin/pg_dump/pg_dump.c | 10 ++-------- src/bin/pg_dump/t/002_pg_dump.pl | 1 + src/bin/pg_upgrade/dump.c | 2 +- src/test/modules/test_pg_dump/t/001_base.pl | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 0ae40f9be58..63cca18711a 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -1298,6 +1298,17 @@ PostgreSQL documentation </listitem> </varlistentry> + <varlistentry> + <term><option>--sequence-data</option></term> + <listitem> + <para> + Include sequence data in the dump. This is the default behavior except + when <option>--no-data</option>, <option>--schema-only</option>, or + <option>--statistics-only</option> is specified. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>--serializable-deferrable</option></term> <listitem> diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 428ed2d60fc..e6253331e27 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -518,6 +518,7 @@ main(int argc, char **argv) {"sync-method", required_argument, NULL, 15}, {"filter", required_argument, NULL, 16}, {"exclude-extension", required_argument, NULL, 17}, + {"sequence-data", no_argument, &dopt.sequence_data, 1}, {NULL, 0, NULL, 0} }; @@ -801,14 +802,6 @@ main(int argc, char **argv) if (dopt.column_inserts && dopt.dump_inserts == 0) dopt.dump_inserts = DUMP_DEFAULT_ROWS_PER_INSERT; - /* - * Binary upgrade mode implies dumping sequence data even in schema-only - * mode. This is not exposed as a separate option, but kept separate - * internally for clarity. - */ - if (dopt.binary_upgrade) - dopt.sequence_data = 1; - if (data_only && schema_only) pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together"); if (schema_only && statistics_only) @@ -1275,6 +1268,7 @@ help(const char *progname) printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n")); printf(_(" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n")); printf(_(" --section=SECTION dump named section (pre-data, data, or post-data)\n")); + printf(_(" --sequence-data include sequence data in dump\n")); printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n")); printf(_(" --snapshot=SNAPSHOT use given snapshot for the dump\n")); printf(_(" --statistics-only dump only the statistics, not schema or data\n")); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index d281e27aa67..ed379033da7 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -66,6 +66,7 @@ my %pgdump_runs = ( '--file' => "$tempdir/binary_upgrade.dump", '--no-password', '--no-data', + '--sequence-data', '--binary-upgrade', '--dbname' => 'postgres', # alternative way to specify database ], diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c index 23fe7280a16..b8fd0d0acee 100644 --- a/src/bin/pg_upgrade/dump.c +++ b/src/bin/pg_upgrade/dump.c @@ -52,7 +52,7 @@ generate_old_dump(void) snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid); parallel_exec_prog(log_file_name, NULL, - "\"%s/pg_dump\" %s --no-data %s --quote-all-identifiers " + "\"%s/pg_dump\" %s --no-data %s --sequence-data --quote-all-identifiers " "--binary-upgrade --format=custom %s --no-sync --file=\"%s/%s\" %s", new_cluster.bindir, cluster_conn_opts(&old_cluster), log_opts.verbose ? "--verbose" : "", diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index a9bcac4169d..adcaa419616 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -48,7 +48,7 @@ my %pgdump_runs = ( dump_cmd => [ 'pg_dump', '--no-sync', '--file' => "$tempdir/binary_upgrade.sql", - '--schema-only', '--binary-upgrade', + '--schema-only', '--sequence-data', '--binary-upgrade', '--dbname' => 'postgres', ], }, -- 2.39.5 (Apple Git-154) --/4djzC0ZDFNHPdW9 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v6-0003-pg_upgrade-Add-swap-for-faster-file-transfer.patch" ^ permalink raw reply [nested|flat] 8+ messages in thread
* [PATCH v7 3/4] pg_dump: Add --sequence-data. @ 2025-02-19 17:25 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 8+ messages in thread From: Nathan Bossart @ 2025-02-19 17:25 UTC (permalink / raw) This new option instructs pg_dump to dump sequence data when the --no-data, --schema-only, or --statistics-only option is specified. This was originally considered for commit a7e5457db8, but it was left out at that time because there was no known use-case. A follow-up commit will use this to optimize pg_upgrade's file transfer step. Discussion: https://postgr.es/m/Zyvop-LxLXBLrZil%40nathan --- doc/src/sgml/ref/pg_dump.sgml | 11 +++++++++++ src/bin/pg_dump/pg_dump.c | 10 ++-------- src/bin/pg_dump/t/002_pg_dump.pl | 1 + src/bin/pg_upgrade/dump.c | 2 +- src/test/modules/test_pg_dump/t/001_base.pl | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 0ae40f9be58..63cca18711a 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -1298,6 +1298,17 @@ PostgreSQL documentation </listitem> </varlistentry> + <varlistentry> + <term><option>--sequence-data</option></term> + <listitem> + <para> + Include sequence data in the dump. This is the default behavior except + when <option>--no-data</option>, <option>--schema-only</option>, or + <option>--statistics-only</option> is specified. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>--serializable-deferrable</option></term> <listitem> diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 428ed2d60fc..e6253331e27 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -518,6 +518,7 @@ main(int argc, char **argv) {"sync-method", required_argument, NULL, 15}, {"filter", required_argument, NULL, 16}, {"exclude-extension", required_argument, NULL, 17}, + {"sequence-data", no_argument, &dopt.sequence_data, 1}, {NULL, 0, NULL, 0} }; @@ -801,14 +802,6 @@ main(int argc, char **argv) if (dopt.column_inserts && dopt.dump_inserts == 0) dopt.dump_inserts = DUMP_DEFAULT_ROWS_PER_INSERT; - /* - * Binary upgrade mode implies dumping sequence data even in schema-only - * mode. This is not exposed as a separate option, but kept separate - * internally for clarity. - */ - if (dopt.binary_upgrade) - dopt.sequence_data = 1; - if (data_only && schema_only) pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together"); if (schema_only && statistics_only) @@ -1275,6 +1268,7 @@ help(const char *progname) printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n")); printf(_(" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n")); printf(_(" --section=SECTION dump named section (pre-data, data, or post-data)\n")); + printf(_(" --sequence-data include sequence data in dump\n")); printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n")); printf(_(" --snapshot=SNAPSHOT use given snapshot for the dump\n")); printf(_(" --statistics-only dump only the statistics, not schema or data\n")); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index d281e27aa67..ed379033da7 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -66,6 +66,7 @@ my %pgdump_runs = ( '--file' => "$tempdir/binary_upgrade.dump", '--no-password', '--no-data', + '--sequence-data', '--binary-upgrade', '--dbname' => 'postgres', # alternative way to specify database ], diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c index 23fe7280a16..b8fd0d0acee 100644 --- a/src/bin/pg_upgrade/dump.c +++ b/src/bin/pg_upgrade/dump.c @@ -52,7 +52,7 @@ generate_old_dump(void) snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid); parallel_exec_prog(log_file_name, NULL, - "\"%s/pg_dump\" %s --no-data %s --quote-all-identifiers " + "\"%s/pg_dump\" %s --no-data %s --sequence-data --quote-all-identifiers " "--binary-upgrade --format=custom %s --no-sync --file=\"%s/%s\" %s", new_cluster.bindir, cluster_conn_opts(&old_cluster), log_opts.verbose ? "--verbose" : "", diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index a9bcac4169d..adcaa419616 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -48,7 +48,7 @@ my %pgdump_runs = ( dump_cmd => [ 'pg_dump', '--no-sync', '--file' => "$tempdir/binary_upgrade.sql", - '--schema-only', '--binary-upgrade', + '--schema-only', '--sequence-data', '--binary-upgrade', '--dbname' => 'postgres', ], }, -- 2.39.5 (Apple Git-154) --alRlLvGJpBe9wL+1 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v7-0004-pg_upgrade-Add-swap-for-faster-file-transfer.patch" ^ permalink raw reply [nested|flat] 8+ messages in thread
* [PATCH v8 3/4] pg_dump: Add --sequence-data. @ 2025-02-19 17:25 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 8+ messages in thread From: Nathan Bossart @ 2025-02-19 17:25 UTC (permalink / raw) This new option instructs pg_dump to dump sequence data when the --no-data, --schema-only, or --statistics-only option is specified. This was originally considered for commit a7e5457db8, but it was left out at that time because there was no known use-case. A follow-up commit will use this to optimize pg_upgrade's file transfer step. Discussion: https://postgr.es/m/Zyvop-LxLXBLrZil%40nathan --- doc/src/sgml/ref/pg_dump.sgml | 11 +++++++++++ src/bin/pg_dump/pg_dump.c | 10 ++-------- src/bin/pg_dump/t/002_pg_dump.pl | 1 + src/bin/pg_upgrade/dump.c | 2 +- src/test/modules/test_pg_dump/t/001_base.pl | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 0ae40f9be58..63cca18711a 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -1298,6 +1298,17 @@ PostgreSQL documentation </listitem> </varlistentry> + <varlistentry> + <term><option>--sequence-data</option></term> + <listitem> + <para> + Include sequence data in the dump. This is the default behavior except + when <option>--no-data</option>, <option>--schema-only</option>, or + <option>--statistics-only</option> is specified. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>--serializable-deferrable</option></term> <listitem> diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 428ed2d60fc..e6253331e27 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -518,6 +518,7 @@ main(int argc, char **argv) {"sync-method", required_argument, NULL, 15}, {"filter", required_argument, NULL, 16}, {"exclude-extension", required_argument, NULL, 17}, + {"sequence-data", no_argument, &dopt.sequence_data, 1}, {NULL, 0, NULL, 0} }; @@ -801,14 +802,6 @@ main(int argc, char **argv) if (dopt.column_inserts && dopt.dump_inserts == 0) dopt.dump_inserts = DUMP_DEFAULT_ROWS_PER_INSERT; - /* - * Binary upgrade mode implies dumping sequence data even in schema-only - * mode. This is not exposed as a separate option, but kept separate - * internally for clarity. - */ - if (dopt.binary_upgrade) - dopt.sequence_data = 1; - if (data_only && schema_only) pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together"); if (schema_only && statistics_only) @@ -1275,6 +1268,7 @@ help(const char *progname) printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n")); printf(_(" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n")); printf(_(" --section=SECTION dump named section (pre-data, data, or post-data)\n")); + printf(_(" --sequence-data include sequence data in dump\n")); printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n")); printf(_(" --snapshot=SNAPSHOT use given snapshot for the dump\n")); printf(_(" --statistics-only dump only the statistics, not schema or data\n")); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index d281e27aa67..ed379033da7 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -66,6 +66,7 @@ my %pgdump_runs = ( '--file' => "$tempdir/binary_upgrade.dump", '--no-password', '--no-data', + '--sequence-data', '--binary-upgrade', '--dbname' => 'postgres', # alternative way to specify database ], diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c index 23fe7280a16..b8fd0d0acee 100644 --- a/src/bin/pg_upgrade/dump.c +++ b/src/bin/pg_upgrade/dump.c @@ -52,7 +52,7 @@ generate_old_dump(void) snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid); parallel_exec_prog(log_file_name, NULL, - "\"%s/pg_dump\" %s --no-data %s --quote-all-identifiers " + "\"%s/pg_dump\" %s --no-data %s --sequence-data --quote-all-identifiers " "--binary-upgrade --format=custom %s --no-sync --file=\"%s/%s\" %s", new_cluster.bindir, cluster_conn_opts(&old_cluster), log_opts.verbose ? "--verbose" : "", diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index a9bcac4169d..adcaa419616 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -48,7 +48,7 @@ my %pgdump_runs = ( dump_cmd => [ 'pg_dump', '--no-sync', '--file' => "$tempdir/binary_upgrade.sql", - '--schema-only', '--binary-upgrade', + '--schema-only', '--sequence-data', '--binary-upgrade', '--dbname' => 'postgres', ], }, -- 2.39.5 (Apple Git-154) --hXfPGy3/J5GGHYhH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v8-0004-pg_upgrade-Add-swap-for-faster-file-transfer.patch" ^ permalink raw reply [nested|flat] 8+ messages in thread
* [PATCH v9 2/3] pg_dump: Add --sequence-data. @ 2025-02-19 17:25 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 8+ messages in thread From: Nathan Bossart @ 2025-02-19 17:25 UTC (permalink / raw) This new option instructs pg_dump to dump sequence data when the --no-data, --schema-only, or --statistics-only option is specified. This was originally considered for commit a7e5457db8, but it was left out at that time because there was no known use-case. A follow-up commit will use this to optimize pg_upgrade's file transfer step. Reviewed-by: Greg Sabino Mullane <[email protected]> Reviewed-by: Bruce Momjian <[email protected]> Reviewed-by: Robert Haas <[email protected]> Discussion: https://postgr.es/m/Zyvop-LxLXBLrZil%40nathan --- doc/src/sgml/ref/pg_dump.sgml | 11 +++++++++++ src/bin/pg_dump/pg_dump.c | 10 ++-------- src/bin/pg_dump/t/002_pg_dump.pl | 1 + src/bin/pg_upgrade/dump.c | 2 +- src/test/modules/test_pg_dump/t/001_base.pl | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 0ae40f9be58..63cca18711a 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -1298,6 +1298,17 @@ PostgreSQL documentation </listitem> </varlistentry> + <varlistentry> + <term><option>--sequence-data</option></term> + <listitem> + <para> + Include sequence data in the dump. This is the default behavior except + when <option>--no-data</option>, <option>--schema-only</option>, or + <option>--statistics-only</option> is specified. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>--serializable-deferrable</option></term> <listitem> diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 428ed2d60fc..e6253331e27 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -518,6 +518,7 @@ main(int argc, char **argv) {"sync-method", required_argument, NULL, 15}, {"filter", required_argument, NULL, 16}, {"exclude-extension", required_argument, NULL, 17}, + {"sequence-data", no_argument, &dopt.sequence_data, 1}, {NULL, 0, NULL, 0} }; @@ -801,14 +802,6 @@ main(int argc, char **argv) if (dopt.column_inserts && dopt.dump_inserts == 0) dopt.dump_inserts = DUMP_DEFAULT_ROWS_PER_INSERT; - /* - * Binary upgrade mode implies dumping sequence data even in schema-only - * mode. This is not exposed as a separate option, but kept separate - * internally for clarity. - */ - if (dopt.binary_upgrade) - dopt.sequence_data = 1; - if (data_only && schema_only) pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together"); if (schema_only && statistics_only) @@ -1275,6 +1268,7 @@ help(const char *progname) printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n")); printf(_(" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n")); printf(_(" --section=SECTION dump named section (pre-data, data, or post-data)\n")); + printf(_(" --sequence-data include sequence data in dump\n")); printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n")); printf(_(" --snapshot=SNAPSHOT use given snapshot for the dump\n")); printf(_(" --statistics-only dump only the statistics, not schema or data\n")); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index d281e27aa67..ed379033da7 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -66,6 +66,7 @@ my %pgdump_runs = ( '--file' => "$tempdir/binary_upgrade.dump", '--no-password', '--no-data', + '--sequence-data', '--binary-upgrade', '--dbname' => 'postgres', # alternative way to specify database ], diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c index 23fe7280a16..b8fd0d0acee 100644 --- a/src/bin/pg_upgrade/dump.c +++ b/src/bin/pg_upgrade/dump.c @@ -52,7 +52,7 @@ generate_old_dump(void) snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid); parallel_exec_prog(log_file_name, NULL, - "\"%s/pg_dump\" %s --no-data %s --quote-all-identifiers " + "\"%s/pg_dump\" %s --no-data %s --sequence-data --quote-all-identifiers " "--binary-upgrade --format=custom %s --no-sync --file=\"%s/%s\" %s", new_cluster.bindir, cluster_conn_opts(&old_cluster), log_opts.verbose ? "--verbose" : "", diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index a9bcac4169d..adcaa419616 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -48,7 +48,7 @@ my %pgdump_runs = ( dump_cmd => [ 'pg_dump', '--no-sync', '--file' => "$tempdir/binary_upgrade.sql", - '--schema-only', '--binary-upgrade', + '--schema-only', '--sequence-data', '--binary-upgrade', '--dbname' => 'postgres', ], }, -- 2.39.5 (Apple Git-154) --pLR3ODfl/bBGLi7m Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v9-0003-pg_upgrade-Add-swap-for-faster-file-transfer.patch" ^ permalink raw reply [nested|flat] 8+ messages in thread
* [PATCH v3 2/4] pg_dump: Add --sequence-data. @ 2025-02-19 17:25 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 8+ messages in thread From: Nathan Bossart @ 2025-02-19 17:25 UTC (permalink / raw) This new option instructs pg_dump to dump sequence data when the --no-data, --schema-only, or --statistics-only option is specified. This was originally considered for commit a7e5457db8, but it was left out at that time because there was no known use-case. A follow-up commit will use this to optimize pg_upgrade's file transfer step. Discussion: https://postgr.es/m/Zyvop-LxLXBLrZil%40nathan --- doc/src/sgml/ref/pg_dump.sgml | 11 +++++++++++ src/bin/pg_dump/pg_dump.c | 10 ++-------- src/bin/pg_dump/t/002_pg_dump.pl | 1 + src/bin/pg_upgrade/dump.c | 2 +- src/test/modules/test_pg_dump/t/001_base.pl | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 1975054d7bf..b05f16995c3 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -1289,6 +1289,17 @@ PostgreSQL documentation </listitem> </varlistentry> + <varlistentry> + <term><option>--sequence-data</option></term> + <listitem> + <para> + Include sequence data in the dump. This is the default behavior except + when <option>--no-data</option>, <option>--schema-only</option>, or + <option>--statistics-only</option> is specified. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>--serializable-deferrable</option></term> <listitem> diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 4f4ad2ee150..f63215eb3f9 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -517,6 +517,7 @@ main(int argc, char **argv) {"sync-method", required_argument, NULL, 15}, {"filter", required_argument, NULL, 16}, {"exclude-extension", required_argument, NULL, 17}, + {"sequence-data", no_argument, &dopt.sequence_data, 1}, {NULL, 0, NULL, 0} }; @@ -803,14 +804,6 @@ main(int argc, char **argv) if (dopt.column_inserts && dopt.dump_inserts == 0) dopt.dump_inserts = DUMP_DEFAULT_ROWS_PER_INSERT; - /* - * Binary upgrade mode implies dumping sequence data even in schema-only - * mode. This is not exposed as a separate option, but kept separate - * internally for clarity. - */ - if (dopt.binary_upgrade) - dopt.sequence_data = 1; - if (data_only && schema_only) pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together"); if (schema_only && statistics_only) @@ -1275,6 +1268,7 @@ help(const char *progname) printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n")); printf(_(" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n")); printf(_(" --section=SECTION dump named section (pre-data, data, or post-data)\n")); + printf(_(" --sequence-data include sequence data in dump\n")); printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n")); printf(_(" --snapshot=SNAPSHOT use given snapshot for the dump\n")); printf(_(" --statistics-only dump only the statistics, not schema or data\n")); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index c7bffc1b045..8ae6c5374fc 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -66,6 +66,7 @@ my %pgdump_runs = ( '--file' => "$tempdir/binary_upgrade.dump", '--no-password', '--no-data', + '--sequence-data', '--binary-upgrade', '--dbname' => 'postgres', # alternative way to specify database ], diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c index 23fe7280a16..b8fd0d0acee 100644 --- a/src/bin/pg_upgrade/dump.c +++ b/src/bin/pg_upgrade/dump.c @@ -52,7 +52,7 @@ generate_old_dump(void) snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid); parallel_exec_prog(log_file_name, NULL, - "\"%s/pg_dump\" %s --no-data %s --quote-all-identifiers " + "\"%s/pg_dump\" %s --no-data %s --sequence-data --quote-all-identifiers " "--binary-upgrade --format=custom %s --no-sync --file=\"%s/%s\" %s", new_cluster.bindir, cluster_conn_opts(&old_cluster), log_opts.verbose ? "--verbose" : "", diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index 9b2a90b0469..27c6c2ab0f3 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -48,7 +48,7 @@ my %pgdump_runs = ( dump_cmd => [ 'pg_dump', '--no-sync', "--file=$tempdir/binary_upgrade.sql", '--schema-only', - '--binary-upgrade', '--dbname=postgres', + '--sequence-data', '--binary-upgrade', '--dbname=postgres', ], }, clean => { -- 2.39.5 (Apple Git-154) --riA+Qo0L+2qqy04o Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v3-0003-Add-new-frontend-functions-for-durable-file-opera.patch" ^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2025-02-19 17:25 UTC | newest] Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-12-15 23:20 [PATCH 5/5] Improve find_em_expr_usable_for_sorting_rel comment Tomas Vondra <[email protected]> 2025-02-19 17:25 [PATCH v4 2/3] pg_dump: Add --sequence-data. Nathan Bossart <[email protected]> 2025-02-19 17:25 [PATCH v5 2/3] pg_dump: Add --sequence-data. Nathan Bossart <[email protected]> 2025-02-19 17:25 [PATCH v6 2/3] pg_dump: Add --sequence-data. Nathan Bossart <[email protected]> 2025-02-19 17:25 [PATCH v7 3/4] pg_dump: Add --sequence-data. Nathan Bossart <[email protected]> 2025-02-19 17:25 [PATCH v8 3/4] pg_dump: Add --sequence-data. Nathan Bossart <[email protected]> 2025-02-19 17:25 [PATCH v9 2/3] pg_dump: Add --sequence-data. Nathan Bossart <[email protected]> 2025-02-19 17:25 [PATCH v3 2/4] pg_dump: Add --sequence-data. Nathan Bossart <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox