Index: openacs-4/packages/acs-developer-support/tcl/acs-developer-support-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-developer-support/tcl/acs-developer-support-procs.tcl,v diff -u -r1.19 -r1.20 --- openacs-4/packages/acs-developer-support/tcl/acs-developer-support-procs.tcl 1 Nov 2003 09:28:25 -0000 1.19 +++ openacs-4/packages/acs-developer-support/tcl/acs-developer-support-procs.tcl 10 Nov 2003 13:11:00 -0000 1.20 @@ -181,37 +181,40 @@ ad_proc -private ds_collect_db_call { db command statement_name sql start_time errno error } { if { [ds_enabled_p] && [ds_collection_enabled_p] && [ds_database_enabled_p] } { - set bound_sql $sql + set bound_sql $sql - # It is very useful to be able to see the bind variable values displayed in the - # ds output. For postgresql we have a way of doing this with the proc db_bind_var_substitution - # but this proc does not work for Oracle - if { [string equal [db_type] "postgresql"] } { - upvar bind bind - set errno [catch { - if { [info exists bind] && [llength $bind] != 0 } { - if { [llength $bind] == 1 } { - set bind_vars [list] - set len [ns_set size $bind] - for {set i 0} {$i < $len} {incr i} { - lappend bind_vars [ns_set key $bind $i] \ - [ns_set value $bind $i] - } - set bound_sql [db_bind_var_substitution $sql $bind_vars] - } else { - set bound_sql [db_bind_var_substitution $sql $bind] - } - } else { - set bound_sql [uplevel 4 [list db_bind_var_substitution $sql]] - } - } error] + # It is very useful to be able to see the bind variable values displayed in the + # ds output. For postgresql we have a way of doing this with the proc db_bind_var_substitution + # but this proc does not work for Oracle + # JCD: don't bind if there was an error since this can potentially mess up the traceback + # making bugs much harder to track down + if { !$errno && [string equal [db_type] "postgresql"] } { + upvar bind bind + set errno [catch { + if { [info exists bind] && [llength $bind] != 0 } { + if { [llength $bind] == 1 } { + set bind_vars [list] + set len [ns_set size $bind] + for {set i 0} {$i < $len} {incr i} { + lappend bind_vars [ns_set key $bind $i] \ + [ns_set value $bind $i] + } + set bound_sql [db_bind_var_substitution $sql $bind_vars] + } else { + set bound_sql [db_bind_var_substitution $sql $bind] + } + } else { + set bound_sql [uplevel 4 [list db_bind_var_substitution $sql]] + } + } error] if { $errno } { - ns_log Error "ds_collect_db_call: $error" + ns_log Warning "ds_collect_db_call: $error" + set bound_sql $sql } - } - - ds_add db $db $command $statement_name $bound_sql $start_time [clock clicks] $errno $error + } + + ds_add db $db $command $statement_name $bound_sql $start_time [clock clicks] $errno $error } }