public inbox for [email protected]
help / color / mirror / Atom feedFrom: Kirill Reshke <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: CREATE SCHEMA ... CREATE DOMAIN support
Date: Tue, 12 Nov 2024 17:54:46 +0500
Message-ID: <CALdSSPh4jUSDsWu3K58hjO60wnTRR0DuO4CKRcwa8EVuOSfXxg@mail.gmail.com> (raw)
Hi hackers!
This copy of my reply mail from pgsql-general[0], & [1] which was held
for moderation for some reason.
Here it goes as-is :
== begin
Hi Álvaro, thanks for the detailed explanation.
So, IIUC you are suggesting to support SQL standard features before
any work with PostgreSQL extension.
Ok, I will try to go this way. PFA patch implementing CREATE DOMAIN
support for CREATE SCHEMA statement.
Of all other options, CREATE DOMAIN support looks like the most stranfoward one.
Patch obviously leaks doc & regression tests, but I'm posting it to
see if this contribution is needed in PostgreSQL
== end
[0] https://www.postgresql.org/message-id/CALdSSPgxcRkooZ2iQ5A7XhYoexVAdbiT6znZDqJTE8hxUVjz_A%40mail.gma...
[1] https://www.postgresql.org/message-id/202411111009.ckna4vp7ahyk%40alvherre.pgsql
--
Best regards,
Kirill Reshke
Attachments:
[application/octet-stream] v1-0001-Extend-CREATE-SCHEMA-element-with-DOMAIN-support.patch (2.3K, 2-v1-0001-Extend-CREATE-SCHEMA-element-with-DOMAIN-support.patch)
download | inline diff:
From 86515dab036e9a8339d250f8da3a6185d3bc0ff2 Mon Sep 17 00:00:00 2001
From: reshke kirill <[email protected]>
Date: Mon, 11 Nov 2024 21:18:56 +0000
Subject: [PATCH v1] Extend CREATE SCHEMA element with DOMAIN support.
SQL standart allow domain to be specified with CREATE SCHEMA
statement. This patch adds support in PostgreSQL for that.
---
src/backend/parser/gram.y | 1 +
src/backend/parser/parse_utilcmd.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 67eb96396a..ad8d9270ac 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -1584,6 +1584,7 @@ schema_stmt:
| CreateTrigStmt
| GrantStmt
| ViewStmt
+ | CreateDomainStmt
;
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 0f324ee4e3..e74b6f8a04 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -105,6 +105,7 @@ typedef struct
List *indexes; /* CREATE INDEX items */
List *triggers; /* CREATE TRIGGER items */
List *grants; /* GRANT items */
+ List *domains; /* DOMAIN items */
} CreateSchemaStmtContext;
@@ -4039,6 +4040,7 @@ transformCreateSchemaStmtElements(List *schemaElts, const char *schemaName)
cxt.indexes = NIL;
cxt.triggers = NIL;
cxt.grants = NIL;
+ cxt.domains = NIL;
/*
* Run through each schema element in the schema element list. Separate
@@ -4107,6 +4109,19 @@ transformCreateSchemaStmtElements(List *schemaElts, const char *schemaName)
cxt.grants = lappend(cxt.grants, element);
break;
+ case T_CreateDomainStmt:
+ {
+ CreateDomainStmt *elp = (CreateDomainStmt *) element;
+
+ /* DOMAIN name can be already qualified. */
+ if (elp->domainname->length == 1) {
+ elp->domainname = lcons(makeString(pstrdup(cxt.schemaname)), elp->domainname);
+ }
+
+ cxt.domains = lappend(cxt.domains, element);
+ }
+ break;
+
default:
elog(ERROR, "unrecognized node type: %d",
(int) nodeTag(element));
@@ -4120,6 +4135,7 @@ transformCreateSchemaStmtElements(List *schemaElts, const char *schemaName)
result = list_concat(result, cxt.indexes);
result = list_concat(result, cxt.triggers);
result = list_concat(result, cxt.grants);
+ result = list_concat(result, cxt.domains);
return result;
}
--
2.34.1
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: CREATE SCHEMA ... CREATE DOMAIN support
In-Reply-To: <CALdSSPh4jUSDsWu3K58hjO60wnTRR0DuO4CKRcwa8EVuOSfXxg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox