Re: CREATE TABLE .. PARTITION OF fails to preserve tgenabled for inherited row triggers
Zhihong Yu <zyu@yugabyte.com>
From: Zhihong Yu <zyu@yugabyte.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Justin Pryzby <pryzby@telsasoft.com>, Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL-development <pgsql-hackers@postgresql.org>,
Amit Langote <amitlangote09@gmail.com>
Date: 2021-07-14T18:42:35Z
Lists: pgsql-hackers
On Wed, Jul 14, 2021 at 11:02 AM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote: > On 2020-Oct-27, Justin Pryzby wrote: > > > I think either way could be ok - if you assume that the trigger was > disabled > > with ONLY, then it'd make sense to restore it with ONLY, but I think > it's at > > least as common to ALTER TABLE [*]. It might look weird to the user if > they > > used ALTER TABLE ONLY and the pg_dump output uses ALTER TABLE for that > table, > > and then again for all its children (or vice versa). But it's fine as > long as > > the state is correctly restored. > > > > There are serveral issues: > > - fail to preserve childs' tgenabled in CREATE TABLE PARTITION OF; > > - fail to preserve childs' tgenabled in pg_dump; > > - fail to preserve childs' comments in pg_dump; > > > > I'm going step away from this patch at least for awhile, so I'm > attaching my > > latest in case it's useful. > > Here's a new cut of this series. I used your pg_dump patch, but I blank > out the CREATE TRIGGER query before stashing the ALTER TRIGGER; > otherwise the dump has an error at restore time (because the trigger is > created again on the partition, but it already exists because it's been > created for the parent). Also, the new query has the "OR tgenabled <>" > test only if the table is a partition; and apply this new query only in > 11 and 12; keep 9.x-10 unchanged, because it cannot possibly match > anything. > > I tested this by creating 10k tables with one trigger each (no > partitioned tables). Total time to dump is the same as before. I was > concerned that because the query now has two LEFT JOINs it would be > slower; but it seems to be only marginally so. > > I'm thinking to apply my patch that changes the server behavior only to > 14 and up. I could be persuaded to backpatch all the way to 11, if > anybody supports the idea. > > -- > Álvaro Herrera 39°49'30"S 73°17'W — > https://www.EnterpriseDB.com/ > "Puedes vivir sólo una vez, pero si lo haces bien, una vez es suficiente" > Hi, Alvaro: It would be nice if this is backported to PG 11+ Thanks
Commits
-
Fix pg_dump for disabled triggers on partitioned tables
- f0e21f2f6167 15.0 landed
- ccfc3cbb341a 11.13 landed
- cc340af33453 13.4 landed
- 5992c94dc7e4 12.8 landed
- 3c5b7c628621 14.0 landed
-
Preserve firing-on state when cloning row triggers to partitions
- fed35bd4a650 11.13 landed
- eef92de11e50 14.0 landed
- df80fa2ee504 15.0 landed
- c31516ae5b43 13.4 landed
- 7584ec1f6098 12.8 landed
-
Fix ALTER TABLE .. ENABLE/DISABLE TRIGGER recursion
- bbb927b4db9b 14.0 landed
- a795f6782fa8 11.10 landed
- 5f6463a20af1 13.1 landed
- 0e6b6f8c7192 12.5 landed
-
psql \d: Display table where trigger is defined, if inherited
- c33869cc3bfc 13.0 cited
-
Fix cloning of row triggers to sub-partitions
- 1fa846f1c9af 13.0 cited
-
Make pg_dump emit ATTACH PARTITION instead of PARTITION OF (reprise)
- 33a53130a894 12.0 cited