function "cursor_to_xmlschema" causes a crash - Mailing list pgsql-hackers

From 杨伯宇(长堂)
Subject function "cursor_to_xmlschema" causes a crash
Date
Msg-id dd343010-c637-434c-a8cb-418f53bda3b8.yangboyu.yby@alibaba-inc.com
Whole thread Raw
Responses Re: function "cursor_to_xmlschema" causes a crash
List pgsql-hackers
Hello postgres hackers:
I recently notice that function "cursor_to_xmlschema" can lead to a crash if the
cursor parameter points to the query itself. Here is an example:

postgres=# SELECT cursor_to_xmlschema('' :: refcursor, TRUE , FALSE , 'xxx' ) into temp;
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

The reason could be that this function doesn't ensure the cursor is correctly
opened, as a "select into" statement can't be opened as a cursor. Although it may
be challenging to perform a perfect check in this scenario, it seems sufficient
just to check the tuple descriptor of the portal, since only the query that
returns tuples can be opened as a cursor.

Only in my opinion, self-pointing cursors like this do not make practical sense.
This bug is discovered through randomly generated SQL statements.

Best regards,
Boyu Yang
Attachment

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Speed up transaction completion faster after many relations are accessed in a transaction
Next
From: Suraj Kharage
Date:
Subject: Re: Server crash on RHEL 9/s390x platform against PG16