[freetds] Supporting fast forward-only cursors?

Sebastien FLAESCH sf at 4js.com
Fri Jan 11 06:10:33 EST 2008


Hi Frediano,

It's not that critical for us, we can go with "normal" server cursors in a first time.

Can be done in next version (0.83?) as a performance improvement.
SQLCancel() / HY008 is more critical, because it is a functional difference.

If odbcss.h Copyright is a problem, maybe you could define your own constants?
On our side we have no problem to use different constant names as SQL Server's.
However it would not simplify migration of existing code using odbcss.h ...

Many thanks for taking my requests in consideration.

Bye,
Seb

ZIGLIO, Frediano, VF-IT wrote:
>> So far I have one remaining "FIXME" comment in my FreeTDS 
>> driver interface, regarding fast forward cursors...
>>
> 
> I call it a TODO :)
> 
>> With the native MSSQL ODBC drivers, when you set:
>>
>>    r = SQLSetStmtAttr(st->stmtHandle, 
>> SQL_SOPT_SS_CURSOR_OPTIONS, (SQLPOINTER) SQL_CO_FFO, SQL_IS_UINTEGER);
>>
>> You get fast forward-only cursors, as described in:
>>
>> http://msdn2.microsoft.com/en-us/library/aa172573.aspx
>>
>> Note this is a SQL Server 2000 feature...
>>
>> Other link:
>>
>> http://msdn2.microsoft.com/en-us/library/aa177106(SQL.80).aspx
>>
>> I was wondering how difficult it would be to support this 
>> MSSQL specific statement attribute...
>>
>> If it's just a matter of sp_cursoroption, then you should...
>>
>> Attached a sample (must compile with -D USE_FAST_FOWARD to 
>> use FFO cursor)
>>
>> I noticed that SQL Profiler should different values in the 
>> @p5 and @p6 parameters of the sp_cursorprepexec() call:
>>
>> With FFO:
>>
>> @p5=16
>> @p6=1
>>
> 
> See http://jtds.sourceforge.net/apiCursors.html
> 
> 16 == Fast forward-only cursor
> 1  == Read-only
> 
>> With SQL_NONSCROLLABLE / SQL_SENSITIVE:
>>
>> @p5=4
>> @p6=4
>>
> 
> 4 == Forward-only cursor
> 4 == Optimistic. Checks timestamps and, when not available, values.
> 
>> Tested with SQL Server 2005 ...
>>
>> Thanks!
>> Seb
> 
> I think the better way is to try to enable FFO when needed but ignore
> error... if supported you will gain network performance, if not it
> works.
> 
> Another problem is how to define these constants. These constants are
> not "open" that is are contained in copyrighted header (odbcss.h).
> Should we extract constants with somethink like:
> 
> #include <odbcss.h>
> 
> #define STR(s) #s
> 
> void main()
> {
>   printf("%s\n", STR(SQL_SOPT_SS_CURSOR_OPTIONS));
> }
> 
> ??
> 
> Having to enable explicitly these function make it do not break any
> compatibility however I think it's better to posticipate this stuff.
> Currently there are some issue I want to fix/workaround before release
> - Mac OS X compile (quite easy)
> - select(2) problem (I have a patch quite ready for net.c)
> - wrong result SQLExecDirect with INSERT INTO and cursors (I'm not
> really sure this is the real problem)
> - HY008 on SQLCancel
> 
> freddy77
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
> 



More information about the FreeTDS mailing list