I have three queries that I'm running through SQLite. These are what I'm running; the first is the table declaration and then the next 3 are the actual queries.
Declaration:
"CREATE TABLE IF NOT EXISTS items (busid INTEGER PRIMARY KEY, ipaddr TEXT, time TEXT DEFAULT (NOW()));"
Queries:
- (Works) "INSERT INTO items (time, ipaddr) VALUES ('test', '192.168.1.1');"
- (Crashes) "INSERT INTO items (busid, ipaddr) VALUES (10, '192.168.1.1');"
- (Crashes) "INSERT INTO items (ipaddr) VALUES ('192.168.1.1');"
Query 1 works fine, whereas queries 2 and 3 cause a crash by means of an EXC_BAD_ACCESS within sqlite3ExprCodeTarget. Tracing back, I discover the last point my code touches is a sqlite3_prepare_v2() statement, which passes a valid database/string/etc. and, as I said, works fine with statement 1 above but not 2 or 3. What's wrong with this, and how can I fix it? Thanks.
EDIT 1: To clarify, Query 1, 2, and 3 are run separately in different runs of the program, not in sequence, and the database is destroyed in between runs, so running Query 1 has no effect on running Query 2 after the reset.
EDIT 2: Example C++ source file showing issue: http://cl.ly/2w3c - just set the database path in the source code to wherever you want it to create the test database.