The following bug has been logged on the website:
Bug reference: 15657
Logged by: James Stonehill
Email address: jamesstonehill@gmail.com
PostgreSQL version: 11.1
Operating system: Mac OS 10.14.3
Description:
Truncation does not ignore foreign key triggers when the
session_replication_role is set to "replica" like DELETE does.
```
CREATE TABLE users (
id serial PRIMARY KEY
);
CREATE TABLE posts(
id serial PRIMARY KEY,
user_id INTEGER REFERENCES users(id)
);
INSERT INTO users(id) VALUES (1);
INSERT INTO posts(id, user_id) VALUES (1, 1);
SET session_replication_role = replica;
TRUNCATE users;
```
returns
> ERROR: cannot truncate a table referenced in a foreign key constraint
> DETAIL: Table "posts" references "users".
> HINT: Truncate table "posts" at the same time, or use TRUNCATE ...
CASCADE.