Re: Pass ParseState as down to utility functions.

Kirill Reshke <reshkekirill@gmail.com>

From: Kirill Reshke <reshkekirill@gmail.com>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: jian he <jian.universality@gmail.com>, Michael Paquier <michael@paquier.xyz>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-12-09T07:50:20Z
Lists: pgsql-hackers

Attachments

Thank you for reviewing this!

On Fri, 6 Dec 2024 at 19:01, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
> I think it would make more sense to write the commit message in terms of
> the DDL commands that now report error position, than the C functions.
> Such a list of commands does not need to be exhaustive; a
> representative-enough sample probably suffices.

Hi! I fixed the commit message as suggested.

> Once upon a time, ereport() was a simpler macro that did not
> use variadic arguments.  Back then, the list of functions embedded in it
> (errcode, errmsg etc) were forced to be in an additional level of
> parentheses so that the macro would work at all (IIRC failure to do that
> resulted in strange compile-time problems).  This is why a majority of
> code is written in the style with those parens.  But commit e3a87b4991cc
> changed ereport to use __VA_ARGS__, so the auxiliary functions are
> actual arguments to errstart() -- which means that the parentheses
> you're adding here are unnecessary and discouraged.  Just add the
> parser_errposition() call and it'll be fine.


Should be fixed in v7.



-- 
Best regards,
Kirill Reshke

Commits

  1. Print out error position for some ALTER TABLE ALTER COLUMN type

  2. Print out error position for some more DDLs

  3. Print out error position for CREATE DOMAIN

  4. Add some regression tests for missing DDL patterns

  5. Re-implement the ereport() macro using __VA_ARGS__.