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: 0001-fix-cursor_to_xmlschema-can-cause-a-crash.patch
Description: Binary data

Reply via email to