From: Pierangelo Masarati Date: Tue, 10 Aug 2010 19:55:28 +0000 (+0000) Subject: (blind) addition of 'autocommit' configuration statement (ITS#6612) X-Git-Tag: MIGRATION_CVS2GIT~526 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bca5e0ed1e751c7accc909e6011570e8802e8a7c;p=openldap (blind) addition of 'autocommit' configuration statement (ITS#6612) --- diff --git a/doc/man/man5/slapd-sql.5 b/doc/man/man5/slapd-sql.5 index 2444737a2b..b53811fc2e 100644 --- a/doc/man/man5/slapd-sql.5 +++ b/doc/man/man5/slapd-sql.5 @@ -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 diff --git a/servers/slapd/back-sql/back-sql.h b/servers/slapd/back-sql/back-sql.h index 4be0931c1b..7c30046769 100644 --- a/servers/slapd/back-sql/back-sql.h +++ b/servers/slapd/back-sql/back-sql.h @@ -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 diff --git a/servers/slapd/back-sql/config.c b/servers/slapd/back-sql/config.c index 06cc682ab2..4203876e03 100644 --- a/servers/slapd/back-sql/config.c +++ b/servers/slapd/back-sql/config.c @@ -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; } diff --git a/servers/slapd/back-sql/sql-wrap.c b/servers/slapd/back-sql/sql-wrap.c index 357d5cf42a..681da223ce 100644 --- a/servers/slapd/back-sql/sql-wrap.c +++ b/servers/slapd/back-sql/sql-wrap.c @@ -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,