Index: openacs-4/packages/acs-bootstrap-installer/tcl/40-db-query-dispatcher-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-bootstrap-installer/tcl/40-db-query-dispatcher-procs.tcl,v diff -u -r1.21 -r1.22 --- openacs-4/packages/acs-bootstrap-installer/tcl/40-db-query-dispatcher-procs.tcl 17 Sep 2001 01:02:09 -0000 1.21 +++ openacs-4/packages/acs-bootstrap-installer/tcl/40-db-query-dispatcher-procs.tcl 20 Nov 2001 02:04:50 -0000 1.22 @@ -35,8 +35,8 @@ } proc db_rdbms_compatible_p {rdbms_test rdbms_pattern} { - db_qd_log Notice "The RDBMS_TEST is [db_rdbms_get_type $rdbms_test] - [db_rdbms_get_version $rdbms_test]" - db_qd_log Notice "The RDBMS_PATTERN is [db_rdbms_get_type $rdbms_pattern] - [db_rdbms_get_version $rdbms_pattern]" + db_qd_log Debug "The RDBMS_TEST is [db_rdbms_get_type $rdbms_test] - [db_rdbms_get_version $rdbms_test]" + db_qd_log Debug "The RDBMS_PATTERN is [db_rdbms_get_type $rdbms_pattern] - [db_rdbms_get_version $rdbms_pattern]" # If the pattern is for all RDBMS, then yeah, compatible if {[empty_string_p [db_rdbms_get_type $rdbms_test]]} { @@ -45,7 +45,7 @@ # If the RDBMS types are not the same, we have a problem if {[db_rdbms_get_type $rdbms_test] != [db_rdbms_get_type $rdbms_pattern]} { - db_qd_log Notice "compatibility - RDBMS types are different!" + db_qd_log Debug "compatibility - RDBMS types are different!" return 0 } @@ -60,7 +60,7 @@ return 1 } - db_qd_log Notice "compatibility - version numbers are bad!" + db_qd_log Debug "compatibility - version numbers are bad!" return 0 } @@ -146,7 +146,9 @@ # A procedure that is called from the outside world (APM) # to load a particular file proc db_qd_load_query_file {file_path} { - db_qd_internal_load_cache $file_path + if { [catch {db_qd_internal_load_cache $file_path} errmsg] } { + db_qd_log Error "Error parsing queryfile $file_path:\n\n$errmsg" + } } # Find the fully qualified name of the query @@ -168,7 +170,7 @@ # If util_memoize, we have to go back up one in the stack if {[lindex $proc_name 0] == "util_memoize"} { - db_qd_log Notice "util_memoize! going up one level" + db_qd_log Debug "util_memoize! going up one level" set proc_name [info level [expr "-2 - $added_stack_num"]] } @@ -182,12 +184,12 @@ # TEST for {set i 0} {$i < 6} {incr i} { - if {[catch {db_qd_log Notice "LEVEL=$i= [info level [expr "-1 - $i"]]"} errmsg]} {} + if {[catch {db_qd_log Debug "LEVEL=$i= [info level [expr "-1 - $i"]]"} errmsg]} {} } # Check the ad_conn stuff if {[ns_conn isconnected]} { - if {[catch {db_qd_log Notice "the ad_conn file is [ad_conn file]"} errmsg]} {} + if {[catch {db_qd_log Debug "the ad_conn file is [ad_conn file]"} errmsg]} {} } # Now we do a check to see if this is a directly accessed URL or a @@ -201,21 +203,21 @@ switch $proc_name { ns_sourceproc { - db_qd_log Notice "We are in a WWW page, woohoo!" + db_qd_log Debug "We are in a WWW page, woohoo!" set real_url_p 1 set url [ns_conn url] } rp_handle_tcl_request { - db_qd_log Notice "We are in a VUH page sourced by rp_handle_tcl_request, woohoo!" + db_qd_log Debug "We are in a VUH page sourced by rp_handle_tcl_request, woohoo!" set real_url_p 0 regsub {\.vuh} [ad_conn file] {} url set url [ad_make_relative_path $url] regsub {^/?packages} $url {} url } default { - db_qd_log Notice "We are in a WWW page sourced by apm_source, woohoo!" + db_qd_log Debug "We are in a WWW page sourced by apm_source, woohoo!" set real_url_p 0 set url [lindex $proc_name 1] set url [ad_make_relative_path $url] @@ -235,7 +237,7 @@ # We insert the "www" after the package key regexp {^([^\.]*)(.*)} $url all package_key rest - db_qd_log Notice "package key is $package_key and rest is $rest" + db_qd_log Debug "package key is $package_key and rest is $rest" if {$real_url_p} { set full_name [db_qd_make_absolute_path "${package_key}.www${rest}." $local_name] @@ -255,14 +257,14 @@ # (Openacs - DanW) set calling_namespace [string range [uplevel [expr 1 + $added_stack_num] {namespace current}] 2 end] - db_qd_log Notice "calling namespace = $calling_namespace" + db_qd_log Debug "calling namespace = $calling_namespace" if {![string equal $calling_namespace ""] && ![regexp {::} $proc_name all]} { set proc_name ${calling_namespace}::${proc_name} } - db_qd_log Notice "proc_name is -$proc_name-" + db_qd_log Debug "proc_name is -$proc_name-" # We use the ad_proc construct!! # (woohoo, can't believe that was actually useful!) @@ -271,14 +273,14 @@ # probably dealing with one of the bootstrap procs, and so we just # return a bogus proc name if {![nsv_exists api_proc_doc $proc_name]} { - db_qd_log Notice "there is no documented proc with name $proc_name -- we used default SQL" + db_qd_log Debug "there is no documented proc with name $proc_name -- we used default SQL" return [db_qd_null_path] } array set doc_elements [nsv_get api_proc_doc $proc_name] set url $doc_elements(script) - db_qd_log Notice "tcl file is $url" + db_qd_log Debug "tcl file is $url" regsub {.tcl$} $url {} url @@ -290,14 +292,14 @@ # We need to remove packages. regexp {^packages\.(.*)} $url all rest - db_qd_log Notice "TEMP - QD: proc_name is $proc_name" - db_qd_log Notice "TEMP - QD: local_name is $local_name" + db_qd_log Debug "TEMP - QD: proc_name is $proc_name" + db_qd_log Debug "TEMP - QD: local_name is $local_name" # set full_name "acs.$rest.${proc_name}.${local_name}" set full_name [db_qd_make_absolute_path "${rest}.${proc_name}." $local_name] } - db_qd_log Notice "generated fullname of $full_name" + db_qd_log Debug "generated fullname of $full_name" return $full_name } @@ -319,7 +321,7 @@ if {![empty_string_p $fullquery]} { set sql [db_fullquery_get_querytext $fullquery] } else { - db_qd_log Notice "NO FULLQUERY FOR $statement_name --> using default SQL" + db_qd_log Debug "NO FULLQUERY FOR $statement_name --> using default SQL" } return $sql @@ -332,7 +334,7 @@ set fullquery [db_qd_fetch $fullname] set sql [db_fullquery_get_querytext $fullquery] - db_qd_log Notice "PARTIALQUERY FOR $fullname: $sql" + db_qd_log Debug "PARTIALQUERY FOR $fullname: $sql" return [uplevel 1 [list subst -nobackslashes $sql]] } @@ -373,7 +375,7 @@ # we're going to assume smaller files for now. Plus, this doesn't happen # often. - db_qd_log Notice "Loading $file_tag" + db_qd_log Debug "Loading $file_tag" # Read entire contents set whole_file [read $file_pointer] @@ -384,18 +386,18 @@ # Iterate and parse out each query set parsing_state [db_qd_internal_parse_init $whole_file $file_tag] - db_qd_log Notice "parsing state - $parsing_state" + db_qd_log Debug "parsing state - $parsing_state" # We need this for queries with relative paths set acs_file_path [ad_make_relative_path $file_tag] set queryname_root [db_qd_internal_get_queryname_root $acs_file_path] - db_qd_log Notice "queryname root is $queryname_root" + db_qd_log Debug "queryname root is $queryname_root" while {1} { set result [db_qd_internal_parse_one_query $parsing_state] - db_qd_log Notice "one parse result -$result-" + db_qd_log Debug "one parse result -$result-" # If we get the empty string, we are done parsing if {$result == ""} { @@ -405,7 +407,7 @@ set one_query [lindex $result 0] set parsing_state [lindex $result 1] - db_qd_log Notice "loaded one query - [db_fullquery_get_name $one_query]" + db_qd_log Debug "loaded one query - [db_fullquery_get_name $one_query]" # Relative Path for the Query if {[db_qd_relative_path_p [db_fullquery_get_name $one_query]]} { @@ -421,7 +423,7 @@ set one_query $new_fullquery - db_qd_log Notice "relative path, replaced name with $new_name" + db_qd_log Debug "relative path, replaced name with $new_name" } # Store the query @@ -451,7 +453,7 @@ } # See if we have the correct location for this query - db_qd_log Notice "query $fullquery_name from [db_fullquery_get_load_location $fullquery_array]" + db_qd_log Debug "query $fullquery_name from [db_fullquery_get_load_location $fullquery_array]" # reload the fullquery set fullquery_array [nsv_get OACS_FULLQUERIES $fullquery_name] @@ -467,13 +469,13 @@ # Check if it's compatible at all! if {![db_rdbms_compatible_p [db_fullquery_get_rdbms $fullquery] [db_current_rdbms]]} { - db_qd_log Notice "Query [db_fullquery_get_name $fullquery] is *NOT* compatible" + db_qd_log Debug "Query [db_fullquery_get_name $fullquery] is *NOT* compatible" return } set name [db_fullquery_get_name $fullquery] - db_qd_log Notice "Query $name is compatible! fullquery = $fullquery, name = $name" + db_qd_log Debug "Query $name is compatible! fullquery = $fullquery, name = $name" # If we already have a query for that name, we need to # figure out which one is *most* compatible. @@ -546,7 +548,7 @@ # Check that it's a queryset if {[xml_node_get_name $root_node] != "queryset"} { - db_qd_log Notice "OH OH, error, first node is [xml_node_get_name $root_node]" + db_qd_log Debug "OH OH, error, first node is [xml_node_get_name $root_node]" # CHANGE THIS: throw an error!!! return "" } @@ -555,14 +557,14 @@ set rdbms_nodes [xml_node_get_children_by_name $root_node rdbms] if {[llength $rdbms_nodes] > 0} { set default_rdbms [db_rdbms_parse_from_xml_node [lindex $rdbms_nodes 0]] - db_qd_log Notice "Detected DEFAULT RDBMS for whole queryset: $default_rdbms" + db_qd_log Debug "Detected DEFAULT RDBMS for whole queryset: $default_rdbms" } else { set default_rdbms "" } set parsed_stuff [xml_node_get_children_by_name $root_node fullquery] - db_qd_log Notice "end of parse_init: $index; $parsed_stuff; $parsed_doc; $default_rdbms; $file_path" + db_qd_log Debug "end of parse_init: $index; $parsed_stuff; $parsed_doc; $default_rdbms; $file_path" return [list $index $parsed_stuff $parsed_doc $default_rdbms $file_path] } @@ -583,16 +585,16 @@ set default_rdbms [lindex $parsing_state 3] set file_path [lindex $parsing_state 4] - db_qd_log Notice "default_rdbms is $default_rdbms" + db_qd_log Debug "default_rdbms is $default_rdbms" - db_qd_log Notice "node_list is $node_list with length [llength $node_list] and index $index" + db_qd_log Debug "node_list is $node_list with length [llength $node_list] and index $index" # BASE CASE if {[llength $node_list] <= $index} { # Clean up xml_doc_free $parsed_doc - db_qd_log Notice "Cleaning up, done parsing" + db_qd_log Debug "Cleaning up, done parsing" # return nothing return "" @@ -619,7 +621,7 @@ # Parse one query from an XML node proc db_qd_internal_parse_one_query_from_xml_node {one_query_node {default_rdbms {}} {file_path {}}} { - db_qd_log Notice "parsing one query node in XML with name -[xml_node_get_name $one_query_node]-" + db_qd_log Debug "parsing one query node in XML with name -[xml_node_get_name $one_query_node]-" # Check that this is a fullquery if {[xml_node_get_name $one_query_node] != "fullquery"} { @@ -636,7 +638,7 @@ # If we have no RDBMS specified, use the default if {[llength $rdbms_nodes] == 0} { - db_qd_log Notice "Wow, Nelly, no RDBMS for this query, using default rdbms $default_rdbms" + db_qd_log Debug "Wow, Nelly, no RDBMS for this query, using default rdbms $default_rdbms" set rdbms $default_rdbms } else { set rdbms_node [lindex $rdbms_nodes 0] @@ -650,15 +652,15 @@ proc db_rdbms_parse_from_xml_node {rdbms_node} { # Check that it's RDBMS if {[xml_node_get_name $rdbms_node] != "rdbms"} { - db_qd_log Notice "PARSER = BAD RDBMS NODE!" + db_qd_log Debug "PARSER = BAD RDBMS NODE!" return "" } # Get the type and version tags set type [xml_node_get_content [xml_node_get_first_child_by_name $rdbms_node type]] set version [xml_node_get_content [xml_node_get_first_child_by_name $rdbms_node version]] - db_qd_log Notice "PARSER = RDBMS parser - $type - $version" + db_qd_log Debug "PARSER = RDBMS parser - $type - $version" return [db_rdbms_create $type $version] } @@ -741,7 +743,7 @@ set rest_of_file_content [string range $rest_of_file_content [expr "$first_querytext_close + $querytext_close_len"] end] } - db_qd_log Notice "new massaged file content: \n $new_file_content \n" + db_qd_log Debug "new massaged file content: \n $new_file_content \n" return $new_file_content } @@ -754,6 +756,6 @@ proc db_qd_log {level msg} { # Centralized DB QD logging # We switch everything to debug for now - ns_log Debug "QD_LOGGER = $msg" + ns_log $level "QD_LOGGER = $msg" }