]> git.sur5r.net Git - openldap/commitdiff
more new API ... back-sql should be OK
authorPierangelo Masarati <ando@openldap.org>
Thu, 3 Apr 2003 00:35:16 +0000 (00:35 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 3 Apr 2003 00:35:16 +0000 (00:35 +0000)
servers/slapd/back-sql/bind.c
servers/slapd/back-sql/init.c
servers/slapd/back-sql/modify.c
servers/slapd/back-sql/other.c
servers/slapd/back-sql/search.c
servers/slapd/back-sql/sql-wrap.c
servers/slapd/back-sql/sql-wrap.h

index b768d40dc7fe4ac494e6e68e814198a9924cfe25..10f871be40b086f86de1a20b0f28909679680287 100644 (file)
@@ -52,7 +52,7 @@ backsql_bind( Operation *op, SlapReply *rs )
        /*
         * method = LDAP_AUTH_SIMPLE
         */
-       rs->sr_err = backsql_get_db_conn( op->o_bd, op->o_conn, &dbh );
+       rs->sr_err = backsql_get_db_conn( op, &dbh );
        if (!dbh) {
                Debug( LDAP_DEBUG_TRACE, "backsql_bind(): "
                        "could not get connection handle - exiting\n",
index 1548b7e39ca4d1e9afaad238dcf2a324039e3846..b946f24c10c8bf43835329dffd568211e55af7c7 100644 (file)
@@ -161,11 +161,12 @@ backsql_db_open(
        BackendDB       *bd )
 {
        backsql_info    *si = (backsql_info*)bd->be_private;
-       Connection      tmp;
        SQLHDBC         dbh;
        ber_len_t       idq_len;
        struct berval   bv;
 
+       Operation       otmp;
+               
        Debug( LDAP_DEBUG_TRACE, "==>backsql_db_open(): "
                "testing RDBMS connection\n", 0, 0, 0 );
        if ( si->dbname == NULL ) {
@@ -362,9 +363,9 @@ backsql_db_open(
                si->delentry_query = ch_strdup( backsql_def_delentry_query );
        }
 
-
-       tmp.c_connid =- 1;
-       if ( backsql_get_db_conn( bd, &tmp, &dbh ) != LDAP_SUCCESS ) {
+       otmp.o_connid = -1;
+       otmp.o_bd = bd;
+       if ( backsql_get_db_conn( &otmp, &dbh ) != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
                        "connection failed, exiting\n", 0, 0, 0 );
                return 1;
@@ -418,7 +419,7 @@ backsql_db_open(
                        &si->children_cond );
        si->has_children_query = bv.bv_val;
  
-       backsql_free_db_conn( bd, &tmp );
+       backsql_free_db_conn( &otmp );
        if ( !BACKSQL_SCHEMA_LOADED( si ) ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_db_open(): "
                        "test failed, schema map not loaded - exiting\n",
@@ -441,12 +442,14 @@ backsql_db_close(
 }
 
 int
-backsql_connection_destroy(
-       BackendDB       *be,
-       Connection      *conn )
+backsql_connection_destroy( Backend *bd, Connection *c )
 {
+       Operation o;
+       o.o_bd = bd;
+       o.o_connid = c->c_connid;
+
        Debug( LDAP_DEBUG_TRACE, "==>backsql_connection_destroy()\n", 0, 0, 0 );
-       backsql_free_db_conn( be, conn );
+       backsql_free_db_conn( &o );
        Debug( LDAP_DEBUG_TRACE, "<==backsql_connection_destroy()\n", 0, 0, 0 );
        return 0;
 }
index 1b203f855eb17bd1a3e6c42d7148e5c13821a791..10bcd29f710d06a86c38fca7b0229a77a4813ce8 100644 (file)
@@ -30,7 +30,7 @@
 /*
  * Skip:
  * - the first occurrence of objectClass, which is used
- *   to determine how to bulid the SQL entry (FIXME ?!?)
+ *   to determine how to build the SQL entry (FIXME ?!?)
  * - operational attributes
  *   empty attributes (FIXME ?!?)
  */
 
 static int
 backsql_modify_internal(
-       BackendDB               *be,
-       Connection              *conn,
        Operation               *op,
+       SlapReply               *rs,
        SQLHDBC                 dbh, 
        backsql_oc_map_rec      *oc,
        backsql_entryID         *e_id,
-       Modifications           *modlist,
-       const char              **text )
+       Modifications           *modlist )
 {
-       backsql_info    *bi = (backsql_info*)be->be_private;
+       backsql_info    *bi = (backsql_info*)op->o_bd->be_private;
        RETCODE         rc;
        SQLHSTMT        sth;
        Modifications   *ml;
-       int             res = LDAP_SUCCESS;
 
        Debug( LDAP_DEBUG_TRACE, "backsql_modify_internal(): "
                "traversing modifications list\n", 0, 0, 0 );
 
-       *text = NULL;
-
 #ifndef BACKSQL_REALLOC_STMT
        SQLAllocStmt( dbh, &sth );
 #endif /* BACKSQL_REALLOC_STMT */
@@ -102,8 +97,8 @@ backsql_modify_internal(
                                ad->ad_cname.bv_val, 0, 0 );
 
                        if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                               res = LDAP_UNWILLING_TO_PERFORM;
-                               *text = "operation not permitted "
+                               rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+                               rs->sr_text = "operation not permitted "
                                        "within namingContext";
                                goto done;
                        }
@@ -129,8 +124,8 @@ backsql_modify_internal(
                                        at->ad->ad_cname.bv_val, 0, 0 );
 
                                if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       res = LDAP_UNWILLING_TO_PERFORM;
-                                       *text = "operation not permitted "
+                                       rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+                                       rs->sr_text = "operation not permitted "
                                                "within namingContext";
                                        goto done;
                                }
@@ -147,8 +142,8 @@ backsql_modify_internal(
                                        at->ad->ad_cname.bv_val, 0, 0 );
 
                                if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       res = LDAP_UNWILLING_TO_PERFORM;
-                                       *text = "operation not permitted "
+                                       rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+                                       rs->sr_text = "operation not permitted "
                                                "within namingContext";
                                        goto done;
                                }
@@ -166,8 +161,8 @@ del_all:
                                                asth, rc );
 
                                if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       res = LDAP_OTHER;
-                                       *text = "SQL-backend error";
+                                       rs->sr_err = LDAP_OTHER;
+                                       rs->sr_text = "SQL-backend error";
                                        goto done;
                                }
 
@@ -185,8 +180,8 @@ del_all:
                                SQLFreeStmt( asth, SQL_DROP );
 
                                if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       res = LDAP_OTHER;
-                                       *text = "SQL-backend error";
+                                       rs->sr_err = LDAP_OTHER;
+                                       rs->sr_text = "SQL-backend error";
                                        goto done;
                                }
 
@@ -204,8 +199,8 @@ del_all:
                                SQLFreeStmt( asth, SQL_DROP );
 
                                if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       res = LDAP_OTHER;
-                                       *text = "SQL-backend error";
+                                       rs->sr_err = LDAP_OTHER;
+                                       rs->sr_text = "SQL-backend error";
                                        goto done;
                                }
 
