61 const char **ha_copy_log_base_p,
int *ha_max_mem_size_p);
133 for (i = 0; name[
i] != 0; i++)
135 if (isspace (name[i]) || name[i] ==
'/' || name[i] ==
'\\' || !isprint (name[i])
136 || (existing_or_new_db ==
NEW_DATABASE && name[i] ==
'@'))
177 for (i = 0; name[
i] != 0; i++)
179 if (isspace (name[i]) || name[i] ==
'/' || name[i] ==
'\\' || !isprint (name[i]))
209 for (i = 0; arg_map[
i].
arg_ch; i++)
211 if (arg_map[i].arg_ch == arg_ch)
250 if (arg_map[index].arg_value.
i == 1)
273 if (index < arg_map[arg_index].value_info.
num_strings)
275 return (((
char **) arg_map[arg_index].arg_value.
p)[index]);
280 return ((
char *) arg_map[arg_index].arg_value.
p);
328 extern size_t confstr (
int,
char *,
size_t);
329 r = confstr (_CS_LFS_CFLAGS, buf, 1024);
332 return fopen64 (filename, type);
334 return fopen (filename, type);
336 #if _LFS64_LARGEFILE == 1 337 return fopen64 (filename, type);
339 return fopen (filename, type);
341 #elif defined(AIX) || (defined(I386) && defined(LINUX)) 342 return fopen64 (filename, type);
344 return fopen (filename, type);
356 if (*keyval_p >= 0 && *keystr_p ==
NULL)
359 for (keyp = keywords; keyp->
keyval >= 0; keyp++)
361 if (*keyval_p == keyp->
keyval)
363 *keystr_p = const_cast <
char *>(keyp->
keystr);
368 else if (*keyval_p < 0 && *keystr_p !=
NULL)
371 for (keyp = keywords; keyp->
keystr !=
NULL; keyp++)
373 if (!strcasecmp (*keystr_p, keyp->
keystr))
392 struct tm *tm_p, tm_val;
399 tm_p = localtime_r (ts, &tm_val);
402 memset (result, 0,
sizeof (
struct tm));
406 memcpy (result, tm_p,
sizeof (
struct tm));
454 for (a = hostname_a, b = hostname_b; *a && *b && (*a == *b); ++a, ++b)
457 if (*a ==
'\0' && *b !=
'\0')
461 else if (*a !=
'\0' && *b ==
'\0')
480 char **ha_node_list_pp =
NULL;
481 int num_of_nodes = 0;
483 if (node_list ==
NULL)
489 for (num_of_nodes = 0; ha_node_list_pp[num_of_nodes] !=
NULL;)
508 start_node = (
char *) strchr (str,
'@');
509 if (start_node ==
NULL || str == start_node)
573 const char **ha_copy_log_base_p,
int *ha_max_mem_size_p)
578 if (*(ha_db_list_p) ==
NULL || **(ha_db_list_p) ==
'\0')
586 if (*(ha_node_list_p) ==
NULL || **(ha_node_list_p) ==
'\0')
597 if (*(ha_copy_log_base_p) ==
NULL || **(ha_copy_log_base_p) ==
'\0')
599 *(ha_copy_log_base_p) = (
char *)
envvar_get (
"DATABASES");
600 if (*(ha_copy_log_base_p) ==
NULL)
602 *(ha_copy_log_base_p) =
".";
612 bool is_replica_node =
false;
615 char *ha_replica_list_p, **ha_replica_list_pp =
NULL;
618 if (ha_replica_list_p !=
NULL && *(ha_replica_list_p) !=
'\0')
621 if (ha_replica_list_pp !=
NULL && (
GETHOSTNAME (local_host_name,
sizeof (local_host_name)) == 0))
623 for (i = 0; ha_replica_list_pp[
i] !=
NULL; i++)
625 if (strcmp (ha_replica_list_pp[i], local_host_name) == 0)
627 is_replica_node =
true;
635 if (ha_replica_list_pp)
640 return is_replica_node;
656 for (i = 0, nc = ha_conf->
node_conf; i < ha_conf->num_node_conf; i++)
663 if (nc[i].copy_log_base)
668 if (nc[i].copy_sync_mode)
698 char *ha_db_list_p =
NULL;
699 char *ha_node_list_p =
NULL, **ha_node_list_pp =
NULL;
700 char *ha_sync_mode_p =
NULL, **ha_sync_mode_pp =
NULL;
701 const char *ha_copy_log_base_p;
703 bool is_replica_node;
706 util_get_ha_parameters (&ha_node_list_p, &ha_db_list_p, &ha_sync_mode_p, &ha_copy_log_base_p, &ha_max_mem_size);
716 fprintf (stderr, message);
723 if (ha_node_list_pp ==
NULL)
726 fprintf (stderr, message);
732 for (i = 0; ha_node_list_pp[
i] !=
NULL;)
742 fprintf (stderr, message);
752 if (is_replica_node ==
true)
754 for (i = 0; i < num_ha_nodes; i++)
760 fprintf (stderr, message);
769 if (ha_sync_mode_p ==
NULL || *(ha_sync_mode_p) ==
'\0')
771 for (i = 0; i < num_ha_nodes; i++)
777 fprintf (stderr, message);
789 if (ha_sync_mode_pp ==
NULL)
792 fprintf (stderr, message);
798 for (i = 0; i < num_ha_nodes; i++)
806 (ha_sync_mode_pp[i]) ? ha_sync_mode_pp[i] :
"");
816 fprintf (stderr, message);
825 for (i = 0; i < num_ha_nodes; i++)
836 fprintf (stderr, message);
847 ha_node_list_pp =
NULL;
853 ha_sync_mode_pp =
NULL;
877 #if !defined(WINDOWS) 887 const char *null_dev =
"/dev/null";
890 fd = open (null_dev, O_WRONLY);
911 if (strcasecmp (post,
"b") == 0)
915 else if ((strcasecmp (post,
"k") == 0) || (strcasecmp (post,
"kb") == 0))
920 else if ((strcasecmp (post,
"m") == 0) || (strcasecmp (post,
"mb") == 0))
925 else if ((strcasecmp (post,
"g") == 0) || (strcasecmp (post,
"gb") == 0))
930 else if ((strcasecmp (post,
"t") == 0) || (strcasecmp (post,
"tb") == 0))
935 else if ((strcasecmp (post,
"p") == 0) || (strcasecmp (post,
"pb") == 0))
958 const char *ss =
"BKMGTP";
959 double v = (double) size_num;
961 int i, decpt, sign, num_len;
970 while (pow < 6 && v >=
ONE_K)
976 _dtoa (v, 3, 1, &decpt, &sign, &rve, num_str, 0);
978 num_len = (int)
strlen (num_str);
980 if (len < (
size_t) (decpt + 4))
985 for (i = 0; i <= decpt + 1; i++)
991 else if (i == decpt + 1)
995 buf[
i] = num_str[num_len - 1];
1001 buf[i + 1] = ss[pow];
1006 if (num_len < decpt && i >= num_len)
1012 buf[
i] = num_str[
i];
1030 const char *default_unit =
"B";
1032 const char *size_unit;
1034 if (size_str ==
NULL || size_num ==
NULL)
1040 val = strtod (size_str, &end);
1041 if (end == size_str)
1057 size_unit = default_unit;
1065 *size_num = (UINT64) val;
1078 if ((strcasecmp (post,
"ms") == 0) || (strcasecmp (post,
"msec") == 0))
1082 else if ((strcasecmp (post,
"s") == 0) || (strcasecmp (post,
"sec") == 0))
1087 else if (strcasecmp (post,
"min") == 0)
1092 else if (strcasecmp (post,
"h") == 0)
1129 error = snprintf (buf, len,
"%lld.%03lld sec", (
long long) sec, (
long long) msec);
1133 error = snprintf (buf, len,
"%lld", (
long long) v);
1137 error = snprintf (buf, len,
"%lld msec", (
long long) v);
1158 const char *default_unit =
"ms";
1160 const char *time_unit;
1162 if (time_str ==
NULL || msec_num ==
NULL)
1168 val = strtod (time_str, &end);
1169 if (end == time_str)
1176 *msec_num = (INT64) val;
1186 time_unit = default_unit;
1194 *msec_num = (INT64) val;
1213 fprintf (stderr,
"error: msgcat_message");
1217 fprintf (stderr, fmt, option);
1230 FILE *fp = fopen (fname,
"r");
1242 if (c ==
' ' || c ==
'\t' || c ==
',' || c ==
'\n' || c == EOF)
bool util_is_localhost(char *host)
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)
#define HA_SERVER_STATE_IDLE_STR
#define PRINT_AND_LOG_ERR_MSG(...)
void util_redirect_stdout_to_null(void)
int util_size_string_to_byte(UINT64 *size_num, const char *size_str)
union UTIL_ARG_MAP::@81 value_info
static int check_database_name_local(const char *name, int existing_or_new_db)
bool are_hostnames_equal(const char *hostname_a, const char *hostname_b)
union UTIL_ARG_MAP::@82 arg_value
#define assert_release(e)
int util_get_table_list_from_file(char *fname, dynamic_array *darray)
#define SM_MAX_IDENTIFIER_LENGTH
int util_byte_to_size_string(char *buf, size_t len, UINT64 size_num)
int check_volume_name(const char *name)
int check_database_name(const char *name)
int util_time_string_to_msec(INT64 *msec_num, char *time_str)
int util_msec_to_time_string(char *buf, size_t len, INT64 msec_num)
int util_log_write_errid(int message_id,...)
int er_init(const char *msglog_filename, int exit_ask)
int utility_get_option_int_value(UTIL_ARG_MAP *arg_map, int arg_ch)
static KEYWORD_RECORD keywords[]
int utility_keyword_search(UTIL_KEYWORD *keywords, int *keyval_p, char **keystr_p)
void util_print_deprecated(const char *option)
INT64 utility_get_option_bigint_value(UTIL_ARG_MAP *arg_map, int arg_ch)
bool utility_get_option_bool_value(UTIL_ARG_MAP *arg_map, int arg_ch)
int prm_get_integer_value(PARAM_ID prm_id)
#define HA_SERVER_STATE_DEAD_STR
int utility_localtime(const time_t *ts, struct tm *result)
#define HA_SERVER_STATE_MAINTENANCE_STR
#define HA_SERVER_STATE_TO_BE_STANDBY_STR
static enum scanner_mode mode
int check_new_database_name(const char *name)
static int util_size_to_byte(double *pre, const char *post)
static char ** util_split_ha_node(const char *str)
void util_free_ha_conf(HA_CONF *ha_conf)
static char ** util_split_ha_db(const char *str)
static char ** util_split_ha_sync(const char *str)
void util_free_string_array(char **array)
static int utility_get_option_index(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)
char ** util_split_string(const char *str, const char *delim)
const char * utility_get_generic_message(int message_index)
const char * envvar_get(const char *name)
static void error(const char *msg)
#define HA_SERVER_STATE_STANDBY_STR
int changemode_keyword(int *keyval_p, char **keystr_p)
int da_add(dynamic_array *da, void *data)
#define free_and_init(ptr)
char * prm_get_string_value(PARAM_ID prm_id)
#define HA_SERVER_STATE_TO_BE_ACTIVE_STR
char * msgcat_message(int cat_id, int set_id, int msg_id)
int util_get_num_of_ha_nodes(const char *node_list)
const char * prm_get_name(PARAM_ID prm_id)
char * strdup(const char *str)
int util_get_ha_mode_for_sa_utils(void)
#define OPTION_STRING_TABLE
#define ER_BO_CANNOT_ACCESS_MESSAGE_CATALOG
int copylogdb_keyword(int *keyval_p, char **keystr_p)
#define HA_SERVER_STATE_ACTIVE_STR
#define CUB_MAXHOSTNAMELEN
int util_make_ha_conf(HA_CONF *ha_conf)
#define GETHOSTNAME(p, l)
char * utility_get_option_string_value(UTIL_ARG_MAP *arg_map, int arg_ch, int index)
static int util_time_to_msec(double *pre, const char *post)
#define MSGCAT_CATALOG_UTILS