I am copying data from one PostgreSQL v10 table to another. The destination table has several foreign key constraints. I was surprised that I did not get any errors, even though none of the tables referred to by the foreign key constraints had any data.
Before I did the copy, I used DISABLE TRIGGER ALL
to ensure that the trigger defined on the destination table did not fire. I was surprised that the copy succeeded. After ENABLE TRIGGER ALL
, I tried to add one more row, a copy of an existing row. That failed with a foreign key constraint violation. I then did DISABLE TRIGGER ALL
, tried to add the new row, and it succeeded.
I conclude that in PostgreSQL 10, DISABLE TRIGGER ALL
will disable foreign key constraint checks. Is that expected behavior?
Details can be found here.