-/*
- * Copyright 1999, Dmitry Kovalev <mit@openldap.org>, All rights reserved.
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Portions Copyright 1999 Dmitry Kovalev.
+ * All rights reserved.
*
- * Redistribution and use in source and binary forms are permitted only
- * as authorized by the OpenLDAP Public License. A copy of this
- * license is available at http://www.OpenLDAP.org/license.html or
- * in file LICENSE in the top-level directory of the distribution.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by Dmitry Kovalev for inclusion
+ * by OpenLDAP Software.
*/
#include "portable.h"
Debug( LDAP_DEBUG_TRACE, "backsql_modify_internal(): "
"replacing values for attribute '%s'\n",
- at->ad->ad_cname.bv_val, 0, 0 );
+ at->bam_ad->ad_cname.bv_val, 0, 0 );
- if ( at->add_proc == NULL ) {
+ if ( at->bam_add_proc == NULL ) {
Debug( LDAP_DEBUG_TRACE,
"backsql_modify_internal(): "
"add procedure is not defined "
"for attribute '%s' "
"- unable to perform replacements\n",
- at->ad->ad_cname.bv_val, 0, 0 );
+ at->bam_ad->ad_cname.bv_val, 0, 0 );
if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
break;
}
- if ( at->delete_proc == NULL ) {
+ if ( at->bam_delete_proc == NULL ) {
Debug( LDAP_DEBUG_TRACE,
"backsql_modify_internal(): "
"delete procedure is not defined "
"for attribute '%s' "
"- adding only\n",
- at->ad->ad_cname.bv_val, 0, 0 );
+ at->bam_ad->ad_cname.bv_val, 0, 0 );
if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
}
del_all:
- rc = backsql_Prepare( dbh, &asth, at->query, 0 );
+ rc = backsql_Prepare( dbh, &asth, at->bam_query, 0 );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
"backsql_modify_internal(): "
rc = SQLFetch( asth );
for ( ; BACKSQL_SUCCESS( rc ); rc = SQLFetch( asth ) ) {
for ( i = 0; i < row.ncols; i++ ) {
- if ( BACKSQL_IS_DEL( at->expect_return ) ) {
+ if ( BACKSQL_IS_DEL( at->bam_expect_return ) ) {
pno = 1;
SQLBindParameter(sth, 1,
SQL_PARAM_OUTPUT,
} else {
pno = 0;
}
- po = ( BACKSQL_IS_DEL( at->param_order ) ) > 0;
+ po = ( BACKSQL_IS_DEL( at->bam_param_order ) ) > 0;
SQLBindParameter( sth, pno + 1 + po,
SQL_PARAM_INPUT,
SQL_C_ULONG, SQL_INTEGER,
Debug( LDAP_DEBUG_TRACE,
"backsql_modify_internal(): "
"executing '%s'\n",
- at->delete_proc, 0, 0 );
+ at->bam_delete_proc, 0, 0 );
rc = SQLExecDirect( sth,
- at->delete_proc, SQL_NTS );
+ at->bam_delete_proc, SQL_NTS );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
"backsql_modify_internal(): "
backsql_FreeRow( &row );
SQLFreeStmt( asth, SQL_DROP );
}
-
+
/*
* PASSTHROUGH - to add new attributes -- do NOT add break
*/
case LDAP_MOD_ADD:
case SLAP_MOD_SOFTADD:
add_only:;
- if ( at->add_proc == NULL ) {
+ if ( at->bam_add_proc == NULL ) {
Debug( LDAP_DEBUG_TRACE,
"backsql_modify_internal(): "
"add procedure is not defined "
"for attribute '%s'\n",
- at->ad->ad_cname.bv_val, 0, 0 );
+ at->bam_ad->ad_cname.bv_val, 0, 0 );
if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
Debug( LDAP_DEBUG_TRACE, "backsql_modify_internal(): "
"adding new values for attribute '%s'\n",
- at->ad->ad_cname.bv_val, 0, 0 );
+ at->bam_ad->ad_cname.bv_val, 0, 0 );
for ( i = 0, at_val = c_mod->sm_bvalues;
at_val->bv_val != NULL;
i++, at_val++ ) {
- if ( BACKSQL_IS_ADD( at->expect_return ) ) {
+ if ( BACKSQL_IS_ADD( at->bam_expect_return ) ) {
pno = 1;
SQLBindParameter( sth, 1,
SQL_PARAM_OUTPUT,
} else {
pno = 0;
}
- po = ( BACKSQL_IS_ADD( at->param_order ) ) > 0;
+ po = ( BACKSQL_IS_ADD( at->bam_param_order ) ) > 0;
SQLBindParameter( sth, pno + 1 + po,
SQL_PARAM_INPUT,
SQL_C_ULONG, SQL_INTEGER,
Debug( LDAP_DEBUG_TRACE,
"backsql_modify_internal(): "
"executing '%s'\n",
- at->add_proc, 0, 0 );
- rc = SQLExecDirect( sth, at->add_proc,
+ at->bam_add_proc, 0, 0 );
+ rc = SQLExecDirect( sth, at->bam_add_proc,
SQL_NTS );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
break;
case LDAP_MOD_DELETE:
- if ( at->delete_proc == NULL ) {
+ if ( at->bam_delete_proc == NULL ) {
Debug( LDAP_DEBUG_TRACE,
"backsql_modify_internal(): "
"delete procedure is not defined "
"for attribute '%s'\n",
- at->ad->ad_cname.bv_val, 0, 0 );
+ at->bam_ad->ad_cname.bv_val, 0, 0 );
if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
"no values given to delete "
"for attribute '%s' "
"-- deleting all values\n",
- at->ad->ad_cname.bv_val, 0, 0 );
+ at->bam_ad->ad_cname.bv_val, 0, 0 );
goto del_all;
}
Debug( LDAP_DEBUG_TRACE, "backsql_modify_internal(): "
"deleting values for attribute '%s'\n",
- at->ad->ad_cname.bv_val, 0, 0 );
+ at->bam_ad->ad_cname.bv_val, 0, 0 );
for ( i = 0, at_val = c_mod->sm_bvalues;
at_val->bv_val != NULL;
i++, at_val++ ) {
- if ( BACKSQL_IS_DEL( at->expect_return ) ) {
+ if ( BACKSQL_IS_DEL( at->bam_expect_return ) ) {
pno = 1;
SQLBindParameter( sth, 1,
SQL_PARAM_OUTPUT,
} else {
pno = 0;
}
- po = ( BACKSQL_IS_DEL( at->param_order ) ) > 0;
+ po = ( BACKSQL_IS_DEL( at->bam_param_order ) ) > 0;
SQLBindParameter( sth, pno + 1 + po,
SQL_PARAM_INPUT,
SQL_C_ULONG, SQL_INTEGER,
Debug( LDAP_DEBUG_TRACE,
"backsql_modify_internal(): "
"executing '%s'\n",
- at->delete_proc, 0, 0 );
- rc = SQLExecDirect( sth, at->delete_proc,
+ at->bam_delete_proc, 0, 0 );
+ rc = SQLExecDirect( sth, at->bam_delete_proc,
SQL_NTS );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
goto modrdn_return;
}
- build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn );
- rs->sr_err = dnNormalize2( NULL, &new_dn, &new_ndn, op->o_tmpmemctx );
+ build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn, NULL );
+ rs->sr_err = dnNormalize( 0, NULL, NULL, &new_dn, &new_ndn,
+ op->o_tmpmemctx );
if ( rs->sr_err != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
"new dn is invalid ('%s') - aborting\n",
return 1;
}
- if ( oc->create_proc == NULL ) {
+ if ( oc->bom_create_proc == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
"create procedure is not defined for this objectclass "
"- aborting\n", 0, 0, 0 );
return 1;
} else if ( BACKSQL_CREATE_NEEDS_SELECT( bi )
- && oc->create_keyval == NULL ) {
+ && oc->bom_create_keyval == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
"create procedure needs select procedure, "
"but none is defined - aborting\n", 0, 0, 0 );
}
rs->sr_err = backsql_get_db_conn( op, &dbh );
- if ( prc != LDAP_SUCCESS ) {
+ if ( rs->sr_err != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
"could not get connection handle - exiting\n",
0, 0, 0 );
return 1;
}
- if ( BACKSQL_IS_ADD( oc->expect_return ) ) {
+ if ( BACKSQL_IS_ADD( oc->bom_expect_return ) ) {
SQLBindParameter( sth, 1, SQL_PARAM_OUTPUT, SQL_C_ULONG,
SQL_INTEGER, 0, 0, &new_keyval, 0, 0 );
}
Debug( LDAP_DEBUG_TRACE, "backsql_add(): executing '%s'\n",
- oc->create_proc, 0, 0 );
- rc = SQLExecDirect( sth, oc->create_proc, SQL_NTS );
+ oc->bom_create_proc, 0, 0 );
+ rc = SQLExecDirect( sth, oc->bom_create_proc, SQL_NTS );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
"create_proc execution failed\n", 0, 0, 0 );
SQLTransact( SQL_NULL_HENV, dbh, SQL_ROLLBACK );
}
- if ( !BACKSQL_IS_ADD( oc->expect_return ) ) {
+ if ( !BACKSQL_IS_ADD( oc->bom_expect_return ) ) {
SWORD ncols;
SQLINTEGER value_len;
}
#endif /* BACKSQL_REALLOC_STMT */
- rc = SQLExecDirect( sth, oc->create_keyval, SQL_NTS );
+ rc = SQLExecDirect( sth, oc->bom_create_keyval, SQL_NTS );
if ( rc != SQL_SUCCESS ) {
rs->sr_err = LDAP_OTHER;
rs->sr_text = "SQL-backend error";
continue;
}
- if ( at_rec->add_proc == NULL ) {
+ if ( at_rec->bam_add_proc == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
"add procedure is not defined "
"for attribute '%s'\n",
}
#ifdef BACKSQL_REALLOC_STMT
- rc = backsql_Prepare( dbh, &sth, at_rec->add_proc, 0 );
+ rc = backsql_Prepare( dbh, &sth, at_rec->bam_add_proc, 0 );
if ( rc != SQL_SUCCESS ) {
if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
}
#endif /* BACKSQL_REALLOC_STMT */
- if ( BACKSQL_IS_ADD( at_rec->expect_return ) ) {
+ if ( BACKSQL_IS_ADD( at_rec->bam_expect_return ) ) {
pno = 1;
SQLBindParameter( sth, 1, SQL_PARAM_OUTPUT,
SQL_C_ULONG, SQL_INTEGER,
pno = 0;
}
- po = ( BACKSQL_IS_ADD( at_rec->param_order ) ) > 0;
+ po = ( BACKSQL_IS_ADD( at_rec->bam_param_order ) ) > 0;
currpos = pno + 1 + po;
SQLBindParameter( sth, currpos,
SQL_PARAM_INPUT, SQL_C_ULONG,
* to build the entry
*/
if ( at->a_desc == slap_schema.si_ad_objectClass ) {
- if ( bvmatch( at_val, &oc->oc->soc_cname ) ) {
+ if ( bvmatch( at_val, &oc->bom_oc->soc_cname ) ) {
continue;
}
}
#ifdef SECURITY_PARANOID
Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
"executing '%s', id=%ld\n",
- at_rec->add_proc, new_keyval, 0 );
+ at_rec->bam_add_proc, new_keyval, 0 );
#else
Debug( LDAP_DEBUG_TRACE, "backsql_add(): "
"executing '%s' with val='%s', id=%ld\n",
- at_rec->add_proc, at_val->bv_val, new_keyval );
+ at_rec->bam_add_proc, at_val->bv_val, new_keyval );
#endif
#ifndef BACKSQL_REALLOC_STMT
- rc = SQLExecDirect( sth, at_rec->add_proc, SQL_NTS );
+ rc = SQLExecDirect( sth, at_rec->bam_add_proc, SQL_NTS );
#else /* BACKSQL_REALLOC_STMT */
rc = SQLExecute( sth );
#endif /* BACKSQL_REALLOC_STMT */
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 );
+ 0, 0, &oc->bom_id, 0, 0 );
SQLBindParameter( sth, 3, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
0, 0, &parent_id.id, 0, 0 );
SQLBindParameter( sth, 4, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
Debug( LDAP_DEBUG_TRACE, "backsql_add(): executing '%s' for dn '%s'\n",
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 );
+ "keyval=%ld\n", oc->bom_id, parent_id.id, new_keyval );
#ifndef BACKSQL_REALLOC_STMT
rc = SQLExecDirect( sth, bi->insentry_query, SQL_NTS );
#else /* BACKSQL_REALLOC_STMT */
return 1;
}
- if ( oc->delete_proc == NULL ) {
+ if ( oc->bom_delete_proc == NULL ) {
Debug( LDAP_DEBUG_TRACE, "backsql_delete(): "
"delete procedure is not defined "
"for this objectclass - aborting\n", 0, 0, 0 );
}
SQLAllocStmt( dbh, &sth );
- if ( BACKSQL_IS_DEL( oc->expect_return ) ) {
+ if ( BACKSQL_IS_DEL( oc->bom_expect_return ) ) {
pno = 1;
SQLBindParameter( sth, 1, SQL_PARAM_OUTPUT, SQL_C_ULONG,
SQL_INTEGER, 0, 0, &rc, 0, 0 );
SQL_C_ULONG, SQL_INTEGER, 0, 0, &e_id.keyval, 0, 0 );
Debug( LDAP_DEBUG_TRACE, "backsql_delete(): executing '%s'\n",
- oc->delete_proc, 0, 0 );
- rc = SQLExecDirect( sth, oc->delete_proc, SQL_NTS );
+ oc->bom_delete_proc, 0, 0 );
+ rc = SQLExecDirect( sth, oc->bom_delete_proc, SQL_NTS );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "backsql_delete(): "
"delete_proc execution failed\n", 0, 0, 0 );
SQLTransact( SQL_NULL_HENV, dbh,
op->o_noop ? SQL_ROLLBACK : SQL_COMMIT );
+ rs->sr_err = LDAP_SUCCESS;
send_ldap_result( op, rs );
Debug( LDAP_DEBUG_TRACE, "<==backsql_delete()\n", 0, 0, 0 );
+
return op->o_noop;
}