On Mon, Jul 29, 2024 at 11:17:41AM -0400, Tom Lane wrote:
> I wrote:
> > I think the page is technically correct, but I'm inclined to duplicate
> > this text from the CREATE DOMAIN page:
>
> > where domain_constraint is:
> > [ CONSTRAINT constraint_name ]
> > { NOT NULL | NULL | CHECK (expression) }
>
> > rather than making readers go look that up.
>
> Actually, there *is* a bug in the description, because experimentation
> shows that CREATE DOMAIN accepts NULL in this syntax (as advertised)
> but ALTER DOMAIN does not. We could alternatively decide that that's
> a code bug and make ALTER DOMAIN take it, but I don't think it's worth
> any effort (and this behavior may actually have been intentional, too).
> I think we should just add
>
> where domain_constraint is:
>
> [ CONSTRAINT constraint_name ]
> { NOT NULL | CHECK (expression) }
>
> to the ALTER DOMAIN page, and then remove the claim that it's
> identical to CREATE DOMAIN.
I have written the attached patch to document this. I assume this
should be backpatched to PG 12.
--
Bruce Momjian <[email protected]> https://momjian.us
EDB https://enterprisedb.com
When a patient asks the doctor, "Am I going to die?", he means
"Am I going to die soon?"
diff --git a/doc/src/sgml/ref/alter_domain.sgml b/doc/src/sgml/ref/alter_domain.sgml
index f6704d7557a..74855172222 100644
--- a/doc/src/sgml/ref/alter_domain.sgml
+++ b/doc/src/sgml/ref/alter_domain.sgml
@@ -41,6 +41,11 @@ ALTER DOMAIN <replaceable class="parameter">name</replaceable>
RENAME TO <replaceable class="parameter">new_name</replaceable>
ALTER DOMAIN <replaceable class="parameter">name</replaceable>
SET SCHEMA <replaceable class="parameter">new_schema</replaceable>
+
+<phrase>where <replaceable class="parameter">domain_constraint</replaceable> is:</phrase>
+
+[ CONSTRAINT <replaceable class="parameter">constraint_name</replaceable> ]
+{ NOT NULL | CHECK (<replaceable class="parameter">expression</replaceable>) }
</synopsis>
</refsynopsisdiv>
@@ -79,8 +84,7 @@ ALTER DOMAIN <replaceable class="parameter">name</replaceable>
<term><literal>ADD <replaceable class="parameter">domain_constraint</replaceable> [ NOT VALID ]</literal></term>
<listitem>
<para>
- This form adds a new constraint to a domain using the same syntax as
- <link linkend="sql-createdomain"><command>CREATE DOMAIN</command></link>.
+ This form adds a new constraint to a domain.
When a new constraint is added to a domain, all columns using that
domain will be checked against the newly added constraint. These
checks can be suppressed by adding the new constraint using the