pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15662: Row update in foreign partition does not move row based on partition key
4+ messages / 4 participants
[nested] [flat]

* BUG #15662: Row update in foreign partition does not move row based on partition key
@ 2019-03-01 19:06 PG Bug reporting form <noreply@postgresql.org>
  2019-03-01 19:54 ` Re: BUG #15662: Row update in foreign partition does not move row based on partition key Sergei Kornilov <sk@zsrv.org>
  0 siblings, 1 reply; 4+ messages in thread

From: PG Bug reporting form @ 2019-03-01 19:06 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: derek.hans@gmail.com

The following bug has been logged on the website:

Bug reference:      15662
Logged by:          Derek Hans
Email address:      derek.hans@gmail.com
PostgreSQL version: 11.2
Operating system:   Debian 6.3.0-18+deb9u1
Description:        

In a table with data partitions, updating the partition key of a row only
moves the row across partitions in some of the situations:
- From local partition to local partition
- From local partition to foreign partition
Rows are not moved
- From foreign partition to local partition
- From foreign partition to foreign partition

Repro steps:
Assumes 2 servers. 1st server has user postgres with password 'docker'
available at localhost:5432

-------------BOX 1
CREATE TABLE temperatures_2016 (
    at      date,
    city    text,
    mintemp integer,
    maxtemp integer
);

-------------BOX 2
CREATE TABLE temperatures (
    at      date,
    city    text,
    mintemp integer,
    maxtemp integer
)
PARTITION BY RANGE (at);

CREATE TABLE temperatures_2017
    PARTITION OF temperatures
    FOR VALUES FROM ('2017-01-01') TO ('2018-01-01');

CREATE EXTENSION postgres_fdw;

CREATE SERVER box1 FOREIGN DATA WRAPPER postgres_fdw
    OPTIONS (host 'localhost', dbname 'postgres', port '5432');
	
CREATE USER MAPPING FOR postgres SERVER box1
    OPTIONS (user 'postgres', password 'docker');


CREATE FOREIGN TABLE temperatures_2016
    PARTITION OF temperatures
    FOR VALUES FROM ('2016-01-01') TO ('2017-01-01')
    SERVER box1; 

INSERT INTO temperatures (at, city, mintemp, maxtemp) VALUES ('2016-08-03',
'London', 63, 73);
UPDATE temperatures set at = '2017-01-02';
SELECT * from temperatures_2017;

-----------------------
EXPECTED OUTPUT:
"2017-01-02"	"London"	63	73

ACTUAL OUTPUT:
no data.

Running 
SELECT * from temperatures_2016; 
does output the expected row - i.e. the row remains in the partition where
it was created.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #15662: Row update in foreign partition does not move row based on partition key
  2019-03-01 19:06 BUG #15662: Row update in foreign partition does not move row based on partition key PG Bug reporting form <noreply@postgresql.org>
@ 2019-03-01 19:54 ` Sergei Kornilov <sk@zsrv.org>
  2019-03-04 13:57   ` Re: BUG #15662: Row update in foreign partition does not move row based on partition key Derek Hans <derek.hans@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Sergei Kornilov @ 2019-03-01 19:54 UTC (permalink / raw)
  To: derek.hans@gmail.com <derek.hans@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hello

This is known limitation and documented in the notes section of the UPDATE reference page:

> "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."

https://www.postgresql.org/docs/11/sql-update.html

regards, Sergei




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #15662: Row update in foreign partition does not move row based on partition key
  2019-03-01 19:06 BUG #15662: Row update in foreign partition does not move row based on partition key PG Bug reporting form <noreply@postgresql.org>
  2019-03-01 19:54 ` Re: BUG #15662: Row update in foreign partition does not move row based on partition key Sergei Kornilov <sk@zsrv.org>
@ 2019-03-04 13:57   ` Derek Hans <derek.hans@gmail.com>
  2019-03-04 15:12     ` Re: BUG #15662: Row update in foreign partition does not move row based on partition key Amit Langote <amitlangote09@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Derek Hans @ 2019-03-04 13:57 UTC (permalink / raw)
  To: Sergei Kornilov <sk@zsrv.org>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Thanks. That's a substantial limitation.

