I have a NETCF application that uses SQLite3 version 3.3.5. Its initialization 
code creates the database and several tables, and
creates indexes on the tables.

It works fine on devices both WinCE 4.20 (2003SE) and 5.00 (WM5), but on some 
5.10 WM6 devices, it's failing. In each confirmed case
so far, it's been a WM6 SmartPhone.

The problem seems to occur when processing a CREATE UNIQUE INDEX statement 
immediately after a CREATE TABLE statement.

sqlite3_step is returning SQLITE_ERROR, and the subsequent sqlite3_finalize 
returns SQLITE_SCHEMA.

There's no reason this should be happening. The initialization code runs in a 
separate thread than the UI, but the main thread
doesn't touch the database until later. In addition, if I set breakpoints and 
step through my code, it works fine.

The SQLITE_SCHEMA error is generated by sqlite3VdbeExec processing opcode 
OP_VerifyCookie. The p1 parameter is zero (main database)
and p2 is one more than the database schema version returned by 
sqlite3BtreeGetMeta.

I added the retry code from the SQLite FAQ, but it doesn't help. After retrying 
the SQLITE_SCHEMA error zero or more times (again,
apparently random), sqlite3_prepare fails with "no such table: main.xxxx" (even 
though the table was created immediately prior,
without error).

I found a comment in vdbe.c above the OP_SetCookie code (which is used to 
update the schema version) that says "A transaction must
be started before executing this opcode." So I added code to do just that 
before my table creation code, and it fixed the problem.

My question is why would this work on earlier versions of WinCE, and even on 
other devices running WM6? It's the same binary. I
suspect an uninitialized variable somewhere.

Regards,
David



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to