25.08.2023 17:00, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference: 18070
> ...
> It looks like the following coding in PLy_elog_impl():
> /* Since we have a format string, we cannot have a SPI detail. */
> Assert(detail == NULL);
>
> /* If there's an exception message, it goes in the detail. */
> if (xmsg)
> detail = xmsg;
>
> doesn't expect to process a call PLy_elog(LEVEL, "message") when some (SPI)
> error occurred before the call.
>
Please look at the patch attached, which removes the Assert and changes
the detail message e.g. , for the query:
CREATE EXTENSION plpython3u;
CREATE TYPE tst AS (t text);
CREATE FUNCTION pyfunc() RETURNS SETOF text AS $$
plan = plpy.prepare("SELECT * FROM tst", ["text"])
for row in plpy.cursor(plan, ["w"]):
yield row[0]
$$ LANGUAGE plpython3u;
SELECT pyfunc();
From:
ERROR: error fetching next item from iterator
LINE 1: SELECT * FROM tst
^
DETAIL: spiexceptions.WrongObjectType: cannot open relation "tst"
QUERY: SELECT * FROM tst
CONTEXT: Traceback (most recent call last):
PL/Python function "pyfunc"
To:
ERROR: error fetching next item from iterator
LINE 1: SELECT * FROM tst
^
DETAIL: This operation is not supported for composite types.
QUERY: SELECT * FROM tst
CONTEXT: Traceback (most recent call last):
PL/Python function "pyfunc"
Best regards,
Alexander