tanrj / pyodbc

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

ppc64 failures inserting and querying values #194

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create table (mysql)
USE mydb;
DROP TABLE IF EXISTS testtable;
CREATE TABLE testtable (
       rec_id BIGINT NOT NULL AUTO_INCREMENT,
       state TINYINT NOT NULL,
       PRIMARY KEY(rec_id)
);

2. Run program
import pyodbc

cnxn = pyodbc.connect('DRIVER={mysql};DATABASE=mydb;UID=me;PWD=blahblah')
cur = cnxn.cursor()

for x in range(5):
        cur.execute('''INSERT INTO testtable(state) VALUES(?)''',x)

cnxn.commit()

for r in cur.execute('''SELECT rec_id,state FROM testtable'''):
        print r 

What is the expected output? What do you see instead?

Expected:
(1L, 0)
(2L, 1)
(3L, 2)
(4L, 3)
(5L, 4)

Actual:
(1L, 0)
(2L, 0)
(3L, 0)
(4L, 0)
(5L, 0)

What version of the product are you using? On what operating system?

Red Hat Enterprise Linux Server release 6.0 (ppc64)
pyodbc 2.1.9
python 2.6.5

Please provide any additional information below.

I checked with the unixODBC folks and received this information on the SQL C 
types

"SQL_C_LONG is a 32 bit type, SQL_C_SMALLINT 16 bit and SQL_C_BIGINT 64. This 
doesnt change on 32/64 bit platforms. The names are a hangover from windows 
where a long is 32 bit both on 64 and 32 bit builds."

I made a patch which seems to work - testcase runs as well as provided unittest 
for mysql

diff ./cursor.h /old/src/cursor.h
59c59
<         int32_t l;

---
>         long l;
diff ./getdata.cpp /old/src/getdata.cpp
467c467
<     int32_t value = 0;

---
>     long value = 0;

Original issue reported on code.google.com by Sanders....@gmail.com on 3 Aug 2011 at 6:39

GoogleCodeExporter commented 8 years ago
I believe this is fixed in 3.0.x.  Can you test with a recent build?  I don't 
have a PPC box availble, but the 64-bit Linux (unixODBC), Windows (MS ODBC), 
and OS/X (iODBC) builds are working.

Marking as Hold until I hear back.  Thanks.

Original comment by mkleehammer on 18 Dec 2011 at 11:14

GoogleCodeExporter commented 8 years ago
I pulled the lasted git build (12/22/2011) and built for ppc64 
(created/installed RPM pyodbc-3.0.2_beta02-1.ppc64)

Problem appears to be fixed.

Original comment by Sanders....@gmail.com on 22 Dec 2011 at 3:02