Re: CREATE SCHEMA ... CREATE DOMAIN support

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: CREATE SCHEMA ... CREATE DOMAIN support
Date: 2024-11-28 05:27:00
Message-ID: CALdSSPhckRXW+KEvdsUmkQ-ErbrP_vPNjGwgXNdpXDb8xnLEbQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 27 Nov 2024 at 23:39, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Kirill Reshke <reshkekirill(at)gmail(dot)com> writes:
> > On Wed, 27 Nov 2024 at 08:42, jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> >> CREATE SCHEMA regress_schema_2 AUTHORIZATION CURRENT_ROLE
> >> create domain ss1 as ss
> >> create domain ss as text;
> >> ERROR: type "ss" does not exist
> >>
> >> the error message seems not that OK,
> >> if we can point out the error position, that would be great.
>
> > To implement this, we need to include `ParseLoc location` to the
> > `CreateDomainStmt` struct, which is doubtful, because I don't see any
> > other type of create *something* that does this.
>
> No, that error is thrown from typenameType(), which has a perfectly
> good location in the TypeName. What it's lacking is a ParseState
> containing the source query string.
>
> Breakpoint 1, typenameType (pstate=pstate(at)entry=0x0, typeName=0x25d6b58,
> typmod_p=typmod_p(at)entry=0x7ffe7dcd641c) at parse_type.c:268
> 268 tup = LookupTypeName(pstate, typeName, typmod_p, false);
> (gdb) p pstate
> $2 = (ParseState *) 0x0
> (gdb) p typeName->location
> $3 = 21
>
> We've fixed a few utility statements so that they can receive
> a passed-down ParseState, but not DefineDomain.
>
> regards, tom lane

Indeed, my analysis is wrong.

Turns out passing parsestate to DefineDomain is itself enhancement.

Before this patch:
```
db1=# create domain ss1 as ss;
ERROR: type "ss" does not exist
```

after:

```
db1=# create domain ss1 as ss;
ERROR: type "ss" does not exist
LINE 1: create domain ss1 as ss;
^
```
PFA as an independent patch then. Or should we combine these two into one?

--
Best regards,
Kirill Reshke

Attachment Content-Type Size
v1-0001-Pass-ParseState-as-first-param-to-DefineRelation.patch application/octet-stream 2.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2024-11-28 05:46:51 Re: Auto Vacuum optimisation
Previous Message Thomas Munro 2024-11-28 05:16:55 Re: CI CompilerWarnings test fails on 15 in mingw_cross_warning