2 * Copyright 1999, Dmitry Kovalev <mit@openldap.org>, All rights reserved.
4 * Redistribution and use in source and binary forms are permitted only
5 * as authorized by the OpenLDAP Public License. A copy of this
6 * license is available at http://www.OpenLDAP.org/license.html or
7 * in file LICENSE in the top-level directory of the distribution.
15 #include <sys/types.h>
20 #include "schema-map.h"
24 int backsql_modify(BackendDB *be,Connection *conn,Operation *op,
25 const char *dn,const char *ndn,Modifications *modlist)
27 backsql_info *bi=(backsql_info*)be->be_private;
31 backsql_oc_map_rec *oc=NULL;
32 backsql_entryID e_id,*res;
35 backsql_at_map_rec *at=NULL;
36 struct berval *at_val;
38 int pno,po;/*first parameter no, parameter order*/
39 int prc; /*procedure return code*/
41 Debug(LDAP_DEBUG_TRACE,"==>backsql_modify(): changing entry '%s'\n",ndn,0,0);
42 dbh=backsql_get_db_conn(be,conn);
45 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): could not get connection handle - exiting\n",0,0,0);
46 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
49 res=backsql_dn2id(bi,&e_id,dbh,(char*)ndn);
52 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): could not lookup entry id\n",0,0,0);
53 send_ldap_result(conn,op,LDAP_NO_SUCH_OBJECT,"",NULL,NULL,NULL);
57 oc=backsql_oc_with_id(bi,e_id.oc_id);
60 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): cannot determine objectclass of entry -- aborting\n",0,0,0);
61 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
65 SQLAllocStmt(dbh, &sth);
67 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): traversing modifications list\n",0,0,0);
68 for(ml=modlist;ml!=NULL;ml=ml->sml_next)
71 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): attribute '%s'\n",c_mod->sm_desc->ad_cname.bv_val,0,0);
72 at=backsql_at_with_name(oc,c_mod->sm_desc->ad_cname.bv_val);
75 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): attribute provided is not registered in this objectclass ('%s')\n",c_mod->sm_desc->ad_cname.bv_val,0,0);
81 case LDAP_MOD_REPLACE:
86 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): replacing values for attribute '%s'\n",at->name,0,0);
87 if (at->add_proc==NULL)
89 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): add procedure is not defined for this attribute ('%s') - unable to perform replacements\n",at->name,0,0);
94 if ((rc=backsql_Prepare(dbh,&asth,at->query,0)) != SQL_SUCCESS)
96 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): error preparing query\n",0,0,0);
97 backsql_PrintErrors(bi->db_env,dbh,asth,rc);
101 if (backsql_BindParamID(asth,1,&e_id.keyval) != SQL_SUCCESS)
103 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): error binding key value parameter\n",0,0,0);
104 backsql_PrintErrors(bi->db_env,dbh,asth,rc);
105 SQLFreeStmt(asth,SQL_DROP);
109 if ((rc=SQLExecute(asth)) != SQL_SUCCESS && rc!= SQL_SUCCESS_WITH_INFO)
111 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): error executing attribute query\n",0,0,0);
112 backsql_PrintErrors(bi->db_env,dbh,asth,rc);
113 SQLFreeStmt(asth,SQL_DROP);
117 backsql_BindRowAsStrings(asth,&row);
118 while ((rc=SQLFetch(asth)) == SQL_SUCCESS || rc==SQL_SUCCESS_WITH_INFO)
120 for (i=0;i<row.ncols;i++)
122 if (at->expect_return & BACKSQL_DEL)
125 SQLBindParameter(sth,1,SQL_PARAM_OUTPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&prc,0,0);
129 po=(at->param_order & BACKSQL_DEL)>0;
130 SQLBindParameter(sth,(SQLUSMALLINT)(pno+1+po),SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&e_id.keyval,0,0);
131 /*check for syntax needed here - maybe need binary bind?*/
132 SQLBindParameter(sth,(SQLUSMALLINT)(pno+2-po),SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,0,0,row.cols[i],strlen(row.cols[i]),0);
134 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): executing '%s'\n",at->delete_proc,0,0);
135 rc=SQLExecDirect(sth,at->delete_proc,SQL_NTS);
138 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): delete_proc execution failed\n",0,0,0);
139 backsql_PrintErrors(bi->db_env,dbh,sth,rc);
143 backsql_FreeRow(&row);
144 SQLFreeStmt(asth,SQL_DROP);
146 /*PASSTHROUGH - to add new attributes -- do NOT add break*/
148 if (at->add_proc==NULL)
150 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): add procedure is not defined for this attribute ('%s')\n",at->name,0,0);
153 if (c_mod->sm_bvalues==NULL)
155 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): no values given to add for attribute '%s'\n",at->name,0,0);
158 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): adding new values for attribute '%s'\n",at->name,0,0);
159 for(i=0,at_val=c_mod->sm_bvalues[0];at_val!=NULL;i++,at_val=c_mod->sm_bvalues[i])
161 if (at->expect_return & BACKSQL_ADD)
164 SQLBindParameter(sth,1,SQL_PARAM_OUTPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&prc,0,0);
168 po=(at->param_order & BACKSQL_ADD)>0;
169 SQLBindParameter(sth,(SQLUSMALLINT)(pno+1+po),SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&e_id.keyval,0,0);
170 /*check for syntax needed here - maybe need binary bind?*/
171 SQLBindParameter(sth,(SQLUSMALLINT)(pno+2-po),SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,0,0,at_val->bv_val,at_val->bv_len,0);
173 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): executing '%s'\n",at->add_proc,0,0);
174 rc=SQLExecDirect(sth,at->add_proc,SQL_NTS);
177 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): add_proc execution failed\n",0,0,0);
178 backsql_PrintErrors(bi->db_env,dbh,sth,rc);
182 case LDAP_MOD_DELETE:
183 if (at->delete_proc==NULL)
185 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): delete procedure is not defined for this attribute ('%s')\n",at->name,0,0);
188 if (c_mod->sm_bvalues==NULL)
190 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): no values given to delete for attribute '%s' -- deleting all values\n",at->name,0,0);
193 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): deleting values for attribute '%s'\n",at->name,0,0);
194 for(i=0,at_val=c_mod->sm_bvalues[0];at_val!=NULL;i++,at_val=c_mod->sm_bvalues[i])
196 if (at->expect_return & BACKSQL_DEL)
199 SQLBindParameter(sth,1,SQL_PARAM_OUTPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&prc,0,0);
203 po=(at->param_order & BACKSQL_DEL)>0;
204 SQLBindParameter(sth,(SQLUSMALLINT)(pno+1+po),SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&e_id.keyval,0,0);
205 /*check for syntax needed here - maybe need binary bind?*/
206 SQLBindParameter(sth,(SQLUSMALLINT)(pno+2-po),SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,0,0,at_val->bv_val,at_val->bv_len,0);
208 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): executing '%s'\n",at->delete_proc,0,0);
209 rc=SQLExecDirect(sth,at->delete_proc,SQL_NTS);
212 Debug(LDAP_DEBUG_TRACE,"backsql_modify(): delete_proc execution failed\n",0,0,0);
213 backsql_PrintErrors(bi->db_env,dbh,sth,rc);
218 SQLFreeStmt(sth,SQL_RESET_PARAMS);
221 SQLFreeStmt(sth,SQL_DROP);
222 send_ldap_result(conn,op,LDAP_SUCCESS,"",NULL,NULL,NULL);
223 Debug(LDAP_DEBUG_TRACE,"<==backsql_modify()\n",0,0,0);
227 int backsql_modrdn(BackendDB *be,Connection *conn,Operation *op,
228 const char *dn,const char *ndn,const char *newrdn,int deleteoldrdn,const char *newSuperior)
230 backsql_info *bi=(backsql_info*)be->be_private;
234 backsql_oc_map_rec *oc=NULL;
235 backsql_entryID e_id,pe_id,new_pid,*res;
236 backsql_at_map_rec *at=NULL;
237 char *p_dn=NULL,*new_pdn=NULL, *new_dn;
240 Debug(LDAP_DEBUG_TRACE,"==>backsql_modrdn() renaming entry '%s', newrdn='%s', newSuperior='%s'\n",dn,newrdn,newSuperior);
241 dbh=backsql_get_db_conn(be,conn);
244 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): could not get connection handle - exiting\n",0,0,0);
245 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
248 res=backsql_dn2id(bi,&e_id,dbh,(char*)ndn);
251 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): could not lookup entry id\n",0,0,0);
252 send_ldap_result(conn,op,LDAP_NO_SUCH_OBJECT,"",NULL,NULL,NULL);
255 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): entry id is %d\n",e_id.id,0,0);
257 p_dn=dn_parent(be,ndn);
260 new_pdn=dn_validate(ch_strdup(newSuperior));
264 SQLAllocStmt(dbh, &sth);
266 if (newSuperior && !strcasecmp(p_dn,new_pdn))
268 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): newSuperior is equal to old parent - aborting\n",0,0,0);
269 send_ldap_result(conn,op,LDAP_OTHER,"",NULL,NULL,NULL);
273 if (newSuperior && !strcasecmp(ndn,new_pdn))
275 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): newSuperior is equal to entry being moved - aborting\n",0,0,0);
276 send_ldap_result(conn,op,LDAP_OTHER,"",NULL,NULL,NULL);
280 build_new_dn( &new_dn, dn, new_pdn, newrdn );
281 if (!dn_validate(new_dn))
283 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): new dn is invalid ('%s') - aborting\n",new_dn,0,0);
284 send_ldap_result(conn,op,LDAP_OTHER,"",NULL,NULL,NULL);
287 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): new entry dn is '%s'\n",new_dn,0,0);
289 res=backsql_dn2id(bi,&pe_id,dbh,(char*)p_dn);
292 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): could not lookup old parent entry id\n",0,0,0);
293 send_ldap_result(conn,op,LDAP_NO_SUCH_OBJECT,"",NULL,NULL,NULL);
296 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): old parent entry id is %d\n",pe_id.id,0,0);
298 res=backsql_dn2id(bi,&new_pid,dbh,(char*)new_pdn);
301 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): could not lookup new parent entry id\n",0,0,0);
302 send_ldap_result(conn,op,LDAP_NO_SUCH_OBJECT,"",NULL,NULL,NULL);
305 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): new parent entry id is %d\n",new_pid.id,0,0);
307 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): executing delentry_query\n",0,0,0);
308 SQLBindParameter(sth,1,SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&e_id.id,0,0);
309 rc=SQLExecDirect(sth,bi->delentry_query,SQL_NTS);
310 if (rc != SQL_SUCCESS)
312 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): failed to delete record from ldap_entries\n",0,0,0);
313 backsql_PrintErrors(bi->db_env,dbh,sth,rc);
314 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
318 SQLFreeStmt(sth,SQL_RESET_PARAMS);
320 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): executing insentry_query\n",0,0,0);
321 backsql_BindParamStr(sth,1,new_dn,BACKSQL_MAX_DN_LEN);
322 SQLBindParameter(sth,2,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,0,0,&e_id.oc_id,0,0);
323 SQLBindParameter(sth,3,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,0,0,&new_pid.id,0,0);
324 SQLBindParameter(sth,4,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,0,0,&e_id.keyval,0,0);
325 rc=SQLExecDirect(sth,bi->insentry_query,SQL_NTS);
326 if (rc != SQL_SUCCESS)
328 Debug(LDAP_DEBUG_TRACE,"backsql_modrdn(): could not insert ldap_entries record\n",0,0,0);
329 backsql_PrintErrors(bi->db_env,dbh,sth,rc);
330 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
334 /*should process deleteoldrdn here...*/
336 send_ldap_result(conn,op,LDAP_SUCCESS,"",NULL,NULL,NULL);
338 SQLFreeStmt(sth,SQL_DROP);
339 if (newSuperior && new_pdn)
343 Debug(LDAP_DEBUG_TRACE,"<==backsql_modrdn()\n",0,0,0);
347 int backsql_add(BackendDB *be,Connection *conn,Operation *op,Entry *e)
349 backsql_info *bi=(backsql_info*)be->be_private;
352 unsigned long new_keyval;
355 backsql_oc_map_rec *oc=NULL;
356 backsql_at_map_rec *at_rec=NULL;
357 backsql_entryID parent_id,*res;
359 struct berval *at_val;
361 int pno,po;/*first parameter no, parameter order*/
362 int prc; /*procedure return code*/
364 Debug(LDAP_DEBUG_TRACE,"==>backsql_add(): adding entry '%s'\n",e->e_dn,0,0);
365 if (dn_validate(e->e_dn)==NULL)
367 Debug(LDAP_DEBUG_TRACE,"==>backsql_add(): invalid dn '%s' -- aborting\n",e->e_dn,0,0);
369 for(at=e->e_attrs;at!=NULL;at=at->a_next)
371 /*Debug(LDAP_DEBUG_TRACE,"backsql_add(): scanning entry -- %s\n",at->a_type,0,0);*/
372 if (!strcasecmp(at->a_desc->ad_cname.bv_val,"objectclass"))
374 oc=backsql_oc_with_name(bi,at->a_vals[0]->bv_val);
381 Debug(LDAP_DEBUG_TRACE,"backsql_add(): cannot determine objectclass of entry -- aborting\n",0,0,0);
382 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
385 if (oc->create_proc == NULL)
387 Debug(LDAP_DEBUG_TRACE,"backsql_add(): create procedure is not defined for this objectclass - aborting\n",0,0,0);
388 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
392 dbh=backsql_get_db_conn(be,conn);
395 Debug(LDAP_DEBUG_TRACE,"backsql_add(): could not get connection handle - exiting\n",0,0,0);
396 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
400 SQLAllocStmt(dbh, &sth);
401 SQLBindParameter(sth,1,SQL_PARAM_OUTPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&new_keyval,0,0);
403 Debug(LDAP_DEBUG_TRACE,"backsql_add(): executing '%s'\n",oc->create_proc,0,0);
404 rc=SQLExecDirect(sth,oc->create_proc,SQL_NTS);
405 if (rc != SQL_SUCCESS)
407 Debug(LDAP_DEBUG_TRACE,"backsql_add(): create_proc execution failed\n",0,0,0);
408 backsql_PrintErrors(bi->db_env,dbh,sth,rc);
409 SQLFreeStmt(sth,SQL_DROP);
410 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
413 SQLFreeStmt(sth,SQL_RESET_PARAMS);
414 Debug(LDAP_DEBUG_TRACE,"backsql_add(): create_proc returned keyval=%d\n",new_keyval,0,0);
416 for(at=e->e_attrs;at!=NULL;at=at->a_next)
418 at_rec=backsql_at_with_name(oc,at->a_desc->ad_cname.bv_val);
422 Debug(LDAP_DEBUG_TRACE,"backsql_add(): attribute provided is not registered in this objectclass ('%s')\n",at->a_desc->ad_cname.bv_val,0,0);
425 if (at_rec->add_proc==NULL)
427 Debug(LDAP_DEBUG_TRACE,"backsql_add(): add procedure is not defined for this attribute ('%s')\n",at->a_desc->ad_cname.bv_val,0,0);
431 for(i=0,at_val=at->a_vals[0];at_val!=NULL;i++,at_val=at->a_vals[i])
433 if (at_rec->expect_return & BACKSQL_ADD)
436 SQLBindParameter(sth,1,SQL_PARAM_OUTPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&prc,0,0);
440 po=(at_rec->param_order & BACKSQL_ADD)>0;
441 SQLBindParameter(sth,(SQLUSMALLINT)(pno+1+po),SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&new_keyval,0,0);
442 /*check for syntax needed here - maybe need binary bind?*/
443 SQLBindParameter(sth,(SQLUSMALLINT)(pno+2-po),SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,0,0,at_val->bv_val,at_val->bv_len,0);
444 Debug(LDAP_DEBUG_TRACE,"backsql_add(): executing '%s'\n",at_rec->add_proc,0,0);
445 rc=SQLExecDirect(sth,at_rec->add_proc,SQL_NTS);
448 Debug(LDAP_DEBUG_TRACE,"backsql_add(): add_proc execution failed\n",0,0,0);
449 backsql_PrintErrors(bi->db_env,dbh,sth,rc);
453 SQLFreeStmt(sth,SQL_RESET_PARAMS);
454 pdn=dn_parent(be,e->e_dn);
455 res=backsql_dn2id(bi,&parent_id,dbh,pdn);
458 Debug(LDAP_DEBUG_TRACE,"backsql_add(): could not lookup parent entry for new record ('%s')\n",
460 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
463 backsql_BindParamStr(sth,1,e->e_dn,BACKSQL_MAX_DN_LEN);
464 SQLBindParameter(sth,2,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,0,0,&oc->id,0,0);
465 SQLBindParameter(sth,3,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,0,0,&parent_id.id,0,0);
466 SQLBindParameter(sth,4,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,0,0,&new_keyval,0,0);
467 rc=SQLExecDirect(sth,bi->insentry_query,SQL_NTS);
468 if (rc != SQL_SUCCESS)
470 Debug(LDAP_DEBUG_TRACE,"backsql_add(): could not insert ldap_entries record\n",0,0,0);
471 backsql_PrintErrors(bi->db_env,dbh,sth,rc);
472 /*execute delete_proc to delete data added !!!*/
473 SQLFreeStmt(sth,SQL_DROP);
474 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
477 SQLFreeStmt(sth,SQL_DROP);
478 send_ldap_result(conn,op,LDAP_SUCCESS,"",NULL,NULL,NULL);
482 int backsql_delete(BackendDB *be,Connection *conn,Operation *op,
483 const char *dn,const char *ndn)
485 backsql_info *bi=(backsql_info*)be->be_private;
489 backsql_oc_map_rec *oc=NULL;
490 backsql_entryID e_id,*res;
491 int pno;/*first parameter no, parameter order*/
493 Debug(LDAP_DEBUG_TRACE,"==>backsql_delete(): deleting entry '%s'\n",ndn,0,0);
494 dbh=backsql_get_db_conn(be,conn);
497 Debug(LDAP_DEBUG_TRACE,"backsql_delete(): could not get connection handle - exiting\n",0,0,0);
498 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
501 res=backsql_dn2id(bi,&e_id,dbh,(char*)ndn);
504 Debug(LDAP_DEBUG_TRACE,"backsql_delete(): could not lookup entry id\n",0,0,0);
505 send_ldap_result(conn,op,LDAP_NO_SUCH_OBJECT,"",NULL,NULL,NULL);
509 oc=backsql_oc_with_id(bi,e_id.oc_id);
512 Debug(LDAP_DEBUG_TRACE,"backsql_delete(): cannot determine objectclass of entry -- aborting\n",0,0,0);
513 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
516 if (oc->delete_proc == NULL)
518 Debug(LDAP_DEBUG_TRACE,"backsql_delete(): delete procedure is not defined for this objectclass - aborting\n",0,0,0);
519 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
523 SQLAllocStmt(dbh, &sth);
524 if (oc->expect_return)
527 SQLBindParameter(sth,1,SQL_PARAM_OUTPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&rc,0,0);
531 SQLBindParameter(sth,(SQLUSMALLINT)(pno+1),SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&e_id.keyval,0,0);
532 /*SQLBindParameter(sth,2,SQL_PARAM_OUTPUT,SQL_C_SLONG,SQL_INTEGER,0,0,&retcode,0,0);*/
534 Debug(LDAP_DEBUG_TRACE,"backsql_delete(): executing '%s'\n",oc->delete_proc,0,0);
535 rc=SQLExecDirect(sth,oc->delete_proc,SQL_NTS);
536 if (rc != SQL_SUCCESS)
538 Debug(LDAP_DEBUG_TRACE,"backsql_delete(): delete_proc execution failed\n",0,0,0);
539 backsql_PrintErrors(bi->db_env,dbh,sth,rc);
540 SQLFreeStmt(sth,SQL_DROP);
541 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
544 SQLFreeStmt(sth,SQL_RESET_PARAMS);
546 SQLBindParameter(sth,1,SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&e_id.id,0,0);
547 rc=SQLExecDirect(sth,bi->delentry_query,SQL_NTS);
548 if (rc != SQL_SUCCESS)
550 Debug(LDAP_DEBUG_TRACE,"backsql_delete(): failed to delete record from ldap_entries\n",0,0,0);
551 backsql_PrintErrors(bi->db_env,dbh,sth,rc);
552 SQLFreeStmt(sth,SQL_DROP);
553 send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
556 SQLFreeStmt(sth,SQL_DROP);
558 send_ldap_result(conn,op,LDAP_SUCCESS,"",NULL,NULL,NULL);
559 Debug(LDAP_DEBUG_TRACE,"<==backsql_delete()\n",0,0,0);
563 #endif /* SLAPD_SQL */