@@ -258,8 +253,8 @@ del_all:
                                                                dbh, sth, rc );
 
                                                if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                                       res = LDAP_OTHER;
-                                                       *text = "SQL-backend error";
+                                                       rs->sr_err = LDAP_OTHER;
+                                                       rs->sr_text = "SQL-backend error";
                                                        goto done;
                                                }
                                        }
@@ -287,8 +282,8 @@ add_only:;
                                        at->ad->ad_cname.bv_val, 0, 0 );
 
                                if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       res = LDAP_UNWILLING_TO_PERFORM;
-                                       *text = "operation not permitted "
+                                       rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+                                       rs->sr_text = "operation not permitted "
                                                "within namingContext";
                                        goto done;
                                }
@@ -342,8 +337,8 @@ add_only:;
                                                        dbh, sth, rc );
 
                                        if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                               res = LDAP_OTHER;
-                                               *text = "SQL-backend error";
+                                               rs->sr_err = LDAP_OTHER;
+                                               rs->sr_text = "SQL-backend error";
                                                goto done;
                                        }
                                }
@@ -363,8 +358,8 @@ add_only:;
                                        at->ad->ad_cname.bv_val, 0, 0 );
 
                                if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       res = LDAP_UNWILLING_TO_PERFORM;
-                                       *text = "operation not permitted "
+                                       rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+                                       rs->sr_text = "operation not permitted "
                                                "within namingContext";
                                        goto done;
                                }
@@ -428,8 +423,8 @@ add_only:;
                                                        dbh, sth, rc );
 
                                        if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                               res = LDAP_OTHER;
-                                               *text = "SQL-backend error";
+                                               rs->sr_err = LDAP_OTHER;
+                                               rs->sr_text = "SQL-backend error";
                                                goto done;
                                        }
                                }
@@ -456,36 +451,28 @@ done:;
        /*
         * FIXME: should fail in case one change fails?
         */
-       return res;
+       return rs->sr_err;
 }
 
 int
-backsql_modify(
-       BackendDB       *be,
-       Connection      *conn,
-       Operation       *op,
-       struct berval   *dn,
-       struct berval   *ndn,
-       Modifications   *modlist )
+backsql_modify( Operation *op, SlapReply *rs )
 {
-       backsql_info            *bi = (backsql_info*)be->be_private;
+       backsql_info            *bi = (backsql_info*)op->o_bd->be_private;
        SQLHDBC                 dbh;
        backsql_oc_map_rec      *oc = NULL;
        backsql_entryID         e_id;
        Entry                   e;
-       int                     res;
-       const char              *text = NULL;
 
        /*
         * FIXME: in case part of the operation cannot be performed
         * (missing mapping, SQL write fails or so) the entire operation
         * should be rolled-back
         */
-
        Debug( LDAP_DEBUG_TRACE, "==>backsql_modify(): changing entry '%s'\n",
-               ndn->bv_val, 0, 0 );
-       res = backsql_get_db_conn( be, conn, &dbh );
-       if ( res != LDAP_SUCCESS ) {
+               op->o_req_ndn.bv_val, 0, 0 );
+
+       rs->sr_err = backsql_get_db_conn( op, &dbh );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_modify(): "
                        "could not get connection handle - exiting\n", 
                        0, 0, 0 );
@@ -493,19 +480,19 @@ backsql_modify(
                 * FIXME: we don't want to send back 
                 * excessively detailed messages
                 */
-               send_ldap_result( conn, op, res, NULL,
-                               res == LDAP_OTHER ?  "SQL-backend error" : "",
-                               NULL, NULL );
+               rs->sr_text = ( rs->sr_err == LDAP_OTHER )
+                       ? "SQL-backend error" : NULL;
+               send_ldap_result( op, rs );
                return 1;
        }
 
-       res = backsql_dn2id( bi, &e_id, dbh, ndn );
-       if ( res != LDAP_SUCCESS ) {
+       rs->sr_err = backsql_dn2id( bi, &e_id, dbh, &op->o_req_ndn );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_modify(): "
                        "could not lookup entry id\n", 0, 0, 0 );
-               send_ldap_result( conn, op, res , NULL, 
-                               res == LDAP_OTHER ? "SQL-backend error" : "",
-                               NULL, NULL );
+               rs->sr_text = ( rs->sr_err == LDAP_OTHER )
+                       ? "SQL-backend error" : NULL;
+               send_ldap_result( op, rs );
                return 1;
        }
 
@@ -526,107 +513,94 @@ backsql_modify(
                 * FIXME: we don't want to send back 
                 * excessively detailed messages
                 */
-               send_ldap_result( conn, op, LDAP_OTHER, NULL,
-                               "SQL-backend error", NULL, NULL );
+               rs->sr_err = LDAP_OTHER;
+               rs->sr_text = "SQL-backend error";
+               send_ldap_result( op, rs );
                return 1;
        }
 
        e.e_attrs = NULL;
-       e.e_name = *dn;
-       e.e_nname = *ndn;
-       if ( !acl_check_modlist( be, conn, op, &e, modlist )) {
-               res = LDAP_INSUFFICIENT_ACCESS;
+       e.e_name = op->o_req_dn;
+       e.e_nname = op->o_req_ndn;
+       if ( !acl_check_modlist( op, &e, op->oq_modify.rs_modlist ) ) {
+               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
 
        } else {
-               res = backsql_modify_internal( be, conn, op,
-                               dbh, oc, &e_id, modlist, &text );
+               rs->sr_err = backsql_modify_internal( op, rs, dbh, oc, &e_id,
+                               op->oq_modify.rs_modlist );
        }
 
-       if ( res == LDAP_SUCCESS ) {
+       if ( rs->sr_err == LDAP_SUCCESS ) {
                /*
                 * Commit only if all operations succeed
                 */
                SQLTransact( SQL_NULL_HENV, dbh, 
                                op->o_noop ? SQL_ROLLBACK : SQL_COMMIT );
        }
-       send_ldap_result( conn, op, res, NULL, text, NULL, NULL );
+       send_ldap_result( op, rs );
        Debug( LDAP_DEBUG_TRACE, "<==backsql_modify()\n", 0, 0, 0 );
 
        return op->o_noop;
 }
 
 int
-backsql_modrdn(
-       BackendDB       *be,
-       Connection      *conn,
-       Operation       *op,
-       struct berval   *dn,
-       struct berval   *ndn,
-       struct berval   *newrdn,
-       struct berval   *nnewrdn,
-       int             deleteoldrdn,
-       struct berval   *newSuperior,
-       struct berval   *nnewSuperior )
+backsql_modrdn( Operation *op, SlapReply *rs )
 {
-       backsql_info            *bi = (backsql_info*)be->be_private;
+       backsql_info            *bi = (backsql_info*)op->o_bd->be_private;
        SQLHDBC                 dbh;
        SQLHSTMT                sth;
        RETCODE                 rc;
        backsql_entryID         e_id, pe_id, new_pid;
        backsql_oc_map_rec      *oc = NULL;
-       int                     res;
        struct berval           p_dn, p_ndn,
                                *new_pdn = NULL, *new_npdn = NULL,
                                new_dn, new_ndn;
-       const char              *text = NULL;
        LDAPRDN                 *new_rdn = NULL;
        LDAPRDN                 *old_rdn = NULL;
        Entry                   e;
        Modifications           *mod;
+       struct berval           *newSuperior = op->oq_modrdn.rs_newSup;
  
        Debug( LDAP_DEBUG_TRACE, "==>backsql_modrdn() renaming entry '%s', "
                        "newrdn='%s', newSuperior='%s'\n",
-                       dn->bv_val, newrdn->bv_val, 
+                       op->o_req_dn.bv_val, op->oq_modrdn.rs_newrdn.bv_val, 
                        newSuperior ? newSuperior->bv_val : "(NULL)" );
-       res = backsql_get_db_conn( be, conn, &dbh );
-       if ( res != LDAP_SUCCESS ) {
+       rs->sr_err = backsql_get_db_conn( op, &dbh );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
                        "could not get connection handle - exiting\n", 
                        0, 0, 0 );
-               send_ldap_result( conn, op, res, NULL,
-                               res == LDAP_OTHER ?  "SQL-backend error" : "",
-                               NULL, NULL );
+               rs->sr_text = ( rs->sr_err == LDAP_OTHER )
+                       ?  "SQL-backend error" : NULL;
+               send_ldap_result( op, rs );
                return 1;
        }
 
-       res = backsql_dn2id( bi, &e_id, dbh, ndn );
-       if ( res != LDAP_SUCCESS ) {
+       rs->sr_err = backsql_dn2id( bi, &e_id, dbh, &op->o_req_ndn );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
                        "could not lookup entry id\n", 0, 0, 0 );
-               send_ldap_result( conn, op, res, NULL,
-                               res == LDAP_OTHER ?  "SQL-backend error" : "",
-                               NULL, NULL );
+               rs->sr_text = ( rs->sr_err == LDAP_OTHER )
+                       ?  "SQL-backend error" : NULL;
+               send_ldap_result( op, rs );
                return 1;
        }
 
-       /*
-        * FIXME: check whether entry has children
-        */
-
        Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): entry id is %ld\n",
                e_id.id, 0, 0 );
 
-       if ( backsql_has_children( bi, dbh, ndn ) == LDAP_COMPARE_TRUE ) {
+       if ( backsql_has_children( bi, dbh, &op->o_req_ndn ) == LDAP_COMPARE_TRUE ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
-                       "entry \"%s\" has children\n", dn->bv_val, 0, 0 );
-               send_ldap_result( conn, op, LDAP_NOT_ALLOWED_ON_NONLEAF,
-                               NULL, "subtree delete not supported",
-                               NULL, NULL );
+                       "entry \"%s\" has children\n",
+                       op->o_req_dn.bv_val, 0, 0 );
+               rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF;
+               rs->sr_text = "subtree rename not supported";
+               send_ldap_result( op, rs );
                return 1;
        }
 
-       dnParent( dn, &p_dn );
-       dnParent( ndn, &p_ndn );
+       dnParent( &op->o_req_dn, &p_dn );
+       dnParent( &op->o_req_ndn, &p_ndn );
 
        /*
         * namingContext "" is not supported
@@ -634,9 +608,9 @@ backsql_modrdn(
        if ( p_dn.bv_len == 0 ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
                        "parent is \"\" - aborting\n", 0, 0, 0 );
-               send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, 
-                               NULL, "not allowed within namingContext", 
-                               NULL, NULL );
+               rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+               rs->sr_text = "not allowed within namingContext";
+               send_ldap_result( op, rs );
                goto modrdn_return;
        }
 
@@ -646,10 +620,10 @@ backsql_modrdn(
        e.e_attrs = NULL;
        e.e_name = p_dn;
        e.e_nname = p_ndn;
-       if ( !access_allowed( be, conn, op, &e, slap_schema.si_ad_children, 
+       if ( !access_allowed( op, &e, slap_schema.si_ad_children, 
                                NULL, ACL_WRITE, NULL ) ) {
                Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0, 0, 0 );
-               res = LDAP_INSUFFICIENT_ACCESS;
+               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
                goto modrdn_return;
        }
 
@@ -660,15 +634,14 @@ backsql_modrdn(
                if ( newSuperior->bv_len == 0 ) {
                        Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
                                "newSuperior is \"\" - aborting\n", 0, 0, 0 );
-                       send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, 
-                                       NULL,
-                                       "not allowed within namingContext", 
-                                       NULL, NULL );
+                       rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+                       rs->sr_text = "not allowed within namingContext";
+                       send_ldap_result( op, rs );
                        goto modrdn_return;
                }
 
                new_pdn = newSuperior;
-               new_npdn = nnewSuperior;
+               new_npdn = op->oq_modrdn.rs_nnewSup;
 
                e.e_name = *new_pdn;
                e.e_nname = *new_npdn;
@@ -676,12 +649,11 @@ backsql_modrdn(
                /*
                 * Check for children access to new parent
                 */
-               if ( !access_allowed( be, conn, op, &e, 
-                                       slap_schema.si_ad_children, 
+               if ( !access_allowed( op, &e, slap_schema.si_ad_children, 
                                        NULL, ACL_WRITE, NULL ) ) {
                        Debug( LDAP_DEBUG_TRACE, "no access to new parent\n", 
                                        0, 0, 0 );
-                       res = LDAP_INSUFFICIENT_ACCESS;
+                       rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
                        goto modrdn_return;
                }
 
@@ -697,49 +669,50 @@ backsql_modrdn(
                newSuperior = NULL;
        }
 
-       if ( newSuperior && dn_match( ndn, new_npdn ) ) {
+       if ( newSuperior && dn_match( &op->o_req_ndn, new_npdn ) ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
                        "newSuperior is equal to entry being moved "
                        "- aborting\n", 0, 0, 0 );
-               send_ldap_result( conn, op, LDAP_OTHER,
-                               NULL, "newSuperior is equal to old DN",
-                               NULL, NULL );
+               rs->sr_err = LDAP_OTHER;
+               rs->sr_text = "newSuperior is equal to old DN";
+               send_ldap_result( op, rs );
                goto modrdn_return;
        }
 
-       build_new_dn( &new_dn, new_pdn, newrdn ); 
+       build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn ); 
        if ( dnNormalize2( NULL, &new_dn, &new_ndn ) != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
                        "new dn is invalid ('%s') - aborting\n",
                        new_dn.bv_val, 0, 0 );
-               send_ldap_result( conn, op, LDAP_INVALID_DN_SYNTAX,
-                               NULL, "new DN is invalid", NULL, NULL );
+               rs->sr_err = LDAP_INVALID_DN_SYNTAX;
+               rs->sr_text = "new DN is invalid";
+               send_ldap_result( op, rs );
                goto modrdn_return;
        }
        
        Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): new entry dn is '%s'\n",
                        new_dn.bv_val, 0, 0 );
 
-       res = backsql_dn2id( bi, &pe_id, dbh, &p_ndn );
-       if ( res != LDAP_SUCCESS ) {
+       rs->sr_err = backsql_dn2id( bi, &pe_id, dbh, &p_ndn );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
                        "could not lookup old parent entry id\n", 0, 0, 0 );
-               send_ldap_result( conn, op, res, NULL, 
-                               res == LDAP_OTHER ? "SQL-backend error" : "",
-                               NULL, NULL );
+               rs->sr_text = ( rs->sr_err == LDAP_OTHER )
+                       ? "SQL-backend error" : NULL;
+               send_ldap_result( op, rs );
                goto modrdn_return;
        }
 
        Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
                "old parent entry id is %ld\n", pe_id.id, 0, 0 );
 
-       res = backsql_dn2id( bi, &new_pid, dbh, new_npdn );
-       if ( res != LDAP_SUCCESS ) {
+       rs->sr_err = backsql_dn2id( bi, &new_pid, dbh, new_npdn );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
                        "could not lookup new parent entry id\n", 0, 0, 0 );
-               send_ldap_result( conn, op, res, NULL,
-                               res == LDAP_OTHER ? "SQL-backend error" : "",
-                               NULL, NULL );
+               rs->sr_text = ( rs->sr_err == LDAP_OTHER )
+                       ? "SQL-backend error" : NULL;
+               send_ldap_result( op, rs );
                goto modrdn_return;
        }
        
@@ -758,8 +731,9 @@ backsql_modrdn(
                        "failed to delete record from ldap_entries\n",
                        0, 0, 0 );
                backsql_PrintErrors( bi->db_env, dbh, sth, rc );
-               send_ldap_result( conn, op, LDAP_OTHER,
-                               NULL, "SQL-backend error", NULL, NULL );
+               rs->sr_err = LDAP_OTHER;
+               rs->sr_text = "SQL-backend error";
+               send_ldap_result( op, rs );
                goto modrdn_return;
        }
 
@@ -779,8 +753,9 @@ backsql_modrdn(
                Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
                        "could not insert ldap_entries record\n", 0, 0, 0 );
                backsql_PrintErrors( bi->db_env, dbh, sth, rc );
-               send_ldap_result( conn, op, LDAP_OTHER,
-                               NULL, "SQL-backend error", NULL, NULL );
+               rs->sr_err = LDAP_OTHER;
+               rs->sr_text = "SQL-backend error";
+               send_ldap_result( op, rs );
                goto modrdn_return;
        }
 
@@ -788,7 +763,8 @@ backsql_modrdn(
         * Get attribute type and attribute value of our new rdn,
         * we will need to add that to our new entry
         */
-       if ( ldap_bv2rdn( newrdn, &new_rdn, (char **)&text, 
+       if ( ldap_bv2rdn( &op->oq_modrdn.rs_newrdn, &new_rdn,
+                               (char **)&rs->sr_text, 
                                LDAP_DN_FORMAT_LDAP ) ) {
 #ifdef NEW_LOGGING
                LDAP_LOG ( OPERATION, ERR, 
@@ -801,7 +777,7 @@ backsql_modrdn(
                        "type(s)/values(s) of newrdn\n", 
                        0, 0, 0 );
 #endif
-               rc = LDAP_INVALID_DN_SYNTAX;
+               rs->sr_err = LDAP_INVALID_DN_SYNTAX;
                goto modrdn_return;
        }
 
@@ -819,9 +795,10 @@ backsql_modrdn(
                new_rdn[ 0 ][ 0 ]->la_value.bv_val, 0 );
 #endif
 
-       if ( deleteoldrdn ) {
-               if ( ldap_bv2rdn( dn, &old_rdn, (char **)&text,
-                       LDAP_DN_FORMAT_LDAP ) ) {
+       if ( op->oq_modrdn.rs_deleteoldrdn ) {
+               if ( ldap_bv2rdn( &op->o_req_dn, &old_rdn,
+                                       (char **)&rs->sr_text,
+                                       LDAP_DN_FORMAT_LDAP ) ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG ( OPERATION, ERR, 
                                "backsql_modrdn: can't figure out "
@@ -833,29 +810,27 @@ backsql_modrdn(
                                "the old_rdn type(s)/value(s)\n", 
                                0, 0, 0 );
 #endif
-                       rc = LDAP_OTHER;
+                       rs->sr_err = LDAP_OTHER;
                        goto modrdn_return;             
                }
        }
 
        e.e_name = new_dn;
        e.e_nname = new_ndn;
-       res = slap_modrdn2mods( be, conn, op, &e, old_rdn, new_rdn, 
-                       deleteoldrdn, &mod );
-       if ( res != LDAP_SUCCESS ) {
+       rs->sr_err = slap_modrdn2mods( op, rs, &e, old_rdn, new_rdn, &mod );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                goto modrdn_return;
        }
 
-       if ( !acl_check_modlist( be, conn, op, &e, mod )) {
-               res = LDAP_INSUFFICIENT_ACCESS;
+       if ( !acl_check_modlist( op, &e, mod )) {
+               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
                goto modrdn_return;
        }
 
        oc = backsql_id2oc( bi, e_id.oc_id );
-       res = backsql_modify_internal( be, conn, op, 
-                       dbh, oc, &e_id, mod, &text );
+       rs->sr_err = backsql_modify_internal( op, rs, dbh, oc, &e_id, mod );
 
-       if ( res == LDAP_SUCCESS ) {
+       if ( rs->sr_err == LDAP_SUCCESS ) {
 
                /*
                 * Commit only if all operations succeed
@@ -890,20 +865,16 @@ modrdn_return:
                }
        }
 
-       send_ldap_result( conn, op, res, NULL, text, NULL, NULL );
+       send_ldap_result( op, rs );
 
        Debug( LDAP_DEBUG_TRACE, "<==backsql_modrdn()\n", 0, 0, 0 );
        return op->o_noop;
 }
 
 int
-backsql_add(
-       BackendDB       *be,
-       Connection      *conn,
-       Operation       *op,
-       Entry           *e )
+backsql_add( Operation *op, SlapReply *rs )
 {
-       backsql_info            *bi = (backsql_info*)be->be_private;
+       backsql_info            *bi = (backsql_info*)op->o_bd->be_private;
        SQLHDBC                 dbh;
        SQLHSTMT                sth;
        unsigned long           new_keyval = 0;
@@ -913,7 +884,6 @@ backsql_add(
        backsql_at_map_rec      *at_rec = NULL;
        backsql_entryID         e_id, parent_id;
        Entry                   p;
-       int                     res;
        Attribute               *at;
        struct berval           *at_val;
        struct berval           pdn;
@@ -923,30 +893,26 @@ backsql_add(
        int                     prc;
 
        Debug( LDAP_DEBUG_TRACE, "==>backsql_add(): adding entry '%s'\n",
-                       e->e_name.bv_val, 0, 0 );
+                       op->oq_add.rs_e->e_name.bv_val, 0, 0 );
 
        /* check schema */
        if ( global_schemacheck ) {
-               const char      *text = NULL;
                char            textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' };
-               int             rc;
-               rc = entry_schema_check( be, e, NULL,
-                               &text, textbuf, sizeof( textbuf ) );
-               if ( rc != LDAP_SUCCESS ) {
 
+               rs->sr_err = entry_schema_check( op->o_bd, op->oq_add.rs_e,
+                               NULL,
+                               &rs->sr_text, textbuf, sizeof( textbuf ) );
+               if ( rs->sr_err != LDAP_SUCCESS ) {
                        Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
                                "entry failed schema check -- aborting\n",
                                0, 0, 0 );
-                       send_ldap_result( conn, op, rc, NULL,
-                                       "operation not permitted "
-                                       "within namingContext",
-                                       NULL, NULL );
+                       send_ldap_result( op, rs );
                        return 1;
                }
        }
 
        /* search structural objectClass */
-       for ( at = e->e_attrs; at != NULL; at = at->a_next ) {
+       for ( at = op->oq_add.rs_e->e_attrs; at != NULL; at = at->a_next ) {
                if ( at->a_desc == slap_schema.si_ad_structuralObjectClass ) {
                        break;
                }
@@ -962,9 +928,9 @@ backsql_add(
                Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
                        "cannot determine objectclass of entry -- aborting\n",
                        0, 0, 0 );
-               send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
-                               "operation not permitted within namingContext",
-                               NULL, NULL );
+               rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+               rs->sr_text = "operation not permitted within namingContext";
+               send_ldap_result( op, rs );
                return 1;
        }
 
@@ -972,9 +938,9 @@ backsql_add(
                Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
                        "create procedure is not defined for this objectclass "
                        "- aborting\n", 0, 0, 0 );
-               send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
-                               "operation not permitted within namingContext",
-                               NULL, NULL );
+               rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+               rs->sr_text = "operation not permitted within namingContext";
+               send_ldap_result( op, rs );
                return 1;
 
        } else if ( BACKSQL_CREATE_NEEDS_SELECT( bi )
@@ -982,53 +948,48 @@ backsql_add(
                Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
                        "create procedure needs select procedure, "
                        "but none is defined - aborting\n", 0, 0, 0 );
-               send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
-                               "operation not permitted within namingContext",
-                               NULL, NULL );
+               rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+               rs->sr_text = "operation not permitted within namingContext";
+               send_ldap_result( op, rs );
                return 1;
        }
 
-       prc = backsql_get_db_conn( be, conn, &dbh );
+       rs->sr_err = backsql_get_db_conn( op, &dbh );
        if ( prc != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
                        "could not get connection handle - exiting\n", 
                        0, 0, 0 );
-               send_ldap_result( conn, op, prc, NULL,
-                               prc == LDAP_OTHER ?  "SQL-backend error" : "",
-                               NULL, NULL );
+               rs->sr_text = ( rs->sr_err == LDAP_OTHER )
+                       ?  "SQL-backend error" : NULL,
+               send_ldap_result( op, rs );
                return 1;
        }
 
        /*
         * Check if entry exists
         */
-       res = backsql_dn2id( bi, &e_id, dbh, &e->e_name );
-       if ( res == LDAP_SUCCESS ) {
+       rs->sr_err = backsql_dn2id( bi, &e_id, dbh, &op->oq_add.rs_e->e_name );
+       if ( rs->sr_err == LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
                        "entry '%s' exists\n",
-                       e->e_name.bv_val, 0, 0 );
-               send_ldap_result( conn, op, LDAP_ALREADY_EXISTS,
-                               NULL, NULL, NULL, NULL );
+                       op->oq_add.rs_e->e_name.bv_val, 0, 0 );
+               rs->sr_err = LDAP_ALREADY_EXISTS;
+               send_ldap_result( op, rs );
                return 1;
        }
 
        /*
         * Check if parent exists
         */
-       dnParent( &e->e_name, &pdn );
-       res = backsql_dn2id( bi, &parent_id, dbh, &pdn );
-       if ( res != LDAP_SUCCESS ) {
-               
-               /*
-                * NO SUCH OBJECT seems more appropriate
-                */
+       dnParent( &op->oq_add.rs_e->e_name, &pdn );
+       rs->sr_err = backsql_dn2id( bi, &parent_id, dbh, &pdn );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
                        "could not lookup parent entry for new record '%s'\n",
                        pdn.bv_val, 0, 0 );
 
-               if ( res != LDAP_NO_SUCH_OBJECT ) {
-                       send_ldap_result( conn, op, res,
-                                       NULL, NULL, NULL, NULL );
+               if ( rs->sr_err != LDAP_NO_SUCH_OBJECT ) {
+                       send_ldap_result( op, rs );
                        return 1;
                }
 
@@ -1045,8 +1006,8 @@ backsql_add(
                        /*
                         * Empty DN ("") defaults to LDAP_SUCCESS
                         */
-                       res = backsql_dn2id( bi, &parent_id, dbh, &pdn );
-                       switch ( res ) {
+                       rs->sr_err = backsql_dn2id( bi, &parent_id, dbh, &pdn );
+                       switch ( rs->sr_err ) {
                        case LDAP_NO_SUCH_OBJECT:
                                if ( pdn.bv_len > 0 ) {
                                        break;
@@ -1058,8 +1019,9 @@ backsql_add(
                                /* fail over to next case */
 
                        default:
-                               send_ldap_result( conn, op, res,
-                                               matched, NULL, NULL, NULL );
+                               rs->sr_err = LDAP_NO_SUCH_OBJECT;
+                               rs->sr_matched = matched;
+                               send_ldap_result( op, rs );
                                return 1;
                        } 
                }
@@ -1074,18 +1036,19 @@ backsql_add(
 
        p.e_attrs = NULL;
        p.e_name = pdn;
-       dnParent( &e->e_nname, &p.e_nname );
-       if ( !access_allowed( be, conn, op, &p, slap_schema.si_ad_children,
+       dnParent( &op->oq_add.rs_e->e_nname, &p.e_nname );
+       if ( !access_allowed( op, &p, slap_schema.si_ad_children,
                                NULL, ACL_WRITE, NULL ) ) {
-               send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, 
-                               NULL, NULL, NULL, NULL );
+               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+               send_ldap_result( op, rs );
                return 1;
        }
 
        rc = SQLAllocStmt( dbh, &sth );
        if ( rc != SQL_SUCCESS ) {
-               send_ldap_result( conn, op, LDAP_OTHER,
-                               NULL, "SQL-backend error", NULL, NULL );
+               rs->sr_err = LDAP_OTHER;
+               rs->sr_text = "SQL-backend error";
+               send_ldap_result( op, rs );
                return 1;
        }
 
@@ -1102,8 +1065,9 @@ backsql_add(
                        "create_proc execution failed\n", 0, 0, 0 );
                backsql_PrintErrors( bi->db_env, dbh, sth, rc);
                SQLFreeStmt( sth, SQL_DROP );
-               send_ldap_result( conn, op, LDAP_OTHER,
-                               NULL, "SQL-backend error", NULL, NULL );
+               rs->sr_err = LDAP_OTHER;
+               rs->sr_text = "SQL-backend error";
+               send_ldap_result( op, rs );
                return 1;
        }
        if ( op->o_noop ) {
@@ -1121,18 +1085,18 @@ backsql_add(
                        SQLFreeStmt( sth, SQL_DROP );
                        rc = SQLAllocStmt( dbh, &sth );
                        if ( rc != SQL_SUCCESS ) {
-                               send_ldap_result( conn, op, LDAP_OTHER,
-                                               NULL, "SQL-backend error",
-                                               NULL, NULL );
+                               rs->sr_err = LDAP_OTHER;
+                               rs->sr_text = "SQL-backend error";
+                               send_ldap_result( op, rs );
                                return 1;
                        }
 #endif /* BACKSQL_REALLOC_STMT */
 
                        rc = SQLExecDirect( sth, oc->create_keyval, SQL_NTS );
                        if ( rc != SQL_SUCCESS ) {
-                               send_ldap_result( conn, op, LDAP_OTHER,
-                                               NULL, "SQL-backend error",
-                                               NULL, NULL );
+                               rs->sr_err = LDAP_OTHER;
+                               rs->sr_text = "SQL-backend error";
+                               send_ldap_result( op, rs );
                                return 1;
                        }
                }
@@ -1148,8 +1112,9 @@ backsql_add(
                                0, 0, 0 );
                        backsql_PrintErrors( bi->db_env, dbh, sth, rc);
                        SQLFreeStmt( sth, SQL_DROP );
-                       send_ldap_result( conn, op, LDAP_OTHER,
-                                       NULL, "SQL-backend error", NULL, NULL );
+                       rs->sr_err = LDAP_OTHER;
+                       rs->sr_text = "SQL-backend error";
+                       send_ldap_result( op, rs );
                        return 1;
 
                } else if ( ncols != 1 ) {
@@ -1158,8 +1123,9 @@ backsql_add(
                                ncols, 0, 0 );
                        backsql_PrintErrors( bi->db_env, dbh, sth, rc);
                        SQLFreeStmt( sth, SQL_DROP );
-                       send_ldap_result( conn, op, LDAP_OTHER,
-                                       NULL, "SQL-backend error", NULL, NULL );
+                       rs->sr_err = LDAP_OTHER;
+                       rs->sr_text = "SQL-backend error";
+                       send_ldap_result( op, rs );
                        return 1;
                }
 
@@ -1194,8 +1160,9 @@ backsql_add(
                                0, 0, 0 );
                        backsql_PrintErrors( bi->db_env, dbh, sth, rc);
                        SQLFreeStmt( sth, SQL_DROP );
-                       send_ldap_result( conn, op, LDAP_OTHER,
-                                       NULL, "SQL-backend error", NULL, NULL );
+                       rs->sr_err = LDAP_OTHER;
+                       rs->sr_text = "SQL-backend error";
+                       send_ldap_result( op, rs );
                        return 1;
                }
        }
@@ -1209,7 +1176,7 @@ backsql_add(
        Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
                "create_proc returned keyval=%ld\n", new_keyval, 0, 0 );
 
-       for ( at = e->e_attrs; at != NULL; at = at->a_next ) {
+       for ( at = op->oq_add.rs_e->e_attrs; at != NULL; at = at->a_next ) {
                SQLUSMALLINT    currpos;
 
                Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
@@ -1237,11 +1204,10 @@ backsql_add(
                                BACKSQL_OC_NAME( oc ), 0 );
 
                        if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                               send_ldap_result( conn, op, 
-                                               LDAP_UNWILLING_TO_PERFORM, NULL,
-                                               "operation not permitted "
-                                               "within namingContext",
-                                               NULL, NULL );
+                               rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+                               rs->sr_text = "operation not permitted "
+                                       "within namingContext";
+                               send_ldap_result( op, rs );
                                return 1;
                        }
 
@@ -1255,11 +1221,10 @@ backsql_add(
                                at->a_desc->ad_cname.bv_val, 0, 0 );
 
                        if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                               send_ldap_result( conn, op, 
-                                               LDAP_UNWILLING_TO_PERFORM, NULL,
-                                               "operation not permitted "
-                                               "within namingContext",
-                                               NULL, NULL );
+                               rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+                               rs->sr_text = "operation not permitted "
+                                       "within namingContext";
+                               send_ldap_result( op, rs );
                                return 1;
                        }
 
@@ -1271,9 +1236,9 @@ backsql_add(
                if ( rc != SQL_SUCCESS ) {
 
                        if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                               send_ldap_result( conn, op, LDAP_OTHER,
-                                               NULL, "SQL-backend error",
-                                               NULL, NULL );
+                               rs->sr_err = LDAP_OTHER;
+                               rs->sr_text = "SQL-backend error";
+                               send_ldap_result( op, rs );
                                return 1;
                        }
 
@@ -1339,10 +1304,9 @@ backsql_add(
                                backsql_PrintErrors( bi->db_env, dbh, sth, rc );
 
                                if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       send_ldap_result( conn, op, LDAP_OTHER,
-                                                       NULL,
-                                                       "SQL-backend error",
-                                                       NULL, NULL );
+                                       rs->sr_err = LDAP_OTHER;
+                                       rs->sr_text = "SQL-backend error";
+                                       send_ldap_result( op, rs );
                                        return 1;
                                }
                        }
@@ -1357,13 +1321,15 @@ backsql_add(
 #ifdef BACKSQL_REALLOC_STMT
        rc = backsql_Prepare( dbh, &sth, bi->insentry_query, 0 );
        if ( rc != SQL_SUCCESS ) {
-               send_ldap_result( conn, op, LDAP_OTHER,
-                               NULL, "SQL-backend error", NULL, NULL );
+               rs->sr_err = LDAP_OTHER;
+               rs->sr_text = "SQL-backend error";
+               send_ldap_result( op, rs );
                return 1;
        }
 #endif /* BACKSQL_REALLOC_STMT */
        
-       backsql_BindParamStr( sth, 1, e->e_name.bv_val, BACKSQL_MAX_DN_LEN );
+       backsql_BindParamStr( sth, 1, op->oq_add.rs_e->e_name.bv_val,
+                       BACKSQL_MAX_DN_LEN );
        SQLBindParameter( sth, 2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
                        0, 0, &oc->id, 0, 0 );
        SQLBindParameter( sth, 3, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
@@ -1372,7 +1338,7 @@ backsql_add(
                        0, 0, &new_keyval, 0, 0 );
 
        Debug( LDAP_DEBUG_TRACE, "backsql_add(): executing '%s' for dn '%s'\n",
-                       bi->insentry_query, e->e_name.bv_val, 0 );
+                       bi->insentry_query, op->oq_add.rs_e->e_name.bv_val, 0 );
        Debug( LDAP_DEBUG_TRACE, " for oc_map_id=%ld, parent_id=%ld, "
                        "keyval=%ld\n", oc->id, parent_id.id, new_keyval );
 #ifndef BACKSQL_REALLOC_STMT
@@ -1389,8 +1355,9 @@ backsql_add(
                 * execute delete_proc to delete data added !!!
                 */
                SQLFreeStmt( sth, SQL_DROP );
-               send_ldap_result( conn, op, LDAP_OTHER,
-                               NULL, "SQL-backend error", NULL, NULL );
+               rs->sr_err = LDAP_OTHER;
+               rs->sr_text = "SQL-backend error";
+               send_ldap_result( op, rs );
                return 1;
        }
        
@@ -1407,83 +1374,78 @@ backsql_add(
         * the other operations, and I don't get the reason :(
         */
 
-       send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL, NULL, NULL );
+       send_ldap_result( op, rs );
 
        return op->o_noop;
 }
 
 int
-backsql_delete(
-       BackendDB       *be,
-       Connection      *conn,
-       Operation       *op,
-       struct berval   *dn,
-       struct berval   *ndn )
+backsql_delete( Operation *op, SlapReply *rs )
 {
-       backsql_info            *bi = (backsql_info*)be->be_private;
+       backsql_info            *bi = (backsql_info*)op->o_bd->be_private;
        SQLHDBC                 dbh;
        SQLHSTMT                sth;
        RETCODE                 rc;
        backsql_oc_map_rec      *oc = NULL;
        backsql_entryID         e_id;
        Entry                   e;
-       int                     res;
        /* first parameter no */
        SQLUSMALLINT            pno;
 
        Debug( LDAP_DEBUG_TRACE, "==>backsql_delete(): deleting entry '%s'\n",
-                       ndn->bv_val, 0, 0 );
+                       op->o_req_ndn.bv_val, 0, 0 );
 
-       dnParent( dn, &e.e_name );
-       dnParent( ndn, &e.e_nname );
+       dnParent( &op->o_req_dn, &e.e_name );
+       dnParent( &op->o_req_ndn, &e.e_nname );
        e.e_attrs = NULL;
 
        /* check parent for "children" acl */
-       if ( !access_allowed( be, conn, op, &e, slap_schema.si_ad_children, 
+       if ( !access_allowed( op, &e, slap_schema.si_ad_children, 
                        NULL, ACL_WRITE, NULL ) ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_delete(): "
                        "no write access to parent\n", 
                        0, 0, 0 );
-               send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, 
-                               NULL, NULL, NULL, NULL );
+               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+               send_ldap_result( op, rs );
                return 1;
 
        }
        
-       res = backsql_get_db_conn( be, conn, &dbh );
-       if ( res != LDAP_SUCCESS ) {
+       rs->sr_err = backsql_get_db_conn( op, &dbh );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_delete(): "
                        "could not get connection handle - exiting\n", 
                        0, 0, 0 );
-               send_ldap_result( conn, op, res, NULL, 
-                               res == LDAP_OTHER ? "SQL-backend error" : "",
-                               NULL, NULL );
+               rs->sr_text = ( rs->sr_err == LDAP_OTHER )
+                       ? "SQL-backend error" : NULL,
+               send_ldap_result( op, rs );
                return 1;
        }
        
-       res = backsql_dn2id( bi, &e_id, dbh, ndn );
-       if ( res != LDAP_SUCCESS ) {
+       rs->sr_err = backsql_dn2id( bi, &e_id, dbh, &op->o_req_ndn );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_delete(): "
                        "could not lookup entry id\n", 0, 0, 0 );
-               send_ldap_result( conn, op, res, NULL, NULL, NULL, NULL );
+               send_ldap_result( op, rs );
                return 1;
        }
 
-       res = backsql_has_children( bi, dbh, ndn );
-       switch ( res ) {
+       rs->sr_err = backsql_has_children( bi, dbh, &op->o_req_ndn );
+       switch ( rs->sr_err ) {
        case LDAP_COMPARE_TRUE:
                Debug( LDAP_DEBUG_TRACE, "backsql_delete(): "
-                       "entry \"%s\" has children\n", dn->bv_val, 0, 0 );
-               send_ldap_result( conn, op, LDAP_NOT_ALLOWED_ON_NONLEAF,
-                               NULL, "subtree delete not supported",
-                               NULL, NULL );
+                       "entry \"%s\" has children\n",
+                       op->o_req_dn.bv_val, 0, 0 );
+               rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF;
+               rs->sr_text = "subtree delete not supported";
+               send_ldap_result( op, rs );
                return 1;
 
        case LDAP_COMPARE_FALSE:
                break;
 
        default:
-               send_ldap_result( conn, op, res, NULL, NULL, NULL, NULL );
+               send_ldap_result( op, rs );
                return 1;
        }
 
@@ -1492,9 +1454,9 @@ backsql_delete(
                Debug( LDAP_DEBUG_TRACE, "backsql_delete(): "
                        "cannot determine objectclass of entry -- aborting\n",
                        0, 0, 0 );
-               send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
-                               "operation not permitted within namingContext",
-                               NULL, NULL );
+               rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+               rs->sr_text = "operation not permitted within namingContext";
+               send_ldap_result( op, rs );
                return 1;
        }
 
@@ -1502,9 +1464,9 @@ backsql_delete(
                Debug( LDAP_DEBUG_TRACE, "backsql_delete(): "
                        "delete procedure is not defined "
                        "for this objectclass - aborting\n", 0, 0, 0 );
-               send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
-                               "operation not permitted within namingContext",
-                               NULL, NULL );
+               rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+               rs->sr_text = "operation not permitted within namingContext";
+               send_ldap_result( op, rs );
                return 1;
        }
 
@@ -1528,8 +1490,9 @@ backsql_delete(
                        "delete_proc execution failed\n", 0, 0, 0 );
                backsql_PrintErrors( bi->db_env, dbh, sth, rc );
                SQLFreeStmt( sth, SQL_DROP );
-               send_ldap_result( conn, op, LDAP_OTHER,
-                               NULL, "SQL-backend error", NULL, NULL );
+               rs->sr_err = LDAP_OTHER;
+               rs->sr_text = "SQL-backend error";
+               send_ldap_result( op, rs );
                return 1;
        }
 #ifndef BACKSQL_REALLOC_STMT
@@ -1548,8 +1511,9 @@ backsql_delete(
                        0, 0, 0 );
                backsql_PrintErrors( bi->db_env, dbh, sth, rc );
                SQLFreeStmt( sth, SQL_DROP );
-               send_ldap_result( conn, op, LDAP_OTHER,
-                               NULL, "SQL-backend error", NULL, NULL );
+               rs->sr_err = LDAP_OTHER;
+               rs->sr_text = "SQL-backend error";
+               send_ldap_result( op, rs );
                return 1;
        }
        
@@ -1567,7 +1531,7 @@ backsql_delete(
        SQLTransact( SQL_NULL_HENV, dbh, 
                        op->o_noop ? SQL_ROLLBACK : SQL_COMMIT );
 
-       send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL, NULL, NULL );
+       send_ldap_result( op, rs );
        Debug( LDAP_DEBUG_TRACE, "<==backsql_delete()\n", 0, 0, 0 );
        return op->o_noop;
 }
index 525c07a847aeddc4fcfcfc7b6b06155d4e0dc2dd..b88e4168cf67c5f8dcb29eacd34559a99431005e 100644 (file)
 
 int
 backsql_compare( Operation *op, SlapReply *rs )
-       /*
-       BackendDB       *bd,
-       Connection      *conn,
-       Operation       *op,
-       struct berval   *dn,
-       struct berval   *ndn,
-       AttributeAssertion *ava ) */
 {
        backsql_info            *bi = (backsql_info*)op->o_bd->be_private;
        backsql_entryID         user_id;
@@ -40,7 +33,7 @@ backsql_compare( Operation *op, SlapReply *rs )
  
        Debug( LDAP_DEBUG_TRACE, "==>backsql_compare()\n", 0, 0, 0 );
 
-       rs->sr_err = backsql_get_db_conn( op->o_bd, op->o_conn, &dbh );
+       rs->sr_err = backsql_get_db_conn( op, &dbh );
        if (!dbh) {
                Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
                        "could not get connection handle - exiting\n",
@@ -123,33 +116,33 @@ return_results:;
 
 int
 backsql_operational(
-       BackendDB       *be,
-       Connection      *conn, 
        Operation       *op,
-       Entry           *e,
-       AttributeName   *attrs,
+       SlapReply       *rs,
        int             opattrs,
        Attribute       **a )
 {
 
-       backsql_info            *bi = (backsql_info*)be->be_private;
+       backsql_info            *bi = (backsql_info*)op->o_bd->be_private;
        SQLHDBC                 dbh = SQL_NULL_HDBC;
        Attribute               **aa = a;
        int                     rc = 0;
 
        Debug( LDAP_DEBUG_TRACE, "==>backsql_operational(): entry '%s'\n",
-                       e->e_nname.bv_val, 0, 0 );
+                       rs->sr_entry->e_nname.bv_val, 0, 0 );
 
 
-       if ( ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, attrs ) ) 
-                       && attr_find( e->e_attrs, slap_schema.si_ad_hasSubordinates ) == NULL ) {
+       if ( ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) ) 
+                       && attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_hasSubordinates ) == NULL ) {
                
-               rc = backsql_get_db_conn( be, conn, &dbh );
+               rc = backsql_get_db_conn( op, &dbh );
                if ( rc != LDAP_SUCCESS ) {
-                       goto no_connection;
+                       Debug( LDAP_DEBUG_TRACE, "backsql_operational(): "
+                               "could not get connection handle - exiting\n", 
+                               0, 0, 0 );
+                       return 1;
                }
                
-               rc = backsql_has_children( bi, dbh, &e->e_nname );
+               rc = backsql_has_children( bi, dbh, &rs->sr_entry->e_nname );
 
                switch( rc ) {
                case LDAP_COMPARE_TRUE:
@@ -172,15 +165,6 @@ backsql_operational(
        }
 
        return rc;
-
-no_connection:;
-       Debug( LDAP_DEBUG_TRACE, "backsql_operational(): "
-               "could not get connection handle - exiting\n", 
-               0, 0, 0 );
-       send_ldap_result( conn, op, rc, "", 
-                       rc == LDAP_OTHER ? "SQL-backend error" : "",
-                       NULL, NULL );
-       return 1;
 }
 
 #endif /* SLAPD_SQL */
index 5947d85f8bf9ba497627e6bd95e032948aa324b7..7aa0dcb0e1c58183519753b931df1cfafe6e7a06 100644 (file)
@@ -1038,7 +1038,7 @@ backsql_search( Operation *op, SlapReply *rs )
                return 1;
        }
 
-       sres = backsql_get_db_conn( op->o_bd, op->o_conn, &dbh );
+       sres = backsql_get_db_conn( op, &dbh );
        if ( sres != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_search(): "
                        "could not get connection handle - exiting\n", 
index b86d4da825f7308e82d84453919431b17f2b8dd2..5a5f4cdc4e65b4fb92170bc43e5c27ad9337210e 100644 (file)
@@ -401,13 +401,13 @@ backsql_open_db_conn( backsql_info *si, int ldap_cid, backsql_db_conn **pdbc )
 }
 
 int
-backsql_free_db_conn( Backend *be, Connection *ldapc )
+backsql_free_db_conn( Operation *op )
 {
-       backsql_info            *si = (backsql_info *)be->be_private;
+       backsql_info            *si = (backsql_info *)op->o_bd->be_private;
        backsql_db_conn         tmp, *conn;
 
        Debug( LDAP_DEBUG_TRACE, "==>backsql_free_db_conn()\n", 0, 0, 0 );
-       tmp.ldap_cid = ldapc->c_connid;
+       tmp.ldap_cid = op->o_connid;
        ldap_pvt_thread_mutex_lock( &si->dbconn_mutex );
        conn = avl_delete( &si->db_conns, &tmp, backsql_cmp_connid );
        ldap_pvt_thread_mutex_unlock( &si->dbconn_mutex );
@@ -426,9 +426,9 @@ backsql_free_db_conn( Backend *be, Connection *ldapc )
 }
 
 int
-backsql_get_db_conn( Backend *be, Connection *ldapc, SQLHDBC *dbh )
+backsql_get_db_conn( Operation *op, SQLHDBC *dbh )
 {
-       backsql_info            *si = (backsql_info *)be->be_private;
+       backsql_info            *si = (backsql_info *)op->o_bd->be_private;
        backsql_db_conn         *dbc;
        backsql_db_conn         tmp;
        int                     rc = LDAP_SUCCESS;
@@ -438,7 +438,7 @@ backsql_get_db_conn( Backend *be, Connection *ldapc, SQLHDBC *dbh )
        assert( dbh );
        *dbh = SQL_NULL_HDBC;
 
-       tmp.ldap_cid = ldapc->c_connid;
+       tmp.ldap_cid = op->o_connid;
 
        /*
         * we have one thread per connection, as I understand -- 
@@ -446,7 +446,7 @@ backsql_get_db_conn( Backend *be, Connection *ldapc, SQLHDBC *dbh )
         */
        dbc = avl_find( si->db_conns, &tmp, backsql_cmp_connid );
        if ( !dbc ) {
-               rc = backsql_open_db_conn( si, ldapc->c_connid, &dbc );
+               rc = backsql_open_db_conn( si, op->o_connid, &dbc );
                if ( rc != LDAP_SUCCESS) {
                        Debug( LDAP_DEBUG_TRACE, "backsql_get_db_conn(): "
                                "could not get connection handle "
@@ -462,7 +462,7 @@ backsql_get_db_conn( Backend *be, Connection *ldapc, SQLHDBC *dbh )
                rc = backsql_load_schema_map( si, dbc->dbh );
                if ( rc != LDAP_SUCCESS ) {
                        ldap_pvt_thread_mutex_unlock( &si->schema_mutex );
-                       backsql_free_db_conn( be, ldapc );
+                       backsql_free_db_conn( op );
                        return rc;
                }
        }
index 964a953d2d53a36ad1128b54da63d1ca895eb755..d6ea74b27405ab4d6929c59c4a3cec585fca3a15 100644 (file)
@@ -33,8 +33,8 @@ void backsql_PrintErrors( SQLHENV henv, SQLHDBC hdbc, SQLHSTMT sth, int rc );
 
 int backsql_init_db_env( backsql_info *si );
 int backsql_free_db_env( backsql_info *si );
-int backsql_get_db_conn( Backend *be, Connection *ldapc, SQLHDBC *dbh );
-int backsql_free_db_conn( Backend *be, Connection *ldapc );
+int backsql_get_db_conn( Operation *op, SQLHDBC *dbh );
+int backsql_free_db_conn( Operation *op );
 
 #endif /* __BACKSQL_SQL_WRAP_H__ */