Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t1BJI-00F4J3-Qt for pgsql-docs@arkaria.postgresql.org; Wed, 16 Oct 2024 21:12:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t1BJG-00ALCT-Uo for pgsql-docs@arkaria.postgresql.org; Wed, 16 Oct 2024 21:11:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t1BJG-00ALCJ-MK for pgsql-docs@lists.postgresql.org; Wed, 16 Oct 2024 21:11:59 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t1BJE-001FFK-7h for pgsql-docs@lists.postgresql.org; Wed, 16 Oct 2024 21:11:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2024011501; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=jRvozkGOS69Mn7622nG9XsbrkyMosUtV9SA6euvQj0M=; b=PLU8d rtKUwUkhQs8Hfwb4nk/FYeCH7Hgl8wlJkBr/HX6YaRm2YTT3HtLLkVY4f352uf9qDWc36GDxK8GPA eqM8+OoPeu6Y3fm4MjWZJ4AJlF33/CHL1JvFrLUKjUb50i+Y6BdilpeHck/pjq6QaTcsoFrvExEa8 b767SSV8gtAPO6ckjc+Lu4bLYQaihwGuN8gijJIaIbiyZ6SlsbpqDaKra+swOsLKbq7VHrkI2MWKH DGxDTcXp+sZBV6c9juFjA/q1akcF2fgmW4+ra7oP7+AOuUKP3wODy6wUVttpcPdCBQqniP6rnnH9X evrq+MYecnizouxePBxAs3ZJH0NuA==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1t1BJC-009VOu-13; Wed, 16 Oct 2024 17:11:54 -0400 Date: Wed, 16 Oct 2024 17:11:54 -0400 From: Bruce Momjian To: Tom Lane Cc: "David G. Johnston" , "elionescu@yahoo.com" , "pgsql-docs@lists.postgresql.org" Subject: Re: incorrect (incomplete) description for "alter domain" Message-ID: References: <172225092461.915373.6103973717483380183@wrigleys.postgresql.org> <2585954.1722265086@sss.pgh.pa.us> <2596729.1722266261@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="7+XZtP2qu7B+TDbA" Content-Disposition: inline In-Reply-To: <2596729.1722266261@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --7+XZtP2qu7B+TDbA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 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?" --7+XZtP2qu7B+TDbA Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="domain.diff" 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 name RENAME TO new_name ALTER DOMAIN name SET SCHEMA new_schema + +where domain_constraint is: + +[ CONSTRAINT constraint_name ] +{ NOT NULL | CHECK (expression) } @@ -79,8 +84,7 @@ ALTER DOMAIN name ADD domain_constraint [ NOT VALID ] - This form adds a new constraint to a domain using the same syntax as - CREATE DOMAIN. + 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 --7+XZtP2qu7B+TDbA--