[python-sybase] MemoryError using Sybase, FreeTDS, MS SQL

Shai.Berger@integration.sungard.com Shai.Berger at integration.sungard.com
Sun, 26 Jan 2003 11:02:42 +0200


Hi all,

This exposes a deep problem with text/image columns:

a) They must be treated specially, not like other columns -- they have a
special calling sequence, a special set of functions for dealing with
them;

b) This special treatment cannot be applied to columns in the middle of
the query -- all text/image columns must come after all "normal"
columns.

Now, my knowledge is based on Sybase's client library, ct. FreeTds may
be different. However,

Dave: If the Sybase module does not pay special attention to text/image
columns, it is a bug with the direct Sybase implementation (sorry, no
time to check for myself right now).

Valerie: Whether or not Sybase module has a bug, you may need to change
the query so that the text fields are all in the end. You don't need to
redefine the table, only query with a specified list of fields ("select
a,b,c from table"), so that the order of fields is as required.

Hope this helps,
	Shai.


-----Original Message-----
From: Valerie R. Coffman [mailto:vrc3@cornell.edu]=20
Sent: Thursday, January 23, 2003 22:20
To: Dave Cole
Cc: python-sybase@object-craft.com.au
Subject: Re: [python-sybase] MemoryError using Sybase, FreeTDS, MS SQL


Hi,

Dave, thanks for your response.  We have a big interest in this module=20
because without it, we have to use a combination of Perl and Python and=20
it's pretty ugly.

I've dowloaded the version 0.36pre3 and turned on the debugging.  I'm=20
still seeing the same error and it appears that the problem is with=20
retrieving a text type column.  Here is part of the output.  The full=20
output is attatched in the file "output".

ct_describe(cmd1, 9, &fmt) -> CS_SUCCEED, datafmt8=3D[name:"lengthScale" =

type:CS_FLOAT_TYPE status:CS_FALSE format:CS_FMT_UNUSED count:1
maxlength:8] ct_bind(cmd1, 9, &datafmt8->fmt=3D[name:"lengthScale"
type:CS_FLOAT_TYPE=20
status:CS_FALSE format:CS_FMT_UNUSED count:32 maxlength:8],=20
databuf8->buff, databuf8->copied, databuf8->indicator) -> CS_SUCCEED,
databuf8
ct_describe(cmd1, 10, &fmt) -> CS_SUCCEED, datafmt9=3D[name:"material"=20
type:CS_TEXT_TYPE status:CS_CANBENULL format:CS_FMT_UNUSED count:1=20
maxlength:2147483647]
Traceback (most recent call last):
  File "DBTest.py", line 10, in ?
    db.execute("SELECT * FROM FEMMD_Parameters")
  File "/usr/local/pub/dm/lib/python2.1/site-packages/Sybase.py", line=20
727, in execute
    result_list =3D self._fetch_results()
  File "/usr/local/pub/dm/lib/python2.1/site-packages/Sybase.py", line=20
745, in _fetch_results
    bufs =3D _row_bind(cmd, self.arraysize)
  File "/usr/local/pub/dm/lib/python2.1/site-packages/Sybase.py", line=20
159, in _row_bind
    status, buf =3D cmd.ct_bind(i + 1, fmt)
MemoryError
ct_cmd_drop(cmd1) -> CS_SUCCEED
ct_con_props(conn0, CS_GET, CS_CON_STATUS, &value, CS_UNUSED, NULL) ->=20
CS_SUCCEED, CS_CONSTAT_CONNECTED
ct_close(conn0, CS_OPT_STATS_IO) -> CS_SUCCEED
ct_con_drop(conn0) -> CS_SUCCEED

There should be two more columns after the "material" column, so it=20
seems that it does not finish retrieving one row, but stops at the first

text type row.

Knowing this, I've tried a similar query on a table that does not have a

text column and I get a different error.  Here is part of the output,=20
the full output is attached in "output2".

ct_describe(cmd1, 8, &fmt) -> CS_SUCCEED, datafmt7=3D[name:"energy"=20
type:CS_FLOAT_TYPE status:CS_FALSE format:CS_FMT_UNUSED count:1=20
maxlength:8 scale:0 precision:0]
ct_bind(cmd1, 8, &datafmt7->fmt=3D[name:"energy" type:CS_FLOAT_TYPE=20
status:CS_FALSE format:CS_FMT_UNUSED count:32 maxlength:8 scale:0=20
precision:0], databuf7->buff, databuf7->copied, databuf7->indicator) ->=20
CS_SUCCEED, databuf7
ct_fetch(cmd1, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read) ->=20
CS_ROW_FAIL, 0
Traceback (most recent call last):
  File "DBTest.py", line 10, in ?
    db.execute("SELECT * FROM FEMMD_AtomicInfo")
  File=20
"/afs/.msc.cornell.edu/i386_linux22/usr/local/pub/dm/lib/python2.1/site-
packages/Sybase.py",=20
line 732, in execute
    result_list =3D self._fetch_results()
  File=20
"/afs/.msc.cornell.edu/i386_linux22/usr/local/pub/dm/lib/python2.1/site-
packages/Sybase.py",=20
line 751, in _fetch_results
    logical_result =3D self._fetch_logical_result(bufs)
  File=20
"/afs/.msc.cornell.edu/i386_linux22/usr/local/pub/dm/lib/python2.1/site-
packages/Sybase.py",=20
line 760, in _fetch_logical_result
    rows =3D _fetch_rows(cmd, bufs)
  File=20
"/afs/.msc.cornell.edu/i386_linux22/usr/local/pub/dm/lib/python2.1/site-
packages/Sybase.py",=20
line 196, in _fetch_rows
    raise Error('ct_fetch')
Sybase.Error: ct_fetch
ct_cmd_drop(cmd1) -> CS_SUCCEED
ct_con_props(conn0, CS_GET, CS_CON_STATUS, &value, CS_UNUSED, NULL) ->=20
CS_SUCCEED, CS_CONSTAT_CONNECTED
ct_close(conn0, CS_OPT_STATS_IO) -> CS_SUCCEED
ct_con_drop(conn0) -> CS_SUCCEED

Thanks,
Valerie