On Tue, Mar 7, 2017 at 9:36 AM, Clemens Ladisch <clem...@ladisch.de> wrote:

> Vermes Mátyás wrote:
> > http://comfirm.hu/pub/sqlite3-regression.rb
>
> >     db.execute("select szamla,megnevezes from proba") do |row|
> >         ...
> >         db.execute( "update proba set megnevezes=? where szamla=?",
> row[1]+"*", row[0] )
>
> The equivalent Python code would be:
>
>   for row in db.execute("select ... from proba"):
>     db.execute("update proba ...")
>
> > The linked ruby script demonstrates a feature of the newer sqlite3
> libraries, which may be a regression.
>
> I do not know what you expect to happen, or what actually happens, but
> changing a table and reading it through a query at the same time has an
> unspecified result.  In particular, the database might either fetch the
> next result on demand from the actual table or have some result rows
> already precomputed, so it is undefined whether continuing the SELECT
> sees the old values or the new values or both or neither.
>

Right, unless you use WAL mode for MVCC, and do the updates on a separate
connection and transaction.
That way you iterate on the old rows at the time (snapshot, SCN, etc...)
the select transaction starts,
and the updates (on that other connection, in a different transaction) do
not affect that select.

At least that's the conceptual model I have in my head for SQLite in WAL
mode.
If that's incorrect, please let me know. Thanks, --DD
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to