Re: [HACKERS] adding support for zero-attribute unique/etc keys

2013-03-27 Thread Albe Laurenz
Darren Duncan wrote: > Consider the context however. We're talking about a UNIQUE constraint and so > what we want to do is prevent the existence of multiple tuples in a relation > that are the same for some defined subset of their attributes. I would argue > that logically, and commonsensically,

Re: [HACKERS] adding support for zero-attribute unique/etc keys

2013-03-26 Thread Gavin Flower
On 27/03/13 06:14, Darren Duncan wrote: On 2013.03.26 1:40 AM, Albe Laurenz wrote: Darren Duncan wrote: So, determining if 2 rows are the same involves an iteration of dyadic logical AND over the predicates for each column comparison. Now logical AND has an identity value, which is TRUE, beca

Re: [HACKERS] adding support for zero-attribute unique/etc keys

2013-03-26 Thread Darren Duncan
On 2013.03.26 1:40 AM, Albe Laurenz wrote: Darren Duncan wrote: So, determining if 2 rows are the same involves an iteration of dyadic logical AND over the predicates for each column comparison. Now logical AND has an identity value, which is TRUE, because "TRUE AND p" (and "p AND TRUE") result

Re: [HACKERS] adding support for zero-attribute unique/etc keys

2013-03-26 Thread Albe Laurenz
Darren Duncan wrote: >> The standard defines UNIQUE on the basis of the "UNIQUE predicate": >> ::= UNIQUE >> and states: >> 1) Let T be the result of the . >> 2) If there are no two rows in T such that the value of each column >>in one row is non-null and is not distinct >>from the value

Re: [HACKERS] adding support for zero-attribute unique/etc keys

2013-03-25 Thread Tom Lane
Brendan Jurd writes: > On 26 March 2013 05:04, Darren Duncan wrote: >> On 2013.03.25 1:17 AM, Albe Laurenz wrote: >>> The desired effect can be had today with a unique index: >>> CREATE TABLE singleton (id integer); >>> CREATE UNIQUE INDEX singleton_idx ON singleton((1)); >> Okay, that is helpfu

Re: [HACKERS] adding support for zero-attribute unique/etc keys

2013-03-25 Thread Brendan Jurd
On 26 March 2013 05:04, Darren Duncan wrote: > On 2013.03.25 1:17 AM, Albe Laurenz wrote: >> The desired effect can be had today with a unique index: >> >> CREATE TABLE singleton (id integer); >> CREATE UNIQUE INDEX singleton_idx ON singleton((1)); > > Okay, that is helpful, and less of a kludge t

Re: [HACKERS] adding support for zero-attribute unique/etc keys

2013-03-25 Thread Darren Duncan
On 2013.03.25 1:17 AM, Albe Laurenz wrote: Darren Duncan wrote: From my usage and http://www.postgresql.org/docs/9.2/interactive/sql-createtable.html I see that Postgres requires constraints like unique (and primary) keys, and foreign keys, to range over at least 1 attribute/column. I propose

Re: [HACKERS] adding support for zero-attribute unique/etc keys

2013-03-25 Thread Tom Lane
Albe Laurenz writes: > Darren Duncan wrote: >> I propose that this be generalized so that constraints may instead be >> nullary, >> that is, range over zero or more attributes/columns instead. > Since an imagined zero-column query would have an empty set of > result columns, you could with equal

Re: [HACKERS] adding support for zero-attribute unique/etc keys

2013-03-25 Thread Albe Laurenz
Darren Duncan wrote: > From my usage and > http://www.postgresql.org/docs/9.2/interactive/sql-createtable.html I see that > Postgres requires constraints like unique (and primary) keys, and foreign > keys, > to range over at least 1 attribute/column. > > I propose that this be generalized so tha

[HACKERS] adding support for zero-attribute unique/etc keys

2013-03-24 Thread Darren Duncan
From my usage and http://www.postgresql.org/docs/9.2/interactive/sql-createtable.html I see that Postgres requires constraints like unique (and primary) keys, and foreign keys, to range over at least 1 attribute/column. I propose that this be generalized so that constraints may instead be null