sqllogictest
Check-in [4140649727]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:MSSQL doesn't like calling SQLGetData() twice on the same column for the same row.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 41406497278edae5bc365fa4e6d280ff2d9d99df
User & Date: shaneh 2008-12-02 05:32:00
Context
2008-12-02
13:35
In select2.test, changed coalesce(a,b,c,d,e) in conditions to coalesce(a,b,c,d,e)<>0 to work with MSSQL. check-in: 1cc2a5df15 user: shaneh tags: trunk
05:32
MSSQL doesn't like calling SQLGetData() twice on the same column for the same row. check-in: 4140649727 user: shaneh tags: trunk
04:57
Made the xQuery method of the odbc interface match the SQLite version more closely, honoring type information and formatting in the same manor. check-in: b5897694e8 user: shaneh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/slt_odbc3.c.

463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488

489
490

491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509




510

511
512
513
514
515
516
517
518
519
520
521




522

523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
  if( !rc ){
    /* Loop through the rows in the result-set */
    do {
      ret = SQLFetch(stmt);
      if( SQL_SUCCEEDED(ret) ){
        /* Loop through the columns */
        for(i = 1; !rc && (i <= columns); i++){
          SQLINTEGER indicator;
          ret = SQLGetData(stmt, 
                           i, 
                           SQL_C_CHAR,
                           NULL, 
                           0, 
                           &indicator);
          if( SQL_SUCCEEDED(ret) && (indicator == SQL_NULL_DATA) ){
            ODBC3_appendValue(&res, "NULL");
          } else {
            switch( zType[i-1] ){
              case 'T': {
                /* retrieve column data as a string */
                ret = SQLGetData(stmt, 
                                 i, 
                                 SQL_C_CHAR,
                                 zBuffer, 
                                 sizeof(zBuffer), 
                                 NULL);

                if( SQL_SUCCEEDED(ret) ){
                  char *z;

                  if( zBuffer[0]==0 ) strcpy(zBuffer, "(empty)");
                  ODBC3_appendValue(&res, zBuffer);
                  /* Convert non-printing and control characters to '@' */
                  z = res.azValue[res.nUsed-1];
                  while( *z ){
                    if( *z<' ' || *z>'~' ){ *z = '@'; }
                    z++;
                  }
                }
                break;
              }
              case 'I': {
                long int li = 0L;
                SQLGetData(stmt, 
                           i, 
                           SQL_C_SLONG,
                           &li, 
                           sizeof(li), 
                           NULL);




                sprintf(zBuffer, "%ld", li);

                ODBC3_appendValue(&res, zBuffer);
                break;
              }
              case 'R': {
                double r = 0.0f;
                SQLGetData(stmt, 
                           i, 
                           SQL_C_DOUBLE,
                           &r, 
                           sizeof(r), 
                           NULL);




                sprintf(zBuffer, "%.3f", r);

                ODBC3_appendValue(&res, zBuffer);
                break;
              }
              default: {
                fprintf(stderr, "Unknown character in type-string: %c\n", zType[i-1]);
                rc = 1;
              }
            } /* end switch */
          }
        } /* end for i */
      }
    } while( !rc && SQL_SUCCEEDED(ret) );
  }
  
  if( stmt != SQL_NULL_HSTMT ){
    SQLFreeHandle(SQL_HANDLE_STMT, stmt);







|
<
<
<
<
<
<
<
<
<
|
|
|
|
|
|
|
|
<
>
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
>
>
>
>

>
|
|
|
|
|
|
|
|
|
|
<
>
>
>
>

>
|
|
|
|
|
|
|
|
<







463
464
465
466
467
468
469
470









471
472
473
474
475
476
477
478

479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500

501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516

517
518
519
520
521
522
523
524
525
526
527
528
529
530

531
532
533
534
535
536
537
  if( !rc ){
    /* Loop through the rows in the result-set */
    do {
      ret = SQLFetch(stmt);
      if( SQL_SUCCEEDED(ret) ){
        /* Loop through the columns */
        for(i = 1; !rc && (i <= columns); i++){
          SQLINTEGER indicator = 0;









          switch( zType[i-1] ){
            case 'T': {
              /* retrieve column data as a string */
              ret = SQLGetData(stmt, 
                               i, 
                               SQL_C_CHAR,
                               zBuffer, 
                               sizeof(zBuffer), 

                               &indicator);
              if( SQL_SUCCEEDED(ret) ){
                char *z;
                if( indicator == SQL_NULL_DATA ) strcpy(zBuffer, "NULL");
                if( zBuffer[0]==0 ) strcpy(zBuffer, "(empty)");
                ODBC3_appendValue(&res, zBuffer);
                /* Convert non-printing and control characters to '@' */
                z = res.azValue[res.nUsed-1];
                while( *z ){
                  if( *z<' ' || *z>'~' ){ *z = '@'; }
                  z++;
                }
              }
              break;
            }
            case 'I': {
              long int li = 0L;
              SQLGetData(stmt, 
                         i, 
                         SQL_C_SLONG,
                         &li, 
                         sizeof(li), 

                         &indicator);
              if( indicator == SQL_NULL_DATA ){
                strcpy(zBuffer, "NULL");
              }else{
                sprintf(zBuffer, "%ld", li);
              }
              ODBC3_appendValue(&res, zBuffer);
              break;
            }
            case 'R': {
              double r = 0.0f;
              SQLGetData(stmt, 
                         i, 
                         SQL_C_DOUBLE,
                         &r, 
                         sizeof(r), 

                         &indicator);
              if( indicator == SQL_NULL_DATA ){
                strcpy(zBuffer, "NULL");
              }else{
                sprintf(zBuffer, "%.3f", r);
              }
              ODBC3_appendValue(&res, zBuffer);
              break;
            }
            default: {
              fprintf(stderr, "Unknown character in type-string: %c\n", zType[i-1]);
              rc = 1;
            }
          } /* end switch */

        } /* end for i */
      }
    } while( !rc && SQL_SUCCEEDED(ret) );
  }
  
  if( stmt != SQL_NULL_HSTMT ){
    SQLFreeHandle(SQL_HANDLE_STMT, stmt);