db_qd_internal_load_queries (private)

 db_qd_internal_load_queries file_pointer file_tag

Defined in packages/acs-bootstrap-installer/tcl/40-db-query-dispatcher-procs.tcl

Load up a bunch of queries from a file pointer The file_tag parameter is for later flushing of a series of queries when a particular query file has been changed. DRB: it is now used to track the mtime of the query file when loaded, used by the APM to determine when a package should be reloaded. This code depends on the file tag parameter being set to the actual file path to the query file.

Parameters:
file_pointer (required)
file_tag (required)

Partial Call Graph (max 5 caller/called nodes):
%3 db_qd_internal_load_cache db_qd_internal_load_cache (private) db_qd_internal_load_queries db_qd_internal_load_queries db_qd_internal_load_cache->db_qd_internal_load_queries ad_make_relative_path ad_make_relative_path (public) db_qd_internal_load_queries->ad_make_relative_path db_fullquery_create db_fullquery_create (private) db_qd_internal_load_queries->db_fullquery_create db_fullquery_get_bind_vars db_fullquery_get_bind_vars (private) db_qd_internal_load_queries->db_fullquery_get_bind_vars db_fullquery_get_load_location db_fullquery_get_load_location (private) db_qd_internal_load_queries->db_fullquery_get_load_location db_fullquery_get_name db_fullquery_get_name (private) db_qd_internal_load_queries->db_fullquery_get_name

Testcases:
No testcase defined.
Source code:
    # While there are surely efficient ways of loading large files,
    # we're going to assume smaller files for now. Plus, this doesn't happen
    # often.

    # db_qd_log QDDebug "Loading $file_tag"

    # Read entire contents
    set whole_file [read $file_pointer]

    # PREPARE THE FILE (ben - this is in case the file needs massaging before parsing)
    set whole_file [db_qd_prepare_queryfile_content $whole_file]

    # Iterate and parse out each query
    set parsing_state [db_qd_internal_parse_init $whole_file $file_tag]

    # 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 QDDebug "db_qd_internal_load_queries: \n"  #    "file: [lindex $parsing_state 4] \n"  #    "default_rdbms: [lindex $parsing_state 3] \n"  #    "queryname_root: $queryname_root"

    while {1} {
        set result [db_qd_internal_parse_one_query $parsing_state]

        # db_qd_log QDDebug "one parse result -$result-"

        # If we get the empty string, we are done parsing
        if {$result eq ""} {
            break
        }

        lassign $result one_query parsing_state

        # db_qd_log QDDebug "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]]} {
            set new_name [db_qd_make_absolute_path $queryname_root [db_fullquery_get_name $one_query]]

            set new_fullquery [db_fullquery_create  $new_name  [db_fullquery_get_querytext $one_query]  [db_fullquery_get_bind_vars $one_query]  [db_fullquery_get_query_type $one_query]  [db_fullquery_get_rdbms $one_query]  [db_fullquery_get_load_location $one_query]]

            set one_query $new_fullquery

            # db_qd_log QDDebug "relative path, replaced name with $new_name"
        }

        # Store the query
        db_qd_internal_store_cache $one_query
    }

    set relative_path [string range $file_tag  [expr { [string length $::acs::rootdir] + 1 }] end]
    nsv_set apm_library_mtime $relative_path [file mtime $file_tag]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: