pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix creation of resjunk tlist entries for inherited mixed UPDATE 4+ messages / 1 participants [nested] [flat]
* pgsql: Fix creation of resjunk tlist entries for inherited mixed UPDATE @ 2017-11-27 22:54 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2017-11-27 22:54 UTC (permalink / raw) To: pgsql-committers Fix creation of resjunk tlist entries for inherited mixed UPDATE/DELETE. rewriteTargetListUD's processing is dependent on the relkind of the query's target table. That was fine at the time it was made to act that way, even for queries on inheritance trees, because all tables in an inheritance tree would necessarily be plain tables. However, the 9.5 feature addition allowing some members of an inheritance tree to be foreign tables broke the assumption that rewriteTargetListUD's output tlist could be applied to all child tables with nothing more than column-number mapping. This led to visible failures if foreign child tables had row-level triggers, and would also break in cases where child tables belonged to FDWs that used methods other than CTID for row identification. To fix, delay running rewriteTargetListUD until after the planner has expanded inheritance, so that it is applied separately to the (already mapped) tlist for each child table. We can conveniently call it from preprocess_targetlist. Refactor associated code slightly to avoid the need to heap_open the target relation multiple times during preprocess_targetlist. (The APIs remain a bit ugly, particularly around the point of which steps scribble on parse->targetList and which don't. But avoiding such scribbling would require a change in FDW callback APIs, which is more pain than it's worth.) Also fix ExecModifyTable to ensure that "tupleid" is reset to NULL when we transition from rows providing a CTID to rows that don't. (That's really an independent bug, but it manifests in much the same cases.) Add a regression test checking one manifestation of this problem, which was that row-level triggers on a foreign child table did not work right. Back-patch to 9.5 where the problem was introduced. Etsuro Fujita, reviewed by Ildus Kurbangaliev and Ashutosh Bapat Discussion: https://postgr.es/m/20170514150525.0346ba72@postgrespro.ru Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a57aa430b613250270cf5cc78a34a3454e61acda Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 57 ++++++++++++++ contrib/postgres_fdw/sql/postgres_fdw.sql | 18 +++++ doc/src/sgml/fdwhandler.sgml | 7 +- doc/src/sgml/rules.sgml | 8 +- src/backend/executor/nodeModifyTable.c | 3 +- src/backend/optimizer/plan/planner.c | 10 +-- src/backend/optimizer/prep/preptlist.c | 101 +++++++++++++++---------- src/backend/rewrite/rewriteHandler.c | 74 ++++++++---------- src/include/optimizer/prep.h | 5 +- src/include/rewrite/rewriteHandler.h | 3 + 10 files changed, 185 insertions(+), 101 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix creation of resjunk tlist entries for inherited mixed UPDATE @ 2017-11-27 22:54 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2017-11-27 22:54 UTC (permalink / raw) To: pgsql-committers Fix creation of resjunk tlist entries for inherited mixed UPDATE/DELETE. rewriteTargetListUD's processing is dependent on the relkind of the query's target table. That was fine at the time it was made to act that way, even for queries on inheritance trees, because all tables in an inheritance tree would necessarily be plain tables. However, the 9.5 feature addition allowing some members of an inheritance tree to be foreign tables broke the assumption that rewriteTargetListUD's output tlist could be applied to all child tables with nothing more than column-number mapping. This led to visible failures if foreign child tables had row-level triggers, and would also break in cases where child tables belonged to FDWs that used methods other than CTID for row identification. To fix, delay running rewriteTargetListUD until after the planner has expanded inheritance, so that it is applied separately to the (already mapped) tlist for each child table. We can conveniently call it from preprocess_targetlist. Refactor associated code slightly to avoid the need to heap_open the target relation multiple times during preprocess_targetlist. (The APIs remain a bit ugly, particularly around the point of which steps scribble on parse->targetList and which don't. But avoiding such scribbling would require a change in FDW callback APIs, which is more pain than it's worth.) Also fix ExecModifyTable to ensure that "tupleid" is reset to NULL when we transition from rows providing a CTID to rows that don't. (That's really an independent bug, but it manifests in much the same cases.) Add a regression test checking one manifestation of this problem, which was that row-level triggers on a foreign child table did not work right. Back-patch to 9.5 where the problem was introduced. Etsuro Fujita, reviewed by Ildus Kurbangaliev and Ashutosh Bapat Discussion: https://postgr.es/m/20170514150525.0346ba72@postgrespro.ru Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/06ba5309682e32c997e22563c3a9184fba5131d9 Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 57 ++++++++++++++ contrib/postgres_fdw/sql/postgres_fdw.sql | 18 +++++ doc/src/sgml/fdwhandler.sgml | 7 +- doc/src/sgml/rules.sgml | 8 +- src/backend/executor/nodeModifyTable.c | 3 +- src/backend/optimizer/plan/planner.c | 10 +-- src/backend/optimizer/prep/preptlist.c | 101 +++++++++++++++---------- src/backend/rewrite/rewriteHandler.c | 74 ++++++++---------- src/include/optimizer/prep.h | 5 +- src/include/rewrite/rewriteHandler.h | 3 + 10 files changed, 185 insertions(+), 101 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix creation of resjunk tlist entries for inherited mixed UPDATE @ 2017-11-27 22:54 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2017-11-27 22:54 UTC (permalink / raw) To: pgsql-committers Fix creation of resjunk tlist entries for inherited mixed UPDATE/DELETE. rewriteTargetListUD's processing is dependent on the relkind of the query's target table. That was fine at the time it was made to act that way, even for queries on inheritance trees, because all tables in an inheritance tree would necessarily be plain tables. However, the 9.5 feature addition allowing some members of an inheritance tree to be foreign tables broke the assumption that rewriteTargetListUD's output tlist could be applied to all child tables with nothing more than column-number mapping. This led to visible failures if foreign child tables had row-level triggers, and would also break in cases where child tables belonged to FDWs that used methods other than CTID for row identification. To fix, delay running rewriteTargetListUD until after the planner has expanded inheritance, so that it is applied separately to the (already mapped) tlist for each child table. We can conveniently call it from preprocess_targetlist. Refactor associated code slightly to avoid the need to heap_open the target relation multiple times during preprocess_targetlist. (The APIs remain a bit ugly, particularly around the point of which steps scribble on parse->targetList and which don't. But avoiding such scribbling would require a change in FDW callback APIs, which is more pain than it's worth.) Also fix ExecModifyTable to ensure that "tupleid" is reset to NULL when we transition from rows providing a CTID to rows that don't. (That's really an independent bug, but it manifests in much the same cases.) Add a regression test checking one manifestation of this problem, which was that row-level triggers on a foreign child table did not work right. Back-patch to 9.5 where the problem was introduced. Etsuro Fujita, reviewed by Ildus Kurbangaliev and Ashutosh Bapat Discussion: https://postgr.es/m/20170514150525.0346ba72@postgrespro.ru Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/39f180fdd1e68bf6a897c6ab8733014e74f56973 Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 65 ++++++++++++++++ contrib/postgres_fdw/sql/postgres_fdw.sql | 18 +++++ doc/src/sgml/fdwhandler.sgml | 7 +- doc/src/sgml/rules.sgml | 8 +- src/backend/executor/nodeModifyTable.c | 3 +- src/backend/optimizer/plan/planner.c | 16 +--- src/backend/optimizer/prep/preptlist.c | 102 +++++++++++++++++-------- src/backend/rewrite/rewriteHandler.c | 74 ++++++++---------- src/include/optimizer/prep.h | 5 +- src/include/rewrite/rewriteHandler.h | 3 + 10 files changed, 202 insertions(+), 99 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix creation of resjunk tlist entries for inherited mixed UPDATE @ 2017-11-27 22:54 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2017-11-27 22:54 UTC (permalink / raw) To: pgsql-committers Fix creation of resjunk tlist entries for inherited mixed UPDATE/DELETE. rewriteTargetListUD's processing is dependent on the relkind of the query's target table. That was fine at the time it was made to act that way, even for queries on inheritance trees, because all tables in an inheritance tree would necessarily be plain tables. However, the 9.5 feature addition allowing some members of an inheritance tree to be foreign tables broke the assumption that rewriteTargetListUD's output tlist could be applied to all child tables with nothing more than column-number mapping. This led to visible failures if foreign child tables had row-level triggers, and would also break in cases where child tables belonged to FDWs that used methods other than CTID for row identification. To fix, delay running rewriteTargetListUD until after the planner has expanded inheritance, so that it is applied separately to the (already mapped) tlist for each child table. We can conveniently call it from preprocess_targetlist. Refactor associated code slightly to avoid the need to heap_open the target relation multiple times during preprocess_targetlist. (The APIs remain a bit ugly, particularly around the point of which steps scribble on parse->targetList and which don't. But avoiding such scribbling would require a change in FDW callback APIs, which is more pain than it's worth.) Also fix ExecModifyTable to ensure that "tupleid" is reset to NULL when we transition from rows providing a CTID to rows that don't. (That's really an independent bug, but it manifests in much the same cases.) Add a regression test checking one manifestation of this problem, which was that row-level triggers on a foreign child table did not work right. Back-patch to 9.5 where the problem was introduced. Etsuro Fujita, reviewed by Ildus Kurbangaliev and Ashutosh Bapat Discussion: https://postgr.es/m/20170514150525.0346ba72@postgrespro.ru Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/9a785ad573176b88a93563209980fbe80cd72163 Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 57 ++++++++++++++ contrib/postgres_fdw/sql/postgres_fdw.sql | 18 +++++ doc/src/sgml/fdwhandler.sgml | 7 +- doc/src/sgml/rules.sgml | 8 +- src/backend/executor/nodeModifyTable.c | 3 +- src/backend/optimizer/plan/planner.c | 10 +-- src/backend/optimizer/prep/preptlist.c | 101 +++++++++++++++---------- src/backend/rewrite/rewriteHandler.c | 74 ++++++++---------- src/include/optimizer/prep.h | 5 +- src/include/rewrite/rewriteHandler.h | 3 + 10 files changed, 185 insertions(+), 101 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2017-11-27 22:54 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2017-11-27 22:54 pgsql: Fix creation of resjunk tlist entries for inherited mixed UPDATE Tom Lane <tgl@sss.pgh.pa.us> 2017-11-27 22:54 pgsql: Fix creation of resjunk tlist entries for inherited mixed UPDATE Tom Lane <tgl@sss.pgh.pa.us> 2017-11-27 22:54 pgsql: Fix creation of resjunk tlist entries for inherited mixed UPDATE Tom Lane <tgl@sss.pgh.pa.us> 2017-11-27 22:54 pgsql: Fix creation of resjunk tlist entries for inherited mixed UPDATE Tom Lane <tgl@sss.pgh.pa.us>
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