Sybase: patch for handling DECIMAL data type (Invalid buffer element type)
Hi, I will recap here the problem with SybaseDAv2 regarding the handling of DECIMAL data type, this is the source of the "Invalid buffer element type" error that I found. Right now the database adapter is crashing for DECIMAL data types that are integers with precisions higher than 9 digits. (For DECIMAL data types that are integers with precisions less or equal than 9 digits, the adapter converts them into INT data type, and there will be no problem.) To fix this glitch, I had to modify two files in the SybaseDAv2 distribution. (The current release is v2.0.0b1, http://www.zope.org/Products/DA/SybaseDA/) (1) Follow the instructions till you have done the command make -f Makefile.pre.in boot (2) Edit the file SybaseDAv2/src/sy_occbf.c near the place where it says "Invalid buffer element type", insert another case statement for the CS_DECIMAL_TYPE. The result should look like: case CS_DATETIME4_TYPE: element_size=sizeof(CS_DATETIME4); break; case CS_NUMERIC_TYPE: element_size=sizeof(CS_NUMERIC); break; case CS_DECIMAL_TYPE: element_size=sizeof(CS_NUMERIC); break; case CS_BIT_TYPE: element_size=sizeof(CS_BIT); break; case STRING_CASES: break; default: return SybaseError("Invalid buffer element type"); } (3) Proceed with the instructions and issue the make command, and move the sy_occ.so library a level up to your SybaseDAv2 directory. Follow all other instructions of the README.txt file provided with the distribution. (4) You will also need to edit the SybaseDAv2/db.py file. Search for the lines that say: if string_type(t): v=rstrip(buf[:cop[0]]) elif t is sy_occ.CS_NUMERIC_TYPE: and change the elif line to: elif t in (sy_occ.CS_NUMERIC_TYPE, sy_occ.CS_DECIMAL_TYPE): (5) Restart your Zope. And hopefully this solves your problem with the DECIMAL database. At least this is how fixed my problem. :) I guess SybaseDAv2 needs more people's feedback. Right now it seems to have a some problems. regards, Hung Jung ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
participants (1)
-
Hung Jung Lu