Re: [BUGS] BUG #6669: unique index w/ multiple columns and NULLs

2012-06-05 Thread jo
Jeff Davis wrote: On Mon, 2012-06-04 at 11:56 -0400, Bruce Momjian wrote: I get your point about COUNT(*) really counting rows, not values, but why doesn't GROUP BY then skip nulls? A while ago, I came to the conclusion that applying logic to extrapolate the behavior of NULL is a bad

Re: [BUGS] BUG #6669: unique index w/ multiple columns and NULLs

2012-06-04 Thread jo
Hi Tom, Thanks for the explanation about standard sql. The goodness of it must be accepted by faith. :-) I still have a doubt about the result of the GROUP BY clause. It seems to me that there's an inconsistence between the GROUP BY clause and the unique index. The GROUP BY clause, consider

Re: [BUGS] BUG #6669: unique index w/ multiple columns and NULLs

2012-06-04 Thread Kevin Grittner
jo jose.soa...@sferacarta.com wrote: Thanks for the explanation about standard sql. The goodness of it must be accepted by faith. :-) Not if you have the stamina to fight your way through the standards documents. ;-) I still have a doubt about the result of the GROUP BY clause. It seems

Re: [BUGS] BUG #6669: unique index w/ multiple columns and NULLs

2012-06-04 Thread Bruce Momjian
On Fri, Jun 01, 2012 at 08:58:32AM +0200, jo wrote: Hi Tom, Thanks for the explanation about standard sql. The goodness of it must be accepted by faith. :-) I still have a doubt about the result of the GROUP BY clause. It seems to me that there's an inconsistence between the GROUP BY

Re: [BUGS] BUG #6669: unique index w/ multiple columns and NULLs

2012-06-04 Thread Kevin Grittner
Bruce Momjian br...@momjian.us wrote: COUNT(*) can't skip nulls because there is no specified column, but why does COUNT(col) skip nulls --- again, inconsistent. I disagree -- one is counting rows, the other is counting rows with a value in that column. I guess one could criticize the

Re: [BUGS] BUG #6669: unique index w/ multiple columns and NULLs

2012-06-04 Thread Bruce Momjian
On Mon, Jun 04, 2012 at 10:29:22AM -0500, Kevin Grittner wrote: Bruce Momjian br...@momjian.us wrote: COUNT(*) can't skip nulls because there is no specified column, but why does COUNT(col) skip nulls --- again, inconsistent. I disagree -- one is counting rows, the other is counting

Re: [BUGS] BUG #6669: unique index w/ multiple columns and NULLs

2012-06-04 Thread Kevin Grittner
Bruce Momjian br...@momjian.us wrote: I get your point about COUNT(*) really counting rows, not values, but why doesn't GROUP BY then skip nulls? WITH null_test (col1, col2) AS ( SELECT 1, null UNION ALL SELECT null, null ) SELECT COUNT(*), col2 FROM null_test

Re: [BUGS] BUG #6669: unique index w/ multiple columns and NULLs

2012-06-04 Thread Bruce Momjian
On Mon, Jun 04, 2012 at 11:26:20AM -0500, Kevin Grittner wrote: I think the original complaint is that NULL != NULL in a WHERE clause, but GROUP BY is able to group them together just fine. Whoa! I think I know what you meant, but that is a dangerously misleading misstatement. It is not

Re: [BUGS] BUG #6669: unique index w/ multiple columns and NULLs

2012-06-04 Thread Jeff Davis
On Mon, 2012-06-04 at 11:56 -0400, Bruce Momjian wrote: I get your point about COUNT(*) really counting rows, not values, but why doesn't GROUP BY then skip nulls? A while ago, I came to the conclusion that applying logic to extrapolate the behavior of NULL is a bad idea:

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

2012-05-31 Thread jose . soares
The following bug has been logged on the website: Bug reference: 6669 Logged by: jose soares Email address: jose.soa...@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

Re: [BUGS] BUG #6669: unique index w/ multiple columns and NULLs

2012-05-31 Thread Tom Lane
jose.soa...@sferacarta.com writes: 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), This is entirely correct per SQL standard: unique constraints do not