apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r667328 - in /apr/apr-util/trunk: dbd/apr_dbd.c dbd/apr_dbd_freetds.c dbd/apr_dbd_odbc.c include/apu.h.in
Date Fri, 13 Jun 2008 04:10:08 GMT
Author: bojan
Date: Thu Jun 12 21:10:08 2008
New Revision: 667328

URL: http://svn.apache.org/viewvc?rev=667328&view=rev
Log:
Make FreeTDS and ODBC drivers actually build.
Fix assorted warnings and errors in FreeTDS and ODBC drivers.

Modified:
    apr/apr-util/trunk/dbd/apr_dbd.c
    apr/apr-util/trunk/dbd/apr_dbd_freetds.c
    apr/apr-util/trunk/dbd/apr_dbd_odbc.c
    apr/apr-util/trunk/include/apu.h.in

Modified: apr/apr-util/trunk/dbd/apr_dbd.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbd/apr_dbd.c?rev=667328&r1=667327&r2=667328&view=diff
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd.c Thu Jun 12 21:10:08 2008
@@ -125,6 +125,12 @@
 #if APU_HAVE_ORACLE
     DRIVER_LOAD("oracle", apr_dbd_oracle_driver, pool);
 #endif
+#if APU_HAVE_FREETDS
+    DRIVER_LOAD("freetds", apr_dbd_freetds_driver, pool);
+#endif
+#if APU_HAVE_ODBC
+    DRIVER_LOAD("odbc", apr_dbd_odbc_driver, pool);
+#endif
 #if APU_HAVE_SOME_OTHER_BACKEND
     DRIVER_LOAD("firebird", apr_dbd_other_driver, pool);
 #endif

Modified: apr/apr-util/trunk/dbd/apr_dbd_freetds.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbd/apr_dbd_freetds.c?rev=667328&r1=667327&r2=667328&view=diff
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd_freetds.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd_freetds.c Thu Jun 12 21:10:08 2008
@@ -124,7 +124,6 @@
                               const char *query, int seek)
 {
     apr_dbd_results_t *res;
-    int i;
     if (sql->trans && (sql->trans->errnum != SUCCEED)) {
         return 1;
     }
@@ -237,9 +236,10 @@
 static int dbd_freetds_pselect(apr_pool_t *pool, apr_dbd_t *sql,
                                apr_dbd_results_t **results,
                                apr_dbd_prepared_t *statement,
-                               int seek, int nargs, const char **values)
+                               int seek, const char **values)
 {
-    const char *query = dbd_statement(pool, statement, nargs, values);
+    const char *query = dbd_statement(pool, statement,
+                                      statement->nargs, values);
     return dbd_freetds_select(pool, sql, results, query, seek);
 }
 static int dbd_freetds_pvselect(apr_pool_t *pool, apr_dbd_t *sql,
@@ -260,15 +260,15 @@
         values[i] = va_arg(args, const char*);
     }
 
-    return dbd_freetds_pselect(pool, sql, results, statement, seek,
-                               statement->nargs, values);
+    return dbd_freetds_pselect(pool, sql, results, statement, seek, values);
 }
 static int dbd_freetds_query(apr_dbd_t *sql, int *nrows, const char *query);
 static int dbd_freetds_pquery(apr_pool_t *pool, apr_dbd_t *sql,
                               int *nrows, apr_dbd_prepared_t *statement,
-                              int nargs, const char **values)
+                              const char **values)
 {
-    const char *query = dbd_statement(pool, statement, nargs, values);
+    const char *query = dbd_statement(pool, statement,
+                                      statement->nargs, values);
     return dbd_freetds_query(sql, nrows, query);
 }
 static int dbd_freetds_pvquery(apr_pool_t *pool, apr_dbd_t *sql, int *nrows,
@@ -286,8 +286,7 @@
     for (i = 0; i < statement->nargs; i++) {
         values[i] = va_arg(args, const char*);
     }
-    return dbd_freetds_pquery(pool, sql, nrows, statement,
-                              statement->nargs, values);
+    return dbd_freetds_pquery(pool, sql, nrows, statement, values);
 }
 
 static int dbd_freetds_get_row(apr_pool_t *pool, apr_dbd_results_t *res,
@@ -344,10 +343,10 @@
     int t = dbcoltype(proc, n+1);
     int l = dbcollen(proc, n+1);
     if (dbwillconvert(t, SYBCHAR)) {
-      dbconvert(proc, t, ptr, l, SYBCHAR, row->buf, -1);
+      dbconvert(proc, t, ptr, l, SYBCHAR, (BYTE *)row->buf, -1);
       return (const char*)row->buf;
     }
-    return ptr;
+    return (char*)ptr;
 }
 
 static const char *dbd_freetds_error(apr_dbd_t *sql, int n)
