zmeng3 / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

sybase iq 15.4 integer -1 and 0 return wrong value #360

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.a table has a column ,that type is int
2.insert tow value 0 and -1 into the table
3.query the tow row use pyodbc 3.0.7

What is the expected output? What do you see instead?
expected 0 and -1 output,but it return -4294967296 and 4294967295 instead

What version of the product are you using? On what operating system?
 pyodbc3.0.7 & Linux version 2.6.32-279.el6.x86_64 

Please provide any additional information below.

Original issue reported on code.google.com by lileix...@gmail.com on 7 Mar 2014 at 2:01

GoogleCodeExporter commented 8 years ago
The same problem exists running on RHEL6 against a Sybase IQ database, Sybase 
ASE database, and a SQL Server database, using Data Direct 7.1 ODBC drivers.  
This problem does not manifest in pyodbc-3.0.3.

conn = pyodbc.connect("DSN=...")
cur = conn.execute("select 1 as num")
print cur.fetchall()
print cur.description

[(206158430209, )]
(('num', <type 'int'>, None, 5, 5, 0, False),)

Same code running on RHEL5:

[(1, )]
(('num', <type 'int'>, None, 5, 5, 0, False),)

The ODBC trace files show that, other than the handles (pointers) used, the 
ODBC processing is identical.

Original comment by colorado...@gmail.com on 7 Aug 2014 at 4:49

GoogleCodeExporter commented 8 years ago
I experience the exact same problem as mentioned by @colorado with 3.0.7 when 
querying against Sybase.

import pyodbc
dbconn = pyodbc.connect("DSN=....")
c = dbconn.cursor()
c.execute("select 0, 1, 2, 3, 4, 5, 6")
print c.fetchone()

>> (210453397504, 210453397505, 210453397506, 210453397507, 210453397508, 
210453397509, 210453397510)

It seems to be adding 2^32 * 7 **2 to the value for every result. This is true 
up until 2147483648 is used, at which point values are correct and are returned 
as type Long.

The exact same script using 3.0.3 returns the correct values. I am using RHEL6.

Original comment by michaelw...@gmail.com on 27 Apr 2015 at 10:32