]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-sql/sql-wrap.c
Cleanup ISO C compatibility for recent commits
[openldap] / servers / slapd / back-sql / sql-wrap.c
index 39fbda86e58d2e40eb4853bd6b32b63037ea89e8..cd73ad5b183819dadfe3344665527aff75138bbf 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2008 The OpenLDAP Foundation.
+ * Copyright 1999-2011 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
  * Portions Copyright 2002 Pierangelo Masarati.
  * Portions Copyright 2004 Mark Adamson.
@@ -52,7 +52,7 @@ backsql_PrintErrors( SQLHENV henv, SQLHDBC hdbc, SQLHSTMT sth, int rc )
 }
 
 RETCODE
-backsql_Prepare( SQLHDBC dbh, SQLHSTMT *sth, char *query, int timeout )
+backsql_Prepare( SQLHDBC dbh, SQLHSTMT *sth, const char *query, int timeout )
 {
        RETCODE         rc;
 
@@ -148,7 +148,7 @@ backsql_BindRowAsStrings_x( SQLHSTMT sth, BACKSQL_ROW_NTS *row, void *ctx )
        } else {
                SQLCHAR         colname[ 64 ];
                SQLSMALLINT     name_len, col_type, col_scale, col_null;
-               UDWORD          col_prec;
+               SQLLEN          col_prec;
                int             i;
 
 #ifdef BACKSQL_TRACE
@@ -180,8 +180,8 @@ backsql_BindRowAsStrings_x( SQLHSTMT sth, BACKSQL_ROW_NTS *row, void *ctx )
                        goto nomem;
                }
 
-               row->value_len = (SQLINTEGER *)ber_memcalloc_x( row->ncols,
-                               sizeof( SQLINTEGER ), ctx );
+               row->value_len = (SQLLEN *)ber_memcalloc_x( row->ncols,
+                               sizeof( SQLLEN ), ctx );
                if ( row->value_len == NULL ) {
                        goto nomem;
                }
@@ -424,7 +424,8 @@ backsql_open_db_handle(
         * TimesTen : Turn off autocommit.  We must explicitly
         * commit any transactions. 
         */
-       SQLSetConnectOption( *dbhp, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF );
+       SQLSetConnectOption( *dbhp, SQL_AUTOCOMMIT,
+               BACKSQL_AUTOCOMMIT_ON( bi ) ?  SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF );
 
        /* 
         * See if this connection is to TimesTen.  If it is,
@@ -462,28 +463,31 @@ backsql_open_db_handle(
        return LDAP_SUCCESS;
 }
 
+static void    *backsql_db_conn_dummy;
+
+static void
+backsql_db_conn_keyfree(
+       void            *key,
+       void            *data )
+{
+       (void)backsql_close_db_handle( (SQLHDBC)data );
+}
+
 int
 backsql_free_db_conn( Operation *op, SQLHDBC dbh )
 {
        Debug( LDAP_DEBUG_TRACE, "==>backsql_free_db_conn()\n", 0, 0, 0 );
 
        (void)backsql_close_db_handle( dbh );
+       ldap_pvt_thread_pool_setkey( op->o_threadctx,
+               &backsql_db_conn_dummy, (void *)SQL_NULL_HDBC,
+               backsql_db_conn_keyfree, NULL, NULL );
 
        Debug( LDAP_DEBUG_TRACE, "<==backsql_free_db_conn()\n", 0, 0, 0 );
 
        return LDAP_SUCCESS;
 }
 
-static void    *backsql_db_conn_dummy;
-
-static void
-backsql_db_conn_keyfree(
-       void            *key,
-       void            *data )
-{
-       backsql_close_db_handle( (SQLHDBC)data );
-}
-
 int
 backsql_get_db_conn( Operation *op, SQLHDBC *dbhp )
 {
@@ -514,9 +518,8 @@ backsql_get_db_conn( Operation *op, SQLHDBC *dbhp )
                }
 
                if ( op->o_threadctx ) {
-                       void            *data = NULL;
+                       void            *data = (void *)dbh;
 
-                       data = (void *)dbh;
                        ldap_pvt_thread_pool_setkey( op->o_threadctx,
                                        &backsql_db_conn_dummy, data,
                                        backsql_db_conn_keyfree, NULL, NULL );