Re: pg_dump, ATTACH, and independently restorable child partitions
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>,
David Rowley <drowley@postgresql.org>,
pgsql-hackers@lists.postgresql.org
Date: 2021-01-12T02:28:18Z
Lists: pgsql-hackers
Justin Pryzby <pryzby@telsasoft.com> writes: > [ v5-0001-pg_dump-output-separate-object-for-ALTER-TABLE.AT.patch ] Pushed with mostly cosmetic edits. One thing I changed that isn't cosmetic is that I set the ArchiveEntry's owner to be the owner of the child table. Although we aren't going to do any sort of ALTER OWNER on this, it's still important that the owner be marked as someone who has the right permissions to issue the ALTER. The default case is that the original user will issue the ATTACH, which basically only works if you run the restore as superuser. It looks to me like you copied this decision from the INDEX ATTACH code, which is just as broken --- I'm going to go fix/backpatch that momentarily. Another thing that bothers me still is that it's not real clear that this code plays nicely with selective dumps, because it's not doing anything to set the dobj.dump field in a non-default way (which in turn means that the dobj.dump test in dumpTableAttach can never fire). It seems like it might be possible to emit a TABLE ATTACH object even though one or both of the referenced tables didn't get dumped. In some desultory testing I couldn't get that to actually happen, but maybe I just didn't push on it in the right way. I'd be happier about this if we set the flags with something along the lines of attachinfo->dobj.dump = attachinfo->parentTbl->dobj.dump & attachinfo->partitionTbl->dobj.dump; regards, tom lane
Commits
-
pg_dump: label INDEX ATTACH ArchiveEntries with an owner.
- 9f15188a1b82 11.11 landed
- 9eabfe300a22 14.0 landed
- 436d9c5cabfc 12.6 landed
- 0011c5a0fdac 13.2 landed
-
Dump ALTER TABLE ... ATTACH PARTITION as a separate ArchiveEntry.
- 9a4c0e36fbd6 14.0 landed
-
Make pg_dump emit ATTACH PARTITION instead of PARTITION OF (reprise)
- 33a53130a894 12.0 cited