Aco Vujic
Aco Vujic

Reputation: 67

INSERT statement that does not fire an INSERT trigger

I am using PostgreSQL 9.2 and I need to write an INSERT statement which copies data from table A to table B without firing the INSERT trigger defined on table B (maybe some sort of bulk insertion operation??).

On this specific table (table B) many INSERT, UPDATE and DELETE operations are executed. During each and every one of this executions, a trigger must fire.

I cannot temporary disable the triggers because of standard, day-to-day DML operations.

Can anyone help me with the syntax for this non-trigger-firing INSERT statement?

Upvotes: 1

Views: 1133

Answers (1)

Richard Huxton
Richard Huxton

Reputation: 22943

Run your "privileged" inserts as a different user. That way your trigger can check the current user and exit if it shouldn't do anything.

Upvotes: 1

Related Questions