I just grabbed the 3.7.10 amalgamation source and built it, but have run into 
an issue where DISTINCT doesn't appear to actually return distinct values on a 
table that includes a UNIQUE clause.  It unexpectedly returns duplicates 
instead.

My build environment is:

- Mac OS X 10.6.8
- Xcode 3.2.5
- The source is built from within an Xcode project using LLVM GCC 4.2
- As mentioned above, I'm using the amalgamation source

I found a fairly simple repro case using the shell tool (again, built by Xcode 
as above).

% ./sqlite3 :memory:
SQLite version 3.7.10 2012-01-16 13:28:40
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE t ( a INTEGER NOT NULL, b INTEGER NOT NULL, UNIQUE (a,b) );
sqlite> INSERT INTO t VALUES(1,1);
sqlite> INSERT INTO t VALUES(2,1);
sqlite> INSERT INTO t VALUES(3,1);
sqlite> INSERT INTO t VALUES(2,2);
sqlite> INSERT INTO t VALUES(3,2);
sqlite> INSERT INTO t VALUES(4,2);
sqlite> SELECT DISTINCT b from t WHERE a IN (1,2,3);
1
2
1
2


I obviously don't expect the duplicate results here.  If you create the table 
without the UNIQUE clause, then the results are as expected (1 and 2 both only 
show up once).

As a point of reference, the sqlite3 shell tool that ships with the OS (3.6.12) 
does produce the correct results.



-- Steven Russell
sruss...@extensis.com
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to