From: | Etsuro Fujita <efujita(at)postgresql(dot)org> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: postgres_fdw: Fix incorrect handling of row movement for remote |
Date: | 2019-04-24 09:52:01 |
Message-ID: | E1hJEZN-0001aM-9E@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
postgres_fdw: Fix incorrect handling of row movement for remote partitions.
Commit 3d956d9562 added support for update row movement in postgres_fdw.
This patch fixes the following issues introduced by that commit:
* When a remote partition chosen to insert routed rows into was also an
UPDATE subplan target rel that would be updated later, the UPDATE that
used a direct modification plan modified those routed rows incorrectly
because those routed rows were visible to the later UPDATE command.
The right fix for this would be to have some way in postgres_fdw in
which the later UPDATE command ignores those routed rows, but it seems
hard to do so with the current infrastructure. For now throw an error
in that case.
* When a remote partition chosen to insert routed rows into was also an
UPDATE subplan target rel, fmstate created for the UPDATE that used a
non-direct modification plan was mistakenly overridden by another
fmstate created for inserting those routed rows into the partition.
This caused 1) server crash when the partition would be updated later,
and 2) resource leak when the partition had been already updated. To
avoid that, adjust the treatment of the fmstate for the inserting. As
for #1, since we would also have the incorrectness issue as mentioned
above, error out in that case as well.
Update the docs to mention that postgres_fdw currently does not handle
the case where a remote partition chosen to insert a routed row into is
also an UPDATE subplan target rel that will be updated later.
Author: Amit Langote and Etsuro Fujita
Reviewed-by: Amit Langote
Backpatch-through: 11 where row movement in postgres_fdw was added
Discussion: https://postgr.es/m/21e7eaa4-0d4d-20c2-a1f7-c7e96f4ce440@lab.ntt.co.jp
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/5c47049180b8977154f99fdc7988d5846764afa2
Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 131 +++++++++++++++++++++++++
contrib/postgres_fdw/postgres_fdw.c | 60 ++++++++++-
contrib/postgres_fdw/sql/postgres_fdw.sql | 45 +++++++++
doc/src/sgml/postgres-fdw.sgml | 5 +
4 files changed, 239 insertions(+), 2 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Etsuro Fujita | 2019-04-24 11:54:26 | Re: pgsql: Allow insert and update tuple routing and COPY for foreign table |
Previous Message | Andres Freund | 2019-04-24 04:42:20 | pgsql: Allow pg_class xid & multixid horizons to not be set. |