tdbc::odbc

Check-in [34a5e8496c]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2018 Conference, Houston/TX, US, Oct 15-19
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Aug 20.

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 Unified Diffs Ignore Whitespace Patch

Changes to generic/tdbcodbc.c.

3924
3925
3926
3927
3928
3929
3930
3931



3932



3933
3934
3935
3936
3937

3938
3939
3940
3941
3942
3943
3944

    /* Extract the column information for the result set. */

    if (GetResultSetDescription(interp, rdata) != TCL_OK) {
	return TCL_ERROR;
    }

    /* Determine and store the row count */







    rc = SQLRowCount(rdata->hStmt, &(rdata->rowCount));
    if (!SQL_SUCCEEDED(rc)) {
	TransferSQLError(interp, SQL_HANDLE_STMT, rdata->hStmt,
			 "(counting rows in the result)");
	return TCL_ERROR;

    }

    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------







|
>
>
>

>
>
>
|
|
|
|
|
>







3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951

    /* Extract the column information for the result set. */

    if (GetResultSetDescription(interp, rdata) != TCL_OK) {
	return TCL_ERROR;
    }

    /* Determine and store the row count. Note: iodbc makes it illegal
     * to call SQLRowCount after an operation has returned SQL_NO_DATA,
     * so bypass the SQLRowCount call if there are no results.
     */

    if (rc == SQL_NO_DATA) {
	rdata->rowCount = 0;
    } else {
	rc = SQLRowCount(rdata->hStmt, &(rdata->rowCount));
	if (!SQL_SUCCEEDED(rc)) {
	    TransferSQLError(interp, SQL_HANDLE_STMT, rdata->hStmt,
			     "(counting rows in the result)");
	    return TCL_ERROR;
	}
    }

    return TCL_OK;
}
 
/*
 *----------------------------------------------------------------------

Changes to tests/tdbcodbc.test.

128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
....
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
    -body {
	set status [catch {
	    tdbc::odbc::connection create db {DRIVER={rubbish}}
	} result]
	list $status $::errorCode
    }
    -match glob
    -result {1 {TDBC DRIVER_ERROR IM002 ODBC *}}
}


tcltest::testConstraint connect \
    [expr {[catch {tdbc::odbc::connection create ::db $::connStr}] == 0}]
catch {rename ::db {}}

................................................................................
    }
    -returnCodes error
    -match glob
    -result {bad isolation level "junk"*}
}

test tdbc::odbc-19.11a {$connection configure - -isolation} {*}{
    -constraints !win||!sqlite
    -body {
	list [::db configure -isolation readcommitted] \
	    [::db configure -isolation]
    }
    -result {{} readcommitted}
}
test tdbc::odbc-19.11b {$connection configure - -isolation} {*}{
    -constraints win&&sqlite
    -body {
	list [::db configure -isolation readcommitted] \
	    [::db configure -isolation]
    }
    -result {{} serializable}
}








|







 







|







|







128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
....
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
    -body {
	set status [catch {
	    tdbc::odbc::connection create db {DRIVER={rubbish}}
	} result]
	list $status $::errorCode
    }
    -match glob
    -result {1 *}
}


tcltest::testConstraint connect \
    [expr {[catch {tdbc::odbc::connection create ::db $::connStr}] == 0}]
catch {rename ::db {}}

................................................................................
    }
    -returnCodes error
    -match glob
    -result {bad isolation level "junk"*}
}

test tdbc::odbc-19.11a {$connection configure - -isolation} {*}{
    -constraints !sqlite
    -body {
	list [::db configure -isolation readcommitted] \
	    [::db configure -isolation]
    }
    -result {{} readcommitted}
}
test tdbc::odbc-19.11b {$connection configure - -isolation} {*}{
    -constraints sqlite
    -body {
	list [::db configure -isolation readcommitted] \
	    [::db configure -isolation]
    }
    -result {{} serializable}
}