Re: BUG #18070: Assertion failed when processing error from plpy's iterator

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18070: Assertion failed when processing error from plpy's iterator
Date: 2023-09-15 17:00:00
Message-ID: 9fa9c154-d084-07de-8224-aab7fc8a119e@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

Attachment Content-Type Size
fix-plpy_elog.patch text/x-patch 645 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2023-09-15 18:38:50 Re: BUG #18077: PostgreSQL server subprocess crashed by a SELECT statement with WITH clause
Previous Message Dave Cramer 2023-09-15 16:58:32 Re: the same time value return different values,is it a problem