RE: MemoryError using Sybase, FreeTDS, MS SQL

[email protected]
Newsgroups gmane.comp.python.sybase
Message-ID <71E7879B20E1C84B9055F73AD9B79CD8229C17@msg1-il.integration.sungard.corp>
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:[email protected]] 
Sent: Thursday, January 23, 2003 22:20
To: Dave Cole
Cc: [email protected]
Subject: Re: [python-sybase] MemoryError using Sybase, FreeTDS, MS SQL


Hi,

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

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

ct_describe(cmd1, 9, &fmt) -> CS_SUCCEED, datafmt8=[name:"lengthScale" 
type:CS_FLOAT_TYPE status:CS_FALSE format:CS_FMT_UNUSED count:1
maxlength:8] ct_bind(cmd1, 9, &datafmt8->fmt=[name:"lengthScale"
type:CS_FLOAT_TYPE 
status:CS_FALSE format:CS_FMT_UNUSED count:32 maxlength:8], 
databuf8->buff, databuf8->copied, databuf8->indicator) -> CS_SUCCEED,
databuf8
ct_describe(cmd1, 10, &fmt) -> CS_SUCCEED, datafmt9=[name:"material" 
type:CS_TEXT_TYPE status:CS_CANBENULL format:CS_FMT_UNUSED count:1 
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 
727, in execute
    result_list = self._fetch_results()
  File "/usr/local/pub/dm/lib/python2.1/site-packages/Sybase.py", line 
745, in _fetch_results
    bufs = _row_bind(cmd, self.arraysize)
  File "/usr/local/pub/dm/lib/python2.1/site-packages/Sybase.py", line 
159, in _row_bind
    status, buf = 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) -> 
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 
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, 
the full output is attached in "output2".

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

Thanks,
Valerie
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.