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

« back to all changes in this revision

Viewing changes to DriverManager/SQLColAttributesW.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: SQLColAttributesW.c,v 1.3 2001/12/13 13:00:32 lurcher Exp $
 
30
 * $Id: SQLColAttributesW.c,v 1.8 2002/12/05 17:44:30 lurcher Exp $
31
31
 *
32
32
 * $Log: SQLColAttributesW.c,v $
 
33
 * Revision 1.8  2002/12/05 17:44:30  lurcher
 
34
 *
 
35
 * Display unknown return values in return logging
 
36
 *
 
37
 * Revision 1.7  2002/08/23 09:42:37  lurcher
 
38
 *
 
39
 * Fix some build warnings with casts, and a AIX linker mod, to include
 
40
 * deplib's on the link line, but not the libtool generated ones
 
41
 *
 
42
 * Revision 1.6  2002/08/19 09:11:49  lurcher
 
43
 *
 
44
 * Fix Maxor ineffiecny in Postgres Drivers, and fix a return state
 
45
 *
 
46
 * Revision 1.5  2002/07/24 08:49:51  lurcher
 
47
 *
 
48
 * Alter UNICODE support to use iconv for UNICODE-ANSI conversion
 
49
 *
 
50
 * Revision 1.4  2002/04/25 15:16:46  lurcher
 
51
 *
 
52
 * Fix bug with SQLCOlAttribute(s)(W) where a column of zero could not be
 
53
 * used to get the count value
 
54
 *
33
55
 * Revision 1.3  2001/12/13 13:00:32  lurcher
34
56
 *
35
57
 * Remove most if not all warnings on 64 bit platforms
120
142
    thread_protect( SQL_HANDLE_STMT, statement );
121
143
 
122
144
    if ( column_number == 0 &&
123
 
            statement -> bookmarks_on == SQL_UB_OFF && statement -> connection -> bookmarks_on == SQL_UB_OFF )
 
145
            statement -> bookmarks_on == SQL_UB_OFF && statement -> connection -> bookmarks_on == SQL_UB_OFF &&
 
146
            field_identifier != SQL_DESC_COUNT )
