28
28
**********************************************************************
30
* $Id: SQLEndTran.c,v 1.1.1.1 2001/10/17 16:40:05 lurcher Exp $
30
* $Id: SQLEndTran.c,v 1.6 2002/12/05 17:44:30 lurcher Exp $
32
32
* $Log: SQLEndTran.c,v $
33
* Revision 1.6 2002/12/05 17:44:30 lurcher
35
* Display unknown return values in return logging
37
* Revision 1.5 2002/09/18 14:49:32 lurcher
39
* DataManagerII additions and some more threading fixes
41
* Revision 1.3 2002/08/20 12:41:07 lurcher
43
* Fix incorrect return state from SQLEndTran/SQLTransact
45
* Revision 1.2 2002/08/12 16:20:44 lurcher
47
* Make it try and find a working iconv set of encodings
33
49
* Revision 1.1.1.1 2001/10/17 16:40:05 lurcher
35
51
* First upload to SourceForge
104
120
#include "drivermanager.h"
106
static char const rcsid[]= "$RCSfile: SQLEndTran.c,v $ $Revision: 1.1.1.1 $";
122
static char const rcsid[]= "$RCSfile: SQLEndTran.c,v $ $Revision: 1.6 $";
108
124
SQLRETURN SQLEndTran( SQLSMALLINT handle_type,
109
125
SQLHANDLE handle,
110
126
SQLSMALLINT completion_type )
128
SQLCHAR s1[ 100 + LOG_MESSAGE_LEN ];
112
130
if ( handle_type == SQL_HANDLE_ENV )
114
132
DMHENV environment = (DMHENV) handle;
369
387
return function_return( connection, SQL_ERROR );
390
if( SQL_SUCCEEDED(ret) )
393
SQLINTEGER stmt_remaining;
394
SQLSMALLINT cb_value;
395
SQLSMALLINT cb_value_length = sizeof(SQLSMALLINT);
399
* for each statement belonging to this connection set its state
400
* relative to the commit or rollback behavior
403
statement = __get_stmt_root();
404
stmt_remaining = connection -> statement_count;
406
/* release thread so we can get the info */
407
thread_release( SQL_HANDLE_DBC, connection );
409
if( completion_type == SQL_COMMIT )
411
ret1 = SQLGetInfo(connection,
412
SQL_CURSOR_COMMIT_BEHAVIOR,
417
else /*SQL_ROLLBACK*/
419
ret1 = SQLGetInfo(connection,
420
SQL_CURSOR_ROLLBACK_BEHAVIOR,
426
/* protect thread again */
427
thread_protect( SQL_HANDLE_DBC, connection );
429
if( SQL_SUCCEEDED( ret1 ) )
431
while ( statement && stmt_remaining > 0 )
433
if ( statement -> connection == connection )
435
if ( (statement -> state == STATE_S2 ||
436
statement -> state == STATE_S3) &&
437
cb_value == SQL_CB_DELETE )
439
statement -> state = STATE_S1;
440
statement -> prepared = 0;
442
else if ( statement -> state == STATE_S4 ||
443
statement -> state == STATE_S5 ||
444
statement -> state == STATE_S6 ||
445
statement -> state == STATE_S7 )
447
if( !statement -> prepared &&
448
(cb_value == SQL_CB_DELETE ||
449
cb_value == SQL_CB_CLOSE) )
451
statement -> state = STATE_S1;
453
else if( statement -> prepared )
455
if( cb_value == SQL_CB_DELETE )
457
statement -> state = STATE_S1;
458
statement -> prepared = 0;
460
else if( cb_value == SQL_CB_CLOSE )
462
if ( statement -> state == STATE_S4 )
463
statement -> state = STATE_S2;
465
statement -> state = STATE_S3;
473
statement = statement -> next_class_list;
372
478
if ( log_info.log_flag )
374
480
sprintf( connection -> msg,
375
481
"\n\t\tExit:[%s]",
376
__get_return_status( ret ));
482
__get_return_status( ret, s1 ));
378
484
dm_log_write( __FILE__,