Re: Better error reporting from extension scripts (Was: Extend ALTER OPERATOR)

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Christoph Berg <myon(at)debian(dot)org>, Michael Banck <mbanck(at)gmx(dot)net>, Tommy Pavlicek <tommypav122(at)gmail(dot)com>, Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Better error reporting from extension scripts (Was: Extend ALTER OPERATOR)
Date: 2024-10-13 16:48:03
Message-ID: CAFj8pRALVX8XDY9uZz_JCqd8k5VQjMLk3eGc=STonhMvJoLCSw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

so 12. 10. 2024 v 9:33 odesílatel jian he <jian(dot)universality(at)gmail(dot)com>
napsal:

> On Wed, Oct 9, 2024 at 4:18 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-10-13 17:13:51 Re: Better error reporting from extension scripts (Was: Extend ALTER OPERATOR)
Previous Message Junwang Zhao 2024-10-13 14:43:22 Re: general purpose array_sort