]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-sql/sql-wrap.c
cleanup error messages
[openldap] / servers / slapd / back-sql / sql-wrap.c
index 7e174bacf888c6bad5a3ad0e9e7a2bd98ecb98f4..e86477c1baf915ee79538f8810301bcc35c5f574 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2003 The OpenLDAP Foundation.
+ * Copyright 1999-2004 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
  * All rights reserved.
  *
 #include <stdio.h>
 #include "ac/string.h"
 #include <sys/types.h>
+
 #include "slap.h"
 #include "ldap_pvt.h"
-#include "back-sql.h"
-#include "sql-types.h"
-#include "sql-wrap.h"
-#include "schema-map.h"
+#include "proto-sql.h"
 
 #define MAX_ATTR_LEN 16384
 
@@ -126,31 +124,6 @@ backsql_Prepare( SQLHDBC dbh, SQLHSTMT *sth, char *query, int timeout )
        return SQLPrepare( *sth, query, SQL_NTS );
 }
 
-#if 0
-/*
- * Turned into macros --- see sql-wrap.h
- */
-RETCODE
-backsql_BindParamStr( SQLHSTMT sth, int par_ind, char *str, int maxlen )
-{
-       RETCODE         rc;
-
-       rc = SQLBindParameter( sth, (SQLUSMALLINT)par_ind, SQL_PARAM_INPUT,
-                       SQL_C_CHAR, SQL_VARCHAR,
-                       (SQLUINTEGER)maxlen, 0, (SQLPOINTER)str,
-                       (SQLUINTEGER)maxlen, NULL );
-       return rc;
-}
-
-RETCODE
-backsql_BindParamID( SQLHSTMT sth, int par_ind, unsigned long *id )
-{
-       return SQLBindParameter( sth, (SQLUSMALLINT)par_ind,
-                       SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
-                       0, 0, (SQLPOINTER)id, 0, (SQLINTEGER*)NULL );
-}
-#endif
-
 RETCODE
 backsql_BindRowAsStrings( SQLHSTMT sth, BACKSQL_ROW_NTS *row )
 {
@@ -396,13 +369,18 @@ backsql_open_db_conn( backsql_info *si, int ldap_cid, backsql_db_conn **pdbc )
                Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: "
                        "SQLGetInfo() failed:\n", 0, 0, 0 );
                backsql_PrintErrors( si->db_env, dbc->dbh, SQL_NULL_HENV, rc );
+               return rc;
        }
        /* end TimesTen */
 
        Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(): "
                "connected, adding to tree\n", 0, 0, 0 );
        ldap_pvt_thread_mutex_lock( &si->dbconn_mutex );
-       avl_insert( &si->db_conns, dbc, backsql_cmp_connid, NULL );
+       if ( avl_insert( &si->db_conns, dbc, backsql_cmp_connid, avl_dup_error ) ) {
+               Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: "
+                       "duplicate connection ID\n", 0, 0, 0 );
+               return LDAP_OTHER;
+       }
        ldap_pvt_thread_mutex_unlock( &si->dbconn_mutex );
        Debug( LDAP_DEBUG_TRACE, "<==backsql_open_db_conn()\n", 0, 0, 0 );