Re: BUG #19487: Error while executing SQL query involving XML parsing - Mailing list pgsql-bugs

From Andrey Rachitskiy
Subject Re: BUG #19487: Error while executing SQL query involving XML parsing
Date
Msg-id CAB8bMivZXRRpbjo5vjDsz0RofixSDRUa4q1VsAsEKDUQX9h28A@mail.gmail.com
Whole thread
In response to Re: BUG #19487: Error while executing SQL query involving XML parsing  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BTree index corruption (heap-tid-past-end, unexpected zero page, misplaced TID in posting list) recurring on high-churn tables, PG 18.3, data_checksums=on, no preceding crash
List pgsql-bugs

вс, 30 авг. 2026 г. в 23:04, Tom Lane <tgl@sss.pgh.pa.us>:
Andrey Rachitskiy <pl0h0yp1@gmail.com> writes:
> I think you're right. Fixed it in v3.

I spent some time looking at this, and felt that what we really
ought to do is update clauses.c's handling of XmlExpr across the
board.  In particular, contain_mutable_functions really shouldn't
allow XmlExpr in cases where we know it's not immutable.  So more
or less as attached, where I also spent more effort on the comments.

I agree with handling XmlExpr more consistently. Using the same xmlexpr_is_immutable check for both constant folding and contain_mutable_functions looks right, including the estimate path.

LGTM

I've got mixed emotions about back-patching this.  It's not really
a bug fix, because we already disclaim the safety of relying on
CASE for this purpose, cf [1].  I think it might still be reasonable
to sneak into v19, but I'm unsure that putting it into 18 is a good
idea.

                        regards, tom lane

[1] https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-EXPRESS-EVAL

On back-patching: I share the hesitation about 18. At the same time, SQL-language functions with this pattern did work on earlier branches and broke for some users after the plan-cache change in 18. I would be fine with putting it into 19 and master. If we back-patch to 18, I would treat it as a narrow regression fix rather than a semantic promise about CASE. Either way works for me.

Thank you for your time and for all the work you've put into this.

--
Regards,
Rachitskiy Andrey

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #19595: Three memory-safety defects in src/backend/tsearch/spell.c (dictionary loader), PG 18.3
Next
From: Christophe Pettus
Date:
Subject: Re: REPACK (CONCURRENTLY) doesn't handle invalid indexes