Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

BUG #15657: `session_replication_role = replica` not respected by truncation - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15657: `session_replication_role = replica` not respected by truncation
Date
Msg-id 15657-f94bb6e3ad28e1e2@postgresql.org
Whole thread Raw
List pgsql-bugs
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.


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #15656: Not able to login database
Next
From: Sandeep Thakkar
Date:
Subject: Re: BUG #15647: pgagent file missing