From 6bf69cbf3952c191c0b5cbca0ec065afcbf9866a Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Fri, 7 Sep 2001 13:04:11 +0000 Subject: [PATCH] some cosmetics and minor problems fixed, pointed out by Mei-Hui Su (c++-style comments, newlines etc.) --- servers/slapd/back-sql/back-sql.h | 7 ++-- servers/slapd/back-sql/entry-id.c | 6 +-- servers/slapd/back-sql/entry-id.h | 5 ++- servers/slapd/back-sql/init.c | 3 +- servers/slapd/back-sql/modify.c | 28 +++++++------- servers/slapd/back-sql/schema-map.c | 7 ++-- servers/slapd/back-sql/schema-map.h | 25 +++++++------ servers/slapd/back-sql/search.c | 25 +++++++------ servers/slapd/back-sql/sql-types.h | 3 +- servers/slapd/back-sql/sql-wrap.c | 57 ++++++++++++++++------------- servers/slapd/back-sql/sql-wrap.h | 3 +- servers/slapd/back-sql/util.c | 32 ++++++++-------- servers/slapd/back-sql/util.h | 1 + 13 files changed, 106 insertions(+), 96 deletions(-) diff --git a/servers/slapd/back-sql/back-sql.h b/servers/slapd/back-sql/back-sql.h index 8038494ada..d38b9d0120 100644 --- a/servers/slapd/back-sql/back-sql.h +++ b/servers/slapd/back-sql/back-sql.h @@ -22,8 +22,8 @@ typedef struct char *dbuser; char *dbpasswd; char *dbname; - //SQL condition for subtree searches differs in syntax: - //"LIKE CONCAT('%',?)" or "LIKE '%'+?" or smth else + /*SQL condition for subtree searches differs in syntax: + *"LIKE CONCAT('%',?)" or "LIKE '%'+?" or smth else */ char *subtree_cond; char *oc_query,*at_query; char *insentry_query,*delentry_query; @@ -36,8 +36,9 @@ typedef struct ldap_pvt_thread_mutex_t dbconn_mutex; ldap_pvt_thread_mutex_t schema_mutex; SQLHENV db_env; - int isTimesTen; // TimesTen + int isTimesTen; /* TimesTen */ int has_ldapinfo_dn_ru; /* Does ldapinfo.dn_ru exist in schema? */ }backsql_info; #endif + diff --git a/servers/slapd/back-sql/entry-id.c b/servers/slapd/back-sql/entry-id.c index b1b2eaafad..07f718020e 100644 --- a/servers/slapd/back-sql/entry-id.c +++ b/servers/slapd/back-sql/entry-id.c @@ -34,16 +34,16 @@ backsql_entryID* backsql_dn2id(backsql_info *bi,backsql_entryID *id,SQLHDBC dbh, { SQLHSTMT sth; BACKSQL_ROW_NTS row; - //SQLINTEGER nrows=0; + /*SQLINTEGER nrows=0;*/ RETCODE rc; - // TimesTen + /* TimesTen */ char upperdn[BACKSQL_MAX_DN_LEN+1]; char* toBind; int i, j, k; Debug(LDAP_DEBUG_TRACE,"==>backsql_dn2id(): dn='%s'\n",dn,0,0); - // begin TimesTen + /* begin TimesTen */ Debug(LDAP_DEBUG_TRACE, "id_query '%s'\n", bi->id_query, 0, 0); rc = backsql_Prepare(dbh,&sth,bi->id_query,0); if (rc != SQL_SUCCESS) { diff --git a/servers/slapd/back-sql/entry-id.h b/servers/slapd/back-sql/entry-id.h index 6ade0e071d..5792d85eea 100644 --- a/servers/slapd/back-sql/entry-id.h +++ b/servers/slapd/back-sql/entry-id.h @@ -21,6 +21,7 @@ typedef struct __backsql_entryID }backsql_entryID; backsql_entryID* backsql_dn2id(backsql_info *bi,backsql_entryID* id,SQLHDBC dbh,char *dn); -backsql_entryID* backsql_free_entryID(backsql_entryID* id);//returns next +backsql_entryID* backsql_free_entryID(backsql_entryID* id);/*returns next*/ + +#endif -#endif \ No newline at end of file diff --git a/servers/slapd/back-sql/init.c b/servers/slapd/back-sql/init.c index ec21f5bb86..92f7b5b90b 100644 --- a/servers/slapd/back-sql/init.c +++ b/servers/slapd/back-sql/init.c @@ -196,8 +196,7 @@ int backsql_db_open (BackendDB *bd) else { if (si->has_ldapinfo_dn_ru) { - si->id_query=backsql_strcat(si->id_query,&idq_len,backsql_id_query,"dn_ru= -?",NULL); + si->id_query=backsql_strcat(si->id_query,&idq_len,backsql_id_query,"dn_ru=?",NULL); } else { if (si->isTimesTen) { diff --git a/servers/slapd/back-sql/modify.c b/servers/slapd/back-sql/modify.c index ebaa7834a0..fa5bc70b6e 100644 --- a/servers/slapd/back-sql/modify.c +++ b/servers/slapd/back-sql/modify.c @@ -35,8 +35,8 @@ int backsql_modify(BackendDB *be,Connection *conn,Operation *op, backsql_at_map_rec *at=NULL; struct berval *at_val; int i; - int pno,po;//first parameter no, parameter order - int prc; //procedure return code + int pno,po;/*first parameter no, parameter order*/ + int prc; /*procedure return code*/ Debug(LDAP_DEBUG_TRACE,"==>backsql_modify(): changing entry '%s'\n",ndn,0,0); dbh=backsql_get_db_conn(be,conn); @@ -128,7 +128,7 @@ del_all: pno=0; po=(at->param_order & BACKSQL_DEL)>0; SQLBindParameter(sth,(SQLUSMALLINT)(pno+1+po),SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&e_id.keyval,0,0); - //check for syntax needed here - maybe need binary bind? + /*check for syntax needed here - maybe need binary bind?*/ SQLBindParameter(sth,(SQLUSMALLINT)(pno+2-po),SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,0,0,row.cols[i],strlen(row.cols[i]),0); Debug(LDAP_DEBUG_TRACE,"backsql_modify(): executing '%s'\n",at->delete_proc,0,0); @@ -143,7 +143,7 @@ del_all: backsql_FreeRow(&row); SQLFreeStmt(asth,SQL_DROP); } - //PASSTHROUGH - to add new attributes -- do NOT add break + /*PASSTHROUGH - to add new attributes -- do NOT add break*/ case LDAP_MOD_ADD: if (at->add_proc==NULL) { @@ -167,7 +167,7 @@ del_all: pno=0; po=(at->param_order & BACKSQL_ADD)>0; SQLBindParameter(sth,(SQLUSMALLINT)(pno+1+po),SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&e_id.keyval,0,0); - //check for syntax needed here - maybe need binary bind? + /*check for syntax needed here - maybe need binary bind?*/ 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); Debug(LDAP_DEBUG_TRACE,"backsql_modify(): executing '%s'\n",at->add_proc,0,0); @@ -202,7 +202,7 @@ del_all: pno=0; po=(at->param_order & BACKSQL_DEL)>0; SQLBindParameter(sth,(SQLUSMALLINT)(pno+1+po),SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&e_id.keyval,0,0); - //check for syntax needed here - maybe need binary bind? + /*check for syntax needed here - maybe need binary bind?*/ 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); Debug(LDAP_DEBUG_TRACE,"backsql_modify(): executing '%s'\n",at->delete_proc,0,0); @@ -331,7 +331,7 @@ int backsql_modrdn(BackendDB *be,Connection *conn,Operation *op, goto modrdn_return; } - //should process deleteoldrdn here... + /*should process deleteoldrdn here...*/ send_ldap_result(conn,op,LDAP_SUCCESS,"",NULL,NULL,NULL); modrdn_return: @@ -360,8 +360,8 @@ int backsql_add(BackendDB *be,Connection *conn,Operation *op,Entry *e) Attribute *at; struct berval *at_val; char *pdn; - int pno,po;//first parameter no, parameter order - int prc; //procedure return code + int pno,po;/*first parameter no, parameter order*/ + int prc; /*procedure return code*/ Debug(LDAP_DEBUG_TRACE,"==>backsql_add(): adding entry '%s'\n",e->e_dn,0,0); if (dn_validate(e->e_dn)==NULL) @@ -370,7 +370,7 @@ int backsql_add(BackendDB *be,Connection *conn,Operation *op,Entry *e) } for(at=e->e_attrs;at!=NULL;at=at->a_next) { - //Debug(LDAP_DEBUG_TRACE,"backsql_add(): scanning entry -- %s\n",at->a_type,0,0); + /*Debug(LDAP_DEBUG_TRACE,"backsql_add(): scanning entry -- %s\n",at->a_type,0,0);*/ if (!strcasecmp(at->a_desc->ad_cname->bv_val,"objectclass")) { oc=backsql_oc_with_name(bi,at->a_vals[0]->bv_val); @@ -441,7 +441,7 @@ int backsql_add(BackendDB *be,Connection *conn,Operation *op,Entry *e) pno=0; po=(at_rec->param_order & BACKSQL_ADD)>0; SQLBindParameter(sth,(SQLUSMALLINT)(pno+1+po),SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&new_keyval,0,0); - //check for syntax needed here - maybe need binary bind? + /*check for syntax needed here - maybe need binary bind?*/ 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); Debug(LDAP_DEBUG_TRACE,"backsql_add(): executing '%s'\n",at_rec->add_proc,0,0); rc=SQLExecDirect(sth,at_rec->add_proc,SQL_NTS); @@ -472,7 +472,7 @@ int backsql_add(BackendDB *be,Connection *conn,Operation *op,Entry *e) { Debug(LDAP_DEBUG_TRACE,"backsql_add(): could not insert ldap_entries record\n",0,0,0); backsql_PrintErrors(bi->db_env,dbh,sth,rc); - //execute delete_proc to delete data added !!! + /*execute delete_proc to delete data added !!!*/ SQLFreeStmt(sth,SQL_DROP); send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL); return 1; @@ -491,7 +491,7 @@ int backsql_delete(BackendDB *be,Connection *conn,Operation *op, RETCODE rc; backsql_oc_map_rec *oc=NULL; backsql_entryID e_id,*res; - int pno;//first parameter no, parameter order + int pno;/*first parameter no, parameter order*/ Debug(LDAP_DEBUG_TRACE,"==>backsql_delete(): deleting entry '%s'\n",ndn,0,0); dbh=backsql_get_db_conn(be,conn); @@ -532,7 +532,7 @@ int backsql_delete(BackendDB *be,Connection *conn,Operation *op, else pno=0; SQLBindParameter(sth,(SQLUSMALLINT)(pno+1),SQL_PARAM_INPUT,SQL_C_ULONG,SQL_INTEGER,0,0,&e_id.keyval,0,0); - //SQLBindParameter(sth,2,SQL_PARAM_OUTPUT,SQL_C_SLONG,SQL_INTEGER,0,0,&retcode,0,0); + /*SQLBindParameter(sth,2,SQL_PARAM_OUTPUT,SQL_C_SLONG,SQL_INTEGER,0,0,&retcode,0,0);*/ Debug(LDAP_DEBUG_TRACE,"backsql_delete(): executing '%s'\n",oc->delete_proc,0,0); rc=SQLExecDirect(sth,oc->delete_proc,SQL_NTS); diff --git a/servers/slapd/back-sql/schema-map.c b/servers/slapd/back-sql/schema-map.c index 2055b8f322..879dc9bca7 100644 --- a/servers/slapd/back-sql/schema-map.c +++ b/servers/slapd/back-sql/schema-map.c @@ -119,12 +119,11 @@ int backsql_load_schema_map(backsql_info *si,SQLHDBC dbh) rc = backsql_Prepare(dbh, &oc_sth, backsql_check_dn_ru_query, 0); if (rc == SQL_SUCCESS) { - si->has_ldapinfo_dn_ru = 1; // Yes, the field exists - Debug(LDAP_DEBUG_TRACE, "ldapinfo.dn_ru field exists in the schema\n", 0, 0, -0); + si->has_ldapinfo_dn_ru = 1; /* Yes, the field exists */ + Debug(LDAP_DEBUG_TRACE, "ldapinfo.dn_ru field exists in the schema\n", 0, 0,0); } else { - si->has_ldapinfo_dn_ru = 0; // No such field exists + si->has_ldapinfo_dn_ru = 0; /* No such field exists */ } SQLFreeStmt(oc_sth, SQL_DROP); diff --git a/servers/slapd/back-sql/schema-map.h b/servers/slapd/back-sql/schema-map.h index 3db6331dde..f2fc02bbfa 100644 --- a/servers/slapd/back-sql/schema-map.h +++ b/servers/slapd/back-sql/schema-map.h @@ -16,29 +16,29 @@ typedef struct char *name; char *keytbl; char *keycol; - char *create_proc;//expected to return keyval of newly created entry - char *delete_proc;//supposed to expect keyval as parameter and delete all the attributes as well - int expect_return; //flags whether delete_proc is a function (whether back-sql should bind first parameter as output for return code) + char *create_proc; /*expected to return keyval of newly created entry*/ + char *delete_proc;/*supposed to expect keyval as parameter and delete all the attributes as well*/ + int expect_return; /*flags whether delete_proc is a function (whether back-sql should bind first parameter as output for return code)*/ unsigned long id; Avlnode *attrs; }backsql_oc_map_rec; typedef struct { - char *name;//literal name of corresponding LDAP attribute type + char *name;/*literal name of corresponding LDAP attribute type*/ char *from_tbls; char *join_where; char *sel_expr; - char *add_proc; //supposed to expect 2 binded values: entry keyval and attr. value to add, like "add_name(?,?,?)" - char *delete_proc; //supposed to expect 2 binded values: entry keyval and attr. value to delete - char *query; //for optimization purposes attribute load query is preconstructed from parts on schemamap load time - //following flags are bitmasks (first bit used for add_proc, second - for modify, third - for delete_proc) - int param_order; //order of parameters for procedures above; 1 means "data then keyval", 0 means "keyval then data" - int expect_return; //flags whether one or more of procedures is a function (whether back-sql should bind first parameter as output for return code) - char *sel_expr_u; // TimesTen + char *add_proc; /*supposed to expect 2 binded values: entry keyval and attr. value to add, like "add_name(?,?,?)"*/ + char *delete_proc; /*supposed to expect 2 binded values: entry keyval and attr. value to delete*/ + char *query; /*for optimization purposes attribute load query is preconstructed from parts on schemamap load time*/ + /*following flags are bitmasks (first bit used for add_proc, second - for modify, third - for delete_proc)*/ + int param_order; /*order of parameters for procedures above; 1 means "data then keyval", 0 means "keyval then data"*/ + int expect_return; /*flags whether one or more of procedures is a function (whether back-sql should bind first parameter as output for return code)*/ + char *sel_expr_u; /* TimesTen */ }backsql_at_map_rec; -//defines to support bitmasks above +/*defines to support bitmasks above*/ #define BACKSQL_ADD 1 #define BACKSQL_DEL 2 @@ -49,3 +49,4 @@ backsql_at_map_rec* backsql_at_with_name(backsql_oc_map_rec* objclass,char* attr int backsql_destroy_schema_map(backsql_info *si); #endif + diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index 5104e2c480..e6f60ab57e 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -119,7 +119,7 @@ int backsql_process_sub_filter(backsql_srch_info *bsi,Filter *f) return 0; bsi->flt_where=backsql_strcat(bsi->flt_where,&bsi->fwhere_len,"(",NULL); - // TimesTen + /* TimesTen*/ Debug(LDAP_DEBUG_TRACE,"expr: '%s' '%s'\n",at->sel_expr, at->sel_expr_u?at->sel_expr_u:"",0); if (bsi->bi->upper_func) @@ -155,7 +155,7 @@ int backsql_process_sub_filter(backsql_srch_info *bsi,Filter *f) if (f->f_sub_any!=NULL) for(i=0;f->f_sub_any[i]!=NULL;i++) { - //Debug(LDAP_DEBUG_TRACE,"==>backsql_process_sub_filter(): sub_any='%s'\n",f->f_sub_any[i]->bv_val,0,0); + /*Debug(LDAP_DEBUG_TRACE,"==>backsql_process_sub_filter(): sub_any='%s'\n",f->f_sub_any[i]->bv_val,0,0);*/ if (bsi->bi->upper_func) { bsi->flt_where=backsql_strcat(bsi->flt_where,&bsi->fwhere_len,ldap_pvt_str2upper(f->f_sub_any[i]->bv_val),"%",NULL); @@ -183,7 +183,7 @@ int backsql_process_filter(backsql_srch_info *bsi,Filter *f) backsql_at_map_rec oc_attr={"objectClass","","",NULL,NULL,NULL,NULL}; char *at_name=NULL; int done=0,len=0; - int rc=0; // TimesTen + int rc=0; /* TimesTen */ Debug(LDAP_DEBUG_TRACE,"==>backsql_process_filter()\n",0,0,0); if (f==NULL || f->f_choice==SLAPD_FILTER_COMPUTED) @@ -237,22 +237,24 @@ int backsql_process_filter(backsql_srch_info *bsi,Filter *f) } backsql_merge_from_clause(&bsi->from,&bsi->from_len,at->from_tbls); - //need to add this attribute to list of attrs to load, so that we could do test_filter() later + /*need to add this attribute to list of attrs to load, so that we could do test_filter() later*/ backsql_attrlist_add(bsi,at_name); if (at->join_where != NULL && strstr(bsi->join_where,at->join_where)==NULL) bsi->join_where=backsql_strcat(bsi->join_where,&bsi->jwhere_len," AND ",at->join_where,NULL); - //if (at!=&oc_attr) - // bsi->sel=backsql_strcat(bsi->sel,&bsi->sel_len,",",at->sel_expr," AS ",at->name,NULL); + /*if (at!=&oc_attr) + bsi->sel=backsql_strcat(bsi->sel,&bsi->sel_len,",",at->sel_expr," AS ",at->name,NULL); + */ switch(f->f_choice) { case LDAP_FILTER_EQUALITY: - //maybe we should check type of at->sel_expr here somehow, - //to know whether upper_func is applicable, but for now - //upper_func stuff is made for Oracle, where UPPER is - //safely applicable to NUMBER etc. + /*maybe we should check type of at->sel_expr here somehow, + * to know whether upper_func is applicable, but for now + * upper_func stuff is made for Oracle, where UPPER is + * safely applicable to NUMBER etc. + */ if (bsi->bi->upper_func) { if (at->sel_expr_u) bsi->flt_where=backsql_strcat(bsi->flt_where,&bsi->fwhere_len,"(", @@ -448,8 +450,7 @@ int backsql_oc_get_candidates(backsql_oc_map_rec *oc,backsql_srch_info *bsi) if ((rc=backsql_BindParamStr(sth,2,temp_base_dn,BACKSQL_MAX_DN_LEN)) != SQL_SUCCESS) { - Debug(LDAP_DEBUG_TRACE,"backsql_oc_get_candidates(): error binding base -_dn parameter (2)\n",0,0,0); + Debug(LDAP_DEBUG_TRACE,"backsql_oc_get_candidates(): error binding base_dn parameter (2)\n",0,0,0); backsql_PrintErrors(bsi->bi->db_env,bsi->dbh,sth,rc); return 1; } diff --git a/servers/slapd/back-sql/sql-types.h b/servers/slapd/back-sql/sql-types.h index f709cd3b17..36bb21c4b2 100644 --- a/servers/slapd/back-sql/sql-types.h +++ b/servers/slapd/back-sql/sql-types.h @@ -22,4 +22,5 @@ typedef struct SQLINTEGER* is_null; }BACKSQL_ROW_NTS; -#endif \ No newline at end of file +#endif + diff --git a/servers/slapd/back-sql/sql-wrap.c b/servers/slapd/back-sql/sql-wrap.c index 50ab84daf2..8251b5a0c9 100644 --- a/servers/slapd/back-sql/sql-wrap.c +++ b/servers/slapd/back-sql/sql-wrap.c @@ -62,13 +62,14 @@ RETCODE backsql_Prepare(SQLHDBC dbh,SQLHSTMT *sth,char* query,int timeout) if (rc != SQL_SUCCESS) return rc; - //Debug(LDAP_DEBUG_TRACE,"==>_SQLPrepare()\n", 0,0,0); + /*Debug(LDAP_DEBUG_TRACE,"==>_SQLPrepare()\n", 0,0,0);*/ SQLGetInfo(dbh,SQL_DRIVER_NAME,drv_name,30,&len); - //Debug(LDAP_DEBUG_TRACE,"_SQLPrepare(): driver name='%s'\n", drv_name,0,0); + /*Debug(LDAP_DEBUG_TRACE,"_SQLPrepare(): driver name='%s'\n", drv_name,0,0);*/ if (!strncmp(ldap_pvt_str2upper(drv_name),"SQLSRV32.DLL",30)) { - //stupid default result set in MS SQL Server does not support multiple active statements - //on the same connection -- so we are trying to make it not to use default result set... + /*stupid default result set in MS SQL Server does not support multiple active statements + *on the same connection -- so we are trying to make it not to use default result set... + */ Debug(LDAP_DEBUG_TRACE,"_SQLprepare(): enabling MS SQL Server default result set workaround\n", 0,0,0); rc=SQLSetStmtOption(*sth,SQL_CONCURRENCY,SQL_CONCUR_ROWVER); if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) @@ -86,7 +87,7 @@ RETCODE backsql_Prepare(SQLHDBC dbh,SQLHSTMT *sth,char* query,int timeout) } } - //Debug(LDAP_DEBUG_TRACE,"<==_SQLPrepare() calling SQLPrepare()\n", 0,0,0); + /*Debug(LDAP_DEBUG_TRACE,"<==_SQLPrepare() calling SQLPrepare()\n", 0,0,0);*/ return SQLPrepare(*sth,query,SQL_NTS); } @@ -118,16 +119,16 @@ RETCODE backsql_BindRowAsStrings(SQLHSTMT sth,BACKSQL_ROW_NTS *row) if (row == NULL) return SQL_ERROR; - //Debug(LDAP_DEBUG_TRACE,"==> backsql_BindRowAsStrings()\n",0,0,0); + /*Debug(LDAP_DEBUG_TRACE,"==> backsql_BindRowAsStrings()\n",0,0,0);*/ rc=SQLNumResultCols(sth,&row->ncols); if (rc != SQL_SUCCESS) { - //Debug(LDAP_DEBUG_TRACE,"_SQLBindRowAsStrings(): SQLNumResultCols() failed:\n",0,0,0); + /*Debug(LDAP_DEBUG_TRACE,"_SQLBindRowAsStrings(): SQLNumResultCols() failed:\n",0,0,0);*/ backsql_PrintErrors(SQL_NULL_HENV,SQL_NULL_HDBC,sth,rc); } else { - //Debug(LDAP_DEBUG_TRACE,"backsql_BindRowAsStrings: ncols=%d\n",(int)row->ncols,0,0); + /*Debug(LDAP_DEBUG_TRACE,"backsql_BindRowAsStrings: ncols=%d\n",(int)row->ncols,0,0);*/ row->col_names=(char**)ch_calloc(row->ncols,sizeof(char*)); row->cols=(char**)ch_calloc(row->ncols,sizeof(char*)); row->col_prec=(UDWORD*)ch_calloc(row->ncols,sizeof(UDWORD)); @@ -137,15 +138,16 @@ RETCODE backsql_BindRowAsStrings(SQLHSTMT sth,BACKSQL_ROW_NTS *row) rc=SQLDescribeCol(sth,(SQLSMALLINT)i,&colname[0],(SQLUINTEGER)sizeof(colname)-1,&name_len,&col_type, (UDWORD*) &col_prec,&col_scale,&col_null); row->col_names[i-1]=ch_strdup(colname); - //Debug(LDAP_DEBUG_TRACE,"backsql_BindRowAsStrings: col_name=%s, col_prec[%d]=%d\n",colname,(int)i,(int)col_prec); + /*Debug(LDAP_DEBUG_TRACE,"backsql_BindRowAsStrings: col_name=%s, col_prec[%d]=%d\n",colname,(int)i,(int)col_prec);*/ if (col_type == SQL_LONGVARCHAR || col_type== SQL_LONGVARBINARY) { - //row->cols[i-1]=NULL; - //row->col_prec[i-1]=-1; - //such fields must be handled in some other way since they return 2G - //as their precision (at least it does so with MS SQL Server w/native driver) - //for now, we just set fixed precision for such fields - dirty hack, but... - //no time to deal with SQLGetData() + /*row->cols[i-1]=NULL; + *row->col_prec[i-1]=-1; + *such fields must be handled in some other way since they return 2G + *as their precision (at least it does so with MS SQL Server w/native driver) + *for now, we just set fixed precision for such fields - dirty hack, but... + *no time to deal with SQLGetData() + */ col_prec=MAX_ATTR_LEN; row->cols[i-1]=(char*)ch_calloc((col_prec+1),sizeof(char)); row->col_prec[i-1]=col_prec; @@ -161,7 +163,7 @@ RETCODE backsql_BindRowAsStrings(SQLHSTMT sth,BACKSQL_ROW_NTS *row) } } } - //Debug(LDAP_DEBUG_TRACE,"<== backsql_BindRowAsStrings()\n",0,0,0); + /*Debug(LDAP_DEBUG_TRACE,"<== backsql_BindRowAsStrings()\n",0,0,0);*/ return rc; } @@ -195,7 +197,7 @@ int backsql_cmp_connid(backsql_db_conn *c1,backsql_db_conn *c2) int backsql_close_db_conn(backsql_db_conn *conn) { Debug(LDAP_DEBUG_TRACE,"==>backsql_close_db_conn()\n",0,0,0); - SQLTransact(NULL, conn->dbh, SQL_COMMIT); // TimesTen + SQLTransact(NULL, conn->dbh, SQL_COMMIT); /* TimesTen */ SQLDisconnect(conn->dbh); SQLFreeConnect(conn->dbh); Debug(LDAP_DEBUG_TRACE,"<==backsql_close_db_conn()\n",0,0,0); @@ -218,17 +220,18 @@ int backsql_init_db_env(backsql_info *si) int backsql_free_db_env(backsql_info *si) { Debug(LDAP_DEBUG_TRACE,"==>backsql_free_db_env()\n",0,0,0); - //Debug(LDAP_DEBUG_TRACE,"free_db_env(): delete AVL tree here!!!\n",0,0,0); + /*Debug(LDAP_DEBUG_TRACE,"free_db_env(): delete AVL tree here!!!\n",0,0,0);*/ - //stop, if frontend waits for all threads to shutdown before calling this -- - //then what we are going to delete?? everything is deleted already... + /*stop, if frontend waits for all threads to shutdown before calling this -- + *then what we are going to delete?? everything is deleted already... +*/ Debug(LDAP_DEBUG_TRACE,"<==backsql_free_db_env()\n",0,0,0); return SQL_SUCCESS; } backsql_db_conn* backsql_open_db_conn(backsql_info *si,int ldap_cid) { - char DBMSName[32]; // TimesTen + char DBMSName[32]; /* TimesTen*/ backsql_db_conn *dbc=(backsql_db_conn*)ch_calloc(1,sizeof(backsql_db_conn)); int rc; @@ -276,7 +279,7 @@ backsql_db_conn* backsql_open_db_conn(backsql_info *si,int ldap_cid) Debug(LDAP_DEBUG_TRACE,"backsql_open_db_conn: SQLGetInfo() failed:\n",0,0,0); backsql_PrintErrors(si->db_env,dbc->dbh,SQL_NULL_HENV,rc); } - // end TimesTen + /* end TimesTen */ Debug(LDAP_DEBUG_TRACE,"backsql_open_db_conn(): connected, adding to tree\n",0,0,0); ldap_pvt_thread_mutex_lock(&si->dbconn_mutex); @@ -296,8 +299,9 @@ int backsql_free_db_conn(Backend *be,Connection *ldapc) ldap_pvt_thread_mutex_lock(&si->dbconn_mutex); conn=(backsql_db_conn*)avl_delete(&si->db_conns,&tmp,(AVL_CMP)backsql_cmp_connid); ldap_pvt_thread_mutex_unlock(&si->dbconn_mutex); - //we have one thread per connection, as I understand -- so we can - //get this out of critical section + /*we have one thread per connection, as I understand -- so we can + *get this out of critical section +*/ if (conn!=NULL) { Debug(LDAP_DEBUG_TRACE,"backsql_free_db_conn(): closing db connection\n",0,0,0); @@ -316,8 +320,9 @@ SQLHDBC backsql_get_db_conn(Backend *be,Connection *ldapc) Debug(LDAP_DEBUG_TRACE,"==>backsql_get_db_conn()\n",0,0,0); tmp.ldap_cid=ldapc->c_connid; - //we have one thread per connection, as I understand -- so we do not need - // locking here + /*we have one thread per connection, as I understand -- so we do not need + * locking here +*/ dbc=(backsql_db_conn*)avl_find(si->db_conns,&tmp,(AVL_CMP)backsql_cmp_connid); if (!dbc) dbc=backsql_open_db_conn(si,ldapc->c_connid); diff --git a/servers/slapd/back-sql/sql-wrap.h b/servers/slapd/back-sql/sql-wrap.h index 64067f1088..6bf738ce09 100644 --- a/servers/slapd/back-sql/sql-wrap.h +++ b/servers/slapd/back-sql/sql-wrap.h @@ -25,4 +25,5 @@ int backsql_free_db_env(backsql_info *si); SQLHDBC backsql_get_db_conn(Backend *be,Connection *ldapc); int backsql_free_db_conn(Backend *be,Connection *ldapc); -#endif \ No newline at end of file +#endif + diff --git a/servers/slapd/back-sql/util.c b/servers/slapd/back-sql/util.c index a015674bdd..3de62bae80 100644 --- a/servers/slapd/back-sql/util.c +++ b/servers/slapd/back-sql/util.c @@ -22,14 +22,13 @@ char backsql_def_oc_query[]="SELECT id,name,keytbl,keycol,create_proc,delete_proc,expect_return FROM ldap_oc_mappings"; -char backsql_def_at_query[]="SELECT name,sel_expr,from_tbls,join_where,add_proc, -delete_proc,param_order,expect_return,sel_expr_u FROM ldap_attr_mappings WHERE oc_map_id=?"; +char backsql_def_at_query[]="SELECT name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return,sel_expr_u FROM ldap_attr_mappings WHERE oc_map_id=?"; char backsql_def_delentry_query[]="DELETE FROM ldap_entries WHERE id=?"; char backsql_def_insentry_query[]="INSERT INTO ldap_entries (dn,oc_map_id,parent,keyval) VALUES (?,?,?,?)"; char backsql_def_subtree_cond[]="ldap_entries.dn LIKE CONCAT('%',?)"; char backsql_id_query[]="SELECT id,keyval,oc_map_id FROM ldap_entries WHERE "; -// TimesTen +/* TimesTen*/ char backsql_check_dn_ru_query[] = "SELECT dn_ru from ldap_entries"; char* backsql_strcat(char* dest,int *buflen, ...) @@ -38,7 +37,7 @@ char* backsql_strcat(char* dest,int *buflen, ...) int cdlen,cslen,grow; char *cstr; - //Debug(LDAP_DEBUG_TRACE,"==>my_strcat()\n"); + /*Debug(LDAP_DEBUG_TRACE,"==>my_strcat()\n");*/ va_start(strs,buflen); if (dest==NULL || *buflen<=0) { @@ -52,21 +51,21 @@ char* backsql_strcat(char* dest,int *buflen, ...) grow=BACKSQL_MAX(BACKSQL_STR_GROW,cslen); if (*buflen-cdlen < cslen) { - //Debug(LDAP_DEBUG_TRACE,"my_strcat(): buflen=%d, cdlen=%d, cslen=%d -- reallocating dest\n", - // *buflen,cdlen,cslen); + /*Debug(LDAP_DEBUG_TRACE,"my_strcat(): buflen=%d, cdlen=%d, cslen=%d -- reallocating dest\n", + *buflen,cdlen,cslen); */ dest=(char*)ch_realloc(dest,(*buflen)+grow*sizeof(char)); if (dest == NULL) { Debug(LDAP_DEBUG_ANY,"my_strcat(): could not reallocate string buffer.\n",0,0,0); } *buflen+=grow; - //Debug(LDAP_DEBUG_TRACE,"my_strcat(): new buflen=%d, dest=%p\n",*buflen,dest,0); + /*Debug(LDAP_DEBUG_TRACE,"my_strcat(): new buflen=%d, dest=%p\n",*buflen,dest,0);*/ } strcat(dest,cstr); cdlen+=cslen; } va_end(strs); - //Debug(LDAP_DEBUG_TRACE,"<==my_strcat() (dest='%s')\n",dest,0,0); + /*Debug(LDAP_DEBUG_TRACE,"<==my_strcat() (dest='%s')\n",dest,0,0);*/ return dest; } @@ -119,7 +118,7 @@ char* backsql_get_table_spec(char **p) #define BACKSQL_NEXT_WORD {while (*s && isspace(*s)) s++; if (!*s) return res; q=s; while (*q && !isspace(*q)) q++; if (*q) *q++='\0';} BACKSQL_NEXT_WORD; - res=backsql_strcat(res,&res_len,s,NULL);//table name + res=backsql_strcat(res,&res_len,s,NULL);/*table name*/ s=q; BACKSQL_NEXT_WORD; @@ -128,9 +127,10 @@ char* backsql_get_table_spec(char **p) s=q; BACKSQL_NEXT_WORD; } - //res=backsql_strcat(res,&res_len," AS ",s,NULL);//table alias - //oracle doesn't understand AS :( - res=backsql_strcat(res,&res_len," ",s,NULL);//table alias + /*res=backsql_strcat(res,&res_len," AS ",s,NULL); + *oracle doesn't understand AS :( + */ + res=backsql_strcat(res,&res_len," ",s,NULL);/*table alias*/ return res; } @@ -138,14 +138,14 @@ int backsql_merge_from_clause(char **dest_from,int *dest_len,char *src_from) { char *s,*p,*srcc,*pos,e; - //Debug(LDAP_DEBUG_TRACE,"==>backsql_merge_from_clause(): dest_from='%s',src_from='%s'\n", - // dest_from,src_from,0); + /*Debug(LDAP_DEBUG_TRACE,"==>backsql_merge_from_clause(): dest_from='%s',src_from='%s'\n", + dest_from,src_from,0); */ srcc=ch_strdup(src_from); p=srcc; while(*p) { s=backsql_get_table_spec(&p); - // Debug(LDAP_DEBUG_TRACE,"backsql_merge_from_clause(): p='%s' s='%s'\n",p,s,0); + /* Debug(LDAP_DEBUG_TRACE,"backsql_merge_from_clause(): p='%s' s='%s'\n",p,s,0); */ if (*dest_from==NULL) *dest_from=backsql_strcat(*dest_from,dest_len,s,NULL); else @@ -156,7 +156,7 @@ int backsql_merge_from_clause(char **dest_from,int *dest_len,char *src_from) if (s) ch_free(s); } -// Debug(LDAP_DEBUG_TRACE,"<==backsql_merge_from_clause()\n",0,0,0); +/* Debug(LDAP_DEBUG_TRACE,"<==backsql_merge_from_clause()\n",0,0,0);*/ free(srcc); return 1; } diff --git a/servers/slapd/back-sql/util.h b/servers/slapd/back-sql/util.h index 949ccaa221..dd50fd3d45 100644 --- a/servers/slapd/back-sql/util.h +++ b/servers/slapd/back-sql/util.h @@ -61,3 +61,4 @@ int backsql_merge_from_clause(char **dest_from,int *dest_len,char *src_from); #endif + -- 2.39.5