Firstly, I use `PRAGMA table_info('sample')` in my sample case, which means
that it also calls `sqlite3_prepare_v2` but do not re-prepare. Maybe it does
not contain the specific OP checking the schema.
Secondly, it's hard to know when the schema is changed in multi-conns
implementation. So as telling them to re-prepare.
So, As your word "comthis situation would be a problem" said, is it that I
should not use the non-update-schema-operation in multi-conns implementation ?
If so, who or which doc can tell me that which SQL will or will not update the
schema ?
Original Message
Sender:Jay [email protected]
Recipient:SQLite mailing [email protected]
Date:Friday, Aug 18, 2017 19:46
Subject:Re: [sqlite] SQLite's Results Are Expired While Schema Is Changed !
On Aug 18, 2017, at 4:04 AM, sanhua.zh [email protected] wrote: I am using
SQLite in multi-thread mode, which means that different threads using different
SQLite connection. And now I find an issue that the results of SQLite C
interface returned is expired while the schema of database is changed. The
following sample runs in different threads, but I force them to
runsequentially. Thread 1: 1. Conn A: Open, PRAGMA journal_mode=WAL Thread
2: 2.ConnB: Open, PRAGMA journal_mode=WAL Thread 1: 3.ConnA: CREATE TABLE
sample (i INTEGER); Thread 2: 4.ConnB: PRAGMA table_info('sample')
Firstly, both thread 1 and 2 do initialization for their own conn, which is to
read to schema into memory. Then, Conn A creates a table with Conn A.
Finally, `PRAGMA table_info(sample)` is called in thread 2 with Conn B and it
returns nothing. The same thing could happen if I change the step 4 to
`sqlite3_table_column_metadata` or some other interfaces. I do know the
reason should be the expired in-memory-schema. But I find no docs about which
interface will or will not update the schema and what should I do while I call
a non-update-schema interface ? See the bottom of the sqlite3_prepare*() docs:
https://www.sqlite.org/c3ref/prepare.html And the SQLITE_SCHEMA docs:
https://www.sqlite.org/rescode.html#schema As the docs say, make sure you’re
using sqlite3_prepare*_v2() or _v3(). If a statement is prepared with these
newer versions, it will handle most expiration situations automatically by
re-preparing the statement. Generally speaking, if you do get an SQLITE_SCHEMA
error, you need to rollback the current transaction, re-prepare the statements,
and try again. -j -- Jay A. Kreibich J A Y @ K R E I B I.C H "Intelligence is
like underwear: it is important that you have it, but showing it to the wrong
people has the tendency to make them feel uncomfortable." -- Angela Johnson
_______________________________________________ sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users