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: jian he <jian.universality@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, 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-13T16:48:03Z
Lists: pgsql-hackers
so 12. 10. 2024 v 9:33 odesílatel jian he <jian.universality@gmail.com>
napsal:

> On Wed, Oct 9, 2024 at 4:18 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >
>
> > In the attached v4
>
>
> in the upper code two branch, both will call CleanQuerytext
> so in script_error_callback
>
> + /*
> + * If we have a location (which, as said above, we really always should)
> + * then report a line number to aid in localizing problems in big scripts.
> + */
> + if (location >= 0)
> + {
> + int linenumber = 1;
> +
> + for (query = callback_arg->sql; *query; query++)
> + {
> + if (--location < 0)
> + break;
> + if (*query == '\n')
> + linenumber++;
> + }
> + errcontext("extension script file \"%s\", near line %d",
> +   lastslash, linenumber);
> + }
> + else
> + errcontext("extension script file \"%s\"", lastslash);
>
>
> + /*
> + * If we have a location (which, as said above, we really always should)
> + * then report a line number to aid in localizing problems in big scripts.
> + */
> + if (location >= 0)
> so this part will always be true?
>

yes, after  CleanQuerytext the location should not be -1 ever

Regards

Pavel

Commits

  1. Strip Windows newlines from extension script files manually.

  2. Read extension script files in text not binary mode.

  3. Improve reporting of errors in extension script files.

  4. Improve parser's reporting of statement start locations.

  5. Extend ALTER OPERATOR to allow setting more optimization attributes.

  6. Core support for "extensions", which are packages of SQL objects.