I recently updated our SQLite source to SQLite source distribution 3.7.17. 
Since then, we get assertions when running one of our larger queries. I have 
stripped down the query to a bare minimum query that produces the same 
assertion:

The following rather simple SELECT query gives me an assertion in sqlite3.c 
line 109259:

CREATE TABLE p (
  id INTEGER PRIMARY KEY,
  uid VARCHAR(36),
  t INTEGER
);

CREATE TABLE pa (
  id INTEGER PRIMARY KEY,
  p_id INTEGER,
  a_uid VARCHAR(36)
);

CREATE TABLE a (
  id INTEGER PRIMARY KEY,
  uid VARCHAR(36),
  t INTEGER
);

SELECT DISTINCT    
  pa.p_id AS pid,
  a.uid AS a_uniqueid,
  p.t AS p_t
FROM 
  pa 
  LEFT JOIN p ON
    p.uid='1234'
  LEFT JOIN a ON 
    a.uid=pa.a_uid
WHERE
  a.t=p.t
;


Running this SELECT query causes the following assertion to fire:

Gandalf:~ jens$ sqlite3 < /tmp/foo.sql/
sqlite3.c:109259: failed assertion `(pTerm->prereqRight & newNotReady)!=0'
Assertion failed: (libcompiler_rt abort), function __eprintf, file 
/SourceCache/clang/clang-425.0.27/src/projects/compiler-rt/lib/eprintf.c, line 
31.
Abort trap: 6


I took a look at the source code, but unfortunately, I cannot deduce what's 
going wrong in that function :(

All I found is that when I change the order of the JOIN statements, the query 
works. Unfortunately, while this seems easy in this reduced example, in real 
world, I cannot easily change the order of the JOINs due to other restrictions.

A google query for the expression used in the assertion showed that the block 
of code containing the assertion was introduced in Check-in [5f4907e1c6] 
<http://www.sqlite.org/src/info/5f4907e1c6>... doesn't help me much either :(


Version Info:
Gandalf:~ jens$ sqlite3 -version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668

(This is on Mac OS X, compiling with Apple LLVM version 4.2 (clang-425.0.27) 
(based on LLVM 3.2svn) for 32-bit Intel architecture, in case this matters)


Any help welcome...

Thanks,
-jens

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to