--Re-posted from correct address - apologies if this comes through twice--
On 2018/06/20 7:05 AM, Igor Korot wrote:
One more question:
I presume I should call PRAGMA schema_version right after connection
has been made,
cache the value returned and then create a secondary thread which will
call this query continuously.
Am I right?
That is up to you, but what you need to know is basically that every
time the schema is changed for whatever reason (via standard methods in
the API [1]), there is a schema-version counter that gets incremented
[2], and this counter value is returned when you query pragma
schema_version.
That means that that query will return the same integer value
consistently, across database connections, until the schema changes, and
from then on a new incremented value is returned, so everything that's
been paying attention to the value before will know the value is now new
and so the schema has changed. (One could even deduce how many times it
changed from the value, though that is not typically useful information).
Cheers!
Ryan
[1] There is a way to circumvent the standard methods by setting a
pragma to make the schema writable - in which case I'm not sure if the
schema_version counter still gets updated - but either way, that should
never happen during normal operation.
[2] The counter is also accessible via reading the SQLite file header if
you deal directly with file-io in stead of the normal API or perhaps
have a system that monitors sqlite files rather than a specific
connection (just search "file header" in the SQLite site), but then you
have to deal with file locking, access error handling etc. Best is to
just query the pragma.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users