Re: Better error reporting from extension scripts (Was: Extend ALTER OPERATOR) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Better error reporting from extension scripts (Was: Extend ALTER OPERATOR)
Date
Msg-id 3748500.1728924327@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PATCH] Extend ALTER OPERATOR to support adding commutator, negator, hashes, and merges  (Tommy Pavlicek <tommypav122@gmail.com>)
List pgsql-hackers
jian he <jian.universality@gmail.com> writes:
> On Mon, Oct 14, 2024 at 1:13 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Right, but we might not have entered either of those previous
>> if-blocks.

> in src/backend/parser/gram.y
> your makeRawStmt changes (v4) seem to guarantee that
> RawStmt->stmt_location >= 0.

Yes, I would expect that any RawStmt we see here will have valid
stmt_location.  What you seem to be missing is that an error could
be thrown from

>     raw_parsetree_list = pg_parse_query(sql);

before execute_sql_string reaches its loop over RawStmts.  In that
case we'll reach script_error_callback with callback_arg.stmt_location
still being -1.

> pg_parse_query(sql) doesn't use script_error_callback.

Eh?  We've put that on the error context callback stack.
It is not pg_parse_query's decision whether it will be called.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Alena Rybakina
Date:
Subject: Re: Check for tuplestorestate nullness before dereferencing
Next
From: Masahiko Sawada
Date:
Subject: Re: Remove obsolete comment in reorderbuffer.h