| From: | Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> |
|---|---|
| To: | Kirill Reshke <reshkekirill(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Add CHECK_FOR_INTERRUPTS() to XPath result serialisation |
| Date: | 2026-11-25 08:15:15 |
| Message-ID: | 497dac98-ecba-4527-af15-45d9e141a915@uni-muenster.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Kirill
On 25/11/2026 06:05, Kirill Reshke wrote:
> I think, if patched hunks are related to frequently-used XML features,
> it's good to fix them. Otherwise it would bloat the codebase, huh?
The overhead here is negligible. At least I was unable to measure
anything significant.
create table t (doc xml);
insert into t values (('<r>' || repeat(repeat('<a>', 250) ||
repeat('</a>', 250), 4000) || '</r>')::xml);
== patched ==
postgres=# select xpath('//a', doc) is null from t;
?column?
----------
f
(1 row)
Time: 13281,557 ms (00:13,282)
== master ==
postgres=# \timing on
Timing is on.
postgres=# select xpath('//a', doc) is null from t;
?column?
----------
f
(1 row)
Time: 13260,056 ms (00:13,260)
> Not much in context here, but it looks like places can be frequently hit.
> Also, are there more places to cover? For example, can
> escape_xml/xmlelement take long?
I'd argue that it does not apply to escape_xml. In this case, it's a
linear pass over a single string, and in case the input is too large,
the 1GB limit kicks in:
postgres=# \timing on
Timing is on.
postgres=# select length(xmlelement(name a, repeat('&',
1000000000))::text);
ERROR: string buffer exceeds maximum allowed length (1073741823 bytes)
DETAIL: Cannot enlarge string buffer containing 1073741820 bytes by 5
more bytes.
Time: 5462,958 ms (00:05,463)
Arrays passed to xmlelement are a different story, since
map_sql_value_to_xml_value() loops over every element. While testing it,
I managed to get the backend killed (OOM) with a large array.. but I
suggest we look into it in a different thread, since it needs more than
a CHECK_FOR_INTERRUPTS().
WDYT?
Thanks for the review!
Best, Jim
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ayush Tiwari | 2026-11-25 08:18:26 | Re: Fix leftover data handling and simplify read conditions in copy_read_data() |
| Previous Message | Ajin Cherian | 2026-11-25 08:14:13 | Re: BUG? Unpublished generated columns are reported "missing" by the subscription |