Skip to Content.
Sympa Menu

freetds - [freetds] New thread for pyodbc issues with freetds-0.83.dev

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Peter C. Norton" <spacey-freetds.org AT ssr.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] New thread for pyodbc issues with freetds-0.83.dev
  • Date: Mon, 25 Oct 2010 18:01:36 -0400

[hopefully this doesn't come to you as a repeat. The first time I
sent it, I used the wrong from address]

I'm working on tracking down the particular issue I'm having with
pyodbc, unixODBC and freetds. I wanted to start a new thread for
this, because my prior odbc prepared statement issue is orthogonal and
I don't want to get them confused.

Anyway, here is the code to reproduce the error:

#!/usr/bin/env python
import sys
import pyodbc

def the_long_test(db_name):
"""

Run this after creating a test table that looks like this:

use tempdb
go
create table no_long_test
(id int, name varchar(20))
go
insert into no_long_test values (1, 'abc')
insert into no_long_test values (2, 'xyz')
go
"""
db =
pyodbc.connect("DSN=%s;UID=USER;PWD=PASSWORD;DATABASE=tempdb;APP=python" %
db_name)
q = db.execute("select * from tempdb.dbo.no_long_test where type = ?",
(1L,))
print q.fetchall()

print "Testing sybase"
try:
# the_test("SYBQA1")
the_long_test("SYBQA1")
except Exception, msg:
print "%s" % (msg)


The error itself looks like this:

$ ~/work/odbc_tests/bogus_test_prepared_statements_long.py
Testing sybase
('01000', '[01000] [FreeTDS][SQL Server]ASE is terminating this process.\n
(5702) (SQLExecDirectW)')

At the risk of repeating my earlier report, it looks like a necessary
conversion of the parameter being provided (a long integer 1) to an
appropriate type for the column being queried (an int) is causing ASE
to terminate and toss its cookies (close the connection, refuse to
play, log an error).

Any help would be greatly appreciated.

The dump after most of the initial setup, starting from the prepare for this
query, looks like this:

odbc.c:4446:SQLPrepare(0x28c7520, select * from tempdb.dbo.no_long_test where
id = ?, -3)
odbc.c:4517:Creating prepared statement
mem.c:615:tds_free_all_results()
util.c:156:Changed query state from IDLE to QUERYING
util.c:156:Changed query state from QUERYING to PENDING
net.c:730:Sending packet
0000 0f 01 00 66 00 00 00 00-e7 5b 00 01 00 0a 75 69 |...f.... .[....ui|
0010 72 37 7a 30 36 30 30 30-4c 00 63 72 65 61 74 65 |r7z06000 L.create|
0020 20 70 72 6f 63 20 75 69-72 37 7a 30 36 30 30 30 | proc ui r7z06000|
0030 20 61 73 20 73 65 6c 65-63 74 20 2a 20 66 72 6f | as sele ct * fro|
0040 6d 20 74 65 6d 70 64 62-2e 64 62 6f 2e 6e 6f 5f |m tempdb .dbo.no_|
0050 6c 6f 6e 67 5f 74 65 73-74 20 77 68 65 72 65 20 |long_tes t where |
0060 69 64 20 3d 20 3f - |id = ?|

token.c:539:tds_process_tokens(0x28bd580, 0x7fffaa7f2194, 0x7fffaa7f2190,
0x104)
util.c:156:Changed query state from PENDING to READING
net.c:546:Received header
0000 04 01 00 89 00 00 00 00- |........|

net.c:600:Received packet
0000 04 01 00 89 00 00 00 00-e7 0d 00 20 00 0a 75 69 |........ ... ..ui|
0010 72 37 7a 30 36 30 30 30-20 0d 00 00 00 01 00 00 |r7z06000 .......|
0020 00 00 00 00 00 00 00 00-38 00 61 51 00 00 00 02 |........ 8.aQ....|
0030 00 00 06 74 65 6d 70 64-62 03 64 62 6f 0c 6e 6f |...tempd b.dbo.no|
0040 5f 6c 6f 6e 67 5f 74 65-73 74 02 69 64 10 00 00 |_long_te st.id...|
0050 00 07 00 00 00 38 00 00-06 74 65 6d 70 64 62 03 |.....8.. .tempdb.|
0060 64 62 6f 0c 6e 6f 5f 6c-6f 6e 67 5f 74 65 73 74 |dbo.no_l ong_test|
0070 04 6e 61 6d 65 10 00 00-00 02 00 00 00 27 14 00 |.name... .....'..|
0080 fd 04 00 01 00 00 00 00-00 |........ .|

token.c:554:processing result tokens. marker is e7(TDS5_DYNAMIC)
token.c:554:processing result tokens. marker is 20(TDS5_PARAMFMT2)
token.c:3053:elem 0:
token.c:3054: column_name=[]
token.c:3055: flags=0 utype=0 type=56 varint=0
token.c:3057: colsize=4 prec=0 scale=0
token.c:554:processing result tokens. marker is 61(ROWFMT2)
token.c:1831:tds5_process_result
mem.c:615:tds_free_all_results()
token.c:1855:num_cols=2
token.c:1958:col 0:
token.c:1959: column_name=[id]
token.c:1965: flags=10 utype=7 type=56 varint=0
token.c:1968: colsize=4 prec=0 scale=0
token.c:1958:col 1:
token.c:1959: column_name=[name]
token.c:1965: flags=10 utype=2 type=39 varint=1
token.c:1968: colsize=20 prec=0 scale=0
util.c:156:Changed query state from READING to PENDING
token.c:539:tds_process_tokens(0x28bd580, 0x7fffaa7f2194, 0x7fffaa7f2190,
0x104)
util.c:156:Changed query state from PENDING to READING
token.c:554:processing result tokens. marker is fd(DONE)
token.c:2461:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 0
token.c:2477:tds_process_end() state set to TDS_IDLE
util.c:156:Changed query state from READING to IDLE
token.c:2492: rows_affected = 0
util.c:104:logic error: cannot change query state from IDLE to PENDING
token.c:539:tds_process_tokens(0x28bd580, 0x7fffaa7f2194, 0x7fffaa7f2190,
0x104)
token.c:542:tds_process_tokens() state is COMPLETED
odbc.c:1004:SQLNumParams(0x28c7520, 0x7fffaa7f239e)
odbc.c:1442:SQLBindParameter(0x28c7520, 1, 1, -25, -5, 0, 0, 0x28bde18, 8,
(nil))
odbc.c:1343:_SQLBindParameter(0x28c7520, 1, 1, -25, -5, 0, 0, 0x28bde18, 8,
(nil))
odbc.c:3497:SQLExecute(0x28c7520)
prepare_query.c:203:parsing 0 parameters
sql2tds.c:190:type=-5
sql2tds.c:198:trace
odbc.c:3219:_SQLExecute(0x28c7520)
odbc.c:3224:_SQLExecute() starting with state 0
odbc.c:3335:End prepare, execute
query.c:1817:tds_submit_execute()
mem.c:615:tds_free_all_results()
util.c:156:Changed query state from IDLE to QUERYING
query.c:1470:tds_put_data_info putting status
query.c:1516:HERE!
query.c:1571:tds_put_data: colsize = 8
util.c:156:Changed query state from QUERYING to PENDING
net.c:730:Sending packet
0000 0f 01 00 32 00 00 00 00-e7 0f 00 02 01 0a 75 69 |...2.... ......ui|
0010 72 37 7a 30 36 30 30 30-00 00 ec 0b 00 01 00 00 |r7z06000 ........|
0020 00 00 00 00 00 26 01 00-d7 08 01 00 00 00 00 00 |.....&.. ........|
0030 00 00 - |..|

token.c:539:tds_process_tokens(0x28bd580, 0x7fffaa7f21f4, 0x7fffaa7f21f0,
0x6914)
util.c:156:Changed query state from PENDING to READING
net.c:546:Received header
0000 00 00 00 50 00 00 00 00- |...P....|

net.c:600:Received packet
0000 00 00 00 50 00 00 00 00-e5 3c 00 46 16 00 00 01 |...P.... .<.F....|
0010 0a 05 5a 5a 5a 5a 5a 00-00 00 21 00 41 53 45 20 |..ZZZZZ. ..!.ASE |
0020 69 73 20 74 65 72 6d 69-6e 61 74 69 6e 67 20 74 |is termi nating t|
0030 68 69 73 20 70 72 6f 63-65 73 73 2e 0a 06 53 59 |his proc ess...SY|
0040 42 51 41 31 00 01 00 fd-06 00 01 00 00 00 00 00 |BQA1.... ........|

token.c:554:processing result tokens. marker is e5(EED)
token.c:122:tds_process_default_tokens() marker is e5(EED)
token.c:2710:tds_process_msg() reading message 5702 from server
token.c:2783:tds_process_msg() calling client msg handler
odbc.c:2278:msgno 5702 20003
token.c:2796:tds_process_msg() returning TDS_SUCCEED
token.c:554:processing result tokens. marker is fd(DONE)
token.c:2461:tds_process_end: more_results = 0
was_cancelled = 0
error = 1
done_count_valid = 0
token.c:2477:tds_process_end() state set to TDS_IDLE
util.c:156:Changed query state from READING to IDLE
token.c:2492: rows_affected = 0
util.c:104:logic error: cannot change query state from IDLE to PENDING
odbc.c:3535:odbc_process_tokens: tds_process_tokens returned 1
odbc.c:3536: result_type=4052, TDS_DONE_COUNT=0, TDS_DONE_ERROR=2
odbc.c:3576:odbc_process_tokens: row_count=-1
odbc.c:3375:_SQLExecute: odbc_process_tokens returned result_type 4052
odbc.c:3520:SQLExecute returns SQL_ERROR
error.c:517:SQLGetDiagRec(3, 0x28c7520, 1, 0x7fffaa7f2240, 0x7fffaa7f225c,
0x7fffaa7f2040, 512, 0x7fffaa7f2258)
error.c:566:SQLGetDiagRec: "[FreeTDS][SQL Server]ASE is terminating this
process.
"
error.c:517:SQLGetDiagRec(3, 0x28c7520, 2, 0x7fffaa7f2240, 0x7fffaa7f225c,
0x7fffaa7f2040, 512, 0x7fffaa7f2258)
error.c:517:SQLGetDiagRec(3, 0x28c7520, 1, 0x7fffaa7f2370, 0x7fffaa7f2388,
0x7fffaa7f1f70, 1023, 0x7fffaa7f238e)
error.c:566:SQLGetDiagRec: "[FreeTDS][SQL Server]ASE is terminating this
process.
"
odbc.c:4155:SQLFreeStmt(0x28c7520, 0)
odbc.c:4076:_SQLFreeStmt(0x28c7520, 0, 0)
odbc.c:4155:SQLFreeStmt(0x28c7520, 3)
odbc.c:4076:_SQLFreeStmt(0x28c7520, 3, 0)
odbc.c:3981:SQLFreeHandle(3, 0x28c7520)
odbc.c:4076:_SQLFreeStmt(0x28c7520, 1, 0)
query.c:1918:tds_submit_unprepare() uir7z06000
mem.c:615:tds_free_all_results()
util.c:156:Changed query state from IDLE to QUERYING
util.c:156:Changed query state from QUERYING to PENDING
net.c:730:Sending packet
0000 0f 01 00 1a 00 00 00 00-e7 0f 00 04 00 0a 75 69 |........ ......ui|
0010 72 37 7a 30 36 30 30 30-00 00 |r7z06000 ..|

token.c:539:tds_process_tokens(0x28bd580, 0x7fffaa7f236c, 0x7fffaa7f2368,
0x100)
util.c:156:Changed query state from PENDING to READING
util.c:331:tdserror(0x28bb900, 0x28bd580, 20017, 115)
odbc.c:2278:msgno 20017 20003
util.c:361:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:384:tdserror: returning TDS_INT_CANCEL(2)
util.c:156:Changed query state from READING to DEAD
token.c:554:processing result tokens. marker is 0()
token.c:122:tds_process_default_tokens() marker is 0()
token.c:125:leaving tds_process_default_tokens() connection dead
util.c:104:logic error: cannot change query state from DEAD to PENDING
error.c:517:SQLGetDiagRec(2, 0x28bbb60, 1, 0x7fffaa7f2380, 0x7fffaa7f239c,
0x7fffaa7f2180, 512, 0x7fffaa7f2398)
odbc.c:4665:SQLEndTran(2, 0x28bbb60, 1)
odbc.c:4643:_SQLTransact((nil), 0x28bbb60, 1)
odbc.c:4604:change_transaction(0x0x28bbb60,0)
util.c:131:logic error: cannot change query state from DEAD to QUERYING
util.c:331:tdserror(0x28bb900, 0x28bd580, 20006, 0)
odbc.c:2278:msgno 20006 20003
util.c:361:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:384:tdserror: returning TDS_INT_CANCEL(2)
util.c:156:Changed query state from DEAD to QUERYING
error.c:412:odbc_errs_add: "Could not perform COMMIT or ROLLBACK"
error.c:517:SQLGetDiagRec(2, 0x28bbb60, 1, 0x7fffaa7f23e0, 0x7fffaa7f23fc,
0x7fffaa7f21e0, 512, 0x7fffaa7f23f8)
error.c:566:SQLGetDiagRec: "[FreeTDS][SQL Server]Could not perform COMMIT or
ROLLBACK"
error.c:517:SQLGetDiagRec(2, 0x28bbb60, 2, 0x7fffaa7f23e0, 0x7fffaa7f23fc,
0x7fffaa7f21e0, 512, 0x7fffaa7f23f8)
odbc.c:2248:SQLDisconnect(0x28bbb60)
odbc.c:4076:_SQLFreeStmt(0x28c7520, 1, 1)
query.c:1918:tds_submit_unprepare() uir7z06000
util.c:131:logic error: cannot change query state from DEAD to QUERYING
util.c:331:tdserror(0x28bb900, 0x28bd580, 20006, 0)
odbc.c:2278:msgno 20006 20003
util.c:361:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:384:tdserror: returning TDS_INT_CANCEL(2)
util.c:156:Changed query state from DEAD to QUERYING
odbc.c:4076:_SQLFreeStmt(0x28bb9d0, 1, 1)
mem.c:615:tds_free_all_results()
odbc.c:3981:SQLFreeHandle(2, 0x28bbb60)
odbc.c:4007:_SQLFreeConnect(0x28bbb60)
odbc.c:3981:SQLFreeHandle(1, 0x28ba4a0)
odbc.c:4051:_SQLFreeEnv(0x28ba4a0)




Archive powered by MHonArc 2.6.24.

Top of Page