Re: PRIMARY KEY on a *group* of columns imply that each column is

From: Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>
To: Marco Colombo <pgsql(at)esiway(dot)net>
Subject: Re: PRIMARY KEY on a *group* of columns imply that each column is
Date: 2005-04-28 16:56:10
Message-ID: 427115AA.8060300@cheapcomplexdevices.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Marco Colombo wrote:
> That is, given a variable A, you can always write a boolean expression
> that evaluates True or False to test if A is _equal_ to None/undef/NULL
> (in C):

And of course you can do this in SQL as well.

> ('a', NULL) is neither the same _nor different_ from ('a', 2).

Uh, I'm not sure what you mean by "the same"; but
certainly ('a',NULL) is distinct from ('a',2).

>The result of comparison is NULL, no matter how you're testing it:

Unless you're testing with the IS DISTINCT FROM operator.

fli=# select ('a',NULL) IS DISTINCT FROM ('a',2);
?column?
----------
t
(1 row)

> marco=# select ('a', 2) = ('a', NULL);
> ?column?
> ----------
>
> (1 row)
>
> marco=# select ('a', 2) <> ('a', NULL);
> ?column?
> ----------
>
> (1 row)

fli=# select ('a',NULL) IS DISTINCT FROM ('a',NULL);
?column?
----------
f
(1 row)

> That's why NULLs are not allowed in primary keys...

But in general I agree with most of the rest of what you said.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Typing80wpm 2005-04-28 17:04:35 Postgresql and VBA vs Python
Previous Message Tony Caduto 2005-04-28 16:18:00 Is there a bug in the win32 pg_restore (version 8.02) ?