124
147
    {
125
148
        dm_log_write( __FILE__, 
126
149
                __LINE__, 
128
151
                LOG_INFO, 
129
152
                "Error: 07009" );
130
153
 
131
 
        __post_internal_error( &statement -> error,
 
154
        __post_internal_error_api( &statement -> error,
132
155
                ERROR_07009, NULL,
133
 
                statement -> connection -> environment -> requested_version );
 
156
                statement -> connection -> environment -> requested_version,
 
157
                SQL_API_SQLCOLATTRIBUTES );
134
158
 
135
159
        thread_release( SQL_HANDLE_STMT, statement );
136
160
 
309
333
        {
310
334
            if ( CHECK_SQLCOLATTRIBUTE( statement -> connection ))
311
335
            {
 
336
                SQLCHAR *as1;
 
337
 
312
338
                /*
313
339
                 * map to the ODBC3 function
314
340
                 */
315
341
 
316
342
                field_identifier = map_ca_odbc2_to_3( field_identifier );
317
343
 
 
344
                switch( field_identifier )
 
345
                {
 
346
                  case SQL_DESC_BASE_COLUMN_NAME:
 
347
                  case SQL_DESC_BASE_TABLE_NAME:
 
348
                  case SQL_DESC_CATALOG_NAME:
 
349
                  case SQL_DESC_LABEL:
 
350
                  case SQL_DESC_LITERAL_PREFIX:
 
351
                  case SQL_DESC_LITERAL_SUFFIX:
 
352
                  case SQL_DESC_LOCAL_TYPE_NAME:
 
353
                  case SQL_DESC_NAME:
 
354
                  case SQL_DESC_SCHEMA_NAME:
 
355
                  case SQL_DESC_TABLE_NAME:
 
356
                  case SQL_DESC_TYPE_NAME:
 
357
                  case SQL_COLUMN_NAME:
 
358
                    buffer_length = buffer_length / 2;
 
359
                    if ( buffer_length > 0 )
 
360
                    {
 
361
                        as1 = malloc( buffer_length + 1 );
 
362
                    }
 
363
                    break;
 
364
 
 
365
                  default:
 
366
                    break;
 
367
                }
 
368
 
318
369
                ret = SQLCOLATTRIBUTE( statement -> connection,
319
370
                    statement -> driver_stmt,
320
371
                    column_number,
321
372
                    field_identifier,
322
 
                    character_attribute,
 
373
                    as1 ? as1 : character_attribute,
323
374
                    buffer_length,
324
375
                    string_length,
325
376
                    numeric_attribute );
338
389
                  case SQL_DESC_TABLE_NAME:
339
390
                  case SQL_DESC_TYPE_NAME:
340
391
                  case SQL_COLUMN_NAME:
341
 
                    if ( SQL_SUCCEEDED( ret ) && character_attribute )
342
 
                    {
343
 
                        ansi_to_unicode_in_place( character_attribute, SQL_NTS );
 
392
                    if ( SQL_SUCCEEDED( ret ) && character_attribute && as1 )
 
393
                    {
 
394
                        ansi_to_unicode_copy( character_attribute, (char*) as1, SQL_NTS, statement -> connection );
 
395
                    }
 
396
 
 
397
                    if ( as1 ) 
 
398
                    {
 
399
                        free( as1 );
344
400
                    }
345
401
                    break;
346
402
 
367
423
        }
368
424
        else
369
425
        {
 
426
            SQLCHAR *as1;
 
427
 
 
428
            switch( field_identifier )
 
429
            {
 
430
              case SQL_DESC_BASE_COLUMN_NAME:
 
431
              case SQL_DESC_BASE_TABLE_NAME:
 
432
              case SQL_DESC_CATALOG_NAME:
 
433
              case SQL_DESC_LABEL:
 
434
              case SQL_DESC_LITERAL_PREFIX:
 
435
              case SQL_DESC_LITERAL_SUFFIX:
 
436
              case SQL_DESC_LOCAL_TYPE_NAME:
 
437
              case SQL_DESC_NAME:
 
438
              case SQL_DESC_SCHEMA_NAME:
 
439
              case SQL_DESC_TABLE_NAME:
 
440
              case SQL_DESC_TYPE_NAME:
 
441
              case SQL_COLUMN_NAME:
 
442
                buffer_length = buffer_length / 2;
 
443
                if ( buffer_length > 0 )
 
444
                {
 
445
                    as1 = malloc( buffer_length + 1 );
 
446
                }
 
447
                break;
 
448
                break;
 
449
 
 
450
              default:
 
451
                break;
 
452
            }
 
453
 
370
454
            ret = SQLCOLATTRIBUTES( statement -> connection,
371
455
                    statement -> driver_stmt,
372
456
                    column_number,
373
457
                    field_identifier,
374
 
                    character_attribute,
 
458
                    as1 ? as1 : character_attribute,
375
459
                    buffer_length,
376
460
                    string_length,
377
461
                    numeric_attribute );
390
474
              case SQL_DESC_TABLE_NAME:
391
475
              case SQL_DESC_TYPE_NAME:
392
476
              case SQL_COLUMN_NAME:
393
 
                if ( SQL_SUCCEEDED( ret ) && character_attribute )
394
 
                {
395
 
                    ansi_to_unicode_in_place( character_attribute, SQL_NTS );
 
477
                if ( SQL_SUCCEEDED( ret ) && character_attribute && as1 )
 
478
                {
 
479
                    ansi_to_unicode_copy( character_attribute, (char*) as1, SQL_NTS, statement -> connection );
 
480
                }
 
481
 
 
482
                if ( as1 ) 
 
483
                {
 
484
                    free( as1 );
396
485
                }
397
486
                break;
398
487
 
447
536
    {
448
537
        sprintf( statement -> msg, 
449
538
                "\n\t\tExit:[%s]",
450
 
                    __get_return_status( ret ));
 
539
                    __get_return_status( ret, s1 ));
451
540
 
452
541
        dm_log_write( __FILE__, 
453
542
                __LINE__,