(blind) addition of 'autocommit' configuration statement (ITS#6612)

This commit is contained in:
Pierangelo Masarati 2010-08-10 19:55:28 +00:00
parent 6ac38f9cc6
commit bca5e0ed1e
4 changed files with 40 additions and 1 deletions

View 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. 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. 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 .SH METAINFORMATION USED
.LP .LP
Almost everything mentioned later is illustrated in examples located Almost everything mentioned later is illustrated in examples located

View file

@ -517,6 +517,7 @@ typedef struct backsql_info {
#define BSQLF_FETCH_ALL_OPATTRS 0x0400 #define BSQLF_FETCH_ALL_OPATTRS 0x0400
#define BSQLF_FETCH_ALL_ATTRS (BSQLF_FETCH_ALL_USERATTRS|BSQLF_FETCH_ALL_OPATTRS) #define BSQLF_FETCH_ALL_ATTRS (BSQLF_FETCH_ALL_USERATTRS|BSQLF_FETCH_ALL_OPATTRS)
#define BSQLF_CHECK_SCHEMA 0x0800 #define BSQLF_CHECK_SCHEMA 0x0800
#define BSQLF_AUTOCOMMIT_ON 0x1000
#define BACKSQL_ISF(si, f) \ #define BACKSQL_ISF(si, f) \
(((si)->sql_flags & f) == f) (((si)->sql_flags & f) == f)
@ -549,6 +550,8 @@ typedef struct backsql_info {
BACKSQL_ISF(si, BSQLF_FETCH_ALL_ATTRS) BACKSQL_ISF(si, BSQLF_FETCH_ALL_ATTRS)
#define BACKSQL_CHECK_SCHEMA(si) \ #define BACKSQL_CHECK_SCHEMA(si) \
BACKSQL_ISF(si, BSQLF_CHECK_SCHEMA) BACKSQL_ISF(si, BSQLF_CHECK_SCHEMA)
#define BACKSQL_AUTOCOMMIT_ON(si) \
BACKSQL_ISF(si, BSQLF_AUTOCOMMIT_ON)
Entry *sql_baseObject; Entry *sql_baseObject;
#ifdef BACKSQL_ARBITRARY_KEY #ifdef BACKSQL_ARBITRARY_KEY

View file

@ -639,6 +639,37 @@ backsql_db_config(
ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_aliasing_quote ); 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 { } else {
return SLAP_CONF_UNKNOWN; return SLAP_CONF_UNKNOWN;
} }

View file

@ -424,7 +424,8 @@ backsql_open_db_handle(
* TimesTen : Turn off autocommit. We must explicitly * TimesTen : Turn off autocommit. We must explicitly
* commit any transactions. * 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, * See if this connection is to TimesTen. If it is,