~ubuntu-branches/debian/sid/unixodbc/sid

« back to all changes in this revision

Viewing changes to DriverManager/SQLEndTran.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2004-10-15 03:07:52 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041015030752-dzw4vhxlgycz3woj
Tags: 2.2.4-11
Brown paper bag me: conflicts do not write themselves just because
you add a line to the changelog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 *
28
28
 **********************************************************************
29
29
 *
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 $
31
31
 *
32
32
 * $Log: SQLEndTran.c,v $
 
33
 * Revision 1.6  2002/12/05 17:44:30  lurcher
 
34
 *
 
35
 * Display unknown return values in return logging
 
36
 *
 
37
 * Revision 1.5  2002/09/18 14:49:32  lurcher
 
38
 *
 
39
 * DataManagerII additions and some more threading fixes
 
40
 *
 
41
 * Revision 1.3  2002/08/20 12:41:07  lurcher
 
42
 *
 
43
 * Fix incorrect return state from SQLEndTran/SQLTransact
 
44
 *
 
45
 * Revision 1.2  2002/08/12 16:20:44  lurcher
 
46
 *
 
47
 * Make it try and find a working iconv set of encodings
 
48
 *
33
49
 * Revision 1.1.1.1  2001/10/17 16:40:05  lurcher
34
50
 *
35
51
 * First upload to SourceForge
103
119
 
104
120
#include "drivermanager.h"
105
121
 
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 $";
107
123
 
108
124
SQLRETURN SQLEndTran( SQLSMALLINT handle_type,
109
125
        SQLHANDLE handle,
110
126
        SQLSMALLINT completion_type )
111
127
{
 
128
    SQLCHAR s1[ 100 + LOG_MESSAGE_LEN ];
 
129
 
112
130
    if ( handle_type == SQL_HANDLE_ENV )
113
131
    {
114
132
        DMHENV environment = (DMHENV) handle;
169
187
                    __LINE__, 
170
188
                    LOG_INFO, 
171
189
                    LOG_INFO, 
172
 
                    "Error: HY092" );
 
190
                    "Error: HY012" );
173
191
 
174
192
            __post_internal_error( &environment -> error,
175
 
                    ERROR_HY092, NULL,
 
193
                    ERROR_HY012, NULL,
176
194
                    environment -> requested_version );
177
195
 
178
196
            thread_release( SQL_HANDLE_ENV, environment );
262
280
 
263
281
        sprintf( environment -> msg, 
264
282
                "\n\t\tExit:[%s]",
265
 
                    __get_return_status( SQL_SUCCESS ));
 
283
                    __get_return_status( SQL_SUCCESS, s1 ));
266
284
 
267
285
        dm_log_write( __FILE__, 
268
286
                __LINE__, 
327
345
                    __LINE__, 
328
346
                    LOG_INFO, 
329
347
                    LOG_INFO, 
330
 
                    "Error: HY092" );
 
348
                    "Error: HY012" );
331
349
 
332
350
            __post_internal_error( &connection -> error,
333
 
                    ERROR_HY092, NULL,
 
351
                    ERROR_HY012, NULL,
334
352
                    connection -> environment -> requested_version );
335
353
 
336
354
            thread_release( SQL_HANDLE_DBC, connection );
369
387
            return function_return( connection, SQL_ERROR );
370
388
        }
371
389
 
 
390
            if( SQL_SUCCEEDED(ret) )
 
391
            {
 
392
            DMHSTMT statement;
 
393
            SQLINTEGER stmt_remaining;
 
394
            SQLSMALLINT cb_value;
 
395
            SQLSMALLINT cb_value_length = sizeof(SQLSMALLINT);
 
396
            SQLRETURN ret1;
 
397
            
 
398
            /*
 
399
             * for each statement belonging to this connection set its state 
 
400
             * relative to the commit or rollback behavior
 
401
             */
 
402
            
 
403
            statement = __get_stmt_root();
 
404
            stmt_remaining = connection -> statement_count;
 
405
            
 
406
            /* release thread so we can get the info */
 
407
            thread_release( SQL_HANDLE_DBC, connection );
 
408
            
 
409
            if( completion_type == SQL_COMMIT )
 
410
            {
 
411
                ret1 = SQLGetInfo(connection, 
 
412
                      SQL_CURSOR_COMMIT_BEHAVIOR, 
 
413
                      &cb_value, 
 
414
                      cb_value_length*4,
 
415
                      &cb_value_length);
 
416
            }
 
417
            else         /*SQL_ROLLBACK*/
 
418
            {
 
419
                ret1 = SQLGetInfo(connection, 
 
420
                      SQL_CURSOR_ROLLBACK_BEHAVIOR,
 
421
                      &cb_value, 
 
422
                      cb_value_length*4, 
 
423
                      &cb_value_length);
 
424
            }
 
425
            
 
426
            /* protect thread again */
 
427
            thread_protect( SQL_HANDLE_DBC, connection );
 
428
            
 
429
            if( SQL_SUCCEEDED( ret1 ) )
 
430
            {
 
431
                while ( statement && stmt_remaining > 0 )
 
432
                {
 
433
                    if ( statement -> connection == connection )
 
434
                    {
 
435
                        if ( (statement -> state == STATE_S2 ||
 
436
                              statement -> state == STATE_S3) &&
 
437
                             cb_value == SQL_CB_DELETE )
 
438
                        {
 
439
                            statement -> state = STATE_S1;
 
440
                            statement -> prepared = 0;
 
441
                        }
 
442
                        else if ( statement -> state == STATE_S4 ||
 
443
                              statement -> state == STATE_S5 ||
 
444
                              statement -> state == STATE_S6 ||
 
445
                              statement -> state == STATE_S7 )
 
446
                        {
 
447
                            if( !statement -> prepared && 
 
448
                                (cb_value == SQL_CB_DELETE ||
 
449
                                 cb_value == SQL_CB_CLOSE) )
 
450
                            {
 
451
                                statement -> state = STATE_S1;
 
452
                            }
 
453
                            else if( statement -> prepared )
 
454
                            {
 
455
                                if( cb_value == SQL_CB_DELETE )
 
456
                                {
 
457
                                    statement -> state = STATE_S1;
 
458
                                    statement -> prepared = 0;
 
459
                                }
 
460
                                else if( cb_value == SQL_CB_CLOSE )
 
461
                                {
 
462
                                    if ( statement -> state == STATE_S4 )
 
463
                                      statement -> state = STATE_S2;
 
464
                                    else
 
465
                                      statement -> state = STATE_S3;
 
466
                                }
 
467
                            }
 
468
                        }
 
469
 
 
470
                        stmt_remaining --;
 
471
                    }
 
472
 
 
473
                    statement = statement -> next_class_list;
 
474
                }
 
475
            }
 
476
        }
 
477
 
372
478
        if ( log_info.log_flag )
373
479
        {
374
480
            sprintf( connection -> msg, 
375
481
                    "\n\t\tExit:[%s]",
376
 
                        __get_return_status( ret ));
 
482
                        __get_return_status( ret, s1 ));
377
483
 
378
484
            dm_log_write( __FILE__, 
379
485
                    __LINE__,