]> git.sur5r.net Git - openldap/blob - servers/slapd/back-sql/other.c
trace illegal condition in backsql_strfcat
[openldap] / servers / slapd / back-sql / other.c
1 /*
2  *       Copyright 1999, Dmitry Kovalev <mit@openldap.org>, All rights reserved.
3  *
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.
8  */
9
10 #include "portable.h"
11
12 #ifdef SLAPD_SQL
13
14 #include <stdio.h>
15 #include <sys/types.h>
16 #include "slap.h"
17 #include "back-sql.h"
18 #include "sql-wrap.h"
19 #include "entry-id.h"
20
21 int
22 backsql_compare(
23         BackendDB       *bd,
24         Connection      *conn,
25         Operation       *op,
26         struct berval   *dn,
27         struct berval   *ndn,
28         AttributeAssertion *ava )
29 {
30         Debug( LDAP_DEBUG_TRACE, "==>backsql_compare() - not implemented\n",
31                         0, 0, 0 );
32         return 1;
33 }
34
35 int
36 backsql_abandon(
37         BackendDB       *be,
38         Connection      *conn, 
39         Operation       *op, 
40         int             msgid )
41 {
42         Debug( LDAP_DEBUG_TRACE, "==>backsql_abandon()\n", 0, 0, 0 );
43         Debug( LDAP_DEBUG_TRACE, "<==backsql_abandon()\n", 0, 0, 0 );
44         return 0;
45 }
46
47
48 /*
49  * sets the supported operational attributes (if required)
50  */
51
52 int
53 backsql_operational(
54         BackendDB       *be,
55         Connection      *conn, 
56         Operation       *op,
57         Entry           *e,
58         AttributeName   *attrs,
59         int             opattrs,
60         Attribute       **a )
61 {
62
63         backsql_info            *bi = (backsql_info*)be->be_private;
64         SQLHDBC                 dbh = SQL_NULL_HDBC;
65         Attribute               **aa = a;
66         int                     rc = 0;
67
68         Debug( LDAP_DEBUG_TRACE, "==>backsql_operational(): entry '%s'\n",
69                         e->e_nname.bv_val, 0, 0 );
70
71
72         if ( ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, attrs ) ) 
73 #ifdef SLAP_X_FILTER_HASSUBORDINATES
74                         && attr_find( e->e_attrs, slap_schema.si_ad_hasSubordinates ) == NULL
75 #endif /* SLAP_X_FILTER_HASSUBORDINATES */
76                         ) {
77                 
78                 rc = backsql_get_db_conn( be, conn, &dbh );
79                 if ( rc != LDAP_SUCCESS ) {
80                         goto no_connection;
81                 }
82                 
83                 rc = backsql_has_children( bi, dbh, &e->e_nname );
84
85                 switch( rc ) {
86                 case LDAP_COMPARE_TRUE:
87                 case LDAP_COMPARE_FALSE:
88                         *aa = slap_operational_hasSubordinate( rc == LDAP_COMPARE_TRUE );
89                         if ( *aa != NULL ) {
90                                 aa = &(*aa)->a_next;
91                         }
92                         rc = 0;
93                         break;
94
95                 default:
96                         Debug(LDAP_DEBUG_TRACE, 
97                                 "backsql_operational(): "
98                                 "has_children failed( %d)\n", 
99                                 rc, 0, 0 );
100                         rc = 1;
101                         break;
102                 }
103         }
104
105         return rc;
106
107 no_connection:;
108         Debug( LDAP_DEBUG_TRACE, "backsql_operational(): "
109                 "could not get connection handle - exiting\n", 
110                 0, 0, 0 );
111         send_ldap_result( conn, op, rc, "", 
112                         rc == LDAP_OTHER ? "SQL-backend error" : "",
113                         NULL, NULL );
114         return 1;
115 }
116
117 #endif /* SLAPD_SQL */
118