agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
pgsql: Deparse FOR PORTION OF using the range column's current name.
2+ messages / 1 participants
[nested] [flat]

* pgsql: Deparse FOR PORTION OF using the range column's current name.
@ 2026-07-27 13:37  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2026-07-27 13:37 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Deparse FOR PORTION OF using the range column's current name.

Commit 8e72d914c recorded the range column's name in ForPortionOfExpr
and used that for deparsing FOR PORTION OF.  This gives the wrong
answer if the ForPortionOfExpr is saved in a rule or SQL function and
then the column gets renamed.  Drop the ForPortionOfExpr.range_name
field; instead fetch the current column name from the catalogs when
needed.

Also drop ForPortionOfState.fp_rangeName, which wasn't being used
anywhere.

Full disclosure: an earlier draft of this patch was made with
Claude Opus 4.8.

Reported-by: John Naylor <johncnaylorls@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CANWCAZYFEpJ5Oi45gi4q9Y6LYa4_oiAXxuNNWe-1ym-i0fF8Pw@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7090c696cc9ea96a278e679e8bbfe9b051740105

Modified Files
--------------
src/backend/executor/nodeModifyTable.c       |  2 --
src/backend/optimizer/plan/planner.c         |  4 +++-
src/backend/parser/analyze.c                 |  1 -
src/backend/utils/adt/ruleutils.c            | 15 +++++++++----
src/include/catalog/catversion.h             |  2 +-
src/include/nodes/execnodes.h                |  1 -
src/include/nodes/primnodes.h                |  1 -
src/test/regress/expected/for_portion_of.out | 33 ++++++++++++++++++++++++++++
src/test/regress/sql/for_portion_of.sql      | 16 ++++++++++++++
9 files changed, 64 insertions(+), 11 deletions(-)



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

* pgsql: Deparse FOR PORTION OF using the range column's current name.
@ 2026-07-27 13:37  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2026-07-27 13:37 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Deparse FOR PORTION OF using the range column's current name.

Commit 8e72d914c recorded the range column's name in ForPortionOfExpr
and used that for deparsing FOR PORTION OF.  This gives the wrong
answer if the ForPortionOfExpr is saved in a rule or SQL function and
then the column gets renamed.  Drop the ForPortionOfExpr.range_name
field; instead fetch the current column name from the catalogs when
needed.

Also drop ForPortionOfState.fp_rangeName, which wasn't being used
anywhere.

Full disclosure: an earlier draft of this patch was made with
Claude Opus 4.8.

Reported-by: John Naylor <johncnaylorls@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CANWCAZYFEpJ5Oi45gi4q9Y6LYa4_oiAXxuNNWe-1ym-i0fF8Pw@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2a9541ddfd3a5b069c505e36a91f289126871a21

Modified Files
--------------
src/backend/executor/nodeModifyTable.c       |  2 --
src/backend/optimizer/plan/planner.c         |  4 +++-
src/backend/parser/analyze.c                 |  1 -
src/backend/utils/adt/ruleutils.c            | 15 +++++++++----
src/include/catalog/catversion.h             |  2 +-
src/include/nodes/execnodes.h                |  1 -
src/include/nodes/primnodes.h                |  1 -
src/test/regress/expected/for_portion_of.out | 33 ++++++++++++++++++++++++++++
src/test/regress/sql/for_portion_of.sql      | 16 ++++++++++++++
9 files changed, 64 insertions(+), 11 deletions(-)



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


end of thread, other threads:[~2026-07-27 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-07-27 13:37 pgsql: Deparse FOR PORTION OF using the range column's current name. Tom Lane <tgl@sss.pgh.pa.us>
2026-07-27 13:37 pgsql: Deparse FOR PORTION OF using the range column's current name. Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox