Re: Pass ParseState as down to utility functions.

jian he <jian.universality@gmail.com>

From: jian he <jian.universality@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Kirill Reshke <reshkekirill@gmail.com>, Alvaro Herrera <alvherre@alvh.no-ip.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-12-12T04:38:06Z
Lists: pgsql-hackers

Attachments

On Thu, Dec 12, 2024 at 10:29 AM Michael Paquier <michael@paquier.xyz> wrote:
>
> I think that the patch should be split a bit more.  Even if different
> areas of the code are touched, there's more than one idea of how to
> create this information for the error position, so each piece could be
> committed separately with changes showing up as diffs in the
> regression tests.
> --

I've split it into two patches, one for CREATE DOMAIN only. one for
another DDL command.

0001:
I am using DefineDomain(ParseState *pstate, CreateDomainStmt *stmt) for now.
we can also pass querystring or another struct.

0002:
passing AlterTableUtilityContext for some ALTER TABLE subroutine.
add parser_errposition to some existing `ereport(ERROR` places.
-------------------
you mentioned ALTER DOMAIN, I have further simplified it at
https://postgr.es/m/CACJufxG0N_WLfk-NC_k5w6vv26qLvXupbHvnkKtc2npftJQicQ@mail.gmail.com


create domain d_fail as int constraint cc REFERENCES this_table_not_exists(i);
like this command will fail, so we don't need to change
create_domain.sgml synopsis section
?

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__.