Re: CTAS not honoring NOT NULL, DEFAULT modifiers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Nikhil Sontakke <nikhil(dot)sontakke(at)enterprisedb(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CTAS not honoring NOT NULL, DEFAULT modifiers
Date: 2010-04-20 15:24:43
Message-ID: 10850.1271777083@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> Tom Lane wrote:
>> Actually, SQL:2008 does say that if an output column of the SELECT is
>> known not nullable, then the created table should have the NOT NULL
>> property for that column. We don't implement anything about "known not
>> nullable", though, so I'd view this as a small part of an unimplemented
>> SQL feature. The usefulness seems rather debatable anyway.

> It is supposed to inspect the underlying column or look at the data
> values returned and set NOT NULL based on that? The later seems weird.

"Known not nullable" is entirely different from "all values happen to be
not null at the moment". I don't recall what conditions the SQL spec
expects people to be able to prove not-nullability from, but being a
direct copy of a NOT NULL column would certainly be the base case.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2010-04-20 15:39:11 should I post the patch as committed?
Previous Message Bruce Momjian 2010-04-20 15:17:15 Re: CTAS not honoring NOT NULL, DEFAULT modifiers