Re: pg_restore with --disable-triggers discards ENABLE ALWAYS
Duncan Sands <duncan.sands@deepbluecap.com>
From: Duncan Sands <duncan.sands@deepbluecap.com>
To: Tom Lane <tgl@sss.pgh.pa.us>, Laurenz Albe <laurenz.albe@cybertec.at>
Cc: pgsql-bugs@lists.postgresql.org
Date: 2024-09-13T09:04:07Z
Lists: pgsql-bugs
Hi Tom, thanks for taking a look. > The given recipe seems incomplete, I'm not sure what is missing in the recipe. I just dropped and recreated the database, and performed exactly the steps listed in my original email, and get exactly the same result. > but I think Duncan has put his > finger on a shortcoming. pg_restore with --disable-triggers will > issue > > ALTER TABLE foo DISABLE TRIGGER ALL; > > and later > > ALTER TABLE foo ENABLE TRIGGER ALL; > > and if you read the fine print in the ALTER TABLE man page, > you'll discover that ENABLE TRIGGER sets the triggers' replication > mode to the default (origin only). I'm not sure why somebody > thought that replication mode shouldn't be stored separately > from enable/disable, but it isn't: there's just one four-valued > state field. > > We could probably add code to make pg_dump individually re-enable > the table's triggers with the appropriate state(s), but I can't > muster too much enthusiasm for writing that myself.