Index: openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/00-database-procs.tcl,v diff -u -r1.103 -r1.104 --- openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl 3 Jul 2018 17:58:48 -0000 1.103 +++ openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl 4 Jul 2018 13:10:14 -0000 1.104 @@ -2148,6 +2148,15 @@ } } +if {[info commands ns_cache_transaction_begin] eq ""} { + # + # When the server has no support for ns_cache_transaction_*, + # provide dummy procs to avoid runtime "if" statements. + # + proc ns_cache_transaction_begin args {;} + proc ns_cache_transaction_commit args {;} + proc ns_cache_transaction_rollback args {;} +} ad_proc -public db_transaction {{ -dbn ""} transaction_code args } { Usage: db_transaction transaction_code [ on_error { error_code_block } ] @@ -2218,6 +2227,7 @@ set level [incr db_state(transaction_level,$dbh)] if { $level == 1 } { ns_db dml $dbh "begin transaction" + ns_cache_transaction_begin } } # Execute the transaction code. @@ -2237,6 +2247,7 @@ 3 { # TCL_BREAK - Abort the transaction and do the break. ns_db dml $dbh "abort transaction" + ns_cache_transaction_rollback db_release_unused_handles -dbn $dbn break } @@ -2277,7 +2288,9 @@ # useful than simply punting ... ns_db dml $dbh "abort transaction" + ns_cache_transaction_rollback ns_db dml $dbh "begin transaction" + ns_cache_transaction_begin } @@ -2300,6 +2313,7 @@ 3 { # TCL_BREAK ns_db dml $dbh "abort transaction" + ns_cache_transaction_rollback db_release_unused_handles break } @@ -2318,6 +2332,7 @@ # We're at the top level, so we abort the transaction. set db_state(db_abort_p,$dbh) 0 ns_db dml $dbh "abort transaction" + ns_cache_transaction_rollback } # We throw this error because it was thrown from the error handling code that the programmer must fix. error $on_errmsg $::errorInfo $::errorCode @@ -2328,6 +2343,7 @@ if { $level == 1 } { set db_state(db_abort_p,$dbh) 0 ns_db dml $dbh "abort transaction" + ns_cache_transaction_rollback # We still have the transaction generated error. We don't want to throw it, so we log it. ns_log Error "Aborting transaction due to error:\n$errmsg" } else { @@ -2339,6 +2355,7 @@ # Otherwise, we continue on through the lower transaction levels. if { $level == 1} { ns_db dml $dbh "end transaction" + ns_cache_transaction_commit } } } @@ -2347,6 +2364,7 @@ if { $level == 1 } { set db_state(db_abort_p,$dbh) 0 ns_db dml $dbh "abort transaction" + ns_cache_transaction_rollback error "Transaction aborted: $errmsg" $::errorInfo $::errorCode } else { db_abort_transaction -dbn $dbn @@ -2360,10 +2378,12 @@ if { $level == 1 } { set db_state(db_abort_p,$dbh) 0 ns_db dml $dbh "abort transaction" + ns_cache_transaction_rollback } } elseif { $level == 1 } { # Success! No errors and no requested abort. Commit. ns_db dml $dbh "end transaction" + ns_cache_transaction_commit } } } Index: openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl,v diff -u -r1.49 -r1.50 --- openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 26 Jun 2018 12:09:00 -0000 1.49 +++ openacs-4/packages/acs-tcl/tcl/test/acs-tcl-test-procs.tcl 4 Jul 2018 13:10:14 -0000 1.50 @@ -514,7 +514,7 @@ aa_equals "Test we can insert a row in a db_transaction clause" \ - [db_transaction {db_dml test1 {insert into tmp_db_transaction_test(a,b) values (1,2)}}] "" + [catch {db_transaction {db_dml test1 {insert into tmp_db_transaction_test(a,b) values (1,2)}}}] 0 aa_equals "Verify clean insert worked" \ [db_string check1 {select a from tmp_db_transaction_test} -default missing] 1