Re: Better error reporting from extension scripts (Was: Extend ALTER OPERATOR)
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: jian he <jian.universality@gmail.com>
Cc: Pavel Stehule <pavel.stehule@gmail.com>, Christoph Berg <myon@debian.org>, Michael Banck <mbanck@gmx.net>, Tommy Pavlicek <tommypav122@gmail.com>, Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>, pgsql-hackers@lists.postgresql.org
Date: 2024-10-14T16:45:27Z
Lists: 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
Commits
-
Strip Windows newlines from extension script files manually.
- 6cfb3a337469 18.0 landed
-
Read extension script files in text not binary mode.
- 924e03917d6f 18.0 landed
-
Improve reporting of errors in extension script files.
- 774171c4f640 18.0 landed
-
Improve parser's reporting of statement start locations.
- 14e5680eee19 18.0 landed
-
Extend ALTER OPERATOR to allow setting more optimization attributes.
- 2b5154beab79 17.0 landed
-
Core support for "extensions", which are packages of SQL objects.
- d9572c4e3b47 9.1.0 cited