freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Gregg Jensen" <greggj AT savvis.com>
- To: freetds
- Subject: patch for dblib
- Date: Thu, 3 Sep 1998 15:28:32
Included is a patch for dblib/dblib.c (and include/sybdb.h) that fills in a
couple more dblib functions and provides the ability to define the protocol
for the "session" (at login time). There is a dblib function that sets the
version which is used by sybperl and sqsh-1.4. The problem is, it is
hardcoded in those pieces of software and does not allow the user any means
for changing it. So, in order to not change that code, I added the
additional functionality to read the protocol version from an environment
variable (DBLIB_VERSION). Basically, this will override what is set by
calling dbsetversion (and what is defined when you compiled the library). I
have not had any feedback about this approach, so I assume that it OK to
submit the patch. The possible values for DBLIB_VERSION are:
(taken from sybdb.h)
DBVERSION_46 1
DBVERSION_100 2
DBVERSION_42 3
(use the numbers not the names)
Gregg
------------------------------------cut here ----------------------------
*** src/dblib/dblib.c Thu Aug 6 21:42:19 1998
--- ../tds/src/dblib/dblib.c Thu Sep 3 13:54:15 1998
***************
*** 10,15 ****
--- 10,16 ----
int (*g_dblib_err_handler)() = NULL;
extern int (*g_tds_msg_handler)();
extern int (*g_tds_err_handler)();
+ int g_dblib_version = DBVERSION_100;
RETCODE dbinit()
{
***************
*** 71,80 ****
--- 72,95 ----
DBPROCESS *dbproc;
TDSSOCKET *tds;
struct sockaddr_in sin;
+ char *envbuf;
+ int version_value;
dbproc = (DBPROCESS *) malloc(sizeof(DBPROCESS));
memset(dbproc,'\0',sizeof(DBPROCESS));
tds_set_server(login->tds_login,server);
+
+ envbuf = (char*)getenv("DBLIB_VERSION");
+ version_value = atoi(envbuf);
+ if(envbuf)
+ {
+ dblib_setTDS_version(login->tds_login, version_value);
+ }
+ else
+ {
+ dblib_setTDS_version(login->tds_login, g_dblib_version );
+ }
+
dbproc->tds_socket = (void *) tds_connect(login->tds_login);
/* dbproc->dbbuf[0]='\0'; * initialize query buffer */
***************
*** 575,581 ****
}
DBBOOL DBDEAD(DBPROCESS *dbproc)
{
! return FALSE;
}
int (*dberrhandle(int (*handler)())) ()
--- 596,605 ----
}
DBBOOL DBDEAD(DBPROCESS *dbproc)
{
! if(dbproc)
! return FALSE;
! else
! return TRUE;
}
int (*dberrhandle(int (*handler)())) ()
***************
*** 719,732 ****
}
RETCODE dbsetuserdata(DBPROCESS *dbproc, BYTE *ptr)
{
return SUCCEED;
}
BYTE *dbgetuserdata(DBPROCESS *dbproc)
{
! return NULL;
}
RETCODE dbsetversion(DBINT version)
{
return SUCCEED;
}
RETCODE dbmnycopy(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
--- 743,758 ----
}
RETCODE dbsetuserdata(DBPROCESS *dbproc, BYTE *ptr)
{
+ dbproc->user_data = ptr;
return SUCCEED;
}
BYTE *dbgetuserdata(DBPROCESS *dbproc)
{
! return dbproc->user_data;
}
RETCODE dbsetversion(DBINT version)
{
+ g_dblib_version = version;
return SUCCEED;
}
RETCODE dbmnycopy(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
*** include/sybdb.h Mon Jul 13 20:41:16 1998
--- ../tds/include/sybdb.h Mon Aug 10 13:39:52 1998
***************
*** 18,23 ****
--- 18,24 ----
#define DBVERSION_UNKNOWN 0
#define DBVERSION_46 1
#define DBVERSION_100 2
+ #define DBVERSION_42 3
#define SYBAOPCNT 0x4b
#define SYBAOPCNTU 0x4c
***************
*** 37,45 ****
--- 38,48 ----
void *tds_login ;
} LOGINREC;
+ typedef unsigned char BYTE;
typedef struct {
void *tds_socket ;
TDSRESULTINFO resinfo;
+ BYTE *user_data;
unsigned char dbbuf[4096];
} DBPROCESS;
***************
*** 49,55 ****
typedef unsigned char DBTINYINT ;
typedef short DBSMALLINT ;
typedef long DBINT ;
- typedef unsigned char BYTE;
typedef unsigned char DBBINARY ;
typedef float DBREAL ;
typedef double DBFLT8 ;
--- 52,57 ----
*** src/dblib/dbutil.c Wed Jun 24 21:29:09 1998
--- ../tds/src/dblib/dbutil.c Mon Aug 10 13:17:41 1998
***************
*** 81,83 ****
--- 81,100 ----
tds_reset_msg_info(dbproc->tds_socket);
}
}
+
+ void dblib_setTDS_version(TDSLOGIN *tds_login, DBINT version)
+ {
+ switch(version)
+ {
+ case DBVERSION_42:
+ tds_set_version(tds_login, 4, 2);
+ break;
+ case DBVERSION_46:
+ tds_set_version(tds_login, 4, 6);
+ break;
+ case DBVERSION_100:
+ tds_set_version(tds_login, 5, 0);
+ break;
+ }
+
+ }
- patch for dblib, Gregg Jensen, 09/03/1998
Archive powered by MHonArc 2.6.24.