tdbc::odbc

Check-in [34a5e8496c]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:Do not attempt to retrieve row count from an operation that returns SQL_NO_DATA. Tolerate any error message from attempting to open a database with an incorrect driver specified. Allow SQLite to return 'serializable' in place of 'readcommitted' on both Unix and Windows.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 34a5e8496ccee331c4eac5f84fe13510f1d8418db317f8765ddecea47b733d35
User & Date: kbk 2018-06-19 01:40:32
Context
2018-06-19
02:29
Be more permissive about SQL/CLI HY??? general errors in test cases - they aren't all HY010 on some ODBC implementations. check-in: 29da102373 user: kbk tags: trunk
01:40
Do not attempt to retrieve row count from an operation that returns SQL_NO_DATA. Tolerate any error message from attempting to open a database with an incorrect driver specified. Allow SQLite to return 'serializable' in place of 'readcommitted' on both Unix and Windows. check-in: 34a5e8496c user: kbk tags: trunk
2018-05-13
14:31
Put back initalization of "buf" (which was removed in previous commit), so Tcl_UniCharToUtf() can do proper collapsing of surrogates (See: tclUtf.c). See also TIP #389 check-in: e8009cbbf7 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to generic/tdbcodbc.c.

  3924   3924   
  3925   3925       /* Extract the column information for the result set. */
  3926   3926   
  3927   3927       if (GetResultSetDescription(interp, rdata) != TCL_OK) {
  3928   3928   	return TCL_ERROR;
  3929   3929       }
  3930   3930   
  3931         -    /* Determine and store the row count */
         3931  +    /* Determine and store the row count. Note: iodbc makes it illegal
         3932  +     * to call SQLRowCount after an operation has returned SQL_NO_DATA,
         3933  +     * so bypass the SQLRowCount call if there are no results.
         3934  +     */
  3932   3935   
  3933         -    rc = SQLRowCount(rdata->hStmt, &(rdata->rowCount));
  3934         -    if (!SQL_SUCCEEDED(rc)) {
  3935         -	TransferSQLError(interp, SQL_HANDLE_STMT, rdata->hStmt,
  3936         -			 "(counting rows in the result)");
  3937         -	return TCL_ERROR;
         3936  +    if (rc == SQL_NO_DATA) {
         3937  +	rdata->rowCount = 0;
         3938  +    } else {
         3939  +	rc = SQLRowCount(rdata->hStmt, &(rdata->rowCount));
         3940  +	if (!SQL_SUCCEEDED(rc)) {
         3941  +	    TransferSQLError(interp, SQL_HANDLE_STMT, rdata->hStmt,
         3942  +			     "(counting rows in the result)");
         3943  +	    return TCL_ERROR;
         3944  +	}
  3938   3945       }
  3939   3946   
  3940   3947       return TCL_OK;
  3941   3948   }
  3942   3949   
  3943   3950   /*
  3944   3951    *----------------------------------------------------------------------

Changes to tests/tdbcodbc.test.

   128    128       -body {
   129    129   	set status [catch {
   130    130   	    tdbc::odbc::connection create db {DRIVER={rubbish}}
   131    131   	} result]
   132    132   	list $status $::errorCode
   133    133       }
   134    134       -match glob
   135         -    -result {1 {TDBC DRIVER_ERROR IM002 ODBC *}}
          135  +    -result {1 *}
   136    136   }
   137    137   
   138    138   
   139    139   tcltest::testConstraint connect \
   140    140       [expr {[catch {tdbc::odbc::connection create ::db $::connStr}] == 0}]
   141    141   catch {rename ::db {}}
   142    142   
................................................................................
  2762   2762       }
  2763   2763       -returnCodes error
  2764   2764       -match glob
  2765   2765       -result {bad isolation level "junk"*}
  2766   2766   }
  2767   2767   
  2768   2768   test tdbc::odbc-19.11a {$connection configure - -isolation} {*}{
  2769         -    -constraints !win||!sqlite
         2769  +    -constraints !sqlite
  2770   2770       -body {
  2771   2771   	list [::db configure -isolation readcommitted] \
  2772   2772   	    [::db configure -isolation]
  2773   2773       }
  2774   2774       -result {{} readcommitted}
  2775   2775   }
  2776   2776   test tdbc::odbc-19.11b {$connection configure - -isolation} {*}{
  2777         -    -constraints win&&sqlite
         2777  +    -constraints sqlite
  2778   2778       -body {
  2779   2779   	list [::db configure -isolation readcommitted] \
  2780   2780   	    [::db configure -isolation]
  2781   2781       }
  2782   2782       -result {{} serializable}
  2783   2783   }
  2784   2784