Re: pg_dump: fail to restore partition table with serial type
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Rushabh Lathia <rushabh.lathia@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2019-06-07T18:36:41Z
Lists: pgsql-hackers
Attachments
On 2019-May-06, Alvaro Herrera wrote: > On 2019-May-06, Rushabh Lathia wrote: > > > Found another scenario where check constraint is not getting > > dump for the child table. > > You're right, the patched code is bogus; I'm reverting it all for > today's minors. Thanks for reporting. Here's another version of this patch. This time, I added some real tests in pg_dump's suite, including a SERIAL column and NOT NULL constraints. The improved test verifies that the partition is created separately and later attached, and it includes constraints from the parent as well as some locally defined ones. I also added tests with legacy inheritance, which was not considered previously in pg_dump tests as far as I could see. I looked for other cases that could have been broken by changing the partition creation methodology in pg_dump, and didn't find anything. That part of pg_dump (dumpTableSchema) is pretty spaghettish, though; the fact that shouldPrintColumn makes some partitioned-related decisions and then dumpTableSchema make them again is notoriously confusing. I could have easily missed something. One weird thing about pg_dump's output of the serial column in a partitioned table is that it emits the parent table itself first without a DEFAULT clause, then the sequence and marks it as owned by the column; then it emits the partition *with* the default clause, and finally it alters the parent table's column to set the default. Now there is some method in this madness (the OWNED BY clause for the sequence is mingled together with the sequence itself), but I think this arrangement makes a partial restore of the partition fail. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Make pg_dump emit ATTACH PARTITION instead of PARTITION OF (reprise)
- 6a781c4f5fec 11.4 landed
- 33a53130a894 12.0 landed
- 1eb8a5ea463d 10.9 landed
-
Revert "Make pg_dump emit ATTACH PARTITION instead of PARTITION OF"
- a1ec7402e9a0 12.0 landed
- 92880ff8a667 11.3 landed
- 40353bcc67cd 10.8 landed
-
Make pg_dump emit ATTACH PARTITION instead of PARTITION OF
- 3b23552ad8bb 12.0 cited
-
Allow a partitioned table to have a default partition.
- 6f6b99d1335b 11.0 cited
-
Give partitioned table "p" in regression tests a less generic name.
- aa56671836e6 10.0 cited