Skip site navigation (1) Skip section navigation (2)

Re: BUG #5005: unique constraint considers nulls to be equal

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Dean Schulze <dean(dot)w(dot)schulze(at)comcast(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5005: unique constraint considers nulls to be equal
Date: 2009-08-24 00:57:01
Message-ID: 20090824005701.GH5287@alvh.no-ip.org (view raw or flat)
Thread:
Lists: pgsql-bugs
Dean Schulze wrote:

> Here are the duplicate records that violate this constraint:
> 
> select county, year, idnumber, count(0) from table1 group by county, year,
> idnumber having (count(0) > 1) order by county, count(0);
> 
> 
> "county","year","idnumber","count"
> "AD",2009,"A57504",2
> "AD",2009,"A58395",2
> "AD",2009,"A58286",2
> "AD",2009,"A58299",2
> "AD",2009,"",5

What you have here seems to be an empty string, which is not the same as
a NULL value.  True NULLs behave as expected.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

pgsql-bugs by date

Next:From: Peter EisentrautDate: 2009-08-24 08:53:37
Subject: Re: BUG #4999: select 'a' < 'A' is true, but should be false . . .
Previous:From: Dean SchulzeDate: 2009-08-23 22:59:49
Subject: BUG #5005: unique constraint considers nulls to be equal

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group