banDropTrigger

Diagnostic Category: lint/safety/banDropTrigger

Since: vnext

Sources: - Inspired from: pgfence/drop-trigger

Description

Dropping a trigger acquires an ACCESS EXCLUSIVE lock on the table.

DROP TRIGGER blocks all reads and writes on the table while the lock is held. It may also break application logic that depends on the trigger's behavior.

Examples

Invalid

drop trigger my_trigger on my_table;
code-block.sql:1:1 lint/safety/banDropTrigger ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ! Dropping a trigger acquires an ACCESS EXCLUSIVE lock on the table.

  > 1 │ drop trigger my_trigger on my_table;
      │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    2 │ 

  i This blocks all reads and writes. Ensure no application logic depends on the trigger before dropping it.


Valid

select 1;

How to configure


{
  "linter": {
    "rules": {
      "safety": {
        "banDropTrigger": "error"
      }
    }
  }
}