]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-sql/operational.c
Cleanup ISO C compatibility for recent commits
[openldap] / servers / slapd / back-sql / operational.c
index 1423e2156a88cf1d331527d98a621fd7996a9c9f..2cbc23c67257098789ac0778356b3a0f4b36da11 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2005 The OpenLDAP Foundation.
+ * Copyright 1999-2011 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
  * Portions Copyright 2002 Pierangelo Masarati.
  * All rights reserved.
@@ -53,9 +53,9 @@ backsql_operational_entryUUID( backsql_info *bi, backsql_entryID *id )
                return NULL;
        }
 
-       a = ch_malloc( sizeof( Attribute ) );
-       a->a_desc = desc;
+       a = attr_alloc( desc );
 
+       a->a_numvals = 1;
        a->a_vals = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
        a->a_vals[ 0 ] = val;
        BER_BVZERO( &a->a_vals[ 1 ] );
@@ -63,9 +63,6 @@ backsql_operational_entryUUID( backsql_info *bi, backsql_entryID *id )
        a->a_nvals = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
        a->a_nvals[ 0 ] = nval;
        BER_BVZERO( &a->a_nvals[ 1 ] );
-       
-       a->a_next = NULL;
-       a->a_flags = 0;
 
        return a;
 }
@@ -73,17 +70,17 @@ backsql_operational_entryUUID( backsql_info *bi, backsql_entryID *id )
 Attribute *
 backsql_operational_entryCSN( Operation *op )
 {
-       char            csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
+       char            csnbuf[ LDAP_PVT_CSNSTR_BUFSIZE ];
        struct berval   entryCSN;
        Attribute       *a;
 
-       a = ch_malloc( sizeof( Attribute ) );
-       a->a_desc = slap_schema.si_ad_entryCSN;
+       a = attr_alloc( slap_schema.si_ad_entryCSN );
+       a->a_numvals = 1;
        a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
        BER_BVZERO( &a->a_vals[ 1 ] );
 
 #ifdef BACKSQL_SYNCPROV
-       if ( op->o_sync && op->o_tag == LDAP_REQ_SEARCH ) {
+       if ( op->o_sync && op->o_tag == LDAP_REQ_SEARCH && op->o_private != NULL ) {
                assert( op->o_private != NULL );
 
                entryCSN = *((struct berval *)op->o_private);
@@ -100,9 +97,6 @@ backsql_operational_entryCSN( Operation *op )
 
        a->a_nvals = a->a_vals;
 
-       a->a_next = NULL;
-       a->a_flags = 0;
-
        return a;
 }
 
@@ -129,7 +123,7 @@ backsql_operational(
        Debug( LDAP_DEBUG_TRACE, "==>backsql_operational(): entry \"%s\"\n",
                        rs->sr_entry->e_nname.bv_val, 0, 0 );
 
-       for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next ) {
+       for ( ap = &rs->sr_entry->e_attrs; *ap; ap = &(*ap)->a_next ) {
                if ( (*ap)->a_desc == slap_schema.si_ad_hasSubordinates ) {
                        get_conn--;
                        got[ BACKSQL_OP_HASSUBORDINATES ] = 1;
@@ -144,6 +138,27 @@ backsql_operational(
                }
        }
 
+       for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next ) {
+               if ( !got[ BACKSQL_OP_HASSUBORDINATES ] &&
+                       (*ap)->a_desc == slap_schema.si_ad_hasSubordinates )
+               {
+                       get_conn--;
+                       got[ BACKSQL_OP_HASSUBORDINATES ] = 1;
+
+               } else if ( !got[ BACKSQL_OP_ENTRYUUID ] && 
+                       (*ap)->a_desc == slap_schema.si_ad_entryUUID )
+               {
+                       get_conn--;
+                       got[ BACKSQL_OP_ENTRYUUID ] = 1;
+
+               } else if ( !got[ BACKSQL_OP_ENTRYCSN ] &&
+                       (*ap)->a_desc == slap_schema.si_ad_entryCSN )
+               {
+                       get_conn--;
+                       got[ BACKSQL_OP_ENTRYCSN ] = 1;
+               }
+       }
+
        if ( !get_conn ) {
                return 0;
        }
@@ -197,7 +212,7 @@ backsql_operational(
 
                *ap = backsql_operational_entryUUID( bi, &bsi.bsi_base_id );
 
-               (void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
+               (void)backsql_free_entryID( &bsi.bsi_base_id, 0, op->o_tmpmemctx );
 
                if ( bsi.bsi_attrs != NULL ) {
                        op->o_tmpfree( bsi.bsi_attrs, op->o_tmpmemctx );