SYNCHRONOUS = OFF will make new data not visible to select command? (the
same connection, before commit)

-----Original Message-----
From: sqlite-users-boun...@mailinglists.sqlite.org
[mailto:sqlite-users-bounces at mailinglists.sqlite.org] On Behalf Of Simon
Slavin
Sent: Friday, September 11, 2015 2:02 AM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Select after update get new or old values


On 10 Sep 2015, at 5:05pm, Nguyen Dang Quang <quangnd at gmail.com> wrote:

> In (4) the selected rows will have old or new values?

Read this:

<https://www.sqlite.org/isolation.html>

"Within a single database connection X, a SELECT statement always sees all
changes to the database that are completed prior to the start of the SELECT
statement, whether committed or uncommitted. And the SELECT statement
obviously does not see any changes that occur after the SELECT statement
completes. But what about changes that occur while the SELECT statement is
running? What if a SELECT statement is started and the sqlite3_step()
interface steps through roughly half of its output, then some UPDATE
statements are run by the application that modify the table that the SELECT
statement is reading, then more calls to sqlite3_step() are made to finish
out the SELECT statement? Will the later steps of the SELECT statement see
the changes made by the UPDATE or not? The answer is that this behavior is
undefined."

In other words, even if you do some experiments and figure out which one
SQLite is doing now for one specific query, do not depend on this behaviour
staying the same in future versions of SQLite, or even for different queries
in the same version of SQLite.

If you want guaranteed consistent behaviour, do your operation in two
different connections.  Then the answer depends on whether you are using WAL
mode or not.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users at mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to