CUBRID Engine
latest
|
#include <ctype.h>
#include <assert.h>
#include <fcntl.h>
#include "config.h"
#include "utility.h"
#include "util_func.h"
#include "porting.h"
#include "message_catalog.h"
#include "log_common_impl.h"
#include "log_writer.h"
#include "mprec.h"
#include "system_parameter.h"
#include "environment_variable.h"
#include "heartbeat.h"
#include "tcp.h"
Go to the source code of this file.
Enumerations | |
enum | DATABASE_NAME { EXISTING_DATABASE, NEW_DATABASE } |
Functions | |
static int | utility_get_option_index (UTIL_ARG_MAP *arg_map, int arg_ch) |
static int | check_database_name_local (const char *name, int existing_or_new_db) |
static char ** | util_split_ha_node (const char *str) |
static char ** | util_split_ha_db (const char *str) |
static char ** | util_split_ha_sync (const char *str) |
static int | util_get_ha_parameters (char **ha_node_list_p, char **ha_db_list_p, char **ha_sync_mode_p, const char **ha_copy_log_base_p, int *ha_max_mem_size_p) |
static bool | util_is_replica_node (void) |
int | utility_initialize () |
const char * | utility_get_generic_message (int message_index) |
int | check_database_name (const char *name) |
int | check_new_database_name (const char *name) |
int | check_volume_name (const char *name) |
int | utility_get_option_int_value (UTIL_ARG_MAP *arg_map, int arg_ch) |
bool | utility_get_option_bool_value (UTIL_ARG_MAP *arg_map, int arg_ch) |
char * | utility_get_option_string_value (UTIL_ARG_MAP *arg_map, int arg_ch, int index) |
INT64 | utility_get_option_bigint_value (UTIL_ARG_MAP *arg_map, int arg_ch) |
int | utility_get_option_string_table_size (UTIL_ARG_MAP *arg_map) |
FILE * | fopen_ex (const char *filename, const char *type) |
int | utility_keyword_search (UTIL_KEYWORD *keywords, int *keyval_p, char **keystr_p) |
int | utility_localtime (const time_t *ts, struct tm *result) |
bool | util_is_localhost (char *host) |
bool | are_hostnames_equal (const char *hostname_a, const char *hostname_b) |
int | util_get_num_of_ha_nodes (const char *node_list) |
int | copylogdb_keyword (int *keyval_p, char **keystr_p) |
int | changemode_keyword (int *keyval_p, char **keystr_p) |
void | util_free_ha_conf (HA_CONF *ha_conf) |
int | util_make_ha_conf (HA_CONF *ha_conf) |
int | util_get_ha_mode_for_sa_utils (void) |
void | util_redirect_stdout_to_null (void) |
static int | util_size_to_byte (double *pre, const char *post) |
int | util_byte_to_size_string (char *buf, size_t len, UINT64 size_num) |
int | util_size_string_to_byte (UINT64 *size_num, const char *size_str) |
static int | util_time_to_msec (double *pre, const char *post) |
int | util_msec_to_time_string (char *buf, size_t len, INT64 msec_num) |
int | util_time_string_to_msec (INT64 *msec_num, char *time_str) |
void | util_print_deprecated (const char *option) |
int | util_get_table_list_from_file (char *fname, dynamic_array *darray) |
enum DATABASE_NAME |
Enumerator | |
---|---|
EXISTING_DATABASE | |
NEW_DATABASE |
Definition at line 49 of file util_common.c.
Compare two host names if are equal, if one of the host names is canonical name and the other is not, then only host part (e.g. for canonical name "host-1.cubrid.org" host part is "host-1") is used for comparison
for example following hosts are equal: "host-1" "host-1" "host-1" "host-1.cubrid.org" "host-1.cubrid.org" "host-1" "host-1.cubrid.org" "host-1.cubrid.org"
for example following hosts are not equal: "host-1" "host-2" "host-1.cubrid.org" "host-2" "host-1" "host-2.cubrid.org" "host-1.cubrid.org" "host-2.cubrid.org" "host-1.cubrid.org" "host-1.cubrid.com"
hostname_a | first hostname |
hostname_b | second hostname |
Definition at line 449 of file util_common.c.
Referenced by hb_add_node_to_cluster(), hb_check_ping(), hb_cluster_cleanup(), hb_cluster_load_group_and_node_list(), hb_cluster_receive_heartbeat(), hb_cluster_request_heartbeat_to_all(), hb_reload_config(), hb_return_node_by_name(), hb_return_node_by_name_except_me(), hb_return_ui_node(), and util_is_localhost().
int changemode_keyword | ( | int * | keyval_p, |
char ** | keystr_p | ||
) |
Definition at line 555 of file util_common.c.
References HA_SERVER_STATE_ACTIVE, HA_SERVER_STATE_ACTIVE_STR, HA_SERVER_STATE_DEAD, HA_SERVER_STATE_DEAD_STR, HA_SERVER_STATE_IDLE, HA_SERVER_STATE_IDLE_STR, HA_SERVER_STATE_MAINTENANCE, HA_SERVER_STATE_MAINTENANCE_STR, HA_SERVER_STATE_STANDBY, HA_SERVER_STATE_STANDBY_STR, HA_SERVER_STATE_TO_BE_ACTIVE, HA_SERVER_STATE_TO_BE_ACTIVE_STR, HA_SERVER_STATE_TO_BE_STANDBY, HA_SERVER_STATE_TO_BE_STANDBY_STR, keywords, NULL, and utility_keyword_search().
Referenced by changemode().
int check_database_name | ( | const char * | name | ) |
Definition at line 99 of file util_common.c.
References check_database_name_local(), and EXISTING_DATABASE.
Referenced by acldb(), addvoldb(), alterdbhost(), applyinfo(), applylogdb(), backupdb(), changemode(), checkdb(), checksumdb(), copydb(), copylogdb(), deletedb(), diagdb(), gen_tz(), installdb(), killtran(), lockdb(), main(), optimizedb(), paramdump(), patchdb(), plandump(), renamedb(), spacedb(), statdump(), synccolldb(), tde(), tranlist(), and vacuumdb().
|
static |
Definition at line 122 of file util_common.c.
References ER_GENERIC_ERROR, i, MSGCAT_UTIL_GENERIC_BAD_DATABASE_NAME, NEW_DATABASE, NO_ERROR, NULL, PRINT_AND_LOG_ERR_MSG, and utility_get_generic_message().
Referenced by check_database_name(), and check_new_database_name().
int check_new_database_name | ( | const char * | name | ) |
Definition at line 110 of file util_common.c.
References check_database_name_local(), and NEW_DATABASE.
Referenced by copydb(), createdb(), and renamedb().
int check_volume_name | ( | const char * | name | ) |
Definition at line 161 of file util_common.c.
References ER_GENERIC_ERROR, i, MSGCAT_UTIL_GENERIC_BAD_VOLUME_NAME, NO_ERROR, NULL, PRINT_AND_LOG_ERR_MSG, and utility_get_generic_message().
Referenced by addvoldb().
int copylogdb_keyword | ( | int * | keyval_p, |
char ** | keystr_p | ||
) |
Definition at line 536 of file util_common.c.
References keywords, LOGWR_MODE_ASYNC, LOGWR_MODE_SEMISYNC, LOGWR_MODE_SYNC, NULL, and utility_keyword_search().
Referenced by copylogdb(), and util_make_ha_conf().
Definition at line 322 of file util_common.c.
Referenced by extract_classes_to_file(), extract_indexes_to_file(), extract_objects(), extract_triggers_to_file(), load_console_conv_data(), load_ducet(), load_unicode_data(), loaddb_internal(), locale_check_and_set_default_files(), locale_get_cfg_locales(), locale_prepare_C_file(), locale_save_to_C_file(), tzc_check_new_package_validity(), tzc_export_timezone_dot_c(), tzc_load_backward_zones(), tzc_load_countries(), tzc_load_leap_secs(), tzc_load_rule_file(), tzc_load_zone_names(), and xml_parser_exec().
int util_byte_to_size_string | ( | char * | buf, |
size_t | len, | ||
UINT64 | size_num | ||
) |
Definition at line 955 of file util_common.c.
References _dtoa, ER_FAILED, i, NO_ERROR, NULL, ONE_K, and strlen.
Referenced by btree_scan_for_show_index_capacity(), createdb(), prm_print(), spacedb(), and sysprm_print_sysprm_value().
void util_free_ha_conf | ( | HA_CONF * | ha_conf | ) |
Definition at line 651 of file util_common.c.
References _ha_config::db_names, free_and_init, i, _ha_config::node_conf, node_name, NULL, _ha_config::num_node_conf, and util_free_string_array().
Referenced by check_ha_db_and_node_list(), process_heartbeat(), and util_make_ha_conf().
int util_get_ha_mode_for_sa_utils | ( | void | ) |
Definition at line 872 of file util_common.c.
References prm_get_integer_value(), and PRM_ID_HA_MODE_FOR_SA_UTILS_ONLY.
Referenced by css_get_required_conn_num_for_ha(), process_heartbeat_start(), process_heartbeat_stop(), process_heartbeat_util(), process_server(), us_hb_applylogdb_start(), us_hb_copylogdb_start(), and us_hb_server_start().
|
static |
Definition at line 572 of file util_common.c.
References envvar_get(), ER_GENERIC_ERROR, error(), MSGCAT_UTIL_GENERIC_INVALID_PARAMETER, NO_ERROR, NULL, prm_get_integer_value(), prm_get_name(), prm_get_string_value(), PRM_ID_HA_APPLY_MAX_MEM_SIZE, PRM_ID_HA_COPY_LOG_BASE, PRM_ID_HA_COPY_SYNC_MODE, PRM_ID_HA_DB_LIST, PRM_ID_HA_NODE_LIST, and utility_get_generic_message().
Referenced by util_make_ha_conf().
int util_get_num_of_ha_nodes | ( | const char * | node_list | ) |
Definition at line 478 of file util_common.c.
References NULL, util_free_string_array(), and util_split_ha_node().
Referenced by css_get_required_conn_num_for_ha().
int util_get_table_list_from_file | ( | char * | fname, |
dynamic_array * | darray | ||
) |
Definition at line 1226 of file util_common.c.
References da_add(), ER_GENERIC_ERROR, i, MSGCAT_UTIL_GENERIC_FILEOPEN_ERROR, MSGCAT_UTIL_GENERIC_INVALID_ARGUMENT, MSGCAT_UTIL_GENERIC_NO_MEM, NO_ERROR, NULL, p, SM_MAX_IDENTIFIER_LENGTH, and util_log_write_errid().
Referenced by checkdb(), and checksumdb().
bool util_is_localhost | ( | char * | host | ) |
Definition at line 418 of file util_common.c.
References are_hostnames_equal(), CUB_MAXHOSTNAMELEN, and GETHOSTNAME.
Referenced by check_ha_db_and_node_list(), us_hb_applylogdb_start(), us_hb_applylogdb_stop(), us_hb_copylogdb_start(), and us_hb_copylogdb_stop().
|
static |
Definition at line 610 of file util_common.c.
References CUB_MAXHOSTNAMELEN, GETHOSTNAME, i, NULL, prm_get_string_value(), PRM_ID_HA_REPLICA_LIST, util_free_string_array(), and util_split_ha_node().
Referenced by util_make_ha_conf().
int util_make_ha_conf | ( | HA_CONF * | ha_conf | ) |
Definition at line 694 of file util_common.c.
References _node_config::apply_max_mem_size, assert_release, _node_config::copy_log_base, _node_config::copy_sync_mode, copylogdb_keyword(), _ha_config::db_names, ER_GENERIC_ERROR, error(), i, mode, MSGCAT_UTIL_GENERIC_INVALID_PARAMETER, MSGCAT_UTIL_GENERIC_NO_MEM, NO_ERROR, _ha_config::node_conf, _node_config::node_name, NULL, _ha_config::num_node_conf, prm_get_name(), PRM_ID_HA_COPY_SYNC_MODE, strdup(), util_free_ha_conf(), util_free_string_array(), util_get_ha_parameters(), util_is_replica_node(), util_split_ha_db(), util_split_ha_node(), util_split_ha_sync(), and utility_get_generic_message().
Referenced by check_ha_db_and_node_list(), and process_heartbeat().
int util_msec_to_time_string | ( | char * | buf, |
size_t | len, | ||
INT64 | msec_num | ||
) |
Definition at line 1112 of file util_common.c.
References ER_FAILED, error(), NO_ERROR, NULL, and ONE_SEC.
Referenced by prm_print(), and sysprm_print_sysprm_value().
void util_print_deprecated | ( | const char * | option | ) |
Definition at line 1205 of file util_common.c.
References MSGCAT_CATALOG_UTILS, msgcat_message(), MSGCAT_UTIL_GENERIC_DEPRECATED, MSGCAT_UTIL_SET_GENERIC, and NULL.
Referenced by addvoldb(), and createdb().
void util_redirect_stdout_to_null | ( | void | ) |
Definition at line 885 of file util_common.c.
Referenced by applylogdb(), and copylogdb().
int util_size_string_to_byte | ( | UINT64 * | size_num, |
const char * | size_str | ||
) |
Definition at line 1027 of file util_common.c.
References ER_FAILED, NO_ERROR, NULL, and util_size_to_byte().
Referenced by addvoldb(), createdb(), and sysprm_generate_new_value().
|
static |
Definition at line 909 of file util_common.c.
References ER_FAILED, NO_ERROR, ONE_G, ONE_K, ONE_M, ONE_P, and ONE_T.
Referenced by util_size_string_to_byte().
|
static |
Definition at line 518 of file util_common.c.
References util_split_string().
Referenced by util_make_ha_conf().
|
static |
Definition at line 504 of file util_common.c.
References NULL, and util_split_string().
Referenced by util_get_num_of_ha_nodes(), util_is_replica_node(), and util_make_ha_conf().
|
static |
Definition at line 524 of file util_common.c.
References util_split_string().
Referenced by util_make_ha_conf().
int util_time_string_to_msec | ( | INT64 * | msec_num, |
char * | time_str | ||
) |
Definition at line 1155 of file util_common.c.
References ER_FAILED, NO_ERROR, NULL, and util_time_to_msec().
Referenced by sysprm_generate_new_value().
|
static |
Definition at line 1076 of file util_common.c.
References ER_FAILED, NO_ERROR, ONE_HOUR, ONE_MIN, and ONE_SEC.
Referenced by util_time_string_to_msec().
const char* utility_get_generic_message | ( | int | message_index | ) |
Definition at line 88 of file util_common.c.
References MSGCAT_CATALOG_UTILS, msgcat_message(), and MSGCAT_UTIL_SET_GENERIC.
Referenced by check_database_name_local(), check_volume_name(), load_properties(), print_message(), util_admin_usage(), util_admin_version(), util_get_ha_parameters(), util_log_write_errid(), and util_make_ha_conf().
INT64 utility_get_option_bigint_value | ( | UTIL_ARG_MAP * | arg_map, |
int | arg_ch | ||
) |
Definition at line 294 of file util_common.c.
References UTIL_ARG_MAP::arg_value, UTIL_ARG_MAP::l, and utility_get_option_index().
Referenced by applyinfo(), and copylogdb().
bool utility_get_option_bool_value | ( | UTIL_ARG_MAP * | arg_map, |
int | arg_ch | ||
) |
Definition at line 245 of file util_common.c.
References UTIL_ARG_MAP::i, and utility_get_option_index().
Referenced by acldb(), addvoldb(), applyinfo(), backupdb(), changemode(), checkdb(), checksumdb(), compactdb(), copydb(), createdb(), deletedb(), diagdb(), dump_tz(), dumplocale(), genlocale(), get_loaddb_args(), killtran(), loaddb_internal(), paramdump(), patchdb(), plandump(), renamedb(), restoredb(), restoreslave(), spacedb(), statdump(), synccolldb(), tde(), tranlist(), unloaddb(), and vacuumdb().
|
static |
Definition at line 205 of file util_common.c.
References UTIL_ARG_MAP::arg_ch, and i.
Referenced by utility_get_option_bigint_value(), utility_get_option_bool_value(), utility_get_option_int_value(), utility_get_option_string_table_size(), and utility_get_option_string_value().
int utility_get_option_int_value | ( | UTIL_ARG_MAP * | arg_map, |
int | arg_ch | ||
) |
Definition at line 227 of file util_common.c.
References UTIL_ARG_MAP::arg_value, UTIL_ARG_MAP::i, and utility_get_option_index().
Referenced by applyinfo(), applylogdb(), backupdb(), changemode(), checksumdb(), compactdb(), createdb(), diagdb(), dumplocale(), get_loaddb_args(), loaddb_internal(), restoredb(), statdump(), tde(), tranlist(), and unloaddb().
int utility_get_option_string_table_size | ( | UTIL_ARG_MAP * | arg_map | ) |
Definition at line 305 of file util_common.c.
References UTIL_ARG_MAP::num_strings, OPTION_STRING_TABLE, utility_get_option_index(), and UTIL_ARG_MAP::value_info.
Referenced by acldb(), addvoldb(), alterdbhost(), applyinfo(), applylogdb(), backupdb(), changemode(), checkdb(), checksumdb(), compactdb(), copydb(), copylogdb(), createdb(), deletedb(), diagdb(), dumplocale(), genlocale(), installdb(), killtran(), lockdb(), optimizedb(), paramdump(), patchdb(), plandump(), renamedb(), restoredb(), restoreslave(), spacedb(), statdump(), synccolldb(), tde(), tranlist(), unloaddb(), and vacuumdb().
char* utility_get_option_string_value | ( | UTIL_ARG_MAP * | arg_map, |
int | arg_ch, | ||
int | index | ||
) |
Definition at line 266 of file util_common.c.
References NULL, UTIL_ARG_MAP::num_strings, OPTION_STRING_TABLE, UTIL_ARG_MAP::p, and utility_get_option_index().
Referenced by acldb(), addvoldb(), alterdbhost(), applyinfo(), applylogdb(), backupdb(), changemode(), checkdb(), checksumdb(), compactdb(), copydb(), copylogdb(), createdb(), deletedb(), diagdb(), dump_tz(), dumplocale(), gen_tz(), genlocale(), get_loaddb_args(), installdb(), killtran(), lockdb(), optimizedb(), paramdump(), patchdb(), plandump(), renamedb(), restoredb(), restoreslave(), spacedb(), statdump(), synccolldb(), tde(), tranlist(), unloaddb(), and vacuumdb().
int utility_initialize | ( | void | ) |
Definition at line 69 of file util_common.c.
References ER_BO_CANNOT_ACCESS_MESSAGE_CATALOG, er_init(), ER_NEVER_EXIT, msgcat_init(), NO_ERROR, NULL, and PRINT_AND_LOG_ERR_MSG.
Referenced by csql(), and main().
int utility_keyword_search | ( | UTIL_KEYWORD * | keywords, |
int * | keyval_p, | ||
char ** | keystr_p | ||
) |
Definition at line 352 of file util_common.c.
References ER_FAILED, UTIL_KEYWORD::keystr, UTIL_KEYWORD::keyval, NO_ERROR, and NULL.
Referenced by changemode_keyword(), and copylogdb_keyword().
int utility_localtime | ( | const time_t * | ts, |
struct tm * | result | ||
) |
Definition at line 390 of file util_common.c.
References NULL.
Referenced by csql_do_session_cmd(), and print_timestamp().