Re: CREATE SCHEMA ... CREATE DOMAIN support

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: CREATE SCHEMA ... CREATE DOMAIN support
Date: 2024-12-01 09:59:08
Message-ID: CACJufxEvYeyXZ9xj8f1A7cuMU4Fh4WF3Dg8HnArLSkwYbqKO3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Dec 1, 2024 at 1:53 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Kirill Reshke <reshkekirill(at)gmail(dot)com> writes:
> > 3) Why do we delete this in `create_schema.sgml`? Is this untrue? It
> > is about order of definition, not creation, isn't it?
>
> >> - The SQL standard specifies that the subcommands in <command>CREATE
> >> - SCHEMA</command> can appear in any order.
>
> In context with the following sentence, what that is really trying
> to say is that the spec requires us to re-order the subcommands
> to eliminate forward references. After studying the text I cannot
> find any such statement. Maybe I missed something --- there's a
> lot of text --- but it's sure not to be detected in any obvious
> place like 11.1 <schema definition>.
>

I checked, you didn't miss anything
11.1 didn't mention "order" at all.

> (I'd be curious to know how other major implementations handle
> this. Are we the only implementation that ever read the spec
> that way?)
>

quote from https://learn.microsoft.com/en-us/sql/t-sql/statements/create-schema-transact-sql?view=sql-server-ver16
<<>>
CREATE SCHEMA can create a schema, the tables and views it contains, and GRANT,
REVOKE, or DENY permissions on any securable in a single statement. This
statement must be executed as a separate batch. Objects created by the CREATE
SCHEMA statement are created inside the schema that is being created.

Securables to be created by CREATE SCHEMA can be listed in any order, except for
views that reference other views. In that case, the referenced view must be
created before the view that references it.

Therefore, a GRANT statement can grant permission on an object before the object
itself is created, or a CREATE VIEW statement can appear before the CREATE TABLE
statements that create the tables referenced by the view. Also, CREATE TABLE
statements can declare foreign keys to tables that are defined later in the
CREATE SCHEMA statement.
<<>>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Lakhin 2024-12-01 12:00:00 Re: Improving tracking/processing of buildfarm test failures
Previous Message Tom Lane 2024-12-01 05:53:04 Re: CREATE SCHEMA ... CREATE DOMAIN support