agora inbox for pgsql-committers@postgresql.orghelp / color / mirror / Atom feed
pgsql: Fix estimate_array_length error with set-operation array coercio 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix estimate_array_length error with set-operation array coercio @ 2026-04-11 07:42 Richard Guo <rguo@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Richard Guo @ 2026-04-11 07:42 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix estimate_array_length error with set-operation array coercions When a nested set operation's output type doesn't match the parent's expected type, recurse_set_operations builds a projection target list using generate_setop_tlist with varno 0. If the required type coercion involves an ArrayCoerceExpr, estimate_array_length could be called on such a Var, and would pass it to examine_variable, which errors in find_base_rel because varno 0 has no valid relation entry. Fix by skipping the statistics lookup for Vars with varno 0. Bug introduced by commit 9391f7152. Back-patch to v17, where estimate_array_length was taught to use statistics. Reported-by: Justin Pryzby <pryzby@telsasoft.com> Author: Tender Wang <tndrwang@gmail.com> Reviewed-by: Richard Guo <guofenglinux@gmail.com> Discussion: https://postgr.es/m/adjW8rfPDkplC7lF@pryzbyj2023 Backpatch-through: 17 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/77d0e82e58854cfa5e2c4f365a97f16c0d91c394 Modified Files -------------- src/backend/utils/adt/selfuncs.c | 12 ++++++++++++ src/test/regress/expected/union.out | 17 +++++++++++++++++ src/test/regress/sql/union.sql | 4 ++++ 3 files changed, 33 insertions(+) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix estimate_array_length error with set-operation array coercio @ 2026-04-11 07:42 Richard Guo <rguo@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Richard Guo @ 2026-04-11 07:42 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix estimate_array_length error with set-operation array coercions When a nested set operation's output type doesn't match the parent's expected type, recurse_set_operations builds a projection target list using generate_setop_tlist with varno 0. If the required type coercion involves an ArrayCoerceExpr, estimate_array_length could be called on such a Var, and would pass it to examine_variable, which errors in find_base_rel because varno 0 has no valid relation entry. Fix by skipping the statistics lookup for Vars with varno 0. Bug introduced by commit 9391f7152. Back-patch to v17, where estimate_array_length was taught to use statistics. Reported-by: Justin Pryzby <pryzby@telsasoft.com> Author: Tender Wang <tndrwang@gmail.com> Reviewed-by: Richard Guo <guofenglinux@gmail.com> Discussion: https://postgr.es/m/adjW8rfPDkplC7lF@pryzbyj2023 Backpatch-through: 17 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/13e20d1c9d99516d13f3ee0dc164168a74cde0df Modified Files -------------- src/backend/utils/adt/selfuncs.c | 12 ++++++++++++ src/test/regress/expected/union.out | 17 +++++++++++++++++ src/test/regress/sql/union.sql | 4 ++++ 3 files changed, 33 insertions(+) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix estimate_array_length error with set-operation array coercio @ 2026-04-11 07:42 Richard Guo <rguo@postgresql.org> 0 siblings, 0 replies; 3+ messages in thread From: Richard Guo @ 2026-04-11 07:42 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix estimate_array_length error with set-operation array coercions When a nested set operation's output type doesn't match the parent's expected type, recurse_set_operations builds a projection target list using generate_setop_tlist with varno 0. If the required type coercion involves an ArrayCoerceExpr, estimate_array_length could be called on such a Var, and would pass it to examine_variable, which errors in find_base_rel because varno 0 has no valid relation entry. Fix by skipping the statistics lookup for Vars with varno 0. Bug introduced by commit 9391f7152. Back-patch to v17, where estimate_array_length was taught to use statistics. Reported-by: Justin Pryzby <pryzby@telsasoft.com> Author: Tender Wang <tndrwang@gmail.com> Reviewed-by: Richard Guo <guofenglinux@gmail.com> Discussion: https://postgr.es/m/adjW8rfPDkplC7lF@pryzbyj2023 Backpatch-through: 17 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/93ed18720105ebacfd2a2bdeb55bf33feaf2ec80 Modified Files -------------- src/backend/utils/adt/selfuncs.c | 12 ++++++++++++ src/test/regress/expected/union.out | 17 +++++++++++++++++ src/test/regress/sql/union.sql | 4 ++++ 3 files changed, 33 insertions(+) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-04-11 07:42 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-04-11 07:42 pgsql: Fix estimate_array_length error with set-operation array coercio Richard Guo <rguo@postgresql.org> 2026-04-11 07:42 pgsql: Fix estimate_array_length error with set-operation array coercio Richard Guo <rguo@postgresql.org> 2026-04-11 07:42 pgsql: Fix estimate_array_length error with set-operation array coercio Richard Guo <rguo@postgresql.org>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox