]> git.sur5r.net Git - openldap/commitdiff
fix improper use of "fail_if_no_mapping" flag: fail in case of error, don't fail...
authorPierangelo Masarati <ando@openldap.org>
Wed, 1 Jun 2005 16:51:36 +0000 (16:51 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 1 Jun 2005 16:51:36 +0000 (16:51 +0000)
servers/slapd/back-sql/add.c

index 8b1144d126d7ad7fe13bfca7afa7a0292f5b0fc4..d080b75f96072c45039c8a03c495fd377aa414e8 100644 (file)
@@ -91,11 +91,8 @@ backsql_modify_delete_all_values(
                backsql_PrintErrors( bi->sql_db_env, dbh, 
                                asth, rc );
 
-               if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                       rs->sr_text = "SQL-backend error";
-                       return rs->sr_err = LDAP_OTHER;
-               }
-               return LDAP_SUCCESS;
+               rs->sr_text = "SQL-backend error";
+               return rs->sr_err = LDAP_OTHER;
        }
 
        rc = backsql_BindParamID( asth, 1, SQL_PARAM_INPUT, &e_id->eid_keyval );
@@ -109,12 +106,8 @@ backsql_modify_delete_all_values(
                                asth, rc );
                SQLFreeStmt( asth, SQL_DROP );
 
-               if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                       rs->sr_text = "SQL-backend error";
-                       return rs->sr_err = LDAP_OTHER;
-               }
-
-               return LDAP_SUCCESS;
+               rs->sr_text = "SQL-backend error";
+               return rs->sr_err = LDAP_OTHER;
        }
                        
        rc = SQLExecute( asth );
@@ -127,12 +120,8 @@ backsql_modify_delete_all_values(
                                asth, rc );
                SQLFreeStmt( asth, SQL_DROP );
 
-               if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                       rs->sr_text = "SQL-backend error";
-                       return rs->sr_err = LDAP_OTHER;
-               }
-
-               return LDAP_SUCCESS;
+               rs->sr_text = "SQL-backend error";
+               return rs->sr_err = LDAP_OTHER;
        }
 
        backsql_BindRowAsStrings( asth, &row );
@@ -161,12 +150,8 @@ backsql_modify_delete_all_values(
                                backsql_PrintErrors( bi->sql_db_env, dbh, 
                                                sth, rc );
 
-                               if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       rs->sr_text = "SQL-backend error";
-                                       return rs->sr_err = LDAP_OTHER;
-                               }
-
-                               continue;
+                               rs->sr_text = "SQL-backend error";
+                               return rs->sr_err = LDAP_OTHER;
                        }
 
                        if ( BACKSQL_IS_DEL( at->bam_expect_return ) ) {
@@ -182,12 +167,8 @@ backsql_modify_delete_all_values(
                                                sth, rc );
                                        SQLFreeStmt( sth, SQL_DROP );
 
-                                       if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                               rs->sr_text = "SQL-backend error";
-                                               return rs->sr_err = LDAP_OTHER;
-                                       }
-
-                                       continue;
+                                       rs->sr_text = "SQL-backend error";
+                                       return rs->sr_err = LDAP_OTHER;
                                }
 
                        } else {
@@ -205,12 +186,8 @@ backsql_modify_delete_all_values(
                                        sth, rc );
                                SQLFreeStmt( sth, SQL_DROP );
 
-                               if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       rs->sr_text = "SQL-backend error";
-                                       return rs->sr_err = LDAP_OTHER;
-                               }
-
-                               continue;
+                               rs->sr_text = "SQL-backend error";
+                               return rs->sr_err = LDAP_OTHER;
                        }
 #ifdef BACKSQL_ARBITRARY_KEY
                        Debug( LDAP_DEBUG_TRACE,
@@ -240,12 +217,8 @@ backsql_modify_delete_all_values(
                                        sth, rc );
                                SQLFreeStmt( sth, SQL_DROP );
 
-                               if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       rs->sr_text = "SQL-backend error";
-                                       return rs->sr_err = LDAP_OTHER;
-                               }
-
-                               continue;
+                               rs->sr_text = "SQL-backend error";
+                               return rs->sr_err = LDAP_OTHER;
                        }
         
                        Debug( LDAP_DEBUG_TRACE, 
@@ -267,21 +240,15 @@ backsql_modify_delete_all_values(
                                        /* SQL procedure executed fine 
                                         * but returned an error */
                                        rs->sr_err = BACKSQL_SANITIZE_ERROR( prc );
-                                       rs->sr_text = op->ora_e->e_name.bv_val;
-                                       SQLFreeStmt( sth, SQL_DROP );
-                                       return rs->sr_err;
 
                                } else {
                                        backsql_PrintErrors( bi->sql_db_env, dbh,
                                                        sth, rc );
-                                       if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) 
-                                       {
-                                               rs->sr_err = LDAP_OTHER;
-                                               rs->sr_text = op->ora_e->e_name.bv_val;
-                                               SQLFreeStmt( sth, SQL_DROP );
-                                               return rs->sr_err;
-                                       }
+                                       rs->sr_err = LDAP_OTHER;
                                }
+                               rs->sr_text = op->ora_e->e_name.bv_val;
+                               SQLFreeStmt( sth, SQL_DROP );
+                               return rs->sr_err;
                        }
                        SQLFreeStmt( sth, SQL_DROP );
                }
@@ -551,12 +518,10 @@ add_only:;
                                        backsql_PrintErrors( bi->sql_db_env,
                                                        dbh, sth, rc );
 
-                                       if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                               SQLFreeStmt( sth, SQL_DROP );
-                                               rs->sr_err = LDAP_OTHER;
-                                               rs->sr_text = "SQL-backend error";
-                                               goto done;
-                                       }
+                                       SQLFreeStmt( sth, SQL_DROP );
+                                       rs->sr_err = LDAP_OTHER;
+                                       rs->sr_text = "SQL-backend error";
+                                       goto done;
                                }
                                SQLFreeStmt( sth, SQL_DROP );
                        }
@@ -676,11 +641,9 @@ add_only:;
                                                sth, rc );
                                        SQLFreeStmt( sth, SQL_DROP );
 
-                                       if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                               rs->sr_text = "SQL-backend error";
-                                               rs->sr_err = LDAP_OTHER;
-                                               goto done;
-                                       }
+                                       rs->sr_text = "SQL-backend error";
+                                       rs->sr_err = LDAP_OTHER;
+                                       goto done;
                                }
 
                                Debug( LDAP_DEBUG_TRACE,
@@ -709,13 +672,10 @@ add_only:;
                                        } else {
                                                backsql_PrintErrors( bi->sql_db_env,
                                                                dbh, sth, rc );
-                                               if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) )
-                                               {
-                                                       SQLFreeStmt( sth, SQL_DROP );
-                                                       rs->sr_err = LDAP_OTHER;
-                                                       rs->sr_text = at->bam_ad->ad_cname.bv_val;
-                                                       goto done;
-                                               }
+                                               SQLFreeStmt( sth, SQL_DROP );
+                                               rs->sr_err = LDAP_OTHER;
+                                               rs->sr_text = at->bam_ad->ad_cname.bv_val;
+                                               goto done;
                                        }
                                }
                                SQLFreeStmt( sth, SQL_DROP );
@@ -823,13 +783,8 @@ backsql_add_attr(
 
                rc = backsql_Prepare( dbh, &sth, at_rec->bam_add_proc, 0 );
                if ( rc != SQL_SUCCESS ) {
-
-                       if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                               rs->sr_text = "SQL-backend error";
-                               return rs->sr_err = LDAP_OTHER;
-                       }
-
-                       return LDAP_SUCCESS;
+                       rs->sr_text = "SQL-backend error";
+                       return rs->sr_err = LDAP_OTHER;
                }
 
                if ( BACKSQL_IS_ADD( at_rec->bam_expect_return ) ) {
@@ -844,12 +799,8 @@ backsql_add_attr(
                                        sth, rc );
                                SQLFreeStmt( sth, SQL_DROP );
 
-                               if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       rs->sr_text = "SQL-backend error";
-                                       return rs->sr_err = LDAP_OTHER;
-                               }
-
-                               return LDAP_SUCCESS;
+                               rs->sr_text = "SQL-backend error";
+                               return rs->sr_err = LDAP_OTHER;
                        }
 
                } else {
@@ -869,12 +820,8 @@ backsql_add_attr(
                                sth, rc );
                        SQLFreeStmt( sth, SQL_DROP );
 
-                       if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                               rs->sr_text = "SQL-backend error";
-                               return rs->sr_err = LDAP_OTHER;
-                       }
-
-                       return LDAP_SUCCESS;
+                       rs->sr_text = "SQL-backend error";
+                       return rs->sr_err = LDAP_OTHER;
                }
 
                currpos = pno + 2 - po;
@@ -894,12 +841,8 @@ backsql_add_attr(
                                sth, rc );
                        SQLFreeStmt( sth, SQL_DROP );
 
-                       if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                               rs->sr_text = "SQL-backend error";
-                               return rs->sr_err = LDAP_OTHER;
-                       }
-
-                       return LDAP_SUCCESS;
+                       rs->sr_text = "SQL-backend error";
+                       return rs->sr_err = LDAP_OTHER;
                }
 
 #ifdef LDAP_DEBUG
@@ -930,12 +873,10 @@ backsql_add_attr(
                        } else {
                                backsql_PrintErrors( bi->sql_db_env, dbh,
                                                sth, rc );
-                               if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
-                                       rs->sr_err = LDAP_OTHER;
-                                       rs->sr_text = op->ora_e->e_name.bv_val;
-                                       SQLFreeStmt( sth, SQL_DROP );
-                                       return rs->sr_err;
-                               }
+                               rs->sr_err = LDAP_OTHER;
+                               rs->sr_text = op->ora_e->e_name.bv_val;
+                               SQLFreeStmt( sth, SQL_DROP );
+                               return rs->sr_err;
                        }
                }
                SQLFreeStmt( sth, SQL_DROP );