Re: BUG #19487: Error while executing SQL query involving XML parsing

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>
Cc: i(dot)portnov(at)compassplus(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19487: Error while executing SQL query involving XML parsing
Date: 2026-08-28 19:49:13
Message-ID: 1589702.1787946553@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrey Rachitskiy 2026-08-28 19:55:37 Re: BUG #19487: Error while executing SQL query involving XML parsing
Previous Message Andrey Rachitskiy 2026-08-28 19:38:44 Re: BUG #19641: Unexpected results on an SP-GiST indexed column with a non-deterministic collation