if (!OidIsValid(seqinfo->owning_tab))
continue; /* not an owned sequence */
- if (seqinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
- continue; /* no need to search */
+
owning_tab = findTableByOid(seqinfo->owning_tab);
- if (owning_tab && owning_tab->dobj.dump)
- {
+
+ /*
+ * We need to dump the components that are being dumped for the table
+ * and any components which the sequence is explicitly marked with.
+ *
+ * We can't simply use the set of components which are being dumped for
+ * the table as the table might be in an extension (and only the
+ * non-extension components, eg: ACLs if changed, security labels, and
+ * policies, are being dumped) while the sequence is not (and therefore
+ * the definition and other components should also be dumped).
+ *
+ * If the sequence is part of the extension then it should be properly
+ * marked by checkExtensionMembership() and this will be a no-op as the
+ * table will be equivalently marked.
+ */
+ seqinfo->dobj.dump = seqinfo->dobj.dump | owning_tab->dobj.dump;
+
+ if (seqinfo->dobj.dump != DUMP_COMPONENT_NONE)
seqinfo->interesting = true;
- seqinfo->dobj.dump = DUMP_COMPONENT_ALL;
- }
}
}
{
TableInfo *owning_tab = findTableByOid(tbinfo->owning_tab);
- if (owning_tab && owning_tab->dobj.dump)
+ if (owning_tab && owning_tab->dobj.dump & DUMP_COMPONENT_DEFINITION)
{
resetPQExpBuffer(query);
appendPQExpBuffer(query, "ALTER SEQUENCE %s",
only_dump_test_schema => 1,
only_dump_test_table => 1,
test_schema_plus_blobs => 1, }, },
+ 'ALTER SEQUENCE test_table_col1_seq' => {
+ regexp => qr/^
+ \QALTER SEQUENCE test_table_col1_seq OWNED BY test_table.col1;\E
+ /xm,
+ like => {
+ binary_upgrade => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ exclude_test_table_data => 1,
+ no_privs => 1,
+ no_owner => 1,
+ only_dump_test_schema => 1,
+ only_dump_test_table => 1,
+ pg_dumpall_dbprivs => 1,
+ schema_only => 1,
+ section_pre_data => 1,
+ test_schema_plus_blobs => 1, },
+ unlike => {
+ exclude_test_table => 1,
+ exclude_dump_test_schema => 1,
+ pg_dumpall_globals => 1,
+ pg_dumpall_globals_clean => 1,
+ section_post_data => 1, }, },
+ 'ALTER SEQUENCE test_third_table_col1_seq' => {
+ regexp => qr/^
+ \QALTER SEQUENCE test_third_table_col1_seq OWNED BY test_third_table.col1;\E
+ /xm,
+ like => {
+ binary_upgrade => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ exclude_dump_test_schema => 1,
+ exclude_test_table => 1,
+ exclude_test_table_data => 1,
+ no_privs => 1,
+ no_owner => 1,
+ pg_dumpall_dbprivs => 1,
+ schema_only => 1,
+ section_pre_data => 1, },
+ unlike => {
+ only_dump_test_schema => 1,
+ only_dump_test_table => 1,
+ pg_dumpall_globals => 1,
+ pg_dumpall_globals_clean => 1,
+ section_post_data => 1,
+ test_schema_plus_blobs => 1, }, },
'ALTER TABLE ONLY test_table ADD CONSTRAINT ... PRIMARY KEY' => {
regexp => qr/^
\QALTER TABLE ONLY test_table\E \n^\s+
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
+ 'CREATE SEQUENCE regress_pg_dump_table_col1_seq' => {
+ regexp => qr/^
+ \QCREATE SEQUENCE regress_pg_dump_table_col1_seq\E
+ \n\s+\QSTART WITH 1\E
+ \n\s+\QINCREMENT BY 1\E
+ \n\s+\QNO MINVALUE\E
+ \n\s+\QNO MAXVALUE\E
+ \n\s+\QCACHE 1;\E
+ $/xm,
+ like => { binary_upgrade => 1, },
+ unlike => {
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_privs => 1,
+ no_owner => 1,
+ pg_dumpall_globals => 1,
+ schema_only => 1,
+ section_pre_data => 1,
+ section_post_data => 1, }, },
+ 'CREATE SEQUENCE regress_pg_dump_seq' => {
+ regexp => qr/^
+ \QCREATE SEQUENCE regress_pg_dump_seq\E
+ \n\s+\QSTART WITH 1\E
+ \n\s+\QINCREMENT BY 1\E
+ \n\s+\QNO MINVALUE\E
+ \n\s+\QNO MAXVALUE\E
+ \n\s+\QCACHE 1;\E
+ $/xm,
+ like => { binary_upgrade => 1, },
+ unlike => {
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_privs => 1,
+ no_owner => 1,
+ pg_dumpall_globals => 1,
+ schema_only => 1,
+ section_pre_data => 1,
+ section_post_data => 1, }, },
'CREATE TABLE regress_pg_dump_table' => {
regexp => qr/^
\QCREATE TABLE regress_pg_dump_table (\E
- \n\s+\Qcol1 integer,\E
+ \n\s+\Qcol1 integer NOT NULL,\E
\n\s+\Qcol2 integer\E
\n\);$/xm,
like => { binary_upgrade => 1, },
no_privs => 1,
pg_dumpall_globals => 1,
section_post_data => 1, }, },
+ 'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role' => {
+ create_order => 5,
+ create_sql => 'GRANT USAGE ON SEQUENCE regress_pg_dump_table_col1_seq
+ TO regress_dump_test_role;',
+ regexp => qr/^
+ \QGRANT USAGE ON SEQUENCE regress_pg_dump_table_col1_seq TO regress_dump_test_role;\E
+ $/xm,
+ like => {
+ binary_upgrade => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_owner => 1,
+ schema_only => 1,
+ section_pre_data => 1, },
+ unlike => {
+ no_privs => 1,
+ pg_dumpall_globals => 1,
+ section_post_data => 1, }, },
+ 'GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role' => {
+ regexp => qr/^
+ \QGRANT USAGE ON SEQUENCE regress_pg_dump_seq TO regress_dump_test_role;\E
+ $/xm,
+ like => {
+ binary_upgrade => 1, },
+ unlike => {
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_owner => 1,
+ no_privs => 1,
+ pg_dumpall_globals => 1,
+ schema_only => 1,
+ section_pre_data => 1,
+ section_post_data => 1, }, },
'REVOKE SELECT(col1) ON regress_pg_dump_table' => {
create_order => 3,
create_sql => 'REVOKE SELECT(col1) ON regress_pg_dump_table
\echo Use "CREATE EXTENSION test_pg_dump" to load this file. \quit
CREATE TABLE regress_pg_dump_table (
- col1 int,
+ col1 serial,
col2 int
);
+CREATE SEQUENCE regress_pg_dump_seq;
+
+GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role;
+
GRANT SELECT ON regress_pg_dump_table TO regress_dump_test_role;
GRANT SELECT(col1) ON regress_pg_dump_table TO public;