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



On 18 July 2013 17:56, Martyn Russell <martyn lanedo com> wrote:
On 12/07/13 12:03, Jonatan Pålsson wrote:

Hi list,


Hello Jonatan,

Hi Martyn!

I couldn't verify this easily.

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
$


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
history of the project does not appear to be searchable easily. Is the
fact that the semantics are correct for version 3.7.9, and the fact
that the PRAGMA is deprecated in the current documentation enough?

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

--
Regards,
Jonatan Pålsson

Pelagicore AB
Ekelundsgatan 4, 6th floor, SE-411 18 Gothenburg, Sweden


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