Handle XmlExpr more honestly in clauses.c. eval_const_expressions() didn't constant-fold XmlExpr. In some cases it cannot, but often it can. Failure to do so can cause visible regressions in SQL-language function behavior compared to pre-v18, though only in a rather narrow set of contexts: basically, if you're trying to use a CASE to prevent evaluation of a failure-prone XML function.
While we're at it, make contain_mutable_functions() handle XmlExpr more precisely, and adjust some comments that justify not treating XmlExpr explicitly. This seems worth sneaking into v19, but I'm hesitant to put it into v18. It's not really a bug fix, because we disclaim the safety of using CASE this way, and it carries some risk of de-optimizing queries that worked satisfactorily before. Bug: #19487 Reported-by: Ilya Portnov <[email protected]> Author: Andrey Rachitskiy <[email protected]> Co-authored-by: Tom Lane <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: 19 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f3ac68ffe38692582c24880ef10cc365ec683fa6 Modified Files -------------- src/backend/optimizer/util/clauses.c | 83 +++++++++++++++++++++++++++++++----- src/test/regress/expected/xml.out | 11 +++++ src/test/regress/sql/xml.sql | 7 +++ 3 files changed, 90 insertions(+), 11 deletions(-)
