]> git.sur5r.net Git - openldap/commitdiff
remove global_schemacheck
authorPierangelo Masarati <ando@openldap.org>
Thu, 12 May 2005 00:03:50 +0000 (00:03 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 12 May 2005 00:03:50 +0000 (00:03 +0000)
servers/slapd/back-sql/add.c
servers/slapd/back-sql/back-sql.h
servers/slapd/back-sql/config.c
servers/slapd/back-sql/entry-id.c
servers/slapd/back-sql/init.c
servers/slapd/back-sql/modify.c
servers/slapd/back-sql/modrdn.c

index 40aac5a3e42c5eb7b38d5ab4f1297547b1e7a561..03accfc5ea0f871b838d3293f2af69eccbacab34 100644 (file)
@@ -986,7 +986,7 @@ backsql_add( Operation *op, SlapReply *rs )
                        op->ora_e->e_name.bv_val, 0, 0 );
 
        /* check schema */
-       if ( global_schemacheck ) {
+       if ( BACKSQL_CHECK_SCHEMA( bi ) ) {
                char            textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' };
 
                rs->sr_err = entry_schema_check( op->o_bd, op->ora_e,
index d905d2bf23943e7081101af57d330bfe11488c8a..9945a615db3c7baed573a6ab2382cdf367430804 100644 (file)
@@ -508,6 +508,7 @@ typedef struct backsql_info {
 #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)
@@ -538,6 +539,8 @@ typedef struct backsql_info {
        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
index 9e82f0b3584fc15945b19c07e122a20cf347eef9..1a89a0da84c1b818418aea03b1641d4bc3feb686 100644 (file)
@@ -561,6 +561,36 @@ backsql_db_config(
                        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;
        }
index 071be1e47a6a1e9372dd2ae22fc369e234850956..d02857553b06dcf62dc782586107375cc1379ab7 100644 (file)
@@ -934,40 +934,41 @@ next:;
                }
        }
 
-       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:;
index 4a236a17183f2407a281676d4e44ad93c53804b0..a6e6d292e3157cac527a1fb04213111728f6daa5 100644 (file)
@@ -474,6 +474,7 @@ backsql_db_open(
                /* enable if only one suffix is defined */
                bi->sql_flags |= BSQLF_USE_SUBTREE_SHORTCUT;
        }
+       bi->sql_flags |= BSQLF_CHECK_SCHEMA;
        
        Debug( LDAP_DEBUG_TRACE, "<==backsql_db_open(): "
                "test succeeded, schema map loaded\n", 0, 0, 0 );
index 8f5be4fc39039b382320b21d9a09bdd3d9cd6f0b..b75697a2d82765b148b56b81c9b28f771aa8b34c 100644 (file)
@@ -155,7 +155,7 @@ backsql_modify( Operation *op, SlapReply *rs )
                goto do_transact;
        }
 
-       if ( global_schemacheck ) {
+       if ( BACKSQL_CHECK_SCHEMA( bi ) ) {
                char            textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' };
 
                entry_clean( &m );
index 55acd62d2d7b92fe10f550fb51bf7571c4cd97d3..7c6c36baeae093deb76b9ad86e3539dd4dc79364 100644 (file)
@@ -446,7 +446,7 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                goto done;
        }
 
-       if ( global_schemacheck ) {
+       if ( BACKSQL_CHECK_SCHEMA( bi ) ) {
                char            textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' };
 
                entry_clean( &r );