Hi hackers!
PFA patch fixing a number of places where typenameType called with NULL pstate.

=== motivation.

Per discussion in a nearby thread for `CREATE SCHEMA ... CREATE DOMAIN
support`. Suggested by Jian He & Tom Lane.

On Thu, 28 Nov 2024 at 10:52, Tom Lane <t...@sss.pgh.pa.us> wrote:
>
> Kirill Reshke <reshkekir...@gmail.com> writes:
> > On Wed, 27 Nov 2024 at 23:39, Tom Lane <t...@sss.pgh.pa.us> wrote:
> >> We've fixed a few utility statements so that they can receive
> >> a passed-down ParseState, but not DefineDomain.
>
> > PFA as an independent patch then. Or should we combine these two into one?
>
> No, I don't think this should be part of the patch discussed in this
> thread.
>
> It feels rather random to me to be fixing only DefineDomain;
> I'm sure there's more in the same vein.  I'd like to see a
> patch with a scope along the lines of "fix everything reachable
> within CREATE SCHEMA" or perhaps "fix all calls of typenameType".
> (A quick grep shows that an outright majority of the callers of that
> are passing null ParseState.  I didn't look to see if any of them
> have a good excuse beyond "we didn't do the plumbing work".)
>
>                         regards, tom lane


I chosed "fix all calls of typenameType" way.

I searched for typenameType(NULL pattern within sources and changed to
pass pstate where appropriate. This is AlterType, DefineDomain and
transformOfType cases. There are 2 more usages of this pattern left,
inside ATExecAlterColumnType & ATExecAddOf, which I dont think need to
be addressed (cure worse than disease).

=== examples
1) CREATE TYPE.
before:

```
db2=# create type int8alias3 (
    input = int8alias2in,
    output = int8alias2out,
    like = int82
);
ERROR:  type "int82" does not exist
db2=# ^C
```

after:

```
db2=# create type int8alias3 (
    input = int8alias2in,
    output = int8alias2out,
    like = int82
);
ERROR:  type "int82" does not exist
LINE 4:     like = int82
                   ^
db2=#
```

2) TABLE of TYPENAME case

before:

```
db2=# CREATE TABLE example OF mytype2 (PRIMARY KEY (some_id));
ERROR:  type "mytype2" does not exist
db2=#

```

after:

```
db2=# CREATE TABLE example OF mytype2 (PRIMARY KEY (some_id));
ERROR:  type "mytype2" does not exist
LINE 1: CREATE TABLE example OF mytype2 (PRIMARY KEY (some_id));
                                ^
```

3) CREATE DOMAIN - analogous.

==== testing

By-hand. Let me know if we can check this any other way.


-- 
Best regards,
Kirill Reshke

Attachment: v2-0001-Pass-ParseState-as-down-to-utility-functions.patch
Description: Binary data

Reply via email to