Thread: BUG #13810: cursor_to_xml ignores tableforest parameter

BUG #13810: cursor_to_xml ignores tableforest parameter

From
filip@jirsak.org
Date:
The following bug has been logged on the website:

Bug reference:      13810
Logged by:          Filip Jirsák
Email address:      filip@jirsak.org
PostgreSQL version: 9.4.5
Operating system:   x86_64-pc-linux-gnu
Description:

CREATE FUNCTION test_cursor_to_xml() RETURNS xml AS $$
DECLARE
    curs CURSOR FOR SELECT generate_series(1, 5);
BEGIN
  OPEN curs;
  RETURN cursor_to_xml(curs, 10, TRUE, FALSE, '');
END;
$$ LANGUAGE plpgsql;

SELECT test_cursor_to_xml();


This returns XML forrest instead of XML document with single root.

Re: BUG #13810: cursor_to_xml ignores tableforest parameter

From
Peter Eisentraut
Date:
On 12/9/15 9:07 AM, filip@jirsak.org wrote:
> CREATE FUNCTION test_cursor_to_xml() RETURNS xml AS $$
> DECLARE
>     curs CURSOR FOR SELECT generate_series(1, 5);
> BEGIN
>   OPEN curs;
>   RETURN cursor_to_xml(curs, 10, TRUE, FALSE, '');
> END;
> $$ LANGUAGE plpgsql;
>
> SELECT test_cursor_to_xml();
>
>
> This returns XML forrest instead of XML document with single root.

You're right, this should have a <table>...</table> around it, like
query_to_xml() does.

--
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Re: BUG #13810: cursor_to_xml ignores tableforest parameter

From
Thomas Munro
Date:
On Wed, Aug 3, 2016 at 5:48 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
> On 12/9/15 9:07 AM, filip@jirsak.org wrote:
>> CREATE FUNCTION test_cursor_to_xml() RETURNS xml AS $$
>> DECLARE
>>     curs CURSOR FOR SELECT generate_series(1, 5);
>> BEGIN
>>   OPEN curs;
>>   RETURN cursor_to_xml(curs, 10, TRUE, FALSE, '');
>> END;
>> $$ LANGUAGE plpgsql;
>>
>> SELECT test_cursor_to_xml();
>>
>>
>> This returns XML forrest instead of XML document with single root.
>
> You're right, this should have a <table>...</table> around it, like
> query_to_xml() does.

Then it would have to use the cursor name, not a table name, like this, right?

--
Thomas Munro
http://www.enterprisedb.com

Attachment

Re: [BUGS] BUG #13810: cursor_to_xml ignores tableforest parameter

From
Peter Eisentraut
Date:
On 8/2/16 20:03, Thomas Munro wrote:
> On Wed, Aug 3, 2016 at 5:48 AM, Peter Eisentraut
> <peter.eisentraut@2ndquadrant.com> wrote:
>> On 12/9/15 9:07 AM, filip@jirsak.org wrote:
>>> CREATE FUNCTION test_cursor_to_xml() RETURNS xml AS $$
>>> DECLARE
>>>     curs CURSOR FOR SELECT generate_series(1, 5);
>>> BEGIN
>>>   OPEN curs;
>>>   RETURN cursor_to_xml(curs, 10, TRUE, FALSE, '');
>>> END;
>>> $$ LANGUAGE plpgsql;
>>>
>>> SELECT test_cursor_to_xml();
>>>
>>>
>>> This returns XML forrest instead of XML document with single root.
>>
>> You're right, this should have a <table>...</table> around it, like
>> query_to_xml() does.
> 
> Then it would have to use the cursor name, not a table name, like this, right?

[older thread]

I have applied a fix for this to master.  I'll let the build farm take
it for a spin and then apply it to the backbranches.

(We don't use the cursor name for the element name.  It's documented to
use just "table".)

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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

Re: [BUGS] BUG #13810: cursor_to_xml ignores tableforest parameter

From
Peter Eisentraut
Date:
On 5/3/17 21:55, Peter Eisentraut wrote:
> I have applied a fix for this to master.  I'll let the build farm take
> it for a spin and then apply it to the backbranches.

done

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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

Re: [BUGS] BUG #13810: cursor_to_xml ignores tableforest parameter

From
Tom Lane
Date:
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
>>> You're right, this should have a <table>...</table> around it, like
>>> query_to_xml() does.

> I have applied a fix for this to master.  I'll let the build farm take
> it for a spin and then apply it to the backbranches.

I think this is missing an update for the documentation.  Section 9.14.4
describes the wrapping nodes as being <tablename> --- don't we want that
to match reality a bit better?
        regards, tom lane


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

Re: [BUGS] BUG #13810: cursor_to_xml ignores tableforest parameter

From
Peter Eisentraut
Date:
On 5/5/17 15:01, Tom Lane wrote:
> Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
>>>> You're right, this should have a <table>...</table> around it, like
>>>> query_to_xml() does.
> 
>> I have applied a fix for this to master.  I'll let the build farm take
>> it for a spin and then apply it to the backbranches.
> 
> I think this is missing an update for the documentation.  Section 9.14.4
> describes the wrapping nodes as being <tablename> --- don't we want that
> to match reality a bit better?

It also says "If no table name is available, that is, when mapping a
query or a cursor, the string `table` is used in the first format, `row`
in the second format.", so I think it's correct and complete.  (Could
have more examples perhaps, but not critical to bug fix backpatch.)

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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

Re: [BUGS] BUG #13810: cursor_to_xml ignores tableforest parameter

From
Tom Lane
Date:
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
> On 5/5/17 15:01, Tom Lane wrote:
>> I think this is missing an update for the documentation.  Section 9.14.4
>> describes the wrapping nodes as being <tablename> --- don't we want that
>> to match reality a bit better?

> It also says "If no table name is available, that is, when mapping a
> query or a cursor, the string `table` is used in the first format, `row`
> in the second format.", so I think it's correct and complete.  (Could
> have more examples perhaps, but not critical to bug fix backpatch.)

OK, fair enough.
        regards, tom lane


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