Re: [HACKERS] patch: function xmltable - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: [HACKERS] patch: function xmltable
Date
Msg-id 20170124203849.2r2xzkraix6qy3i7@alvherre.pgsql
Whole thread Raw
In response to Re: [HACKERS] patch: function xmltable  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: [HACKERS] patch: function xmltable  (Andres Freund <andres@anarazel.de>)
Re: [HACKERS] patch: function xmltable  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: [HACKERS] patch: function xmltable  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
Pavel Stehule wrote:

> * SELECT (xmltable(..)).* + regress tests
> * compilation and regress tests without --with-libxml

Thanks.  I just realized that this is doing more work than necessary --
I think it would be simpler to have tableexpr fill a tuplestore with the
results, instead of just expecting function execution to apply
ExecEvalExpr over and over to obtain the results.  So evaluating a
tableexpr returns just the tuplestore, which function evaluation can
return as-is.  That code doesn't use the value-per-call interface
anyway.

I also realized that the expr context callback is not called if there's
an error, which leaves us without shutting down libxml properly.  I
added PG_TRY around the fetchrow calls, but I'm not sure that's correct
either, because there could be an error raised in other parts of the
code, after we've already emitted a few rows (for example out of
memory).  I think the right way is to have PG_TRY around the execution
of the whole thing rather than just row at a time; and the tuplestore
mechanism helps us with that.

I think it would be good to have a more complex test case in regress --
let's say there is a table with some simple XML values, then we use
XMLFOREST (or maybe one of the table_to_xml functions) to generate a
large document, and then XMLTABLE uses that document as input document.

Please fix.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: [HACKERS] PoC plpgsql - possibility to force custom or generic plan
Next
From: Robert Haas
Date:
Subject: Re: [HACKERS] Declarative partitioning - another take