Re: CREATE SCHEMA ... CREATE DOMAIN support

jian he <jian.universality@gmail.com>

From: jian he <jian.universality@gmail.com>
To: Kirill Reshke <reshkekirill@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-11-23T05:19:27Z
Lists: pgsql-hackers

Attachments

On Tue, Nov 12, 2024 at 8:55 PM Kirill Reshke <reshkekirill@gmail.com> wrote:
>
> Patch obviously leaks doc & regression tests, but I'm posting it to
> see if this contribution is needed in PostgreSQL

the following two statement should fail:
CREATE SCHEMA regress_schema_2 AUTHORIZATION CURRENT_ROLE
  CREATE table t(a ss)
  create domain public.ss as text not null default 'hello' constraint
nn check (value <> 'hello');

CREATE SCHEMA regress_schema_2 AUTHORIZATION CURRENT_ROLE
  CREATE table t(a ss)
  create domain postgres.public.ss as text not null default 'hello'
constraint nn check (value <> 'hello');

we aslo need to consider the dependency issue. like the following should be ok.
CREATE SCHEMA regress_schema_3 AUTHORIZATION CURRENT_ROLE
  create view test as select 'hello'::ss as test
  CREATE table t(a ss)
  create domain ss as text not null;

i fixed these two issues, and add the above example as tests in
src/test/regress/sql/create_schema.sql

I didn't add a doc entry. I will do it later.

Commits

  1. Don't try to re-order the subcommands of CREATE SCHEMA.

  2. Execute foreign key constraints in CREATE SCHEMA at the end.

  3. Support more object types within CREATE SCHEMA.