pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
BUG #15642: UPDATE statements that change a partition key and FDW partitions problem. 2+ messages / 2 participants [nested] [flat]
* BUG #15642: UPDATE statements that change a partition key and FDW partitions problem. @ 2019-02-19 14:13 PG Bug reporting form <noreply@postgresql.org> 0 siblings, 1 reply; 2+ messages in thread From: PG Bug reporting form @ 2019-02-19 14:13 UTC (permalink / raw) To: pgsql-bugs@lists.postgresql.org; +Cc: maxim.boguk@gmail.com The following bug has been logged on the website: Bug reference: 15642 Logged by: Maksym Boguk Email address: maxim.boguk@gmail.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 ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #15642: UPDATE statements that change a partition key and FDW partitions problem. @ 2019-02-20 02:30 Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp> parent: PG Bug reporting form <noreply@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Etsuro Fujita @ 2019-02-20 02:30 UTC (permalink / raw) To: maxim.boguk@gmail.com; pgsql-bugs@lists.postgresql.org; +Cc: PG Bug reporting form <noreply@postgresql.org> (2019/02/19 23:13), PG Bug reporting form wrote: > The following bug has been logged on the website: > 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. Unfortunately, this is not supported as documented in the notes section of the UPDATE reference page [1]: "Currently, rows cannot be moved from a partition that is a foreign table to some other partition, but they can be moved into a foreign table if the foreign data wrapper supports it." Best regards, Etsuro Fujita [1] https://www.postgresql.org/docs/11/sql-update.html ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2019-02-20 02:30 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-02-19 14:13 BUG #15642: UPDATE statements that change a partition key and FDW partitions problem. PG Bug reporting form <noreply@postgresql.org> 2019-02-20 02:30 ` Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>
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