Re: Better error reporting from extension scripts (Was: Extend ALTER OPERATOR)
Pavel Stehule <pavel.stehule@gmail.com>
From: Pavel Stehule <pavel.stehule@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: 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, jian.universality@gmail.com
Date: 2024-10-11T13:37:24Z
Lists: pgsql-hackers
Hi út 8. 10. 2024 v 22:18 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal: > I wrote: > > ... There's still a question > > of whether reporting the whole script as the query is OK when > > we have a syntax error, but I have no good ideas as to how to > > make that terser. > > I had an idea about this: we can use a pretty simple heuristic > such as "break at semicolon-newline sequences". That could fail > and show you just a fragment of a statement, but that still seems > better than showing a whole extension script. We can ameliorate > the problem that we might not show enough to clearly identify > what failed by including a separate line number counter. > In the attached v4 I included that in the context line that > reports the script file, eg > > +CONTEXT: SQL statement "CREATE OR REPLACE FUNCTION ext_cor_func() > RETURNS text > + AS $$ SELECT 'ext_cor_func: from extension'::text $$ LANGUAGE sql" > +extension script file "test_ext_cor--1.0.sql", near line 8 > > This way seems a whole lot more usable when dealing with a > large extension script. > I tested it and it is working nicely. I tested it against Orafce and I found an interesting point. The body of plpgsql functions is not checked. Do you know the reason? Regards Pavel > 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