pgsql: Improve reporting of errors in extension script files.
От | Tom Lane |
---|---|
Тема | pgsql: Improve reporting of errors in extension script files. |
Дата | |
Msg-id | E1t3Gvw-001vQ4-83@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
Improve reporting of errors in extension script files. Previously, CREATE/ALTER EXTENSION gave basically no useful context about errors reported while executing script files. I think the idea was that you could run the same commands manually to see the error, but that's often quite inconvenient. Let's improve that. If we get an error during raw parsing, we won't have a current statement identified by a RawStmt node, but we should always get a syntax error position. Show the portion of the script from the last semicolon-newline before the error position to the first one after it. There are cases where this might show only a fragment of a statement, but that should be uncommon, and it seems better than showing the whole script file. Without an error cursor, if we have gotten past raw parsing (which we probably have), we can report just the current SQL statement as an item of error context. In any case also report the script file name as error context, since it might not be entirely obvious which of a series of update scripts failed. We can also show an approximate script line number in case whatever we printed of the query isn't sufficiently identifiable. The error-context code path is already exercised by some test_extensions test cases, but add tests for the syntax-error path. Discussion: https://postgr.es/m/ZvV1ClhnbJLCz7Sm@msg.df7cb.de Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/774171c4f640853b1cf8747a4762631d2f5d25be Modified Files -------------- src/backend/commands/extension.c | 167 ++++++++++++++++++++- src/test/modules/test_extensions/Makefile | 4 +- .../test_extensions/expected/test_extensions.out | 42 ++++++ src/test/modules/test_extensions/meson.build | 2 + .../test_extensions/sql/test_extensions.sql | 4 + .../test_extensions/test_ext7--2.0--2.1bad.sql | 14 ++ .../test_extensions/test_ext7--2.0--2.2bad.sql | 13 ++ src/tools/pgindent/typedefs.list | 1 + 8 files changed, 244 insertions(+), 3 deletions(-)
В списке pgsql-committers по дате отправления: