mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-17 20:07:00 +08:00
When considering a sequence's Data entry in dumpSequenceData, we were actually looking at the sequence definition's dump flag to decide if we should dump the data or not. That's generally fine, except for when the sequence data entry was created by processExtensionTables() because it's a config sequence. In that case, the sequence itself won't be marked as dumping data because it's part of an extension, leading to the need for processExtensionTables() to create the sequence data entry. This leads to extension config sequence data not being included in the dump when it should be. Fix this by looking at the sequence data's dump flag instead, just as dumpTableData() was doing for tables (which is why config tables were correctly being handled), and add a regression test to make sure we don't break it moving forward. All of this is a bit round-about since we can now represent which components of a given dump item should be dumped out through the dump flag. A future improvement might be to change checkExtensionMembership() to check for config sequences/tables and set the dump flag based on that directly, possibly removing the need for processExtensionTables(). Bug found by Daniele Varrazzo. Discussion: https://postgr.es/m/CA+mi_8ZmxQM7+nZ7pJ8uyfxc9V3o=UAG14dVqvftdmvw8OJ3gQ@mail.gmail.com Patch by Michael Paquier, with some tweaking of the regression tests by me. Back-patch to 9.6 where the bug was introduced.
49 lines
1.7 KiB
SQL
49 lines
1.7 KiB
SQL
/* src/test/modules/test_pg_dump/test_pg_dump--1.0.sql */
|
|
|
|
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
|
\echo Use "CREATE EXTENSION test_pg_dump" to load this file. \quit
|
|
|
|
CREATE TABLE regress_pg_dump_table (
|
|
col1 serial,
|
|
col2 int
|
|
);
|
|
|
|
CREATE SEQUENCE regress_pg_dump_seq;
|
|
|
|
CREATE SEQUENCE regress_seq_dumpable;
|
|
SELECT pg_catalog.pg_extension_config_dump('regress_seq_dumpable', '');
|
|
|
|
CREATE SCHEMA regress_pg_dump_schema;
|
|
|
|
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;
|
|
|
|
GRANT SELECT(col2) ON regress_pg_dump_table TO regress_dump_test_role;
|
|
REVOKE SELECT(col2) ON regress_pg_dump_table FROM regress_dump_test_role;
|
|
|
|
CREATE ACCESS METHOD regress_test_am TYPE INDEX HANDLER bthandler;
|
|
|
|
-- Create a set of objects that are part of the schema created by
|
|
-- this extension.
|
|
CREATE TABLE regress_pg_dump_schema.test_table (
|
|
col1 int,
|
|
col2 int
|
|
);
|
|
GRANT SELECT ON regress_pg_dump_schema.test_table TO regress_dump_test_role;
|
|
|
|
CREATE SEQUENCE regress_pg_dump_schema.test_seq;
|
|
GRANT USAGE ON regress_pg_dump_schema.test_seq TO regress_dump_test_role;
|
|
|
|
CREATE TYPE regress_pg_dump_schema.test_type AS (col1 int);
|
|
GRANT USAGE ON TYPE regress_pg_dump_schema.test_type TO regress_dump_test_role;
|
|
|
|
CREATE FUNCTION regress_pg_dump_schema.test_func () RETURNS int
|
|
AS 'SELECT 1;' LANGUAGE SQL;
|
|
GRANT EXECUTE ON FUNCTION regress_pg_dump_schema.test_func() TO regress_dump_test_role;
|
|
|
|
CREATE AGGREGATE regress_pg_dump_schema.test_agg(int2)
|
|
(SFUNC = int2_sum, STYPE = int8);
|
|
GRANT EXECUTE ON FUNCTION regress_pg_dump_schema.test_agg(int2) TO regress_dump_test_role;
|