Re: pg_restore with --disable-triggers discards ENABLE ALWAYS

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Duncan Sands <duncan(dot)sands(at)deepbluecap(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: pg_restore with --disable-triggers discards ENABLE ALWAYS
Date: 2024-09-12 20:47:07
Message-ID: 4156698.1726174027@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> writes:
> On Thu, 2024-09-12 at 10:27 +0200, Duncan Sands wrote:
>> pg_restore --data-only --disable-triggers --dbname duncan dump.custom
>> ^ Observe that "Triggers firing always" has disappeared.

> This looks like a user error to me.
> If you restore with --data-only, the table and constraint definitions
> are not restored at all. So the table "test_table" in database "duncan"
> must already have existed before the restore, and the trigger was already
> defined like that.

The given recipe seems incomplete, 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.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Thomas Munro 2024-09-12 22:33:28 Re: BUG #18610: llvm error: __aarch64_swp4_acq_rel which could not be resolved
Previous Message Laurenz Albe 2024-09-12 20:02:01 Re: pg_restore with --disable-triggers discards ENABLE ALWAYS