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

From Tom Lane
Subject Re: BUG #19487: Error while executing SQL query involving XML parsing
Date
Msg-id 1589702.1787946553@sss.pgh.pa.us
Whole thread
List pgsql-bugs
Andrey Rachitskiy <pl0h0yp1@gmail.com> writes:
> # Proposal Fix
> Fold constant `XmlExpr` in `eval_const_expressions` (same path as
> `MinMaxExpr` / `ArrayExpr`), so `IS DOCUMENT` becomes a boolean Const and
> CASE drops the unused arm before simplifying `xpath()`.

I don't object to simplifying XmlExpr where possible, but this patch
appears to believe that every variant of XmlExpr is immutable.
This is demonstrably false, eg

regression=# set timezone = 'America/New_York';
SET
regression=# SELECT xmlforest('2026-08-28 12:00 UTC'::timestamptz AS foo);
              xmlforest               
--------------------------------------
 <foo>2026-08-28T08:00:00-04:00</foo>
(1 row)

regression=# set timezone = 'America/Chicago';
SET
regression=# SELECT xmlforest('2026-08-28 12:00 UTC'::timestamptz AS foo);
              xmlforest               
--------------------------------------
 <foo>2026-08-28T07:00:00-05:00</foo>
(1 row)

So you need to take a closer look at which variants can be promised to
be immutable.

            regards, tom lane



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #19641: Unexpected results on an SP-GiST indexed column with a non-deterministic collation
Next
From: PG Bug reporting form
Date:
Subject: BUG #19644: byteaout, float8out and float4out are marked IMMUTABLE but depend on GUCs