Don't let JSON constructor coercions block SQL function inlining

contain_context_dependent_node_walker() reports a CaseTestExpr as
context-dependent unless it sits under a simple CaseExpr or the
elemexpr of an ArrayCoerceExpr.  A JsonConstructorExpr whose RETURNING
type requires a coercion also carries a CaseTestExpr placeholder in
that coercion, so any SQL function called with such a constructor as
an argument was refused inlining.

Teach the walker that a CaseTestExpr is expected within the coercion
of a JsonConstructorExpr, the same way it already handles the elemexpr
of an ArrayCoerceExpr.  This is safe now that eval_const_expressions
no longer lets an enclosing simple CASE clobber that placeholder.

Author: Richard Guo <[email protected]>
Discussion: 
https://postgr.es/m/CAMbWs48A=vcfbtetkucokno1_0-cu0ambt0m07dm7vj1qyi...@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9e9dc104badf49c1f2e536ca3468e0f64f9a44a5

Modified Files
--------------
src/backend/optimizer/util/clauses.c  | 23 ++++++++++++++++++++++-
src/test/regress/expected/sqljson.out | 18 ++++++++++++++++++
src/test/regress/sql/sqljson.sql      |  8 ++++++++
3 files changed, 48 insertions(+), 1 deletion(-)

Reply via email to