large integer handling, as used in LIMIT for unlimited size, fails in 3.1 as a bind param

Bug #686232 reported by Mike Bayer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oursql
New
Undecided
Unassigned

Bug Description

MySQL's documented syntax for selecting with an OFFSET and unlimited LIMIT is to specify the large number 18446744073709551615 as the second argument:

http://dev.mysql.com/doc/refman/5.0/en/select.html

    To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter.
    This statement retrieves all rows from the 96th row to the last:

        SELECT * FROM tbl LIMIT 95,18446744073709551615;

The following script fails in Python 3.1, OurSQL 0.9.2:

    import oursql

    conn = oursql.connect(db='test', user='scott', passwd='tiger', host='localhost')

    cursor = conn.cursor()
    try:
        cursor.execute("drop table test")
    except:
        pass

    cursor.execute("""
    create table test(
        id integer primary key
    )
    """)

    cursor.execute("select * from test LIMIT ?, ? ", (5, 18446744073709551615))
    print("hi")
    cursor.fetchall()

hiTraceback (most recent call last):
  File "test.py", line 18, in <module>
    print("hi")
OverflowError: Python int too large to convert to C long

the "print("hi")" is important (in that there is some kind of method call before the fetchall()), as it triggers a particular oddness I've seen when Python has problems with native libraries. You'll notice it actually prints the "hi", then fails before getting to the fetchall().

The script works if the number is passed as a string. The script works as is in Python 2.x.

Revision history for this message
Aaron Gallagher (habnabit) wrote :

Looking into this. I need to rebuild python 3.1 with debugging flags to be able to step through it.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.