Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9c49f0e

Browse files
pg_dump: Add --sequence-data.
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 a7e5457, 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: Robert Haas <[email protected]> Discussion: https://postgr.es/m/Zyvop-LxLXBLrZil%40nathan
1 parent cf131fa commit 9c49f0e

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

doc/src/sgml/ref/pg_dump.sgml

+11
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,17 @@ PostgreSQL documentation
12981298
</listitem>
12991299
</varlistentry>
13001300

1301+
<varlistentry>
1302+
<term><option>--sequence-data</option></term>
1303+
<listitem>
1304+
<para>
1305+
Include sequence data in the dump. This is the default behavior except
1306+
when <option>--no-data</option>, <option>--schema-only</option>, or
1307+
<option>--statistics-only</option> is specified.
1308+
</para>
1309+
</listitem>
1310+
</varlistentry>
1311+
13011312
<varlistentry>
13021313
<term><option>--serializable-deferrable</option></term>
13031314
<listitem>

src/bin/pg_dump/pg_dump.c

+2-8
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ main(int argc, char **argv)
518518
{"sync-method", required_argument, NULL, 15},
519519
{"filter", required_argument, NULL, 16},
520520
{"exclude-extension", required_argument, NULL, 17},
521+
{"sequence-data", no_argument, &dopt.sequence_data, 1},
521522

522523
{NULL, 0, NULL, 0}
523524
};
@@ -801,14 +802,6 @@ main(int argc, char **argv)
801802
if (dopt.column_inserts && dopt.dump_inserts == 0)
802803
dopt.dump_inserts = DUMP_DEFAULT_ROWS_PER_INSERT;
803804

804-
/*
805-
* Binary upgrade mode implies dumping sequence data even in schema-only
806-
* mode. This is not exposed as a separate option, but kept separate
807-
* internally for clarity.
808-
*/
809-
if (dopt.binary_upgrade)
810-
dopt.sequence_data = 1;
811-
812805
if (data_only && schema_only)
813806
pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together");
814807
if (schema_only && statistics_only)
@@ -1275,6 +1268,7 @@ help(const char *progname)
12751268
printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n"));
12761269
printf(_(" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
12771270
printf(_(" --section=SECTION dump named section (pre-data, data, or post-data)\n"));
1271+
printf(_(" --sequence-data include sequence data in dump\n"));
12781272
printf(_(" --serializable-deferrable wait until the dump can run without anomalies\n"));
12791273
printf(_(" --snapshot=SNAPSHOT use given snapshot for the dump\n"));
12801274
printf(_(" --statistics-only dump only the statistics, not schema or data\n"));

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

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
'--file' => "$tempdir/binary_upgrade.dump",
6767
'--no-password',
6868
'--no-data',
69+
'--sequence-data',
6970
'--binary-upgrade',
7071
'--dbname' => 'postgres', # alternative way to specify database
7172
],

src/bin/pg_upgrade/dump.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ generate_old_dump(void)
5252
snprintf(log_file_name, sizeof(log_file_name), DB_DUMP_LOG_FILE_MASK, old_db->db_oid);
5353

5454
parallel_exec_prog(log_file_name, NULL,
55-
"\"%s/pg_dump\" %s --no-data %s --quote-all-identifiers "
55+
"\"%s/pg_dump\" %s --no-data %s --sequence-data --quote-all-identifiers "
5656
"--binary-upgrade --format=custom %s --no-sync --file=\"%s/%s\" %s",
5757
new_cluster.bindir, cluster_conn_opts(&old_cluster),
5858
log_opts.verbose ? "--verbose" : "",

src/test/modules/test_pg_dump/t/001_base.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
dump_cmd => [
4949
'pg_dump', '--no-sync',
5050
'--file' => "$tempdir/binary_upgrade.sql",
51-
'--schema-only', '--binary-upgrade',
51+
'--schema-only', '--sequence-data', '--binary-upgrade',
5252
'--dbname' => 'postgres',
5353
],
5454
},

0 commit comments

Comments
 (0)