[freetds] --enable-msdblib options...

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Mon Oct 11 05:45:11 EDT 2004


Honestly I don't like this option. It produces a very slightly modified
version (that is 4 lines of code in dblib) but a library that is not
binary compatible. I'd like to use just some if to fix this. Mainly if
application define MSDBLIB this produce a sligtly modified dbopen call
(like "tdsopen(login, server, 1)") so we can store a flag in DBPROCESS
and use it when needed. This require a change in tdsdbopen declaration
so I'd like to do this change before 0.63 release. This also require
that client application define MSDBLIB before the #include <sybdb.h> (as
should do now...).

Patch follow

diff -u -r1.138 configure.in
--- configure.in        25 Jun 2004 19:42:01 -0000      1.138
+++ configure.in        11 Oct 2004 09:37:22 -0000
@@ -403,13 +403,6 @@
        AC_HELP_STRING([--disable-pool], [skip build of src/pool
directory]))
  AM_CONDITIONAL(INCPOOL, test "$enable_pool" != "no")

-AC_ARG_ENABLE(msdblib,
-  AC_HELP_STRING([--enable-msdblib], [for MS style dblib]))
-
-if test "$enable_msdblib" = "yes" ; then
-       CPPFLAGS="$CPPFLAGS -DMSDBLIB"
-fi
-
 AC_ARG_ENABLE(sybase-compat,
   AC_HELP_STRING([--enable-sybase-compat], [enable increased Open
Client binary compatibility]))
 AM_CONDITIONAL(SYBASE_COMPAT, test x$enable_sybase_compat = xyes)
diff -u -r1.19 dblib.h
--- include/dblib.h     17 Jun 2004 15:39:57 -0000      1.19
+++ include/dblib.h     11 Oct 2004 09:37:22 -0000
@@ -141,6 +141,9 @@
        FILE *ftos;
        DB_DBCHKINTR_FUNC dbchkintr;
        DB_DBHNDLINTR_FUNC dbhndlintr;
+
+       /** boolean use ms behaviour */
+       int msdblib;
 };

 #define DBLIB_INFO_MSG_TYPE 0
diff -u -r1.62 sybdb.h
--- include/sybdb.h     6 Oct 2004 09:34:41 -0000       1.62
+++ include/sybdb.h     11 Oct 2004 09:37:24 -0000
@@ -606,10 +606,14 @@
 int dbnumcompute(DBPROCESS * dbprocess);
 int DBNUMORDERS(DBPROCESS * dbprocess);
 int dbnumrets(DBPROCESS * dbproc);
-DBPROCESS *tdsdbopen(LOGINREC * login, char *server);
+DBPROCESS *tdsdbopen(LOGINREC * login, char *server, int msdblib);
 DBPROCESS *dbopen(LOGINREC * login, char *server);

-#define   dbopen(x,y) tdsdbopen((x),(y))
+#ifdef MSDBLIB
+#define   dbopen(x,y) tdsdbopen((x),(y), 1)
+#else
+#define   dbopen(x,y) tdsdbopen((x),(y), 0)
+#endif
 int dbordercol(DBPROCESS * dbprocess, int order);
 RETCODE dbpoll(DBPROCESS * dbproc, long milliseconds, DBPROCESS **
ready_dbproc, int *return_reason);
 void dbprhead(DBPROCESS * dbproc);
diff -u -r1.102 bcp.c
--- src/dblib/bcp.c     20 Sep 2004 08:21:17 -0000      1.102
+++ src/dblib/bcp.c     11 Oct 2004 09:37:25 -0000
@@ -282,11 +282,10 @@
 {
        BCP_HOSTCOLINFO *hostcol;

-#ifdef MSDBLIB
        /* Microsoft specifies a "file_termlen" of zero if there's no
terminator */
-       if (host_termlen == 0)
+       if (dbproc->msdblib && host_termlen == 0)
                host_termlen = -1;
-#endif
+
        if (dbproc->bcpinfo == NULL) {
                _bcp_err_handler(dbproc, SYBEBCPI);
                return FAIL;
diff -u -r1.184 dblib.c
--- src/dblib/dblib.c   20 Sep 2004 08:21:18 -0000      1.184
+++ src/dblib/dblib.c   11 Oct 2004 09:37:27 -0000
@@ -918,11 +940,11 @@
  * \todo separate error messages for \em no-such-server and \em
no-such-user.
  */
 DBPROCESS *
-tdsdbopen(LOGINREC * login, char *server)
+tdsdbopen(LOGINREC * login, char *server, int msdblib)
 {
        DBPROCESS *dbproc;
        TDSCONNECTION *connection;
        char temp_filename[256];

        dbproc = (DBPROCESS *) malloc(sizeof(DBPROCESS));
        if (dbproc == NULL) {
@@ -930,6 +953,7 @@
                return NULL;
        }
        memset(dbproc, '\0', sizeof(DBPROCESS));
+       dbproc->msdblib = msdblib;

        dbproc->dbopts = init_dboptions();
        if (dbproc->dbopts == NULL) {
@@ -4698,7 +4755,6 @@

        tds_datecrack(SYBDATETIME, datetime, &dr);

-#ifndef MSDBLIB
        di->dateyear = dr.year;
        di->datemonth = dr.month;
        di->datedmonth = dr.day;
@@ -4708,17 +4764,10 @@
        di->dateminute = dr.minute;
        di->datesecond = dr.second;
        di->datemsecond = dr.millisecond;
-#else
-       di->year = dr.year;
-       di->month = dr.month + 1;
-       di->day = dr.day;
-       di->dayofyear = dr.dayofyear;
-       di->weekday = dr.weekday + 1;
-       di->hour = dr.hour;
-       di->minute = dr.minute;
-       di->second = dr.second;
-       di->millisecond = dr.millisecond;
-#endif
+       if (dbproc->msdblib) {
+               ++di->datemonth;
+               ++di->datedweek;
+       }
        return SUCCEED;
 }

diff -u -r1.26 dbutil.c
--- src/dblib/dbutil.c  1 Jun 2004 07:34:50 -0000       1.26
+++ src/dblib/dbutil.c  11 Oct 2004 09:37:27 -0000
@@ -139,13 +139,12 @@
                        rc = INT_EXIT;
                        break;
                case INT_CONTINUE:
-#ifndef MSDBLIB
-                       /* Sybase behavior */
-                       rc = INT_EXIT;
-#else
-                       /* Microsoft behavior */
-                       rc = INT_CANCEL;
-#endif
+                       if (!dbproc || !dbproc->msdblib)
+                               /* Sybase behavior */
+                               rc = INT_EXIT;
+                       else
+                               /* Microsoft behavior */
+                               rc = INT_CANCEL;
                        break;
                default:
                        break;

Well... this patch don't update manual but should...

freddy77


More information about the FreeTDS mailing list