BUG #6669: unique index w/ multiple columns and NULLs

From: jose(dot)soares(at)sferacarta(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6669: unique index w/ multiple columns and NULLs
Date: 2012-05-31 05:25:24
Message-ID: E1SZxsy-0001GO-JW@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 6669
Logged by: jose soares
Email address: jose(dot)soares(at)sferacarta(dot)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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Postgres User 2012-05-31 05:57:17 Re: BUG #6668: hashjoin cost problem
Previous Message Tom Lane 2012-05-31 05:03:24 Re: BUG #6668: hashjoin cost problem