diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2014-05-08 10:43:48 -0400 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2014-05-08 10:44:58 -0400 |
commit | 770a60b121c80a95b552c2698b11c5d52aa458ed (patch) | |
tree | 165307c737017772883ed3c48f96e37d62df8558 /libBasicTableOperations.tcl | |
parent | c1f8b1e82b4c690734d7f2fed604f9cf1e93c445 (diff) | |
download | GradeBook-770a60b121c80a95b552c2698b11c5d52aa458ed.tar.gz GradeBook-770a60b121c80a95b552c2698b11c5d52aa458ed.zip |
reworked transaction start/end logic now it is not closing if someone else wanted it started
Diffstat (limited to 'libBasicTableOperations.tcl')
-rwxr-xr-x | libBasicTableOperations.tcl | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/libBasicTableOperations.tcl b/libBasicTableOperations.tcl index 04c6d00..70b8dab 100755 --- a/libBasicTableOperations.tcl +++ b/libBasicTableOperations.tcl @@ -110,11 +110,12 @@ proc DeleteColumnFromTable { table columnname } { } } -set isDbTransactionActive false +set beginTransactionCounter 0 proc begin_db_transaction { } { - global isDbTransactionActive - if { !$isDbTransactionActive } { - set isDbTransactionActive true + global beginTransactionCounter + incr beginTransactionCounter + if { $beginTransactionCounter == 1 } { + # starting transaction set eval_str [concat BEGIN TRANSACTION] set err [catch {db eval $eval_str } errStat] if { $err } { @@ -125,16 +126,16 @@ proc begin_db_transaction { } { } proc end_db_transaction { } { - global isDbTransactionActive - if { $isDbTransactionActive } { - set isDbTransactionActive false - set eval_str [concat END TRANSACTION] - set err [catch {db eval $eval_str } errStat] - if { $err } { - htmlErrorMsg $errStat end_db_transaction - dbg "the following error happen: $errStat" msg_level_critical begin_db_transaction - } - } + global beginTransactionCounter + incr beginTransactionCounter -1 + if { $beginTransactionCounter > 0 } return; + # closing transaction + set eval_str [concat END TRANSACTION] + set err [catch {db eval $eval_str } errStat] + if { $err } { + htmlErrorMsg $errStat end_db_transaction + dbg "the following error happen: $errStat" msg_level_critical begin_db_transaction + } } |