pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Repair bogus handling of multi-assignment Params in upper plan l
5+ messages / 1 participants
[nested] [flat]

* pgsql: Repair bogus handling of multi-assignment Params in upper plan l
@ 2018-12-12 18:50 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2018-12-12 18:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Repair bogus handling of multi-assignment Params in upper plan levels.

Our support for multiple-set-clauses in UPDATE assumes that the Params
referencing a MULTIEXPR_SUBLINK SubPlan will appear before that SubPlan
in the targetlist of the plan node that calculates the updated row.
(Yeah, it's a hack...)  In some PG branches it's possible that a Result
node gets inserted between the primary calculation of the update tlist
and the ModifyTable node.  setrefs.c did the wrong thing in this case
and left the upper-level Params as Params, causing a crash at runtime.
What it should do is replace them with "outer" Vars referencing the child
plan node's output.  That's a result of careless ordering of operations
in fix_upper_expr_mutator, so we can fix it just by reordering the code.

Fix fix_join_expr_mutator similarly for consistency, even though join
nodes could never appear in such a context.  (In general, it seems
likely to be a bit cheaper to use Vars than Params in such situations
anyway, so this patch might offer a tiny performance improvement.)

The hazard extends back to 9.5 where the MULTIEXPR_SUBLINK stuff
was introduced, so back-patch that far.  However, this may be a live
bug only in 9.6.x and 10.x, as the other branches don't seem to want
to calculate the final tlist below the Result node.  (That plan shape
change between branches might be a mini-bug in itself, but I'm not
really interested in digging into the reasons for that right now.
Still, add a regression test memorializing what we expect there,
so we'll notice if it changes again.)

Per bug report from Eduards Bezverhijs.

Discussion: https://postgr.es/m/b6cd572a-3e44-8785-75e9-c512a5a17a73@tieto.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0f7ec8d9c3aeb8964d3539561e5c8d4caef42bf6

Modified Files
--------------
src/backend/optimizer/plan/setrefs.c | 24 +++++++++++++-----------
src/test/regress/expected/update.out | 31 +++++++++++++++++++++++++++++++
src/test/regress/sql/update.sql      | 10 ++++++++++
3 files changed, 54 insertions(+), 11 deletions(-)



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

* pgsql: Repair bogus handling of multi-assignment Params in upper plan l
@ 2018-12-12 18:50 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2018-12-12 18:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Repair bogus handling of multi-assignment Params in upper plan levels.

Our support for multiple-set-clauses in UPDATE assumes that the Params
referencing a MULTIEXPR_SUBLINK SubPlan will appear before that SubPlan
in the targetlist of the plan node that calculates the updated row.
(Yeah, it's a hack...)  In some PG branches it's possible that a Result
node gets inserted between the primary calculation of the update tlist
and the ModifyTable node.  setrefs.c did the wrong thing in this case
and left the upper-level Params as Params, causing a crash at runtime.
What it should do is replace them with "outer" Vars referencing the child
plan node's output.  That's a result of careless ordering of operations
in fix_upper_expr_mutator, so we can fix it just by reordering the code.

Fix fix_join_expr_mutator similarly for consistency, even though join
nodes could never appear in such a context.  (In general, it seems
likely to be a bit cheaper to use Vars than Params in such situations
anyway, so this patch might offer a tiny performance improvement.)

The hazard extends back to 9.5 where the MULTIEXPR_SUBLINK stuff
was introduced, so back-patch that far.  However, this may be a live
bug only in 9.6.x and 10.x, as the other branches don't seem to want
to calculate the final tlist below the Result node.  (That plan shape
change between branches might be a mini-bug in itself, but I'm not
really interested in digging into the reasons for that right now.
Still, add a regression test memorializing what we expect there,
so we'll notice if it changes again.)

Per bug report from Eduards Bezverhijs.

Discussion: https://postgr.es/m/b6cd572a-3e44-8785-75e9-c512a5a17a73@tieto.com

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/302d4eee933ec76ef91575d6129558caa64307ca

Modified Files
--------------
src/backend/optimizer/plan/setrefs.c | 24 +++++++++++++-----------
src/test/regress/expected/update.out | 31 +++++++++++++++++++++++++++++++
src/test/regress/sql/update.sql      | 10 ++++++++++
3 files changed, 54 insertions(+), 11 deletions(-)



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

* pgsql: Repair bogus handling of multi-assignment Params in upper plan l
@ 2018-12-12 18:50 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2018-12-12 18:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Repair bogus handling of multi-assignment Params in upper plan levels.

Our support for multiple-set-clauses in UPDATE assumes that the Params
referencing a MULTIEXPR_SUBLINK SubPlan will appear before that SubPlan
in the targetlist of the plan node that calculates the updated row.
(Yeah, it's a hack...)  In some PG branches it's possible that a Result
node gets inserted between the primary calculation of the update tlist
and the ModifyTable node.  setrefs.c did the wrong thing in this case
and left the upper-level Params as Params, causing a crash at runtime.
What it should do is replace them with "outer" Vars referencing the child
plan node's output.  That's a result of careless ordering of operations
in fix_upper_expr_mutator, so we can fix it just by reordering the code.

Fix fix_join_expr_mutator similarly for consistency, even though join
nodes could never appear in such a context.  (In general, it seems
likely to be a bit cheaper to use Vars than Params in such situations
anyway, so this patch might offer a tiny performance improvement.)

The hazard extends back to 9.5 where the MULTIEXPR_SUBLINK stuff
was introduced, so back-patch that far.  However, this may be a live
bug only in 9.6.x and 10.x, as the other branches don't seem to want
to calculate the final tlist below the Result node.  (That plan shape
change between branches might be a mini-bug in itself, but I'm not
really interested in digging into the reasons for that right now.
Still, add a regression test memorializing what we expect there,
so we'll notice if it changes again.)

Per bug report from Eduards Bezverhijs.

Discussion: https://postgr.es/m/b6cd572a-3e44-8785-75e9-c512a5a17a73@tieto.com

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f9f63ed1f2e5c654926fdb44beabab8ff28e0387

Modified Files
--------------
src/backend/optimizer/plan/setrefs.c | 24 +++++++++++++-----------
src/test/regress/expected/update.out | 31 +++++++++++++++++++++++++++++++
src/test/regress/sql/update.sql      | 10 ++++++++++
3 files changed, 54 insertions(+), 11 deletions(-)



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

* pgsql: Repair bogus handling of multi-assignment Params in upper plan l
@ 2018-12-12 18:50 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2018-12-12 18:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Repair bogus handling of multi-assignment Params in upper plan levels.

Our support for multiple-set-clauses in UPDATE assumes that the Params
referencing a MULTIEXPR_SUBLINK SubPlan will appear before that SubPlan
in the targetlist of the plan node that calculates the updated row.
(Yeah, it's a hack...)  In some PG branches it's possible that a Result
node gets inserted between the primary calculation of the update tlist
and the ModifyTable node.  setrefs.c did the wrong thing in this case
and left the upper-level Params as Params, causing a crash at runtime.
What it should do is replace them with "outer" Vars referencing the child
plan node's output.  That's a result of careless ordering of operations
in fix_upper_expr_mutator, so we can fix it just by reordering the code.

Fix fix_join_expr_mutator similarly for consistency, even though join
nodes could never appear in such a context.  (In general, it seems
likely to be a bit cheaper to use Vars than Params in such situations
anyway, so this patch might offer a tiny performance improvement.)

The hazard extends back to 9.5 where the MULTIEXPR_SUBLINK stuff
was introduced, so back-patch that far.  However, this may be a live
bug only in 9.6.x and 10.x, as the other branches don't seem to want
to calculate the final tlist below the Result node.  (That plan shape
change between branches might be a mini-bug in itself, but I'm not
really interested in digging into the reasons for that right now.
Still, add a regression test memorializing what we expect there,
so we'll notice if it changes again.)

Per bug report from Eduards Bezverhijs.

Discussion: https://postgr.es/m/b6cd572a-3e44-8785-75e9-c512a5a17a73@tieto.com

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/10bad8c0f02e43dd2448316c4658f50b75f9cba8

Modified Files
--------------
src/backend/optimizer/plan/setrefs.c | 24 +++++++++++++-----------
src/test/regress/expected/update.out | 31 +++++++++++++++++++++++++++++++
src/test/regress/sql/update.sql      | 10 ++++++++++
3 files changed, 54 insertions(+), 11 deletions(-)



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

* pgsql: Repair bogus handling of multi-assignment Params in upper plan l
@ 2018-12-12 18:50 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2018-12-12 18:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Repair bogus handling of multi-assignment Params in upper plan levels.

Our support for multiple-set-clauses in UPDATE assumes that the Params
referencing a MULTIEXPR_SUBLINK SubPlan will appear before that SubPlan
in the targetlist of the plan node that calculates the updated row.
(Yeah, it's a hack...)  In some PG branches it's possible that a Result
node gets inserted between the primary calculation of the update tlist
and the ModifyTable node.  setrefs.c did the wrong thing in this case
and left the upper-level Params as Params, causing a crash at runtime.
What it should do is replace them with "outer" Vars referencing the child
plan node's output.  That's a result of careless ordering of operations
in fix_upper_expr_mutator, so we can fix it just by reordering the code.

Fix fix_join_expr_mutator similarly for consistency, even though join
nodes could never appear in such a context.  (In general, it seems
likely to be a bit cheaper to use Vars than Params in such situations
anyway, so this patch might offer a tiny performance improvement.)

The hazard extends back to 9.5 where the MULTIEXPR_SUBLINK stuff
was introduced, so back-patch that far.  However, this may be a live
bug only in 9.6.x and 10.x, as the other branches don't seem to want
to calculate the final tlist below the Result node.  (That plan shape
change between branches might be a mini-bug in itself, but I'm not
really interested in digging into the reasons for that right now.
Still, add a regression test memorializing what we expect there,
so we'll notice if it changes again.)

Per bug report from Eduards Bezverhijs.

Discussion: https://postgr.es/m/b6cd572a-3e44-8785-75e9-c512a5a17a73@tieto.com

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6548d62a98f9801fa0e6c1528568560f1b218477

Modified Files
--------------
src/backend/optimizer/plan/setrefs.c | 10 ++++++----
src/test/regress/expected/update.out | 31 +++++++++++++++++++++++++++++++
src/test/regress/sql/update.sql      | 10 ++++++++++
3 files changed, 47 insertions(+), 4 deletions(-)



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


end of thread, other threads:[~2018-12-12 18:50 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-12-12 18:50 pgsql: Repair bogus handling of multi-assignment Params in upper plan l Tom Lane <tgl@sss.pgh.pa.us>
2018-12-12 18:50 pgsql: Repair bogus handling of multi-assignment Params in upper plan l Tom Lane <tgl@sss.pgh.pa.us>
2018-12-12 18:50 pgsql: Repair bogus handling of multi-assignment Params in upper plan l Tom Lane <tgl@sss.pgh.pa.us>
2018-12-12 18:50 pgsql: Repair bogus handling of multi-assignment Params in upper plan l Tom Lane <tgl@sss.pgh.pa.us>
2018-12-12 18:50 pgsql: Repair bogus handling of multi-assignment Params in upper plan l 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