pg_dump: Fix gathering of sequence information.
Nathan Bossart <nathan@postgresql.org>
pg_dump: Fix gathering of sequence information. Since commit bd15b7db48, pg_dump uses pg_get_sequence_data() (née pg_sequence_read_tuple()) to gather all sequence data in a single query as opposed to a query per sequence. Two related bugs have been identified: * If the user lacks appropriate privileges on the sequence, pg_dump generates a setval() command with garbage values instead of failing as expected. * pg_dump can fail due to a concurrently dropped sequence, even if the dropped sequence's data isn't part of the dump. This commit fixes the above issues by 1) teaching pg_get_sequence_data() to return nulls instead of erroring for a missing sequence and 2) teaching pg_dump to fail if it tries to dump the data of a sequence for which pg_get_sequence_data() returned nulls. Note that pg_dump may still fail due to a concurrently dropped sequence, but it should now only do so when the sequence data is part of the dump. This matches the behavior before commit bd15b7db48. Bug: #19365 Reported-by: Paveł Tyślacki <pavel.tyslacki@gmail.com> Suggested-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/19365-6245240d8b926327%40postgresql.org Discussion: https://postgr.es/m/2885944.1767029161%40sss.pgh.pa.us Backpatch-through: 18
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/commands/sequence.c | modified | +8 −6 |
| src/bin/pg_dump/pg_dump.c | modified | +12 −0 |
Discussion
- improve performance of pg_dump with many sequences 29 messages · 2024-05-03 → 2026-01-09
- BUG #19365: postgres 18 pg_dump fails whan drop sequence concurrently 4 messages · 2025-12-27 → 2026-01-09