# # # # # get_db_data_util.cfv # # # get_db_profiles_dat() # # get_db_option_dat() # get_db_options_server_dat() # get_db_tuning_split_queries_dat() # # include "templates.util.encoding"; # # # # get_db_profiles_dat() # # # subroutine(get_db_profiles_dat( string active_profile_name), ( node profiles = "profiles"; string dat = "["; string item_dat; if (num_subnodes(profiles) > 1) then ( # greater 1 because we don't count the active profile node profile_item; string profile_name; string profile_label; node database_server; string server_type; string database_name; string database_directory; string dir_divider = (if _PLATFORM eq "Windows" then "\\" else "/"); string lai_dir = LOGANALYSISINFO_DIRECTORY; foreach profile_item profiles ( profile_name = node_name(profile_item); if (profile_name ne active_profile_name) then ( profile_label = @profile_item{"label"}; database_server = profile_item{"database"}{"options"}{"server"}; server_type = @database_server{"type"}; database_name = ""; database_directory = ""; if (server_type eq "internal_sql") then ( database_directory = @database_server{"database_directory"}; if (database_directory eq "") then ( # Specify standard database directory database_directory = lai_dir . dir_divider . "Databases" . dir_divider . profile_name . dir_divider; ) else if (!ends_with(database_directory, dir_divider)) then ( database_directory .= dir_divider; ); ) else if (server_type eq "mysql" or server_type eq "odbc_mssql") then ( database_name = @database_server{"database_name"}; if (database_name eq "") then ( # The database name must be the profile_name database_name = profile_name; ); ); item_dat = "{"; item_dat .= add_json("name", profile_name, "string"); item_dat .= add_json("label", profile_label, "string"); item_dat .= add_json("serverType", server_type, "string"); item_dat .= add_json("databaseName", database_name, "string"); item_dat .= add_json("databaseDirectory", database_directory, "string"); item_dat = close_json(item_dat); dat .= item_dat . ","; ); ); dat = replace_last(dat, ",", "]"); ) else ( dat .= "]"; ); dat; )); # # # # get_db_option_dat() # # # subroutine(get_db_option_dat(string option_group, string option_name), ( node options_node = "profiles." . internal.profile_name . ".database." . option_group; string option_value = ""; if (options_node?{option_name}) then ( # Get option value from profile option_value = @options_node{option_name}; ) else if (?("default.default_profile.database." . option_group . "." . option_name)) then ( # Use default profile value option_value = @("default.default_profile.database." . option_group . "." . option_name); ); string option_type = @("option_info.profile.database." . option_group . "." . option_name . ".type"); string json_type = option_info_to_json_type(option_type); string bytes_unit; if (option_type eq "bytes") then ( string option_value_ori = option_value; option_value = get_bytes_number(option_value_ori); bytes_unit = get_bytes_unit(option_value_ori); ); string s = '"' . option_name . '":{'; s .= add_json("value", option_value, json_type); s .= add_json("type", option_type, "string"); if (option_type eq "bytes") then ( s .= add_json("bytesUnit", bytes_unit, "string"); ); s = close_json(s) . ","; s; )); # # # # get_db_options_server_dat() # # # subroutine(get_db_options_server_dat( node server), ( string server_type = @server{"type"}; # # # Handle bulk_import_method and load_data_directory # # string mysql_server_bulk_import_method = "load_data_local_infile"; string mssql_server_bulk_import_method = "ODBC"; string oracle_server_bulk_import_method = "ODBC"; string load_data_directory; string load_data_directory_on_server; if (server_type ne "internal_sql") then ( string bulk_import_method = @server{"bulk_import_method"}; if (server_type eq "mysql") then ( if (bulk_import_method ne "") then ( mysql_server_bulk_import_method = bulk_import_method; ); if (mysql_server_bulk_import_method eq "load_data_server_infile") then ( load_data_directory = @server{"load_data_directory"}; ); ) else if (server_type eq "odbc_mssql") then ( if (bulk_import_method ne "") then ( mssql_server_bulk_import_method = bulk_import_method; ); if (mssql_server_bulk_import_method eq "bulk_insert") then ( load_data_directory = @server{"load_data_directory"}; load_data_directory_on_server = @server{"load_data_directory_on_server"}; ); ) else if (server_type eq "odbc_oracle") then ( if (bulk_import_method ne "") then ( oracle_server_bulk_import_method = bulk_import_method; ); ); ); # # # Get server_dat # # string dat = "{"; dat .= add_json("type", server_type, "string"); dat .= add_json("hostname", @server{"hostname"}, "string"); dat .= add_json("dsn", @server{"dsn"}, "string"); dat .= add_json("password", @server{"password"}, "string"); dat .= add_json("username", @server{"username"}, "string"); dat .= add_json("database_name", @server{"database_name"}, "string"); dat .= add_json("database_directory", @server{"database_directory"}, "string"); dat .= add_json("server_socket", @server{"server_socket"}, "string"); dat .= add_json("mysql_server_bulk_import_method", mysql_server_bulk_import_method, "string"); dat .= add_json("mssql_server_bulk_import_method", mssql_server_bulk_import_method, "string"); dat .= add_json("oracle_server_bulk_import_method", oracle_server_bulk_import_method, "string"); dat .= add_json("load_data_directory", load_data_directory, "string"); dat .= add_json("load_data_directory_on_server", load_data_directory_on_server, "string"); dat .= add_json("sql_table_name_prefix", @server{"sql_table_name_prefix"}, "string"); dat .= add_json("sql_table_name_suffix", @server{"sql_table_name_suffix"}, "string"); dat = close_json(dat); dat; )); # # # # get_db_tuning_split_queries_dat() # # # subroutine(get_db_tuning_split_queries_dat( node tuning), ( string method = @(tuning . ".split_queries.method"); string number_of_threads = @(tuning . ".split_queries.number_of_threads"); string s = '"split_queries":{'; s .= add_json("method", method, "string"); s .= add_json("number_of_threads", number_of_threads, "string"); s = close_json(s) . ","; s; ));