]> git.sur5r.net Git - openldap/commitdiff
(blind) addition of 'autocommit' configuration statement (ITS#6612)
authorPierangelo Masarati <ando@openldap.org>
Tue, 10 Aug 2010 19:55:28 +0000 (19:55 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 10 Aug 2010 19:55:28 +0000 (19:55 +0000)
doc/man/man5/slapd-sql.5
servers/slapd/back-sql/back-sql.h
servers/slapd/back-sql/config.c
servers/slapd/back-sql/sql-wrap.c

index 2444737a2bab2bbb0abbca58da4471fea366dbb3..b53811fc2e32b6cb4f9e2a9d554d762ee801db4d 100644 (file)
@@ -336,6 +336,10 @@ Subsequent args are passed to the layer configuration routine.
 This is \fIhighly experimental\fP and should be used with extreme care.
 The API of the layers is not frozen yet, so it is unpublished.
 
+.TP
+.B autocommit { NO | yes }
+Activates autocommit; by default, it is off.
+
 .SH METAINFORMATION USED
 .LP
 Almost everything mentioned later is illustrated in examples located
index 4be0931c1bebd9a279bf1416cc8dca45e2f5fdcd..7c3004676951ff676bffb33e9b31d3047af5d39c 100644 (file)
@@ -517,6 +517,7 @@ typedef struct backsql_info {
 #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 BSQLF_AUTOCOMMIT_ON            0x1000
 
 #define BACKSQL_ISF(si, f) \
        (((si)->sql_flags & f) == f)
@@ -549,6 +550,8 @@ typedef struct backsql_info {
        BACKSQL_ISF(si, BSQLF_FETCH_ALL_ATTRS)
 #define BACKSQL_CHECK_SCHEMA(si) \
        BACKSQL_ISF(si, BSQLF_CHECK_SCHEMA)
+#define BACKSQL_AUTOCOMMIT_ON(si) \
+       BACKSQL_ISF(si, BSQLF_AUTOCOMMIT_ON)
 
        Entry           *sql_baseObject;
 #ifdef BACKSQL_ARBITRARY_KEY
index 06cc682ab25e437f467c8b7399520d37339294d1..4203876e0306dd035b34310586143bd5552800a5 100644 (file)
@@ -639,6 +639,37 @@ backsql_db_config(
 
                ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_aliasing_quote );
 
+       } else if ( !strcasecmp( argv[ 0 ], "autocommit" ) ) {
+               if ( argc != 2 ) {
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<==backsql_db_config (%s line %d): "
+                               "missing arg "
+                               "in \"autocommit {NO|yes}\" directive\n",
+                               fname, lineno, 0 );
+                       return 1;
+               }
+
+               if ( !strcasecmp( argv[ 1 ], "yes" ) ||
+                       !strcasecmp( argv[ 1 ], "TRUE" ) ||
+                       !strcasecmp( argv[ 1 ], "on" ) )
+               {
+                       bi->sql_flags |= BSQLF_AUTOCOMMIT_ON;
+
+               } else if ( !strcasecmp( argv[ 1 ], "no" ) ||
+                       !strcasecmp( argv[ 1 ], "FALSE" ) ||
+                       !strcasecmp( argv[ 1 ], "off" ) )
+               {
+                       bi->sql_flags &= ~BSQLF_AUTOCOMMIT_ON;
+
+               } else {
+                       Debug( LDAP_DEBUG_TRACE,
+                               "<==backsql_db_config (%s line %d): "
+                               "invalid arg "
+                               "in \"autocommit {NO|yes}\" directive\n",
+                               fname, lineno, 0 );
+                       return 1;
+               }
+
        } else {
                return SLAP_CONF_UNKNOWN;
        }
index 357d5cf42a643823a4fa73239dc31eefdef9c770..681da223ce4659014721b1c3fc060ca0e765b61a 100644 (file)
@@ -424,7 +424,8 @@ backsql_open_db_handle(
         * TimesTen : Turn off autocommit.  We must explicitly
         * commit any transactions. 
         */
-       SQLSetConnectOption( *dbhp, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF );
+       SQLSetConnectOption( *dbhp, SQL_AUTOCOMMIT,
+               BACKSQL_AUTOCOMMIT_ON( bi ) ?  SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF );
 
        /* 
         * See if this connection is to TimesTen.  If it is,