55 static FILE *
ldr_check_file (std::string & file_name,
int &error_code);
113 if (!stat.log_message.empty ())
118 if (!stat.error_message.empty ())
124 fprintf (stderr,
"%s", stat.error_message.c_str ());
139 fprintf (stderr,
"%s\n",
er_msg ());
149 const char *exec_name;
151 exec_name =
basename ((
char *) argv0);
162 if (args->
volume.empty ())
202 if (!file_name.empty ())
204 file_p = fopen (file_name.c_str (),
"r");
223 if (!file_name.empty ())
225 std::string::size_type
p = file_name.find (
':');
226 if (p != std::string::npos)
228 std::string::size_type q = p + 1;
229 for (; q != std::string::npos; ++q)
236 if (file_name[q] == 0)
241 line_no = std::stoi (file_name.substr (p + 1));
250 file_name.resize (p);
278 while (*str != end && *str !=
'\0')
301 char *
p, *name_str, *type_str, *order_str, *storage_order_str, *shared_str;
302 int type, order, storage_order, shared;
304 if (meta ==
NULL || attribute ==
NULL)
315 if (name_str ==
NULL || type_str ==
NULL || order_str ==
NULL || storage_order_str ==
NULL)
322 ||
parse_int (&storage_order, storage_order_str, 10) !=
NO_ERROR || (shared_str[0] !=
'S' 323 && shared_str[0] !=
'I'))
329 shared = shared_str[0] ==
'S';
333 print_log_msg (1,
"\nThe type of attribute (%s.%s)" " does not match with the meta information.", table_name,
340 print_log_msg (1,
"\nThe order of attribute (%s.%s)" " does not match with the meta information.", table_name,
347 print_log_msg (1,
"\nThe storage order of attribute (%s.%s)" " does not match with the meta information.",
354 print_log_msg (1,
"\nThe shared flag of attribute (%s.%s)" " does not match with the meta information.",
361 print_log_msg (1,
"\nThe name of attribute (%s.%s)" " does not match with the meta information.", table_name,
380 char *
p, *colon, *comma;
383 char line[LINE_MAX * 100];
384 size_t line_size = LINE_MAX * 100;
387 if (schema_file ==
NULL)
392 if (fseek (schema_file, 0, SEEK_SET) == -1)
400 p = fgets (line, (
int) line_size - 1, schema_file);
406 if (strncmp (p,
"-- !META! ", 10) != 0)
411 colon = strchr (p,
':');
422 if (table_object ==
NULL)
439 comma = strchr (p,
',');
447 "\nThe table %s is not suitable to be" 448 " replicated since it is different from the original.", table_name);
455 if (attribute || comma)
457 print_log_msg (1,
"\nThe number of columns of %s is different" " from meta information.", table_name);
480 FILE *schema_file =
NULL;
481 FILE *index_file =
NULL;
482 FILE *trigger_file =
NULL;
483 FILE *error_file =
NULL;
484 FILE *object_file =
NULL;
489 static bool interrupted =
false;
492 char log_file_name[PATH_MAX];
493 const char *msg_format;
494 obt_Enable_autoincrement =
false;
496 int schema_file_start_line = 1, index_file_start_line = 1, trigger_file_start_line = 1;
508 PRINT_AND_LOG_ERR_MSG (
"loaddb: CS mode loaddb cannot be run in HA mode. Please turn off HA mode.\n");
542 if (loaddb_log_file ==
NULL)
550 if (!args.
user_name.empty () || !dba_mode)
634 else if (object_file !=
NULL)
636 fclose (object_file);
674 if (error_file ==
NULL)
703 print_log_msg (1,
"\n--load-only parameter is not supported on Client-Server mode. ");
704 print_log_msg (1,
"The default behavior of loaddb is loading without checking the file.\n");
709 if (schema_file !=
NULL)
727 print_log_msg (1,
"\nError occurred during schema loading." "\nAborting current transaction...");
728 msg_format =
"Error occurred during schema loading." "Aborting current transaction...\n";
734 args.
schema_file.c_str (), schema_file_start_line);
751 print_log_msg (1,
"Statistics for Catalog classes have been updated.\n\n");
766 fclose (schema_file);
783 #if defined (SA_MODE) 785 #else // !SA_MODE = CS_MODE 787 #endif // !SA_MODE = CS_MODE 789 if (interrupted || status != 0)
799 if (index_file !=
NULL)
806 print_log_msg (1,
"\nError occurred during index loading." "\nAborting current transaction...");
807 msg_format =
"Error occurred during index loading." "Aborting current transaction...\n";
813 args.
index_file.c_str (), index_file_start_line);
831 if (trigger_file !=
NULL)
839 print_log_msg (1,
"\nError occurred during trigger loading." "\nAborting current transaction...");
840 msg_format =
"Error occurred during trigger loading." "Aborting current transaction...\n";
863 if (index_file !=
NULL)
868 if (trigger_file !=
NULL)
870 fclose (trigger_file);
878 fclose (loaddb_log_file);
885 if (schema_file !=
NULL)
887 fclose (schema_file);
889 if (index_file !=
NULL)
893 if (trigger_file !=
NULL)
895 fclose (trigger_file);
897 if (loaddb_log_file !=
NULL)
899 fclose (loaddb_log_file);
906 #if defined (ENABLE_UNUSED_FUNCTION) 959 int stmt_cnt, stmt_id = 0, stmt_type;
960 int executed_cnt = 0;
961 int last_statement_line_no = 0;
962 int check_line_no =
true;
965 if ((*start_line) > 1)
967 int line_count = *start_line - 1;
971 int c = fgetc (input_stream);
976 file_name, *start_line);
985 while (line_count > 0);
988 check_line_no =
false;
1023 if (stmt_cnt <= 0 || stmt_id <= 0)
1029 if (session_error !=
NULL)
1037 print_log_msg (1,
"In %s line %d,\n", file_name, line + (*start_line) - 1);
1044 while (session_error);
1077 last_statement_line_no);
1078 *start_line = last_statement_line_no + 1;
1093 *start_line = last_statement_line_no + 1;
1094 print_log_msg (1,
"Total %8d statements executed.\n", executed_cnt);
1121 args->
volume = volume ? volume : empty;
1122 args->
input_file = input_file ? input_file : empty;
1123 args->
user_name = user_name ? user_name : empty;
1124 args->
password = password ? password : empty;
1141 args->
schema_file = schema_file ? schema_file : empty;
1142 args->
index_file = index_file ? index_file : empty;
1143 args->
trigger_file = trigger_file ? trigger_file : empty;
1144 args->
object_file = object_file ? object_file : empty;
1145 args->
error_file = error_file ? error_file : empty;
1148 args->
table_name = table_name ? table_name : empty;
1182 *interrupted =
true;
1203 std::this_thread::sleep_for (std::chrono::milliseconds (100));
1302 if (class_mop !=
NULL)
1344 bool use_temp_batch =
false;
1345 bool is_batch_accepted =
false;
1354 use_temp_batch =
true;
1358 while (!is_batch_accepted);
1365 std::string class_name;
1373 if (!is_ignored && !class_name.empty ())
DB_OBJECT * db_find_class(const char *name)
#define LOAD_PERIODIC_COMMIT_S
DB_OBJECT * db_attribute_class(DB_ATTRIBUTE *attribute)
void logddl_set_msg(const char *fmt,...)
static void get_loaddb_args(UTIL_ARG_MAP *arg_map, load_args *args)
int split(int batch_size, const std::string &object_file_name, class_handler &c_handler, batch_handler &b_handler)
#define ER_FILE_UNKNOWN_FILE
void db_set_client_type(int client_type)
#define LOAD_ERROR_CONTROL_FILE_S
#define PRINT_AND_LOG_ERR_MSG(...)
int sysprm_set_force(const char *pname, const char *pvalue)
static int load_has_authorization(const std::string &class_name, DB_AUTH au_type)
DB_ATTRIBUTE * db_get_attributes(DB_OBJECT *obj)
static int ldr_compare_attribute_with_meta(char *table_name, char *meta, DB_ATTRIBUTE *attribute)
int db_login(const char *name, const char *password)
void logddl_set_db_name(const char *db_name)
DB_OBJECT * db_get_owner(DB_OBJECT *class_obj)
std::string error_message
static int ldr_exec_query_from_file(const char *file_name, FILE *input_stream, int *start_line, load_args *args)
#define LOAD_CS_FORCE_LOAD_S
int parse_int(int *ret_p, const char *str_p, int base)
#define AU_DISABLE_PASSWORDS
std::string ignore_class_file
static FILE * ldr_check_file(std::string &file_name, int &error_code)
static int ldr_compare_storage_order(FILE *schema_file)
#define ASSERT_ERROR_AND_SET(error_code)
int db_query_end(DB_QUERY_RESULT *result)
int db_attribute_order(DB_ATTRIBUTE *attribute)
static void ldr_server_load(load_args *args, int *exit_status, bool *interrupted)
bool au_is_dba_group_member(MOP user)
void util_arm_signal_handlers(SIG_HANDLER sigint_handler, SIG_HANDLER sigquit_handler)
void log_set_interrupt(int set)
#define LOAD_IGNORE_LOGGING_S
static void ldr_exec_query_interrupt_handler(void)
int sm_update_catalog_statistics(const char *class_name, bool with_fullscan)
static int ldr_validate_object_file(const char *argv0, load_args *args)
static int ldr_get_start_line_no(std::string &file_name)
static const int PERIODIC_COMMIT_DEFAULT_VALUE
#define LOAD_IGNORE_CLASS_S
#define LOAD_NO_STATISTICS_S
void logddl_set_logging_enabled(bool enable)
int util_log_write_errid(int message_id,...)
#define LOAD_TRIGGER_FILE_L
const char * db_attribute_name(DB_ATTRIBUTE *attribute)
int db_attribute_is_shared(DB_ATTRIBUTE *attribute)
bool db_disable_trigger(void)
int er_init(const char *msglog_filename, int exit_ask)
#define LOAD_INDEX_FILE_S
#define MSGCAT_GENERAL_ARG_DUPLICATE
int utility_get_option_int_value(UTIL_ARG_MAP *arg_map, int arg_ch)
DB_SESSION_ERROR * db_get_next_error(DB_SESSION_ERROR *errors, int *line, int *col)
int parse_ignore_class_file()
#define LOAD_CHECK_ONLY_L
#define LOAD_COMPARE_STORAGE_ORDER_S
int db_restart(const char *program, int print_version, const char *volume)
int db_parse_one_statement(DB_SESSION *session)
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
std::atomic< int64_t > current_line
bool compare_storage_order
static char * ldr_get_token(char *str, char **out_str, char start, char end)
bool utility_get_option_bool_value(UTIL_ARG_MAP *arg_map, int arg_ch)
int prm_get_integer_value(PARAM_ID prm_id)
static int load_object_file(load_args *args, int *exit_status)
int loaddb_install_class(const cubload::batch &batch, bool &class_is_ignored, std::string &class_name)
int loaddb_user(UTIL_FUNCTION_ARG *arg)
#define LOAD_ESTIMATED_SIZE_S
std::function< int64_t(const batch &)> batch_handler
DB_SESSION * db_make_session_for_one_statement_execution(FILE *file)
#define LOAD_TABLE_NAME_S
int sysprm_load_and_init(const char *db_name, const char *conf_file, const int load_flags)
void logddl_set_commit_count(int count)
const char * LOAD_INDEX_MIN_SORT_BUFFER_PAGES_STRING
void ldr_sa_load(load_args *args, int *status, bool *interrupted)
const char * db_error_string(int level)
DB_ATTRIBUTE * db_attribute_next(DB_ATTRIBUTE *attribute)
const char * LOADDB_LOG_FILENAME_SUFFIX
void logddl_set_load_filename(const char *load_filename)
int au_check_authorization(MOP op, DB_AUTH auth)
int db_abort_transaction(void)
std::vector< stats > & get_load_stats()
int loaddb_update_stats()
int db_execute_statement(DB_SESSION *session, int stmt_ndx, DB_QUERY_RESULT **result)
const char * er_msg(void)
int db_compile_statement(DB_SESSION *session)
void db_close_session(DB_SESSION *session)
int64_t last_committed_line
const int LOAD_INDEX_MIN_SORT_BUFFER_PAGES
static void load_usage(const char *argv0)
#define LOAD_CHECK_ONLY_S
#define MSGCAT_SET_GENERAL
#define LOAD_TRIGGER_FILE_S
#define MSGCAT_CATALOG_CUBRID
DB_OBJECT * db_get_user(void)
FILE * fopen_ex(const char *filename, const char *type)
void(* SIG_HANDLER)(void)
#define LOAD_SCHEMA_FILE_S
static void error(const char *msg)
int db_get_statement_type(DB_SESSION *session, int stmt)
#define ER_AU_INVALID_PASSWORD
static FILE * loaddb_log_file
void print_log_msg(int verbose, const char *fmt,...)
void logddl_set_pid(const int pid)
int sm_update_all_catalog_statistics(bool with_fullscan)
static int loaddb_internal(UTIL_FUNCTION_ARG *arg, int dba_mode)
void logddl_set_loaddb_file_type(T_LOADDB_FILE_TYPE file_type)
#define STATS_WITH_FULLSCAN
void logddl_set_app_name(T_APP_NAME app_name)
bool obt_Enable_autoincrement
static void print_stats(std::vector< cubload::stats > &stats, cubload::load_args &args, int *status)
bool prm_get_bool_value(PARAM_ID prm_id)
static void print_er_msg()
int util_log_write_errstr(const char *format,...)
int loaddb_load_batch(const cubload::batch &batch, bool use_temp_batch, bool &is_batch_accepted, load_status &status)
char * basename(const char *path)
std::function< int64_t(const batch &, bool &)> class_handler
DB_TYPE db_attribute_type(DB_ATTRIBUTE *attribute)
char * msgcat_message(int cat_id, int set_id, int msg_id)
const char * prm_get_name(PARAM_ID prm_id)
void get_ignored_errors(std::vector< int > &vec)
#define LOAD_ERROR_CONTROL_FILE_L
void logddl_set_user_name(const char *user_name)
#define OPTION_STRING_TABLE
void logddl_set_err_code(int err_code)
int loaddb_init(cubload::load_args &args)
static void register_signal_handlers()
DB_SESSION_ERROR * db_get_errors(DB_SESSION *session)
const char * command_name
char * utility_get_option_string_value(UTIL_ARG_MAP *arg_map, int arg_ch, int index)
void logddl_set_file_line(int file_line)
int db_commit_transaction(void)
std::vector< int > m_ignored_errors
int loaddb_fetch_status(load_status &status)
int locator_log_force_nologging(void)
void logddl_set_start_time(struct timeval *time_val)
int er_filter_fileset(FILE *ef)
int db_get_line_of_statement(DB_SESSION *session, int stmt_id)
#define MSGCAT_CATALOG_UTILS