Re: BUG #17909: CREATE SCHEMA AUTHORIZATION sch CREATE TABLE foo ( id INT ) will coredump

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: hysong0101(at)163(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17909: CREATE SCHEMA AUTHORIZATION sch CREATE TABLE foo ( id INT ) will coredump
Date: 2023-04-27 10:28:28
Message-ID: CAMbWs49CfOfrMp_AGPiBo7g7BusGf2gy1kGSatm-BYO5aeojvQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Apr 27, 2023 at 5:31 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:

> On Thu, Apr 27, 2023 at 04:59:13PM +0800, Richard Guo wrote:
> > In this case the CreateSchemaStmtContext.schemaname is NULL since it is
> > not explicitly specified, while the schemaname in the schema element is
> > not NULL as it is specified, and setSchemaName cannot copy with such
> > situation. Maybe we should check against RoleSpec.rolename in this case
> > since that is also the schema's name?
>
> In this case, it is cleaner to just set the schema name in
> CreateSchemaStmtContext.schemaname to the role in the RoleSpec if there
> is no schema set in the query, because the schema name will have the
> same name as the role. That also makes the handling of each element
> in schemaElts simpler.

I noticed that in CreateSchemaCommand there is logic that fills schema
name with the role name if it is not specified. Do you think we can
save the new-filled schema name into CreateSchemaStmt.schemaname there?

> The regression tests cruelly lacks of checks here. This is not a
> pattern of CREATE SCHEMA known a lot, but we should do better.

Agreed. It's better to have a case covering this pattern of CREATE
SCHEMA.

Thanks
Richard

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Gustafsson 2023-04-27 14:22:08 Re: pg_basebackup: errors on macOS on directories with ".DS_Store" files
Previous Message Alexander Lakhin 2023-04-27 10:00:00 Re: BUG #17804: Assertion failed in pg_stat after fetching from pg_stat_database and switching cache->snapshot