I looked pretty hard through the various pieces of documentation and
tutorials and saw no mention. The v11 release notes don't mention it
either. Might be worth adding to the docs in more places and more
prominently.

On Fri, Mar 1, 2019 at 2:54 PM Sergei Kornilov <sk@zsrv.org> wrote:

> Hello
>
> This is known limitation and documented in the notes section of the UPDATE
> reference page:
>
> > "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."
>
> https://www.postgresql.org/docs/11/sql-update.html
>
> regards, Sergei
>


-- 
*Derek*
+1 (415) 754-0519 | derek.hans@gmail.com | Skype: derek.hans

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #15662: Row update in foreign partition does not move row based on partition key
  2019-03-01 19:06 BUG #15662: Row update in foreign partition does not move row based on partition key PG Bug reporting form <noreply@postgresql.org>
  2019-03-01 19:54 ` Re: BUG #15662: Row update in foreign partition does not move row based on partition key Sergei Kornilov <sk@zsrv.org>
  2019-03-04 13:57   ` Re: BUG #15662: Row update in foreign partition does not move row based on partition key Derek Hans <derek.hans@gmail.com>
@ 2019-03-04 15:12     ` Amit Langote <amitlangote09@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Amit Langote @ 2019-03-04 15:12 UTC (permalink / raw)
  To: Derek Hans <derek.hans@gmail.com>; +Cc: Sergei Kornilov <sk@zsrv.org>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hi,

On Mon, Mar 4, 2019 at 10:58 PM Derek Hans <derek.hans@gmail.com> wrote:
>
> Thanks. That's a substantial limitation.
>
> I looked pretty hard through the various pieces of documentation and tutorials and saw no mention. The v11 release notes don't mention it either. Might be worth adding to the docs in more places and more prominently.

Perhaps, it would make sense to make a note related to this in the
partitioning chapter where various limitations are listed and link to
it from the v11 release notes.

I've attached a patch. It applies to the PG 11 stable branch, but the
ddl.sgml part of the patch should also be applied to master.

Thanks,
Amit

Attachments:

document-update-row-movement-limitation.patch (application/octet-stream, 1.3K) download diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml index 7bed4f56f0..3b20e73a61 100644 --- a/doc/src/sgml/ddl.sgml +++ b/doc/src/sgml/ddl.sgml @@ -3376,6 +3376,13 @@ ALTER TABLE measurement ATTACH PARTITION measurement_y2008m02 </para> </listitem> + <listitem> + <para> + <command>UPDATE</command> row movement is not supported in the cases + where the old row is contained in a foreign table partition. + </para> + </listitem> + <listitem> <para> <literal>BEFORE ROW</literal> triggers, if necessary, must be defined diff --git a/doc/src/sgml/release-11.sgml b/doc/src/sgml/release-11.sgml index 14e2726f0c..d6fc5a3e31 100644 --- a/doc/src/sgml/release-11.sgml +++ b/doc/src/sgml/release-11.sgml @@ -2578,6 +2578,13 @@ Branch: REL9_3_STABLE [84261eb10] 2018-10-19 17:02:26 -0400 column now cause affected rows to be moved to the appropriate partitions (Amit Khandekar) </para> + + <para> + However, not all cases where such row movment would be necessary + are handled currently; see + <link linkend="ddl-partitioning-declarative-limitations">declarative + partitioning limitations</link> for more information. + </para> </listitem> <listitem>
^ permalink raw reply [nested|flat] 4+ messages in thread


end of thread, other threads:[~2019-03-04 15:12 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-03-01 19:06 BUG #15662: Row update in foreign partition does not move row based on partition key PG Bug reporting form <noreply@postgresql.org>
2019-03-01 19:54 ` Sergei Kornilov <sk@zsrv.org>
2019-03-04 13:57   ` Derek Hans <derek.hans@gmail.com>
2019-03-04 15:12     ` Amit Langote <amitlangote09@gmail.com>

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