Re: pg_dump, ATTACH, and independently restorable child partitions
Justin Pryzby <pryzby@telsasoft.com>
From: Justin Pryzby <pryzby@telsasoft.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: David Rowley <drowley@postgresql.org>, pgsql-hackers@lists.postgresql.org
Date: 2020-10-29T17:00:20Z
Lists: pgsql-hackers
Attachments
On Sat, Oct 24, 2020 at 02:59:49PM -0500, Justin Pryzby wrote: > On Fri, Oct 23, 2020 at 12:29:40AM -0500, Justin Pryzby wrote: > > Since this commit, pg_dump CREATEs tables and then ATTACHes them: > > > > |commit 33a53130a89447e171a8268ae0b221bb48af6468 > > |Author: Alvaro Herrera <alvherre@alvh.no-ip.org> > > |Date: Mon Jun 10 18:56:23 2019 -0400 > > | > > | Make pg_dump emit ATTACH PARTITION instead of PARTITION OF (reprise) > > |... > > | This change also has the advantage that the partition is restorable from > > | the dump (as a standalone table) even if its parent table isn't > > | restored. > > > > I like the idea of child tables being independently restorable, but it doesn't > > seem to work. > ... > > Now that I look, it seems like this is calling PQexec(), which sends a single, > > "simple" libpq message with: > > |CREATE TABLE ..; ALTER TABLE .. ATTACH PARTITION; > > ..which is transactional, so when the 2nd command fails, the CREATE is rolled back. > > https://www.postgresql.org/docs/9.5/libpq-exec.html#LIBPQ-EXEC-MAIN > > The easy fix is to add an explicit begin/commit. Now with updated test script. -- Justin
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