[Date Prev][Date Next] [Chronological] [Thread] [Top]

back-sql with postgresql



	Hello,

  It's my first message on this list and i hope
this is the good place and you'll be able to understand me
(I'm french ).

I have been enjoyed to learn openldap can access a backend SQL.
I use postgreSQL for a long time and i would have it as backend for
openldap.

I've used the following mail as beginning for the SQL data
(backsql_create and test ).
http://www.openldap.org/lists/openldap-bugs/200101/msg00036.html

The modification of search.c seem to be not very portable .
postgreSQL does not support "SELECT DISTINCT hard_value" but other
RDBMS do not support "cast (hard_value as text)"

The following works fine for both postgreSQL and mySQL (I don't have
Oracle or mssql).

ldapsearch works fine but i'm a newbie with odbc . the "CALL
procedure_name", doesn't
work with postgreSQL and unixodbc . Any idea ?

   Any comment would be apreciated.

	I would be happy to help the openldap developement.

I use : postgreSQL 7.0.3 and 7.1
	GNU/Linux Debian woody
	unixodbc 2.0.4-4

		Thanks


diff -Nuar search.c search.c.orig
--- search.c    Tue Apr 17 16:34:05 2001
+++ search.c.orig       Tue Apr 17 16:35:35 2001
@@ -71,8 +71,8 @@
  bsi->id_list=NULL;
  bsi->stoptime=stoptime;
  bsi->bi=bi;
- bsi->sel=NULL; bsi->from=NULL; bsi->join_where=NULL;
bsi->flt_where=NULL; bsi->groupby=NULL;
- bsi->sel_len=0; bsi->from_len=0; bsi->jwhere_len=0; bsi->fwhere_len=0;
bsi->groupby_len=0;
+ bsi->sel=NULL; bsi->from=NULL; bsi->join_where=NULL;
bsi->flt_where=NULL;
+ bsi->sel_len=0; bsi->from_len=0; bsi->jwhere_len=0; bsi->fwhere_len=0;
 }
 
 int backsql_process_filter_list(backsql_srch_info *bsi,Filter *f,int
op)
@@ -284,8 +284,7 @@
  bsi->sel_len=bsi->from_len=bsi->jwhere_len=bsi->fwhere_len=0;
 
  bsi->sel=backsql_strcat(bsi->sel,&bsi->sel_len,
-                               "SELECT
ldap_entries.id,",bsi->oc->keytbl,".",bsi->oc->keycol,
-                               //"SELECT DISTINCT
ldap_entries.id,",bsi->oc->keytbl,".",bsi->oc->keycol,
+                               "SELECT DISTINCT
ldap_entries.id,",bsi->oc->keytbl,".",bsi->oc->keycol,
                                ", '",bsi->oc->name,"' AS objectClass",
                                ", ldap_entries.dn AS dn",
                                NULL);
@@ -320,15 +319,12 @@
  if (backsql_process_filter(bsi,bsi->filter))
  
query=backsql_strcat(query,&q_len,bsi->sel,bsi->from,bsi->join_where,"
AND ",bsi->flt_where,NULL);
 
- bsi->groupby=backsql_strcat(bsi->groupby,&bsi->groupby_len," GROUP BY
ldap_entries.id,",bsi->oc->keytbl,".",bsi->oc->keycol,", ldap_entries.dn
",NULL);
-
bsi->flt_where=backsql_strcat(bsi->flt_where,&bsi->fwhere_len,bsi->groupby,NULL);
-
+
  free(bsi->sel);
  free(bsi->from);
  free(bsi->join_where);
  free(bsi->flt_where);
- free(bsi->groupby);
-
bsi->sel_len=bsi->from_len=bsi->jwhere_len=bsi->fwhere_len=bsi->groupby_len=0;
+ bsi->sel_len=bsi->from_len=bsi->jwhere_len=bsi->fwhere_len=0;
  Debug(LDAP_DEBUG_TRACE,"<==backsql_srch_query()\n",0,0,0);
  return query;
 }

diff -Nuar util.h util.h.orig
--- util.h      Fri Apr 13 20:50:59 2001
+++ util.h.orig Tue Apr 17 16:38:54 2001
@@ -34,8 +34,8 @@
  int abandon;
  backsql_info *bi;
  backsql_oc_map_rec *oc;
- char *sel,*from,*join_where,*flt_where,*groupby;
- int sel_len,from_len,jwhere_len,fwhere_len,groupby_len;
+ char *sel,*from,*join_where,*flt_where;
+ int sel_len,from_len,jwhere_len,fwhere_len;
  SQLHDBC dbh;
  int status;
  Backend *be;
@@ -58,4 +58,4 @@
 int backsql_merge_from_clause(char **dest_from,int *dest_len,char
*src_from);
 

-- 
Loïc  TREGOUËT
http://www.cri74.org
http://www.pingoo.org