[python-sqlite] strange error in parameters binding

17 views
Skip to first unread message

an...@angri.ru

unread,
May 11, 2010, 3:40:38 PM5/11/10
to python...@googlegroups.com
Hi,

It seems like I've just found a very strange bug in python-sqlite (the
version from vanila python 2.6.5 @ linux 2.6.3 amd64):

Here is the test:

import sqlite3
conn = sqlite3.connect(':memory:'); c = conn.cursor()
c.execute('CREATE TABLE tbl (col INTEGER)')
# does not reproduce without this insert:
c.execute('INSERT INTO tbl (col) VALUES (?)', [1])
# this works (parameters are hardcoded in query):
r1 = c.execute('SELECT coalesce(max(tbl.col), 0) + 1 FROM tbl').fetchone()
# and this not (the only difference is the parameters extracted):
r2 = c.execute('SELECT coalesce(max(tbl.col), ?) + ? FROM tbl', [0,
1]).fetchone()
assert r1 == r2, "%s != %s" % (r1, r2)
assert r1 == r2 == (2,)

The same queries pasted into a plain sqlite3 console works well.

Does it need some additional info? Should I create an issue at googlecode?

Thanks in advance,

--
angri

Gerhard Häring

unread,
May 11, 2010, 4:25:37 PM5/11/10
to python...@googlegroups.com
On Tue, May 11, 2010 at 9:40 PM, <an...@angri.ru> wrote:
> Hi,
>
> It seems like I've just found a very strange bug in python-sqlite (the
> version from vanila python 2.6.5 @ linux 2.6.3 amd64):
>
> Here is the test:
> [...]

On my MacBook, this code works with Python 2.6.1 and fails with Python
2.5.5. The SQLite version is identical (3.6.12).

If you say "Linux 2.6.3" this sounds like a Enterprisey Linux of some
sorts, which usually have packages from stone age. Which is the SQLite
version involved?

>>> import sqlite3
>>> sqlite3.sqlite_version
'3.6.12'

-- Gerhard

an...@angri.ru

unread,
May 11, 2010, 4:29:32 PM5/11/10
to python...@googlegroups.com
Hi,

2010/5/12 Gerhard Häring <g...@ghaering.de>:
> On Tue, May 11, 2010 at 9:40 PM,  <an...@angri.ru> wrote:
>> Hi,
>>
>> It seems like I've just found a very strange bug in python-sqlite (the
>> version from vanila python 2.6.5 @ linux 2.6.3 amd64):
>>
>> Here is the test:
>> [...]
>
> On my MacBook, this code works with Python 2.6.1 and fails with Python
> 2.5.5. The SQLite version is identical (3.6.12).
>
> If you say "Linux 2.6.3" this sounds like a Enterprisey Linux of some
> sorts, which usually have packages from stone age.

Oh, I'm sorry, that was a typo: actually it is 2.6.33.

> Which is the SQLite
> version involved?

3.6.23.1

--
angri

Gerhard Häring

unread,
May 11, 2010, 6:58:42 PM5/11/10
to python...@googlegroups.com
I'm afraid I can't reproduce the problem.

Current Python 2.6 maintenance branch against system SQLite doesn't
show the problem on my machine. Neither does the current externally
maintained pysqlite release.

-- Gerhard

an...@angri.ru

unread,
May 12, 2010, 2:48:17 AM5/12/10
to python...@googlegroups.com
Hm, the issue is always reproducible for me with python 2.6.5 on my
archlinux laptop and two ubuntu lucid machines (all of them are
x86-64). It also shows a bug in my another archlinux box with python
2.6.4 and sqlite 3.6.22.1. It is not reproducible on ubuntu karmic
x86-32 with python 2.6.4 and sqlite 3.6.16. On mac os 10.6.1 with
python 2.6.1 and sqlite 3.6.12 everything is ok too.

--
angri

Gerhard Häring

unread,
May 12, 2010, 3:26:33 AM5/12/10
to python...@googlegroups.com
On Wed, May 12, 2010 at 8:48 AM, <an...@angri.ru> wrote:
> [...]
>
> Hm, the issue is always reproducible for me with python 2.6.5 on my
> archlinux laptop and two ubuntu lucid machines (all of them are
> x86-64). It also shows a bug in my another archlinux box with python
> 2.6.4 and sqlite 3.6.22.1. It is not reproducible on ubuntu karmic
> x86-32 with python 2.6.4 and sqlite 3.6.16. On mac os 10.6.1 with
> python 2.6.1 and sqlite 3.6.12 everything is ok too.

I can reproduce the problem on Mac OS X with SQLite versions 3.6.22
and 3.6.23.1.

-- Gerhard

Gerhard Häring

unread,
May 12, 2010, 3:56:47 AM5/12/10
to python...@googlegroups.com
ghaering@ws124~/src/gh/pysqlite$ python testall.py
Building pysqlite against SQLite 3.6.12
Running test against SQLite 3.6.12
Building pysqlite against SQLite 3.6.13
Running test against SQLite 3.6.13
Building pysqlite against SQLite 3.6.14
Running test against SQLite 3.6.14
Building pysqlite against SQLite 3.6.15
Running test against SQLite 3.6.15
Building pysqlite against SQLite 3.6.16
Running test against SQLite 3.6.16
Building pysqlite against SQLite 3.6.17
Running test against SQLite 3.6.17
Building pysqlite against SQLite 3.6.18
Running test against SQLite 3.6.18
Building pysqlite against SQLite 3.6.19
Running test against SQLite 3.6.19
Building pysqlite against SQLite 3.6.20
Running test against SQLite 3.6.20
Building pysqlite against SQLite 3.6.21
Running test against SQLite 3.6.21
Traceback (most recent call last):
File "t.py", line 12, in <module>
assert r1 == r2, "%s != %s" % (r1, r2)
AssertionError: (2,) != (None,)
Building pysqlite against SQLite 3.6.22
Running test against SQLite 3.6.22
Traceback (most recent call last):
File "t.py", line 12, in <module>
assert r1 == r2, "%s != %s" % (r1, r2)
AssertionError: (2,) != (None,)
Building pysqlite against SQLite 3.6.23.1
Running test against SQLite 3.6.23.1
Traceback (most recent call last):
File "t.py", line 12, in <module>
assert r1 == r2, "%s != %s" % (r1, r2)
AssertionError: (2,) != (None,)
Reply all
Reply to author
Forward
0 new messages