Thread: CREATE TABLE docs fix

CREATE TABLE docs fix

From
Neil Conway
Date:
This patch fixes a minor inaccuracy in the documentation: NOT NULL is
not synonymous with CHECK (xxx IS NOT NULL) -- for example, consider
ALTER TABLE ADD PRIMARY KEY, which checks for 'NOT NULL', not a check
constraint.

Cheers,

Neil

--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

Attachment

Re: CREATE TABLE docs fix

From
Rod Taylor
Date:
On Sun, 2002-09-01 at 04:00, Neil Conway wrote:
> This patch fixes a minor inaccuracy in the documentation: NOT NULL is
> not synonymous with CHECK (xxx IS NOT NULL) -- for example, consider
> ALTER TABLE ADD PRIMARY KEY, which checks for 'NOT NULL', not a check
> constraint.

Yeah, but they're still synonymous.


Re: CREATE TABLE docs fix

From
Neil Conway
Date:
Rod Taylor <rbt@zort.ca> writes:

> On Sun, 2002-09-01 at 04:00, Neil Conway wrote:
> > This patch fixes a minor inaccuracy in the documentation: NOT NULL
> > is not synonymous with CHECK (xxx IS NOT NULL) -- for example,
> > consider ALTER TABLE ADD PRIMARY KEY, which checks for 'NOT NULL',
> > not a check constraint.
>
> Yeah, but they're still synonymous.

How so? Their behavior is clearly different (note the case above, as
well as any other situation in which the system attempts to determine
if a column allows a NULL value).

Since they are not interchangeable, they can't be synonyms.

Cheers,

Neil

--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

Re: CREATE TABLE docs fix

From
Rod Taylor
Date:
On Sun, 2002-09-01 at 13:28, Neil Conway wrote:
> Rod Taylor <rbt@zort.ca> writes:
>
> > On Sun, 2002-09-01 at 04:00, Neil Conway wrote:
> > > This patch fixes a minor inaccuracy in the documentation: NOT NULL
> > > is not synonymous with CHECK (xxx IS NOT NULL) -- for example,
> > > consider ALTER TABLE ADD PRIMARY KEY, which checks for 'NOT NULL',
> > > not a check constraint.
> >
> > Yeah, but they're still synonymous.
>
> How so? Their behavior is clearly different (note the case above, as
> well as any other situation in which the system attempts to determine
> if a column allows a NULL value).
>
> Since they are not interchangeable, they can't be synonyms.

The case you brought up is more of a bug or mis-implementation of alter
table / add primary key. I guess you're right. They're not, but they
should be.




Re: CREATE TABLE docs fix

From
Alvaro Herrera
Date:
En 01 Sep 2002 13:44:37 -0400
Rod Taylor <rbt@zort.ca> escribió:

> > > On Sun, 2002-09-01 at 04:00, Neil Conway wrote:
> > > > This patch fixes a minor inaccuracy in the documentation: NOT NULL
> > > > is not synonymous with CHECK (xxx IS NOT NULL) -- for example,
> > > > consider ALTER TABLE ADD PRIMARY KEY, which checks for 'NOT NULL',
> > > > not a check constraint.
>
> The case you brought up is more of a bug or mis-implementation of alter
> table / add primary key. I guess you're right. They're not, but they
> should be.

I think it's very difficult in the general case to determine from a
CHECK constraint if it is setting some column to not null; but if it was
easy, then you better translate(*) it into the SET NOT NULL form, and leave
the ADD PRIMARY KEY code alone.

Anyway IMHO this should be documented to prevent possible confusion.


(*) but I think auto-converting some things into some other things that
may not be what the user wants is a recipe for user frustration.

--
Alvaro Herrera (<alvherre[a]atentus.com>)
"El sabio habla porque tiene algo que decir;
el tonto, porque tiene que decir algo" (Platon).

Re: CREATE TABLE docs fix

From
Bruce Momjian
Date:
Is this patch to be applied?

---------------------------------------------------------------------------

Neil Conway wrote:
> This patch fixes a minor inaccuracy in the documentation: NOT NULL is
> not synonymous with CHECK (xxx IS NOT NULL) -- for example, consider
> ALTER TABLE ADD PRIMARY KEY, which checks for 'NOT NULL', not a check
> constraint.
>
> Cheers,
>
> Neil
>
> --
> Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/ref/create_table.sgml
===================================================================
RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/ref/create_table.sgml,v
retrieving revision 1.55
diff -c -r1.55 create_table.sgml
*** doc/src/sgml/ref/create_table.sgml    18 May 2002 15:44:47 -0000    1.55
--- doc/src/sgml/ref/create_table.sgml    1 Sep 2002 07:52:51 -0000
***************
*** 247,255 ****
      <term><literal>NOT NULL</></term>
      <listitem>
       <para>
!       The column is not allowed to contain NULL values.  This is
!       equivalent to the column constraint <literal>CHECK (<replaceable
!       class="PARAMETER">column</replaceable> NOT NULL)</literal>.
       </para>
      </listitem>
     </varlistentry>
--- 247,253 ----
      <term><literal>NOT NULL</></term>
      <listitem>
       <para>
!       The column is not allowed to contain NULL values.
       </para>
      </listitem>
     </varlistentry>

Re: CREATE TABLE docs fix

From
Neil Conway
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Is this patch to be applied?

Yes, IMHO anyway.

Cheers,

Neil

--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

Re: CREATE TABLE docs fix

From
Bruce Momjian
Date:
Your patch has been added to the PostgreSQL unapplied patches list at:

    http://207.106.42.251/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------


Neil Conway wrote:
> This patch fixes a minor inaccuracy in the documentation: NOT NULL is
> not synonymous with CHECK (xxx IS NOT NULL) -- for example, consider
> ALTER TABLE ADD PRIMARY KEY, which checks for 'NOT NULL', not a check
> constraint.
>
> Cheers,
>
> Neil
>
> --
> Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: CREATE TABLE docs fix

From
Bruce Momjian
Date:
Patch applied.  Thanks.

---------------------------------------------------------------------------


Neil Conway wrote:
> This patch fixes a minor inaccuracy in the documentation: NOT NULL is
> not synonymous with CHECK (xxx IS NOT NULL) -- for example, consider
> ALTER TABLE ADD PRIMARY KEY, which checks for 'NOT NULL', not a check
> constraint.
>
> Cheers,
>
> Neil
>
> --
> Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073