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

« back to all changes in this revision

Viewing changes to DriverManager/SQLTransact.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: SQLTransact.c,v 1.1.1.1 2001/10/17 16:40:07 lurcher Exp $
 
30
 * $Id: SQLTransact.c,v 1.6 2002/12/05 17:44:31 lurcher Exp $
31
31
 *
32
32
 * $Log: SQLTransact.c,v $
 
33
 * Revision 1.6  2002/12/05 17:44:31  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:07  lurcher
34
50
 *
35
51
 * First upload to SourceForge
107
123
 
108
124
#include "drivermanager.h"
109
125
 
110
 
static char const rcsid[]= "$RCSfile: SQLTransact.c,v $ $Revision: 1.1.1.1 $";
 
126
static char const rcsid[]= "$RCSfile: SQLTransact.c,v $ $Revision: 1.6 $";
111
127
 
112
128
SQLRETURN SQLTransact( SQLHENV environment_handle,
113
129
           SQLHDBC connection_handle,
114
130
           SQLUSMALLINT completion_type )
115
131
{
 
132
    SQLCHAR s1[ 100 + LOG_MESSAGE_LEN ];
 
133
 
116
134
    if ( connection_handle != SQL_NULL_HDBC )
117
135
    {
118
136
        DMHDBC connection = (DMHDBC) connection_handle;
176
194
                    __LINE__, 
177
195
                    LOG_INFO, 
178
196
                    LOG_INFO, 
179
 
                    "Error: HY092" );
 
197
                    "Error: HY012" );
180
198
 
181
199
            __post_internal_error( &connection -> error,
182
 
                    ERROR_HY092, NULL,
 
200
                    ERROR_HY012, NULL,
183
201
                    connection -> environment -> requested_version );
184
202
 
185
203
            thread_release( SQL_HANDLE_DBC, connection );
218
236
            return function_return( connection, SQL_ERROR );
219
237
        }
220
238
 
 
239
        if( SQL_SUCCEEDED(ret) )
 
240
        {
 
241
            DMHSTMT statement;
 
242
            SQLINTEGER stmt_remaining;
 
243
            SQLSMALLINT cb_value;
 
244
            SQLSMALLINT cb_value_length = sizeof(SQLSMALLINT);
 
245
            SQLRETURN ret1;
 
246
            
 
247
            /*
 
248
             * for each statement belonging to this connection set its state 
 
249
             * relative to the commit or rollback behavior
 
250
             */
 
251
            
 
252
            statement = __get_stmt_root();
 
253
            stmt_remaining = connection -> statement_count;
 
254
            
 
255
            /* release thread so we can get the info */
 
256
            thread_release( SQL_HANDLE_DBC, connection );
 
257
            
 
258
            if( completion_type == SQL_COMMIT )
 
259
            {
 
260
                ret1 = SQLGetInfo(connection, 
 
261
                      SQL_CURSOR_COMMIT_BEHAVIOR, 
 
262
                      &cb_value, 
 
263
                      cb_value_length,
 
264
                      &cb_value_length);
 
265
            }
 
266
            else         /*SQL_ROLLBACK*/
 
267
            {
 
268
                ret1 = SQLGetInfo(connection, 
 
269
                      SQL_CURSOR_ROLLBACK_BEHAVIOR,
 
270
                      &cb_value, 
 
271
                      cb_value_length, 
 
272
                      &cb_value_length);
 
273
            }
 
274
            
 
275
            /* protect thread again */
 
276
            thread_protect( SQL_HANDLE_DBC, connection );
 
277
            
 
278
            if( SQL_SUCCEEDED( ret1 ) )
 
279
            {
 
280
                while ( statement && stmt_remaining > 0 )
 
281
                {
 
282
                    if ( statement -> connection == connection )
 
283
                    {
 
284
                        if ( (statement -> state == STATE_S2 ||
 
285
                              statement -> state == STATE_S3) &&
 
286
                             cb_value == SQL_CB_DELETE )
 
287
                        {
 
288
                            statement -> state = STATE_S1;
 
289
                            statement -> prepared = 0;
 
290
                        }
 
291
                        else if ( statement -> state == STATE_S4 ||
 
292
                              statement -> state == STATE_S5 ||
 
293
                              statement -> state == STATE_S6 ||
 
294
                              statement -> state == STATE_S7 )
 
295
                        {
 
296
                            if( !statement -> prepared && 
 
297
                                (cb_value == SQL_CB_DELETE ||
 
298
                                 cb_value == SQL_CB_CLOSE) )
 
299
                            {
 
300
                                statement -> state = STATE_S1;
 
301
                            }
 
302
                            else if( statement -> prepared )
 
303
                            {
 
304
                                if( cb_value == SQL_CB_DELETE )
 
305
                                {
 
306
                                    statement -> state = STATE_S1;
 
307
                                    statement -> prepared = 0;
 
308
                                }
 
309
                                else if( cb_value == SQL_CB_CLOSE )
 
310
                                {
 
311
                                    if ( statement -> state == STATE_S4 )
 
312
                                      statement -> state = STATE_S2;
 
313
                                    else
 
314
                                      statement -> state = STATE_S3;
 
315
                                }
 
316
                            }
 
317
                        }
 
318
                        stmt_remaining --;
 
319
                    }
 
320
                    statement = statement -> next_class_list;
 
321
                }
 
322
            }
 
323
        }
 
324
 
221
325
        if ( log_info.log_flag )
222
326
        {
223
327
            sprintf( connection -> msg, 
224
328
                    "\n\t\tExit:[%s]",
225
 
                        __get_return_status( ret ));
 
329
                        __get_return_status( ret, s1 ));
226
330
 
227
331
            dm_log_write( __FILE__, 
228
332
                    __LINE__, 
297
401
                    __LINE__, 
298
402
                    LOG_INFO, 
299
403
                    LOG_INFO, 
300
 
                    "Error: HY092" );
 
404
                    "Error: HY012" );
301
405
 
302
406
            __post_internal_error( &environment -> error,
303
 
                    ERROR_HY092, NULL,
 
407
                    ERROR_HY012, NULL,
304
408
                    environment -> requested_version );
305
409
 
306
410
            thread_release( SQL_HANDLE_ENV, environment );
392
496
        {
393
497
            sprintf( environment -> msg, 
394
498
                    "\n\t\tExit:[%s]",
395
 
                        __get_return_status( SQL_SUCCESS ));
 
499
                        __get_return_status( SQL_SUCCESS, s1 ));
396
500
 
397
501
            dm_log_write( __FILE__, 
398
502
                    __LINE__,