CUBRID Engine  latest
util_common.c File Reference
#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"
Include dependency graph for util_common.c:

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)
 

Enumeration Type Documentation

Enumerator
EXISTING_DATABASE 
NEW_DATABASE 

Definition at line 49 of file util_common.c.

Function Documentation

bool are_hostnames_equal ( const char *  hostname_a,
const char *  hostname_b 
)

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"

Parameters
hostname_afirst hostname
hostname_bsecond hostname
Returns
true if hostname_a is same as hostname_b

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().

Here is the caller graph for this function:

static int check_database_name_local ( const char *  name,
int  existing_or_new_db 
)
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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

void util_free_ha_conf ( HA_CONF ha_conf)
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
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().

Here is the caller graph for this function:

int util_get_table_list_from_file ( char *  fname,
dynamic_array darray 
)
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().

Here is the caller graph for this function:

static bool util_is_replica_node ( void  )
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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

void util_redirect_stdout_to_null ( void  )

Definition at line 885 of file util_common.c.

Referenced by applylogdb(), and copylogdb().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

static int util_size_to_byte ( double *  pre,
const char *  post 
)
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().

Here is the caller graph for this function:

static char ** util_split_ha_db ( const char *  str)
static

Definition at line 518 of file util_common.c.

References util_split_string().

Referenced by util_make_ha_conf().

Here is the caller graph for this function:

static char ** util_split_ha_node ( const char *  str)
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().

Here is the caller graph for this function:

static char ** util_split_ha_sync ( const char *  str)
static

Definition at line 524 of file util_common.c.

References util_split_string().

Referenced by util_make_ha_conf().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

static int util_time_to_msec ( double *  pre,
const char *  post 
)
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().

Here is the caller graph for this function:

const char* utility_get_generic_message ( int  message_index)
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().

Here is the caller graph for this function:

static int utility_get_option_index ( UTIL_ARG_MAP arg_map,
int  arg_ch 
)
static
int utility_get_option_int_value ( UTIL_ARG_MAP arg_map,
int  arg_ch 
)
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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function: