wmjie / ibm-db

Automatically exported from code.google.com/p/ibm-db
0 stars 0 forks source link

Patch to enable building on Python 2.4 #52

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Python 2.4 does not define Py_ssize_t. This can be worked around by a simple 
conditional 
typedef to int.

I realize you probably don't want to officially support Python 2.4, but some 
people are stuck with 
it.

This is lightly tested. I got it to build, and I can create a connection to the 
database successfully, 
but I haven't gone beyond that yet.

What steps will reproduce the problem?
1. cd ibm_db
2. python2.4 setup.py build

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

Instead of completed build, get: 

gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wall 
-Wp,-D_FORTIFY_SOURCE=2 -
fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -
D_GNU_SOURCE -fPIC -fPIC -I/opt/IBM/db2/V8.1/include -I/usr/include/python2.4 
-c ibm_db.c 
-o build/temp.linux-x86_64-2.4/ibm_db.o
ibm_db.c: In function ‘_python_ibm_db_bind_data’:
ibm_db.c:4334: error: ‘Py_ssize_t’ undeclared (first use in this function)
ibm_db.c:4334: error: (Each undeclared identifier is reported only once
ibm_db.c:4334: error: for each function it appears in.)
ibm_db.c:4334: error: expected ‘;’ before ‘buffer_len’
ibm_db.c:4439: error: ‘buffer_len’ undeclared (first use in this function)
ibm_db.c:4554: warning: null argument where non-null required (argument 1)
error: command 'gcc' failed with exit status 1

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

Path: .
URL: http://ibm-db.googlecode.com/svn/trunk
Repository Root: http://ibm-db.googlecode.com/svn
Repository UUID: 1b047d87-d943-0410-8e89-5b5f2422cd04
Revision: 105
Node Kind: directory
Schedule: normal
Last Changed Author: rahul.priyadarshi@in.ibm.com
Last Changed Rev: 102
Last Changed Date: 2010-03-29 08:11:33 -0400 (Mon, 29 Mar 2010)

RHEL 5.5 x86_64

Please provide any additional information below.

Original issue reported on code.google.com by farcep...@gmail.com on 23 Apr 2010 at 3:55

Attachments:

GoogleCodeExporter commented 9 years ago
I've discovered that, although I can do normal queries, the exception handling
doesn't work, because in the Error class, it is using super(), and since in 
Python
2.4 exceptions are classes and not types, it fails. I have come up with a small 
patch
for this.

I still get an exception for when I try to perform a SELECT on system tables. 
This
might in itself be a separate issue. The following query works if I use 
mx.ODBC.DB2.
Also, this is with the patch applied (otherwise it fails in Error.__init__()).

In [4]: c.execute("select tbname,name,coltype,remarks from sysibm.syscolumns s 
where
s.dbname='XXXX' and s.tbname='XXXXXXX'")
---------------------------------------------------------------------------
Error                                     Traceback (most recent call last)

<ipython console> 

/usr/lib/python2.4/site-packages/ibm_db_dbi.py in execute(self, operation, 
parameters)
   1181         self.__description = None
   1182         self._all_stmt_handlers = []
-> 1183         self._prepare_helper(operation)
   1184         self._set_cursor_helper()
   1185         self._execute_helper(None, parameters)

/usr/lib/python2.4/site-packages/ibm_db_dbi.py in _prepare_helper(self, 
operation,
parameters)
   1042             self.stmt_handler = ibm_db.prepare(self.conn_handler, operation)
   1043         except Exception, inst:
-> 1044             raise _get_exception(inst)
   1045 
   1046     # Helper for preparing an SQL statement.

Error: ibm_db_dbi::Error: <exceptions.Exception instance at 0x2ba8a83cd200>

Using DB2 v8.1 (sorry)

Original comment by farcep...@gmail.com on 27 Apr 2010 at 4:07

Attachments:

GoogleCodeExporter commented 9 years ago
Scratch that last bit about it not working on system tables. I *do* have an 
error in
that query. With mx.ODBC.DB2, I get:

InterfaceError: ('42S22', -206, '[IBM][CLI Driver][DB2] SQL0206N  "S.DBNAME" is 
not
valid in the context where it is used.  SQLSTATE=42703\n', 4612)

So I would amend it to say, ibm_db_dbi's error reporting can be improved 
somewhat.

Note that the ibm_db_dbi_p2.4_exc.diff patch is still needed for Python 2.4
compatibility.

Original comment by farcep...@gmail.com on 27 Apr 2010 at 4:13

GoogleCodeExporter commented 9 years ago
We are ready to accept your patch but before that you have to sign contribution
agreement. Please go through http://code.google.com/p/ibm-db/wiki/Contributions 
 to
understand and sign contribution agreement.

We will not officially support python-2.4 but we will include your patch in our
driver. Though this other users who want to use python-2.4 will get benefit of 
your
patch. 

Our currently implemented dbi wrapper is able to report error correctly for the 
query
you are executing. So, you have to improve you dbi patch to handle error 
reporting.

Original comment by rahul.pr...@in.ibm.com on 7 May 2010 at 6:42

GoogleCodeExporter commented 9 years ago
Red Hat Enterprise Linux 5 is an important platform to support, and it ships 
Python 2.4. So it's important to have this issue fixed.

Original comment by troels.a...@gmail.com on 7 Sep 2010 at 7:34

GoogleCodeExporter commented 9 years ago
FWIW, I had to abandon my use of Python-2.4 on RHEL-5 for other compatibility 
reasons not related to this module. Perhaps this trivial patch will be useful 
for someone else, though.

Original comment by farcep...@gmail.com on 17 Nov 2011 at 4:10

GoogleCodeExporter commented 9 years ago
sanity test of ibm_db is working fine, It is still not officially supported.

Original comment by rahul.pr...@in.ibm.com on 1 Mar 2013 at 10:01