SQL that turns foreign key enforcement off/on for the current session.
Every family has its own statement and they are not interchangeable:
SQLite/Turso use a PRAGMA, the MySQL family a session variable, and the
PostgreSQL family session_replication_role. Handing MySQL's
SET FOREIGN_KEY_CHECKS to anything else - which is what the default branch
used to do for every unlisted dialect, PostgreSQL included - produces a
syntax error at the server, and the caller only finds out at runtime.
The PostgreSQL form needs superuser, or a role granted
SET ON PARAMETER session_replication_role (PostgreSQL 15+); on an ordinary
application role the server answers permission denied to set parameter.
when the dialect has no
session-level equivalent (SQL Server, Oracle and Db2 are per-table or
per-constraint; Redshift, Snowflake, ClickHouse and friends do not enforce
foreign keys at all).
SQL that turns foreign key enforcement off/on for the current session.
Every family has its own statement and they are not interchangeable: SQLite/Turso use a PRAGMA, the MySQL family a session variable, and the PostgreSQL family
session_replication_role. Handing MySQL'sSET FOREIGN_KEY_CHECKSto anything else - which is what the default branch used to do for every unlisted dialect, PostgreSQL included - produces a syntax error at the server, and the caller only finds out at runtime.The PostgreSQL form needs superuser, or a role granted
SET ON PARAMETER session_replication_role(PostgreSQL 15+); on an ordinary application role the server answerspermission denied to set parameter.