@@ -442,6 +441,7 @@
 
 static int dbd_freetds_prepare(apr_pool_t *pool, apr_dbd_t *sql,
                              const char *query, const char *label,
+                             int nargs, int nvals, apr_dbd_type_e *types,
                              apr_dbd_prepared_t **statement)
 {
     apr_dbd_prepared_t *stmt;
@@ -642,7 +642,7 @@
     if (dbdead(handle->proc)) {
         /* try again */
         dbclose(handle->proc);
-        handle->proc = freetds_open(handle->pool, handle->params);
+        handle->proc = freetds_open(handle->pool, handle->params, NULL);
         if (!handle->proc || dbdead(handle->proc)) {
             return APR_EGENERAL;
         }

Modified: apr/apr-util/trunk/dbd/apr_dbd_odbc.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/dbd/apr_dbd_odbc.c?rev=667328&r1=667327&r2=667328&view=diff
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd_odbc.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd_odbc.c Thu Jun 12 21:10:08 2008
@@ -26,6 +26,9 @@
 #include "apr_dbd_internal.h"
 #include "apr_thread_proc.h"
 #include "apu_version.h"
+#include "apu_config.h"
+
+#include <stdlib.h>
 
 /* If library is ODBC-V2, use macros for limited ODBC-V2 support 
  * No random access in V2.
@@ -646,7 +649,7 @@
 
     if (SQL_SUCCEEDED(rc) || rc == SQL_NO_DATA) {
 
-        if (rc = SQL_SUCCESS_WITH_INFO
+        if (rc == SQL_SUCCESS_WITH_INFO
             && ( len_indicator == SQL_NO_TOTAL || len_indicator >= bufsize) )
{
             /* not the last read = a full buffer. CLOBs have a null terminator */
             *len = bufsize - (IS_CLOB(bd->type) ? 1 : 0 );
@@ -814,17 +817,17 @@
 
     for(j=i=0 ; i< nparams ; i++)
     {   if      (!apr_strnatcasecmp(name[i], "CONNECT"))
-        {   *datasource = apr_pstrdup(pool, val[i]);
+        {   *datasource = (SQLCHAR *)apr_pstrdup(pool, val[i]);
             *connect=1;
         }
         else if (!apr_strnatcasecmp(name[i], "DATASOURCE"))
-        {   *datasource = apr_pstrdup(pool, val[i]);
+        {   *datasource = (SQLCHAR *)apr_pstrdup(pool, val[i]);
             *connect=0;
         }
         else if (!apr_strnatcasecmp(name[i], "USER"))
-            *user = apr_pstrdup(pool, val[i]);
+            *user = (SQLCHAR *)apr_pstrdup(pool, val[i]);
         else if (!apr_strnatcasecmp(name[i], "PASSWORD"))
-            *password = apr_pstrdup(pool, val[i]);
+            *password = (SQLCHAR *)apr_pstrdup(pool, val[i]);
         else if (!apr_strnatcasecmp(name[i], "BUFSIZE"))
             *defaultBufferSize = atoi(val[i]);
         else if (!apr_strnatcasecmp(name[i], "ACCESS"))
@@ -984,7 +987,8 @@
     int err_htype, i;
     int defaultBufferSize=DEFAULT_BUFFER_SIZE;
     SQLHANDLE err_h = NULL;
-    SQLCHAR  *datasource="", *user="", *password="";
+    SQLCHAR  *datasource=(SQLCHAR *)"", *user=(SQLCHAR *)"",
+             *password=(SQLCHAR *)"";
     int nattrs=0, *attrs=NULL, *attrvals=NULL, connect=0;
 
     err_step="SQLAllocHandle (SQL_HANDLE_DBC)";
@@ -1015,21 +1019,22 @@
             err_htype = SQL_HANDLE_DBC;
             err_h = hdbc;
             rc = SQLDriverConnect(hdbc, NULL, datasource,
-                        (SQLSMALLINT) strlen(datasource),
+                        (SQLSMALLINT) strlen((char *)datasource),
                         out, sizeof(out), &outlen, SQL_DRIVER_NOPROMPT);
         }
         else {
             err_step="SQLConnect";
             err_htype = SQL_HANDLE_DBC;
             err_h = hdbc;
-            rc = SQLConnect(hdbc, datasource, (SQLSMALLINT) strlen(datasource),
-                        user, (SQLSMALLINT) strlen(user),
-                        password, (SQLSMALLINT) strlen(password));
+            rc = SQLConnect(hdbc, datasource,
+                        (SQLSMALLINT) strlen((char *)datasource),
+                        user, (SQLSMALLINT) strlen((char *)user),
+                        password, (SQLSMALLINT) strlen((char *)password));
         }
     }
     if (SQL_SUCCEEDED(rc)) {
         handle = apr_pcalloc(pool, sizeof(apr_dbd_t));
-        handle->dbname = apr_pstrdup(pool, datasource);
+        handle->dbname = apr_pstrdup(pool, (char *)datasource);
         handle->dbc = hdbc;
         handle->pool = pool;
         handle->defaultBufferSize = defaultBufferSize;
@@ -1119,7 +1124,6 @@
 static int odbc_end_transaction(apr_dbd_transaction_t *trans)
 {
     SQLRETURN rc;
-    int action = trans->apr_dbd->can_commit ? SQL_COMMIT : SQL_ROLLBACK;
 
     rc = SQLEndTran(SQL_HANDLE_DBC, trans->dbc, SQL_COMMIT);
     CHECK_ERROR(trans->apr_dbd, "SQLEndTran", rc, SQL_HANDLE_DBC, trans->dbc);
@@ -1327,7 +1331,7 @@
     if (!(sq = strchr(s, '\''))) 
         return (char *) s;
     /* count the single-quotes and allocate a new buffer */
-    for (qcount = 1; sq = strchr(sq + 1, '\''); )
+    for (qcount = 1; (sq = strchr(sq + 1, '\'')); )
         qcount++;
     newstr = apr_palloc(pool, strlen(s) + qcount + 1);
 
@@ -1463,7 +1467,7 @@
     if (res->colnames[col] != NULL)
         return res->colnames[col];      /* we already retrieved it */
     rc = SQLDescribeCol(res->stmt, col + 1,
-                        buffer, sizeof(buffer), &colnamelength,
+                        (SQLCHAR *)buffer, sizeof(buffer), &colnamelength,
                         &coltype, &colsize, &coldecimal, &colnullable);
     CHECK_ERROR(res->apr_dbd, "SQLDescribeCol", rc,
                 SQL_HANDLE_STMT, res->stmt);

Modified: apr/apr-util/trunk/include/apu.h.in
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/include/apu.h.in?rev=667328&r1=667327&r2=667328&view=diff
==============================================================================
--- apr/apr-util/trunk/include/apu.h.in (original)
+++ apr/apr-util/trunk/include/apu.h.in Thu Jun 12 21:10:08 2008
@@ -99,6 +99,8 @@
 #define APU_HAVE_SQLITE3       @apu_have_sqlite3@
 #define APU_HAVE_SQLITE2       @apu_have_sqlite2@
 #define APU_HAVE_ORACLE        @apu_have_oracle@
+#define APU_HAVE_FREETDS       @apu_have_freetds@
+#define APU_HAVE_ODBC          @apu_have_odbc@
 
 #define APU_HAVE_APR_ICONV     @have_apr_iconv@
 #define APU_HAVE_ICONV         @have_iconv@



Mime
View raw message