rails-sqlserver/tiny_tds — Issue #62: Look Into Using dbsetversion() For Sybase Or Best Practice?
Author: metaskills
Created: 2011-11-10 14:27:09+00:00
State: open

Currently, we only use dbsetlversion() for the login structure like so in our `client.c` file.

```c
if (!NIL_P(version))
dbsetlversion(cwrap->login, NUM2INT(version));
```

Then I saw this thread come across the FreeTDS mailing list. Which has this patch to dblib.c so they can have version 100 set in the login structure.

```diff
--- dblib.c.ori Thu Aug 18 02:54:40 2011
+++ dblib.c Thu Nov 10 13:45:56 2011
@@ -936,6 +936,9 @@ dbsetlversion (LOGINREC * login, BYTE ve
case DBVER60:
login->tds_login->tds_version = 0x700;
return SUCCEED;
+ case DBVERSION_100:
+ tds_set_version(login->tds_login, 5, 0);
+ return SUCCEED;
case DBVERSION_71:
tds_set_version(login->tds_login, 7, 1);
return SUCCEED;
```

Below is the documentation for DB-Library. Maybe we should also try to use dbsetversion too? Maybe this would help if FreeTDS was compiled with a lower default `--with-tdsver` config? If so, it would benefit both us and Sybase.

```

Function dbsetversion()
Specify a DB-Library version level.

Syntax:

RETCODE dbsetversion(version)
DBINT version;

Parameters:

￼￼version – The version of DB-Library behavior that the application expects.
The following table lists the symbolic values that are legal for version:

Returns:

SUCCEED or FAIL.

Comments:

* dbversion sets the version of DB-Library behavior that an application
expects. DB-Library will provide the behavior requested, regardless
of the actual version of DB-Library in use.
* An application is not required to call dbsetversion. However, if
dbsetversion is not called, DB-Library provides release 4.6-level
behavior.
* If an application calls dbsetversion, it must do so before calling any
other DB-Library routine, with the exception of dbinit.
* It is an error to call dbsetversion more than once.
```