#include "slap.h"
#include "proto-sql.h"
+#ifdef BACKSQL_SYNCPROV
+#include <lutil.h>
+#endif /* BACKSQL_SYNCPROV */
+
/*
* Skip:
* - null values (e.g. delete modification)
realndn = BER_BVNULL,
realpdn = BER_BVNULL;
+#ifdef BACKSQL_SYNCPROV
+ /*
+ * NOTE: fake successful result to force contextCSN to be bumped up
+ */
+ if ( op->o_sync ) {
+ char buf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
+ struct berval csn = BER_BVNULL;
+
+ slap_get_csn( op, buf, sizeof( buf ), &csn, 1 );
+
+ rs->sr_err = LDAP_SUCCESS;
+ send_ldap_result( op, rs );
+
+ slap_graduate_commit_csn( op );
+
+ return 0;
+ }
+#endif /* BACKSQL_SYNCPROV */
+
Debug( LDAP_DEBUG_TRACE, "==>backsql_add(\"%s\")\n",
op->oq_add.rs_e->e_name.bv_val, 0, 0 );
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 ) {
assert( op->o_private );
entryCSN = *((struct berval *)op->o_private);
- } else {
+ } else
+#endif /* BACKSQL_SYNCPROV */
+ {
slap_get_csn( op, csnbuf, sizeof(csnbuf), &entryCSN, 0 );
}
rc = 1;
goto done;
+#ifdef BACKSQL_SYNCPROV
} else if ( ad == slap_schema.si_ad_entryCSN ) {
/*
* TODO: introduce appropriate entryCSN filtering
goto done;
}
- /* save for later use in operational attributes */
- bsi->bsi_op->o_private = &f->f_av_value;
-
bsi->bsi_flags |= ( BSQL_SF_FILTER_ENTRYCSN | BSQL_SF_RETURN_ENTRYUUID);
/* if doing a syncrepl, try to return as much as possible,
backsql_strfcat( &bsi->bsi_flt_where, "l",
(ber_len_t)STRLENOF( "1=1" ), "1=1" );
+ /* save for later use in operational attributes */
+ /* FIXME: saves only the first occurrence, because
+ * the filter during updates is written as
+ * "(&(entryCSN<={contextCSN})(entryCSN>={oldContextCSN})({filter}))"
+ * so we want our fake entryCSN to match the greatest
+ * value
+ */
+ if ( bsi->bsi_op->o_private == NULL ) {
+ bsi->bsi_op->o_private = &f->f_av_value;
+ }
bsi->bsi_status = LDAP_SUCCESS;
+
rc = 1;
goto done;
+#endif /* BACKSQL_SYNCPROV */
} else if ( ad == slap_schema.si_ad_hasSubordinates || ad == NULL ) {
/*
}
}
+#ifdef BACKSQL_SYNCPROV
if ( bsi.bsi_flags & BSQL_SF_FILTER_ENTRYCSN ) {
a_entryCSN = backsql_operational_entryCSN( op );
if ( a_entryCSN != NULL ) {
*ap = a_entryCSN;
}
}
+#endif /* BACKSQL_SYNCPROV */
if ( test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE )
{
rs->sr_v2ref = NULL;
}
+#ifdef BACKSQL_SYNCPROV
+ if ( op->o_sync ) {
+ Operation op2 = *op;
+ SlapReply rs2 = { 0 };
+ Entry e = { 0 };
+ slap_callback cb = { 0 };
+
+ op2.o_tag = LDAP_REQ_ADD;
+ op2.o_bd = select_backend( &op->o_bd->be_nsuffix[0], 0, 0 );
+ op2.ora_e = &e;
+ op2.o_callback = &cb;
+
+ e.e_name = op->o_bd->be_suffix[0];
+ e.e_nname = op->o_bd->be_nsuffix[0];
+
+ cb.sc_response = slap_null_cb;
+
+ op2.o_bd->be_add( &op2, &rs2 );
+ }
+#endif /* BACKSQL_SYNCPROV */
+
done:;
if ( !BER_BVISNULL( &bsi.bsi_base_id.eid_ndn ) ) {
(void)backsql_free_entryID( &bsi.bsi_base_id, 0 );