Re: [Tracker] PATCH: Don't use the count_changes PRAGMA in SQLite, it is deprecated



Realised, I didn't CC the list.

Also, sorry Jonatan, but I forgot to assign authorship to your commit :(

And GNOME's git doesn't appear to allow me to change that easily. If anyone in the GNOME community knows how to do this to origin (upstream), let me know.

Thanks,


On 19/07/13 14:41, Martyn Russell wrote:
On 19/07/13 08:13, Jonatan Pålsson wrote:
On 18 July 2013 17:56, Martyn Russell <martyn lanedo com> wrote:
Here's a short snippet demonstrating the effects of the PRAGMA on
SQLite 3.7.9, which should show that removing the PRAGMA doesn't
change the behavior of Tracker (I also ran Tracker with the new
PRAGMA, of course, but I think this is a more concrete example). It
should be noted that the following snippet most likely corrupts the
Tracker database, so don't run it on a database with any important
information in it. I will actually corrupt the snippet a bit to
prevent people from just cutting and pasting for the fun of it.

$ cat /tmp/pragma.py ; echo ; echo "Output:" ;
LD_LIBRARY_PATH=/tmp/sqlite_install/lib python /tmp/pragma.py
import sqlite3

def pragma(sql):
     db = sqlite3.connect("/home/jonatan/.cache/tracker/meta.db")
     c = db.cursor()
     if sql:
         c.execute(sql)
!! Warning - Don't actually run this code, it is bad for your
database. !!
     res = c.execute("insert into Resource values ('1008040', 'phony')")
     r = res.fetchone()
     db.close()
     return r

p1 = pragma("PRAGMA count_changes = 1")
p2 = pragma("PRAGMA count_changes = 0")
p3 = pragma(None)
print "p1: %s\np2: %s\np3: %s" % (p1,p2,p3)
if (p2 == p3):
     print "Default behavior equals PRAGMA count_changes = 0"
print "SQLite library version: %s" % sqlite3.sqlite_version

Output:
p1: (1,)
p2: None
p3: None
Default behavior equals PRAGMA count_changes = 0
SQLite library version: 3.7.9

Thanks for the example.

I was looking in the source for SQLite3, but couldn't find it in a short
time. So thanks.

Before I commit, I want to make sure the pragma wasn't deprecated
before the
version we depend on (3.7.9) and the default is correct.

Did you verify this?

The snippet above should serve as verification of the correctness of
the defaults, but I am actually unable to verify when the PRAGMA was
deprecated. I can't find it in any release notes, and the commit

Yea, I was looking in the sources and git log (mirror) for signs of this
and couldn't see anything. Even the website side of things (which used
to be in the source < v3) is no longer in the code base so I can't go on
when the documentation was updated either :/

history of the project does not appear to be searchable easily. Is the

Yea, this was my problem too.

fact that the semantics are correct for version 3.7.9, and the fact
that the PRAGMA is deprecated in the current documentation enough?

Yes, thanks for providing the details here.

I will look a bit more for the deprecating commit, and post an update
if I find it!

I've committed this patch.
Thanks again :)



--
Regards,
Martyn

Founder and CEO of Lanedo GmbH.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]