pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: jamesstonehill@gmail.com
Subject: BUG #15657: `session_replication_role = replica` not respected by truncation
Date: Tue, 26 Feb 2019 13:47:31 +0000
Message-ID: <15657-f94bb6e3ad28e1e2@postgresql.org> (raw)

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.



Message-ID: <15657-f94bb6e3ad28e1e2@postgresql.org>
Permalink:  ../15657-f94bb6e3ad28e1e2@postgresql.org/
Also on:    postgresql.org/message-id/15657-f94bb6e3ad28e1e2@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, jamesstonehill@gmail.com
  Subject: Re: BUG #15657: `session_replication_role = replica` not respected by truncation
  In-Reply-To: <15657-f94bb6e3ad28e1e2@postgresql.org>
  References: <15657-f94bb6e3ad28e1e2@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox