Skip to Content.
Sympa Menu

freetds - Re: [freetds] error: native binds to function params on sql server

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] error: native binds to function params on sql server
  • Date: Thu, 1 Jul 2010 15:16:19 +0200

Thanks for the log.

It seems your not that patched SQL Server version does not like the
way FreeTDS prepare the statement and this lead to some memory errors.
We could try to replace a NULL parameter with a dummy one but is more
complicated for me to explain how you could do this test that trying
by myself... Could you manage to provide me an access (privately
obviously) to this SQL Server to try??

Regards
Frediano Ziglio

2010/6/29 Clovis Fabricio <nosklo AT gmail.com>:
> Hello,
>
> I'm using the software following stack on Ubuntu 10.04 Lucid LTS to
> connect to a database:
>
> 1) python 2.6.5  (ubuntu package)
> 2) pyodbc git trunk commit eb545758079a743b2e809e2e219c8848bc6256b2
> 3) unixodbc 2.2.11 (ubuntu package)
> 4) freetds 0.82 (ubuntu package)
> 5) Windows with Microsoft SQL Server 2000 (8.0)
>
> I get this error when trying to do native parameter binds in arguments
> to a SQL SERVER function:
>
> Traceback (most recent call last):
>  File "/home/nosklo/devel/testes/sqlfunc.py", line 32, in <module>
>    cur.execute("SELECT * FROM fn_FuncTest(?)", ('test',))
> pyodbc.ProgrammingError: ('42000', '[42000] [FreeTDS][SQL
> Server]SqlDumpExceptionHandler: Process 54 generated fatal exception
> c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this
> process.\r\n (0) (SQLPrepare)')
>
> Here's the reproduction code:
>
> import pyodbc
> constring =
> 'server=myserver;uid=uid;pwd=pwd;database=db;TDS_Version=8.0;driver={FreeTDS}'
>
> con = pyodbc.connect(constring)
> print 'VERSION: ', con.getinfo(pyodbc.SQL_DBMS_VER)
>
> cur = con.cursor()
> try:
>    cur.execute('DROP FUNCTION fn_FuncTest')
>    con.commit()
>    print "Function dropped"
> except pyodbc.Error:
>    pass
>
> cur.execute('''
>    CREATE FUNCTION fn_FuncTest (@testparam varchar(4))
>    RETURNS @retTest TABLE (param varchar(4))
>    AS
>    BEGIN
>        INSERT @retTest
>        SELECT @testparam
>        RETURN
>    END''')
> con.commit()
>
> # this works fine (no native bind):
> cur.execute("SELECT * FROM fn_FuncTest('test')")
> assert cur.fetchone()[0] == 'test'
>
> # this fails (trying to native bind):
> cur.execute("SELECT * FROM fn_FuncTest(?)", ('test',))
> assert cur.fetchone()[0] == 'test'
>
> Further investigation reveals some _weird_ stuff I'd like to relate:
>
> a) Everything works fine if I change TDS Version to 4.2 (however,
> version report from sql server is wrong -- using TDS version 4.2 I get
> '95.08.0255' instead of the real version '08.00.0760').
> b) Everything works fine for the other two types of functions ->
> functions that return a value and functions that are just a SELECT
> query (like a view) both work fine. You can even define a new function
> that returns the result of a query on the other (broken) function, and
> this way everything will work, **even when doing native binds on the
> parameters**. For example: CREATE FUNCTION fn_tempFunc(@testparam
> varchar(4)) RETURNS TABLE AS  RETURN (SELECT * FROM
> fn_FuncTest(@testparam))
> c) Connection gets very unstable after this error, you can't recover.
> d) The error happens when trying to bind any type of data.
>
> I'm including full freetds debug log as attachment.
>
> Can someone guide me on how to pursue this further?
>
> Thanks in advance
>
> --
> nosklo
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
>




Archive powered by MHonArc 2.6.24.

Top of Page