#define BSQLF_FETCH_ALL_USERATTRS 0x0200
#define BSQLF_FETCH_ALL_OPATTRS 0x0400
#define BSQLF_FETCH_ALL_ATTRS (BSQLF_FETCH_ALL_USERATTRS|BSQLF_FETCH_ALL_OPATTRS)
+#define BSQLF_CHECK_SCHEMA 0x0800
#define BACKSQL_ISF(si, f) \
(((si)->sql_flags & f) == f)
BACKSQL_ISF(si, BSQLF_FETCH_ALL_OPATTRS)
#define BACKSQL_FETCH_ALL_ATTRS(si) \
BACKSQL_ISF(si, BSQLF_FETCH_ALL_ATTRS)
+#define BACKSQL_CHECK_SCHEMA(si) \
+ BACKSQL_ISF(si, BSQLF_CHECK_SCHEMA)
Entry *sql_baseObject;
#ifdef BACKSQL_ARBITRARY_KEY
return -1;
}
+ } else if ( !strcasecmp( argv[ 0 ], "check_schema") ) {
+ if ( argc < 2 ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<==backsql_db_config (%s line %d): "
+ "missing { yes | no }"
+ "in \"check_schema\" directive\n",
+ fname, lineno, 0 );
+ return 1;
+ }
+
+ if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
+ bi->sql_flags |= BSQLF_CHECK_SCHEMA;
+
+ } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
+ bi->sql_flags &= ~BSQLF_CHECK_SCHEMA;
+
+ } else {
+ Debug( LDAP_DEBUG_TRACE,
+ "<==backsql_db_config (%s line %d): "
+ "\"check_schema\" directive arg "
+ "must be \"yes\" or \"no\"\n",
+ fname, lineno, 0 );
+ return 1;
+
+ }
+ Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
+ "check_schema=%s\n",
+ BACKSQL_CHECK_SCHEMA( bi ) ? "yes" : "no",
+ 0, 0 );
+
} else {
return SLAP_CONF_UNKNOWN;
}
}
}
- if ( global_schemacheck ) {
- const char *text = NULL;
- char textbuf[ 1024 ];
- size_t textlen = sizeof( textbuf );
+ if ( ( bsi->bsi_flags & BSQL_SF_ALL_OPER )
+ || an_find( bsi->bsi_attrs, &AllOper )
+ || an_find( bsi->bsi_attrs, &slap_schema.si_ad_structuralObjectClass->ad_cname ) )
+ {
struct berval bv[ 2 ];
- struct berval soc;
- int rc;
bv[ 0 ] = bsi->bsi_oc->bom_oc->soc_cname;
BER_BVZERO( &bv[ 1 ] );
- rc = structural_class( bv, &soc, NULL,
- &text, textbuf, textlen );
- if ( rc != LDAP_SUCCESS ) {
- Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(%s): "
- "structural_class() failed %d (%s)\n",
- bsi->bsi_e->e_name.bv_val,
- rc, text ? text : "" );
- entry_clean( bsi->bsi_e );
- return rc;
- }
+ if ( BACKSQL_CHECK_SCHEMA( bi ) ) {
+ const char *text = NULL;
+ char textbuf[ 1024 ];
+ size_t textlen = sizeof( textbuf );
+ struct berval soc;
+ int rc;
- if ( ( bsi->bsi_flags & BSQL_SF_ALL_OPER )
- || an_find( bsi->bsi_attrs, &AllOper )
- || an_find( bsi->bsi_attrs, &slap_schema.si_ad_structuralObjectClass->ad_cname ) )
- {
- rc = attr_merge_normalize_one( bsi->bsi_e,
- slap_schema.si_ad_structuralObjectClass,
- &soc, bsi->bsi_op->o_tmpmemctx );
+ rc = structural_class( bv, &soc, NULL,
+ &text, textbuf, textlen );
if ( rc != LDAP_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(%s): "
+ "structural_class() failed %d (%s)\n",
+ bsi->bsi_e->e_name.bv_val,
+ rc, text ? text : "" );
entry_clean( bsi->bsi_e );
return rc;
}
}
+
+ rc = attr_merge_normalize_one( bsi->bsi_e,
+ slap_schema.si_ad_structuralObjectClass,
+ &bv[ 0 ], bsi->bsi_op->o_tmpmemctx );
+ if ( rc != LDAP_SUCCESS ) {
+ entry_clean( bsi->bsi_e );
+ return rc;
+ }
}
done:;