BUG #15642: UPDATE statements that change a partition key and FDW partitions problem.

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: maxim(dot)boguk(at)gmail(dot)com
Subject: BUG #15642: UPDATE statements that change a partition key and FDW partitions problem.
Date: 2019-02-19 14:13:19
Message-ID: 15642-81cfc7b20b18f5ed@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15642
Logged by: Maksym Boguk
Email address: maxim(dot)boguk(at)gmail(dot)com
PostgreSQL version: 11.2
Operating system: Linux
Description:

Update statement which changes value of partition key doesn't doesn't work
with FDW partitions.

Test script:
\c postgres
drop database IF EXISTS test;
drop database IF EXISTS test0;
drop database IF EXISTS test1;
create database test;
create database test0;
create database test1;
\c test0
create table t (id integer not null, constraint id_check check (id<0));
\c test1
create table t (id integer not null, constraint id_check check (id>=0));
\c test
create extension postgres_fdw;
create server if not exists test0 FOREIGN DATA WRAPPER postgres_fdw OPTIONS
(dbname 'test0');
create server if not exists test1 FOREIGN DATA WRAPPER postgres_fdw OPTIONS
(dbname 'test1');
CREATE USER MAPPING FOR public SERVER test0 OPTIONS (user 'postgres');
CREATE USER MAPPING FOR public SERVER test1 OPTIONS (user 'postgres');
CREATE FOREIGN TABLE t0 (id integer not null, constraint id_check check
(id<0) ) SERVER test0 OPTIONS (table_name 't');
CREATE FOREIGN TABLE t1 (id integer not null, constraint id_check check
(id>=0)) SERVER test1 OPTIONS (table_name 't');
create table t (id integer not null) partition by range (id);
alter table t ATTACH PARTITION t0 for values from (MINVALUE) to (0);
alter table t ATTACH PARTITION t1 for values from (0) to (MAXVALUE);
insert into t (id) values (-1);
update t set id=2 where id=-1;

Expected: row in t1 partition.
Reality:
test=# update t set id=2 where id=-1;
ERROR: new row for relation "t" violates check constraint "id_check"
DETAIL: Failing row contains (2).
CONTEXT: remote SQL command: UPDATE public.t SET id = 2 WHERE ((id =
(-1)))

I don't know is this case supposed to work or not, and I can't find any
related notes in documentation.

Kind Regards,
Maxim

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeremy Finzel 2019-02-19 15:32:15 Re: Segmentation Fault in logical decoding get/peek API
Previous Message Andres Freund 2019-02-18 21:51:39 Re: Segmentation Fault in logical decoding get/peek API