BUG #13810: cursor_to_xml ignores tableforest parameter

Started by Nonameover 10 years ago8 messagesbugs
Jump to latest
#1Noname
filip@jirsak.org

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.

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

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Noname (#1)
Re: BUG #13810: cursor_to_xml ignores tableforest parameter

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

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

#3Thomas Munro
thomas.munro@gmail.com
In reply to: Peter Eisentraut (#2)
Re: BUG #13810: cursor_to_xml ignores tableforest parameter

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

Attachments:

cursor-to-xml.patchapplication/octet-stream; name=cursor-to-xml.patchDownload+30-11
#4Peter Eisentraut
peter_e@gmx.net
In reply to: Thomas Munro (#3)
Re: BUG #13810: cursor_to_xml ignores tableforest parameter

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

#5Peter Eisentraut
peter_e@gmx.net
In reply to: Peter Eisentraut (#4)
Re: BUG #13810: cursor_to_xml ignores tableforest parameter

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

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#4)
Re: BUG #13810: cursor_to_xml ignores tableforest parameter

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

#7Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#6)
Re: BUG #13810: cursor_to_xml ignores tableforest parameter

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

#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#7)
Re: BUG #13810: cursor_to_xml ignores tableforest parameter

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