From: jose.soares@sferacarta.com
To: pgsql-bugs@postgresql.org
Subject: BUG #6669: unique index w/ multiple columns and NULLs
Date: Thu, 31 May 2012 05:25:24 +0000
Message-ID: <E1SZxsy-0001GO-JW@wrigleys.postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 6669
Logged by: jose soares
Email address: jose.soares@sferacarta.com
PostgreSQL version: 8.4.8
Operating system: x86_64-pc-linux-gnu, debian
Description:
Hi,
I think I have found an error in pg or at least inconsistency, take a look
at this.
I created an unique index on two columns and pg let me enter repeated values
as NULLs (unknown value),
When I ask pg to tell me if there are repetitions n this index (with group
by),
the inconsistency becomes apparent.
# create table test(id int, data date, code int);
CREATE TABLE
# create UNIQUE index unica on test(data,code);
CREATE INDEX
# \d test
Table "public.test"
Column | Type | Modifiers
--------+---------+-----------
id | integer |
data | date |
code | integer |
Indexes:
"unica" UNIQUE, btree (data, code)
# insert into test values(1,current_date);
INSERT 0 1
# insert into test values(2,current_date);
INSERT 0 1
# insert into test values(3,current_date);
INSERT 0 1
sicer_forli=# select current_date,code, count(*) from test group by 1,2;
date | code | count
------------+------+-------
31-05-2012 | | 3
(1 row)
ps:
Oracle don't allows to insert two NULLs in such column.
I don't know which of them is SQL Standard, but in this case oracle is
not inconsistent.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: jose.soares@sferacarta.com
Subject: Re: BUG #6669: unique index w/ multiple columns and NULLs
In-Reply-To: <E1SZxsy-0001GO-JW@wrigleys.postgresql.org>
References: <E1SZxsy-0001GO-JW@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox