CUBRID Engine  latest
load_db.c
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * load_db.c - Main for database loader
21  */
22 
23 #include "config.h"
24 
25 #include "chartype.h"
26 #include "db.h"
27 #include "load_object.h"
28 #if defined (SA_MODE)
29 #include "load_sa_loader.hpp"
30 #endif // SA_MODE
31 #include "network_interface_cl.h"
32 #include "porting.h"
33 #include "schema_manager.h"
34 #include "transform.h"
35 #include "utility.h"
36 #include "authenticate.h"
37 #include "ddl_log.h"
38 
39 #include <fstream>
40 #include <thread>
41 
44 const char *LOADDB_LOG_FILENAME_SUFFIX = "loaddb.log";
45 
46 using namespace cubload;
47 
48 static FILE *loaddb_log_file;
49 
50 int interrupt_query = false;
51 bool load_interrupted = false;
52 
53 static int ldr_validate_object_file (const char *argv0, load_args * args);
54 static int ldr_get_start_line_no (std::string & file_name);
55 static FILE *ldr_check_file (std::string & file_name, int &error_code);
56 static int loaddb_internal (UTIL_FUNCTION_ARG * arg, int dba_mode);
57 static void ldr_exec_query_interrupt_handler (void);
58 static int ldr_exec_query_from_file (const char *file_name, FILE * input_stream, int *start_line, load_args * args);
59 static int ldr_compare_attribute_with_meta (char *table_name, char *meta, DB_ATTRIBUTE * attribute);
60 static int ldr_compare_storage_order (FILE * schema_file);
61 static void get_loaddb_args (UTIL_ARG_MAP * arg_map, load_args * args);
62 /* *INDENT-OFF* */
63 static void print_stats (std::vector<cubload::stats> &stats, cubload::load_args &args, int *status);
64 /* *INDENT-ON* */
65 
66 static void ldr_server_load (load_args * args, int *exit_status, bool * interrupted);
67 static void register_signal_handlers ();
68 /* *INDENT-OFF* */
69 static int load_has_authorization (const std::string & class_name, DB_AUTH au_type);
70 /* *INDENT-ON* */
71 static int load_object_file (load_args * args, int *exit_status);
72 static void print_er_msg ();
73 
74 /*
75  * print_log_msg - print log message
76  * return: void
77  * verbose(in): if set also print the message to standard output
78  * fmt(in): string format
79  * ...(in): string format arguments
80  */
81 void
82 print_log_msg (int verbose, const char *fmt, ...)
83 {
84  va_list ap;
85 
86  if (verbose)
87  {
88  va_start (ap, fmt);
89  vprintf (fmt, ap);
90  fflush (stdout);
91  va_end (ap);
92  }
93 
94  if (loaddb_log_file != NULL)
95  {
96  va_start (ap, fmt);
97  vfprintf (loaddb_log_file, fmt, ap);
98  fflush (loaddb_log_file);
99  va_end (ap);
100  }
101  else
102  {
103  assert (false);
104  }
105 }
106 
107 /* *INDENT-OFF* */
108 void
109 print_stats (std::vector<cubload::stats> &stats, cubload::load_args &args, int *status)
110 {
111  for (const cubload::stats &stat : stats)
112  {
113  if (!stat.log_message.empty ())
114  {
115  print_log_msg (args.verbose, stat.log_message.c_str ());
116  }
117 
118  if (!stat.error_message.empty ())
119  {
120  /* Skip if syntax check only is enabled since we do not want to stop on error. */
121  if (!args.syntax_check)
122  {
123  *status = 3;
124  fprintf (stderr, "%s", stat.error_message.c_str ());
125  }
126  }
127  }
128 }
129 /* *INDENT-ON* */
130 
131 static void
133 {
134  if (!er_has_error ())
135  {
136  return;
137  }
138 
139  fprintf (stderr, "%s\n", er_msg ());
140 }
141 
142 /*
143  * load_usage() - print an usage of the load-utility
144  * return: void
145  */
146 static void
147 load_usage (const char *argv0)
148 {
149  const char *exec_name;
150 
151  exec_name = basename ((char *) argv0);
153 }
154 
155 /*
156  * ldr_validate_object_file - check input file arguments
157  * return: NO_ERROR if successful, ER_FAILED if error
158  */
159 static int
160 ldr_validate_object_file (const char *argv0, load_args * args)
161 {
162  if (args->volume.empty ())
163  {
165  load_usage (argv0);
166  return ER_FAILED;
167  }
168 
169  if (args->input_file.empty () && args->object_file.empty ())
170  {
171  /* if schema/index file are specified, process them only */
172  if (args->schema_file.empty () && args->index_file.empty ())
173  {
175  load_usage (argv0);
176  return ER_FAILED;
177  }
178  }
179  else if (!args->input_file.empty () && !args->object_file.empty () && args->input_file != args->object_file)
180  {
182  "input-file");
183  return ER_FAILED;
184  }
185  else
186  {
187  if (args->object_file.empty ())
188  {
189  args->object_file = args->input_file;
190  }
191  }
192 
193  return NO_ERROR;
194 }
195 
196 static FILE *
197 ldr_check_file (std::string & file_name, int &error_code)
198 {
199  FILE *file_p = NULL;
200  error_code = NO_ERROR;
201 
202  if (!file_name.empty ())
203  {
204  file_p = fopen (file_name.c_str (), "r");
205  if (file_p == NULL)
206  {
208  print_log_msg (1, msg_format, file_name.c_str ());
209  util_log_write_errstr (msg_format, file_name.c_str ());
210  error_code = ER_FAILED;
211  }
212  }
213 
214  return file_p;
215 }
216 
217 static int
218 ldr_get_start_line_no (std::string & file_name)
219 {
220  // default start from line no 1
221  int line_no = 1;
222 
223  if (!file_name.empty ())
224  {
225  std::string::size_type p = file_name.find (':');
226  if (p != std::string::npos)
227  {
228  std::string::size_type q = p + 1;
229  for (; q != std::string::npos; ++q)
230  {
231  if (!char_isdigit (file_name[q]))
232  {
233  break;
234  }
235  }
236  if (file_name[q] == 0)
237  {
238  /* *INDENT-OFF* */
239  try
240  {
241  line_no = std::stoi (file_name.substr (p + 1));
242  }
243  catch (...)
244  {
245  // parse failed, fallback to default value
246  }
247  /* *INDENT-ON* */
248 
249  // remove line no from file name
250  file_name.resize (p);
251  }
252  }
253  }
254 
255  return line_no;
256 }
257 
258 static char *
259 ldr_get_token (char *str, char **out_str, char start, char end)
260 {
261  char *p = NULL;
262 
263  if (out_str)
264  {
265  *out_str = NULL;
266  }
267 
268  if (str == NULL)
269  {
270  return NULL;
271  }
272 
273  if (*str == start)
274  {
275  str++;
276  p = str;
277  }
278  while (*str != end && *str != '\0')
279  {
280  str++;
281  }
282 
283  if (*str != end)
284  {
285  return NULL;
286  }
287 
288  *str = '\0';
289  *out_str = p;
290  return str + 1;
291 }
292 
293 /*
294  * ldr_compare_attribute_with_meta -
295  * return: NO_ERROR if successful, ER_FAILED otherwise
296  */
297 static int
298 ldr_compare_attribute_with_meta (char *table_name, char *meta, DB_ATTRIBUTE * attribute)
299 {
300  int error = NO_ERROR;
301  char *p, *name_str, *type_str, *order_str, *storage_order_str, *shared_str;
302  int type, order, storage_order, shared;
303 
304  if (meta == NULL || attribute == NULL)
305  {
306  return ER_FAILED;
307  }
308 
309  p = meta;
310  p = ldr_get_token (p, &name_str, '[', ']');
311  p = ldr_get_token (p, &type_str, '(', ')');
312  p = ldr_get_token (p, &order_str, '(', ')');
313  p = ldr_get_token (p, &storage_order_str, '(', ')');
314  p = ldr_get_token (p, &shared_str, '(', ')');
315  if (name_str == NULL || type_str == NULL || order_str == NULL || storage_order_str == NULL)
316  {
317  print_log_msg (1, "\nCan not build meta: %s", table_name);
318  error = ER_FAILED;
319  goto compare_end;
320  }
321  if (parse_int (&type, type_str, 10) != NO_ERROR || parse_int (&order, order_str, 10) != NO_ERROR
322  || parse_int (&storage_order, storage_order_str, 10) != NO_ERROR || (shared_str[0] != 'S'
323  && shared_str[0] != 'I'))
324  {
325  print_log_msg (1, "\nCan not build meta: %s", table_name);
326  error = ER_FAILED;
327  goto compare_end;
328  }
329  shared = shared_str[0] == 'S';
330 
331  if (type != db_attribute_type (attribute))
332  {
333  print_log_msg (1, "\nThe type of attribute (%s.%s)" " does not match with the meta information.", table_name,
334  db_attribute_name (attribute));
335  error = ER_FAILED;
336  goto compare_end;
337  }
338  if (order != db_attribute_order (attribute))
339  {
340  print_log_msg (1, "\nThe order of attribute (%s.%s)" " does not match with the meta information.", table_name,
341  db_attribute_name (attribute));
342  error = ER_FAILED;
343  goto compare_end;
344  }
345  if (storage_order != attribute->storage_order)
346  {
347  print_log_msg (1, "\nThe storage order of attribute (%s.%s)" " does not match with the meta information.",
348  table_name, db_attribute_name (attribute));
349  error = ER_FAILED;
350  goto compare_end;
351  }
352  if (shared != db_attribute_is_shared (attribute))
353  {
354  print_log_msg (1, "\nThe shared flag of attribute (%s.%s)" " does not match with the meta information.",
355  table_name, db_attribute_name (attribute));
356  error = ER_FAILED;
357  goto compare_end;
358  }
359  if (strcmp (name_str, db_attribute_name (attribute)) != 0)
360  {
361  print_log_msg (1, "\nThe name of attribute (%s.%s)" " does not match with the meta information.", table_name,
362  db_attribute_name (attribute));
363  error = ER_FAILED;
364  goto compare_end;
365  }
366 
367 compare_end:
368  return error;
369 }
370 
371 /*
372  * ldr_compare_storage_order -
373  * return: NO_ERROR if successful, ER_FAILED otherwise
374  * compare_tables(in): two tables in a string (ex. foo:bar,apple:banana)
375  */
376 static int
377 ldr_compare_storage_order (FILE * schema_file)
378 {
379  char *table_name;
380  char *p, *colon, *comma;
382  DB_OBJECT *table_object;
383  char line[LINE_MAX * 100];
384  size_t line_size = LINE_MAX * 100;
385  int error = NO_ERROR;
386 
387  if (schema_file == NULL)
388  {
389  return error;
390  }
391 
392  if (fseek (schema_file, 0, SEEK_SET) == -1)
393  {
394  print_log_msg (1, "\nCan not build meta...");
395  return ER_FAILED;
396  }
397 
398  while (true)
399  {
400  p = fgets (line, (int) line_size - 1, schema_file);
401  if (p == NULL)
402  {
403  break;
404  }
405 
406  if (strncmp (p, "-- !META! ", 10) != 0)
407  {
408  continue;
409  }
410  p += 10;
411  colon = strchr (p, ':');
412  if (colon == NULL)
413  {
414  print_log_msg (1, "\nInvalid meta: %s", line);
415  error = ER_FAILED;
416  goto compare_end;
417  }
418 
419  *colon = '\0';
420  p = ldr_get_token (p, &table_name, '[', ']');
421  table_object = db_find_class (table_name);
422  if (table_object == NULL)
423  {
424  print_log_msg (1, "\nCan not find table: %s", table_name);
425  error = ER_FAILED;
426  goto compare_end;
427  }
428 
429  p = colon + 1;
430  comma = p;
431  attribute = db_get_attributes (table_object);
432  for (; attribute && comma; attribute = db_attribute_next (attribute))
433  {
434  if (db_attribute_class (attribute) != table_object)
435  {
436  continue;
437  }
438 
439  comma = strchr (p, ',');
440  if (comma)
441  {
442  *comma = '\0';
443  }
444  if (ldr_compare_attribute_with_meta (table_name, p, attribute) != NO_ERROR)
445  {
446  print_log_msg (1,
447  "\nThe table %s is not suitable to be"
448  " replicated since it is different from the original.", table_name);
449  error = ER_FAILED;
450  goto compare_end;
451  }
452  p = comma + 1;
453  }
454 
455  if (attribute || comma)
456  {
457  print_log_msg (1, "\nThe number of columns of %s is different" " from meta information.", table_name);
458  error = ER_FAILED;
459  goto compare_end;
460  }
461  }
462 
463 compare_end:
464  return error;
465 }
466 
467 /*
468  * loaddb_internal - internal main loaddb function
469  * return: NO_ERROR if successful, error code otherwise
470  * argc(in): argc of main
471  * argv(in): argv of main
472  * dba_mode(in):
473  */
474 static int
475 loaddb_internal (UTIL_FUNCTION_ARG * arg, int dba_mode)
476 {
477  UTIL_ARG_MAP *arg_map = arg->arg_map;
478  int error = NO_ERROR;
479  /* set to static to avoid compiler warning (clobbered by longjump) */
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;
485 
486  char *passwd;
487  int status = 0;
488  /* set to static to avoid compiler warning (clobbered by longjump) */
489  static bool interrupted = false;
490  int au_save = 0;
491  extern bool obt_Enable_autoincrement;
492  char log_file_name[PATH_MAX];
493  const char *msg_format;
494  obt_Enable_autoincrement = false;
495  load_args args;
496  int schema_file_start_line = 1, index_file_start_line = 1, trigger_file_start_line = 1;
497 
498  get_loaddb_args (arg_map, &args);
499 
500  if (utility_get_option_int_value (arg_map, LOAD_CS_MODE_S) == true)
501  {
503  {
505  {
507  {
508  PRINT_AND_LOG_ERR_MSG ("loaddb: CS mode loaddb cannot be run in HA mode. Please turn off HA mode.\n");
509  status = 1;
510  goto error_return;
511  }
512  }
513  }
514  else
515  {
516  PRINT_AND_LOG_ERR_MSG ("loaddb: Cannot load system parameters.\n");
517  status = 1;
518  goto error_return;
519  }
520  }
521 
522  if (ldr_validate_object_file (arg->argv0, &args) != NO_ERROR)
523  {
524  status = 1;
525  goto error_return;
526  }
527 
528  /* error message log file */
529  sprintf (log_file_name, "%s_%s.err", args.volume.c_str (), arg->command_name);
530  er_init (log_file_name, ER_NEVER_EXIT);
531 
533  {
535  }
536 
538 
539  /* open loaddb log file */
540  sprintf (log_file_name, "%s_%s", args.volume.c_str (), LOADDB_LOG_FILENAME_SUFFIX);
541  loaddb_log_file = fopen (log_file_name, "w+");
542  if (loaddb_log_file == NULL)
543  {
544  PRINT_AND_LOG_ERR_MSG ("Cannot open log file %s\n", log_file_name);
545  status = 2;
546  goto error_return;
547  }
548 
549  /* login */
550  if (!args.user_name.empty () || !dba_mode)
551  {
552  (void) db_login (args.user_name.c_str (), args.password.c_str ());
553  error = db_restart (arg->command_name, true, args.volume.c_str ());
554  if (error != NO_ERROR)
555  {
556  if (error == ER_AU_INVALID_PASSWORD)
557  {
558  /* prompt for password and try again */
559  passwd =
561  if (!strlen (passwd))
562  {
563  passwd = NULL;
564  }
565  (void) db_login (args.user_name.c_str (), passwd);
566  error = db_restart (arg->command_name, true, args.volume.c_str ());
567  }
568  }
569  }
570  else
571  {
572  /* if we're in the protected DBA mode, just login without authorization */
575  (void) db_login ("DBA", NULL);
576  error = db_restart (arg->command_name, true, args.volume.c_str ());
577  }
578 
579  if (error != NO_ERROR)
580  {
581  if (er_errid () < ER_FAILED)
582  {
583  // an error was set.
584  print_log_msg (1, "%s\n", db_error_string (3));
586  }
587  else
588  {
589  PRINT_AND_LOG_ERR_MSG ("Cannot restart database %s\n", args.volume.c_str ());
590  }
591  status = 3;
592  goto error_return;
593  }
594 
595  logddl_init ();
598  logddl_set_db_name (args.volume.c_str ());
599  logddl_set_user_name (args.user_name.c_str ());
600  logddl_set_pid (getpid ());
601 
602  /* disable trigger actions to be fired */
604 
605  schema_file_start_line = ldr_get_start_line_no (args.schema_file);
606  index_file_start_line = ldr_get_start_line_no (args.index_file);
607  trigger_file_start_line = ldr_get_start_line_no (args.trigger_file);
608 
609  /* check if schema/index/object files exist */
610  schema_file = ldr_check_file (args.schema_file, error);
611  if (error != NO_ERROR && schema_file == NULL)
612  {
613  status = 2;
614  goto error_return;
615  }
616  index_file = ldr_check_file (args.index_file, error);
617  if (error != NO_ERROR && index_file == NULL)
618  {
619  status = 2;
620  goto error_return;
621  }
622  trigger_file = ldr_check_file (args.trigger_file, error);
623  if (error != NO_ERROR && trigger_file == NULL)
624  {
625  status = 2;
626  goto error_return;
627  }
628  object_file = ldr_check_file (args.object_file, error);
629  if (error != NO_ERROR && object_file == NULL)
630  {
631  status = 2;
632  goto error_return;
633  }
634  else if (object_file != NULL)
635  {
636  fclose (object_file);
637  }
638 
639  if (!args.ignore_class_file.empty ())
640  {
641  int retval = args.parse_ignore_class_file ();
642  if (retval < 0)
643  {
644  if (retval != ER_FILE_UNKNOWN_FILE)
645  {
646  // To keep compatibility we need to continue even though the ignore-classes file does not exist.
647  status = 2;
648  goto error_return;
649  }
650  }
651  }
652 
653  /* Disallow syntax only and load only options together */
654  if (args.load_only && args.syntax_check)
655  {
657  print_log_msg (1, msg_format, "--" LOAD_LOAD_ONLY_L, "--" LOAD_CHECK_ONLY_L);
659  status = 1; /* parsing error */
660  goto error_return;
661  }
662 
663  if (!args.error_file.empty ())
664  {
665  if (args.syntax_check)
666  {
668  print_log_msg (1, msg_format, "--" LOAD_ERROR_CONTROL_FILE_L, "--" LOAD_CHECK_ONLY_L);
670  status = 1; /* parsing error */
671  goto error_return;
672  }
673  error_file = fopen_ex (args.error_file.c_str (), "rt");
674  if (error_file == NULL)
675  {
677  print_log_msg (1, msg_format, args.error_file.c_str ());
678  util_log_write_errstr (msg_format, args.error_file.c_str ());
679  status = 2;
680  goto error_return;
681  }
682  er_filter_fileset (error_file);
683  fclose (error_file);
685  }
686 
687  /* check if no log option can be applied */
688  if (error || (args.ignore_logging != 0 && locator_log_force_nologging () != NO_ERROR))
689  {
690  /* couldn't log in */
691  print_log_msg (1, "%s\n", db_error_string (3));
693  status = 3;
694  db_end_session ();
695  db_shutdown ();
696  goto error_return;
697  }
698 
699 #if defined(CS_MODE)
700  if (args.load_only)
701  {
702  /* This is the default behavior. It is changed from the old one so we notify the user. */
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");
705  }
706 #endif
707 
708  /* if schema file is specified, do schema loading */
709  if (schema_file != NULL)
710  {
711  print_log_msg (1, "\nStart schema loading.\n");
712 
714  logddl_set_load_filename (args.schema_file.c_str ());
715  /*
716  * CUBRID 8.2 should be compatible with earlier versions of CUBRID.
717  * Therefore, we do not perform user authentication when the loader
718  * is executing by DBA group user.
719  */
721  {
722  AU_DISABLE (au_save);
723  }
724 
725  if (ldr_exec_query_from_file (args.schema_file.c_str (), schema_file, &schema_file_start_line, &args) != NO_ERROR)
726  {
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";
729  util_log_write_errstr (msg_format);
730  status = 3;
731  db_end_session ();
732  db_shutdown ();
733  print_log_msg (1, " done.\n\nRestart loaddb with '-%c %s:%d' option\n", LOAD_SCHEMA_FILE_S,
734  args.schema_file.c_str (), schema_file_start_line);
735  logddl_write_end ();
736  goto error_return;
737  }
738 
740  {
741  AU_ENABLE (au_save);
742  }
743 
744  print_log_msg (1, "Schema loading from %s finished.\n", args.schema_file.c_str ());
745 
746  /* update catalog statistics */
747  AU_DISABLE (au_save);
749  AU_ENABLE (au_save);
750 
751  print_log_msg (1, "Statistics for Catalog classes have been updated.\n\n");
752 
753  if (args.compare_storage_order)
754  {
755  if (ldr_compare_storage_order (schema_file) != NO_ERROR)
756  {
757  status = 3;
758  db_end_session ();
759  db_shutdown ();
760  print_log_msg (1, "\nAborting current transaction...\n");
761  goto error_return;
762  }
763  }
764 
766  fclose (schema_file);
767  schema_file = NULL;
768 
769  logddl_write_end ();
770  }
771 
772  if (!args.object_file.empty ())
773  {
774  if (args.syntax_check)
775  {
776  print_log_msg (1, "\nStart object syntax checking.\n");
777  }
778  else
779  {
780  print_log_msg (1, "\nStart object loading.\n");
781  }
782 
783 #if defined (SA_MODE)
784  ldr_sa_load (&args, &status, &interrupted);
785 #else // !SA_MODE = CS_MODE
786  ldr_server_load (&args, &status, &interrupted);
787 #endif // !SA_MODE = CS_MODE
788 
789  if (interrupted || status != 0)
790  {
791  // failed
792  db_end_session ();
793  db_shutdown ();
794  goto error_return;
795  }
796  }
797 
798  /* if index file is specified, do index creation */
799  if (index_file != NULL)
800  {
801  print_log_msg (1, "\nStart index loading.\n");
803  logddl_set_load_filename (args.index_file.c_str ());
804  if (ldr_exec_query_from_file (args.index_file.c_str (), index_file, &index_file_start_line, &args) != NO_ERROR)
805  {
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";
808  util_log_write_errstr (msg_format);
809  status = 3;
810  db_end_session ();
811  db_shutdown ();
812  print_log_msg (1, " done.\n\nRestart loaddb with '-%c %s:%d' option\n", LOAD_INDEX_FILE_S,
813  args.index_file.c_str (), index_file_start_line);
814  logddl_write_end ();
815  goto error_return;
816  }
817 
818  /* update catalog statistics */
819  AU_DISABLE (au_save);
822  AU_ENABLE (au_save);
823 
824  print_log_msg (1, "Index loading from %s finished.\n", args.index_file.c_str ());
826 
827  logddl_set_err_code (error);
828  logddl_write_end ();
829  }
830 
831  if (trigger_file != NULL)
832  {
833  print_log_msg (1, "\nStart trigger loading.\n");
835  logddl_set_load_filename (args.trigger_file.c_str ());
836  if (ldr_exec_query_from_file (args.trigger_file.c_str (), trigger_file, &trigger_file_start_line, &args) !=
837  NO_ERROR)
838  {
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";
841  util_log_write_errstr (msg_format);
842  status = 3;
843  db_end_session ();
844  db_shutdown ();
845  print_log_msg (1, " done.\n\nRestart loaddb with '--%s %s:%d' option\n", LOAD_TRIGGER_FILE_L,
846  args.trigger_file.c_str (), trigger_file_start_line);
847  logddl_write_end ();
848  goto error_return;
849  }
850 
851  /* update catalog statistics */
852  AU_DISABLE (au_save);
854  AU_ENABLE (au_save);
855 
856  print_log_msg (1, "Trigger loading from %s finished.\n", args.trigger_file.c_str ());
858 
859  logddl_set_err_code (error);
860  logddl_write_end ();
861  }
862 
863  if (index_file != NULL)
864  {
865  fclose (index_file);
866  index_file = NULL;
867  }
868  if (trigger_file != NULL)
869  {
870  fclose (trigger_file);
871  trigger_file = NULL;
872  }
873 
875  (void) db_end_session ();
876  (void) db_shutdown ();
877 
878  fclose (loaddb_log_file);
879 
880  logddl_destroy ();
881 
882  return status;
883 
884 error_return:
885  if (schema_file != NULL)
886  {
887  fclose (schema_file);
888  }
889  if (index_file != NULL)
890  {
891  fclose (index_file);
892  }
893  if (trigger_file != NULL)
894  {
895  fclose (trigger_file);
896  }
897  if (loaddb_log_file != NULL)
898  {
899  fclose (loaddb_log_file);
900  }
901 
902  logddl_destroy ();
903  return status;
904 }
905 
906 #if defined (ENABLE_UNUSED_FUNCTION)
907 /*
908  * loaddb_dba - loaddb in DBA mode
909  * return: NO_ERROR if successful, error code otherwise
910  * argc(in): argc in main
911  * argv(in): argv in main
912  */
913 int
914 loaddb_dba (UTIL_FUNCTION_ARG * arg)
915 {
916  return loaddb_internal (arg, 1);
917 }
918 #endif /* ENABLE_UNUSED_FUNCTION */
919 
920 /*
921  * loaddb_user - loaddb in user mode
922  * return: NO_ERROR if successful, error code otherwise
923  * argc(in): argc in main
924  * argv(in): argv in main
925  */
926 int
928 {
929  return loaddb_internal (arg, 0);
930 }
931 
932 /*
933  * ldr_exec_query_interrupt_handler - signal handler registered via
934  * util_arm_signal_handlers
935  * return: void
936  */
937 static void
939 {
940  interrupt_query = true;
941 
942  log_set_interrupt (true);
943 }
944 
945 /*
946  * ldr_exec_query_from_file - execute queries from file
947  * return: 0 if successful, non-zero otherwise
948  * file_name(in): file path
949  * file(in): FILE *
950  * start_line(in): start line
951  * commit_period(in): commit period
952  */
953 static int
954 ldr_exec_query_from_file (const char *file_name, FILE * input_stream, int *start_line, load_args * args)
955 {
957  DB_QUERY_RESULT *res = NULL;
958  int error = NO_ERROR;
959  int stmt_cnt, stmt_id = 0, stmt_type;
960  int executed_cnt = 0;
961  int last_statement_line_no = 0; // tracks line no of the last successfully executed stmt. -1 for failed ones.
962  int check_line_no = true;
963  PT_NODE *statement = NULL;
964 
965  if ((*start_line) > 1)
966  {
967  int line_count = *start_line - 1;
968 
969  do
970  {
971  int c = fgetc (input_stream);
972  if (c == EOF)
973  {
974  print_log_msg (1,
976  file_name, *start_line);
977  error = ER_GENERIC_ERROR;
978  goto end;
979  }
980  else if (c == '\n')
981  {
982  line_count--;
983  }
984  }
985  while (line_count > 0);
986  }
987 
988  check_line_no = false;
989  session = db_make_session_for_one_statement_execution (input_stream);
990  if (session == NULL)
991  {
992  print_log_msg (1, "ERROR: %s\n", db_error_string (3));
993  assert (er_errid () != NO_ERROR);
994  error = er_errid ();
995  goto end;
996  }
997 
999 
1001 
1002  while (true)
1003  {
1004  if (interrupt_query)
1005  {
1006  if (er_errid () != ER_INTERRUPTED)
1007  {
1009  }
1010  error = er_errid ();
1011  db_close_session (session);
1012  goto end;
1013  }
1014 
1015  stmt_cnt = db_parse_one_statement (session);
1016  if (stmt_cnt > 0)
1017  {
1018  stmt_id = db_compile_statement (session);
1019  last_statement_line_no = db_get_line_of_statement (session, stmt_id);
1020  }
1021 
1022  // Any error occured during compilation, report it!
1023  if (stmt_cnt <= 0 || stmt_id <= 0)
1024  {
1025  DB_SESSION_ERROR *session_error;
1026  int line, col;
1027 
1028  session_error = db_get_errors (session);
1029  if (session_error != NULL)
1030  {
1031  do
1032  {
1033  session_error = db_get_next_error (session_error, &line, &col);
1034  if (line >= 0)
1035  {
1036  // We need -1 here since start_line will offset the output.
1037  print_log_msg (1, "In %s line %d,\n", file_name, line + (*start_line) - 1);
1038  print_log_msg (1, "ERROR: %s \n", db_error_string (3));
1039  assert (er_errid () != NO_ERROR);
1040  error = er_errid ();
1041  logddl_set_file_line (line);
1042  }
1043  }
1044  while (session_error);
1045  }
1046  db_close_session (session);
1047  break;
1048  }
1049 
1050  stmt_type = db_get_statement_type (session, stmt_id);
1051 
1052  res = (DB_QUERY_RESULT *) NULL;
1053  error = db_execute_statement (session, stmt_id, &res);
1054 
1055  if (error < 0)
1056  {
1057  print_log_msg (1, "ERROR: %s\n", db_error_string (3));
1058  db_close_session (session);
1059  logddl_set_file_line (last_statement_line_no);
1060  break;
1061  }
1062  executed_cnt++;
1063  error = db_query_end (res);
1064  if (error < 0)
1065  {
1066  print_log_msg (1, "ERROR: %s\n", db_error_string (3));
1067  db_close_session (session);
1068  logddl_set_file_line (last_statement_line_no);
1069  break;
1070  }
1071 
1072  if (stmt_type == CUBRID_STMT_COMMIT_WORK
1073  || (args->periodic_commit && (executed_cnt % args->periodic_commit == 0)))
1074  {
1076  print_log_msg (args->verbose_commit, "%8d statements executed. Commit transaction at line %d\n", executed_cnt,
1077  last_statement_line_no);
1078  *start_line = last_statement_line_no + 1;
1079  }
1080  print_log_msg ((int) args->verbose, "Total %8d statements executed.\r", executed_cnt);
1081  fflush (stdout);
1082  }
1083 
1084 end:
1085  if (error < 0)
1086  {
1088  logddl_set_err_code (error);
1089  logddl_set_commit_count ((executed_cnt / args->periodic_commit) * args->periodic_commit);
1090  }
1091  else
1092  {
1093  *start_line = last_statement_line_no + 1;
1094  print_log_msg (1, "Total %8d statements executed.\n", executed_cnt);
1095  logddl_set_msg ("Total %8d statements executed.", executed_cnt);
1096  fflush (stdout);
1098  }
1099  return error;
1100 }
1101 
1102 static void
1104 {
1105  assert (arg_map != NULL && args != NULL);
1106 
1107  std::string empty;
1108 
1109  char *volume = utility_get_option_string_value (arg_map, OPTION_STRING_TABLE, 0);
1110  char *input_file = utility_get_option_string_value (arg_map, OPTION_STRING_TABLE, 1);
1111  char *user_name = utility_get_option_string_value (arg_map, LOAD_USER_S, 0);
1112  char *password = utility_get_option_string_value (arg_map, LOAD_PASSWORD_S, 0);
1113  char *schema_file = utility_get_option_string_value (arg_map, LOAD_SCHEMA_FILE_S, 0);
1114  char *index_file = utility_get_option_string_value (arg_map, LOAD_INDEX_FILE_S, 0);
1115  char *trigger_file = utility_get_option_string_value (arg_map, LOAD_TRIGGER_FILE_S, 0);
1116  char *object_file = utility_get_option_string_value (arg_map, LOAD_DATA_FILE_S, 0);
1117  char *error_file = utility_get_option_string_value (arg_map, LOAD_ERROR_CONTROL_FILE_S, 0);
1118  char *table_name = utility_get_option_string_value (arg_map, LOAD_TABLE_NAME_S, 0);
1119  char *ignore_class_file = utility_get_option_string_value (arg_map, LOAD_IGNORE_CLASS_S, 0);
1120 
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;
1131  args->verbose_commit = args->periodic_commit > 0;
1132 
1133  /* *INDENT-OFF* */
1134  if (args->periodic_commit == 0)
1135  {
1136  // We set the periodic commit to a default value.
1138  }
1139  /* *INDENT-ON* */
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;
1149  args->ignore_class_file = ignore_class_file ? ignore_class_file : empty;
1150 }
1151 
1152 static void
1153 ldr_server_load (load_args * args, int *exit_status, bool * interrupted)
1154 {
1156 
1157  int error_code = loaddb_init (*args);
1158  if (error_code != NO_ERROR)
1159  {
1160  print_er_msg ();
1161  *exit_status = 3;
1162  return;
1163  }
1164 
1165  error_code = load_object_file (args, exit_status);
1166  if (error_code != NO_ERROR)
1167  {
1168  loaddb_interrupt ();
1169  print_er_msg ();
1170  *exit_status = 3;
1171  }
1172 
1173  /* *INDENT-OFF* */
1174  cubload::stats last_stat;
1175  load_status status;
1176  /* *INDENT-ON* */
1177 
1178  do
1179  {
1180  if (load_interrupted)
1181  {
1182  *interrupted = true;
1183  *exit_status = 3;
1184  break;
1185  }
1186 
1187  error_code = loaddb_fetch_status (status);
1188  if (error_code != NO_ERROR)
1189  {
1190  loaddb_interrupt ();
1191  print_er_msg ();
1192  *exit_status = 3;
1193  break;
1194  }
1195 
1196  print_stats (status.get_load_stats (), *args, exit_status);
1197  if (!status.get_load_stats ().empty ())
1198  {
1199  last_stat = status.get_load_stats ().back ();
1200  }
1201 
1202  /* *INDENT-OFF* */
1203  std::this_thread::sleep_for (std::chrono::milliseconds (100));
1204  /* *INDENT-ON* */
1205  }
1206  while (!(status.is_load_completed () || status.is_load_failed ()) && *exit_status != 3);
1207 
1208  if (load_interrupted)
1209  {
1212  last_stat.current_line.load ());
1214  }
1215 
1216  if (args->syntax_check)
1217  {
1218  if (!last_stat.error_message.empty ())
1219  {
1220  fprintf (stderr, "%s", last_stat.error_message.c_str ());
1221  }
1222 
1223  print_log_msg (1,
1225  last_stat.rows_committed, last_stat.rows_failed);
1226  }
1227  else
1228  {
1230  last_stat.rows_committed, last_stat.rows_failed);
1231  }
1232 
1233  if (!load_interrupted && !status.is_load_failed () && !args->syntax_check && error_code == NO_ERROR)
1234  {
1235  // Update class statistics
1236  error_code = loaddb_update_stats ();
1237  if (error_code != NO_ERROR)
1238  {
1239  print_er_msg ();
1240  *exit_status = 3;
1241  }
1242  else // NO_ERROR
1243  {
1244  // Fetch the latest stats.
1245  error_code = loaddb_fetch_status (status);
1246  if (error_code != NO_ERROR)
1247  {
1248  print_er_msg ();
1249  *exit_status = 3;
1250  }
1251  else // NO_ERROR
1252  {
1253  // Print these stats.
1254  print_stats (status.get_load_stats (), *args, exit_status);
1255  }
1256  }
1257  }
1258 
1259  // Destroy the session.
1260  error_code = loaddb_destroy ();
1261  if (error_code != NO_ERROR)
1262  {
1263  print_er_msg ();
1264  *exit_status = 3;
1265  }
1266 
1267  if (load_interrupted)
1268  {
1270  last_stat.last_committed_line);
1271  }
1272 }
1273 
1274 static void
1276 {
1277  /* *INDENT-OFF* */
1278  static SIG_HANDLER sig_handler = [] ()
1279  {
1280  load_interrupted = true;
1281  loaddb_interrupt ();
1282  };
1283  /* *INDENT-ON* */
1284 
1285  // register handlers for SIGINT and SIGQUIT signals
1286  util_arm_signal_handlers (sig_handler, sig_handler);
1287 }
1288 
1289 static int
1290 load_has_authorization (const std::string & class_name, DB_AUTH au_type)
1291 {
1292  // au_fetch_class
1293  DB_OBJECT *usr = db_get_user ();
1294  if (au_is_dba_group_member (usr))
1295  {
1296  // return early, no need to check dba if authorized
1297  return NO_ERROR;
1298  }
1299 
1300  int error_code = NO_ERROR;
1301  DB_OBJECT *class_mop = db_find_class (class_name.c_str ());
1302  if (class_mop != NULL)
1303  {
1304  DB_OBJECT *owner = db_get_owner (class_mop);
1305  if (owner == usr)
1306  {
1307  // return early, no need to check owner if authorized
1308  return NO_ERROR;
1309  }
1310  }
1311  else
1312  {
1313  ASSERT_ERROR_AND_SET (error_code);
1314  return error_code;
1315  }
1316 
1317  error_code = au_check_authorization (class_mop, au_type);
1318  if (error_code != NO_ERROR)
1319  {
1320  ASSERT_ERROR ();
1321  // promote from warning to error severity
1322  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 0);
1323  }
1324  return error_code;
1325 }
1326 
1327 static int
1328 load_object_file (load_args * args, int *exit_status)
1329 {
1330  if (!args->table_name.empty ())
1331  {
1332  int error_code = load_has_authorization (args->table_name, AU_INSERT);
1333  // user not authorized to insert in class
1334  if (error_code != NO_ERROR)
1335  {
1336  return error_code;
1337  }
1338  }
1339 
1340  /* *INDENT-OFF* */
1341  batch_handler b_handler = [&] (const batch &batch) -> int
1342  {
1343  int error_code = NO_ERROR;
1344  bool use_temp_batch = false;
1345  bool is_batch_accepted = false;
1346  do
1347  {
1348  load_status status;
1349  error_code = loaddb_load_batch (batch, use_temp_batch, is_batch_accepted, status);
1350  if (error_code != NO_ERROR)
1351  {
1352  return error_code;
1353  }
1354  use_temp_batch = true; // don't upload batch again while retrying
1355 
1356  print_stats (status.get_load_stats (), *args, exit_status);
1357  }
1358  while (!is_batch_accepted);
1359 
1360  return error_code;
1361  };
1362 
1363  class_handler c_handler = [] (const batch &batch, bool &is_ignored) -> int
1364  {
1365  std::string class_name;
1366  int error_code = loaddb_install_class (batch, is_ignored, class_name);
1367 
1368  if (error_code != NO_ERROR)
1369  {
1370  return error_code;
1371  }
1372 
1373  if (!is_ignored && !class_name.empty ())
1374  {
1375  error_code = load_has_authorization (class_name, AU_INSERT);
1376  }
1377 
1378  return error_code;
1379  };
1380  /* *INDENT-ON* */
1381 
1382  // here we are sure that object_file exists since it was validated by loaddb_internal function
1383  return split (args->periodic_commit, args->object_file, c_handler, b_handler);
1384 }
DB_OBJECT * db_find_class(const char *name)
Definition: db_info.c:133
#define LOAD_PERIODIC_COMMIT_S
Definition: utility.h:1248
DB_OBJECT * db_attribute_class(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1189
void logddl_set_msg(const char *fmt,...)
Definition: ddl_log.c:392
static void get_loaddb_args(UTIL_ARG_MAP *arg_map, load_args *args)
Definition: load_db.c:1103
std::string error_file
#define NO_ERROR
Definition: error_code.h:46
#define AU_DISABLE(save)
Definition: authenticate.h:106
int split(int batch_size, const std::string &object_file_name, class_handler &c_handler, batch_handler &b_handler)
#define ER_FILE_UNKNOWN_FILE
Definition: error_code.h:90
void db_set_client_type(int client_type)
Definition: db_admin.c:495
#define ASSERT_ERROR()
#define LOAD_ERROR_CONTROL_FILE_S
Definition: utility.h:1262
#define PRINT_AND_LOG_ERR_MSG(...)
Definition: util_func.h:49
int sysprm_set_force(const char *pname, const char *pvalue)
static int load_has_authorization(const std::string &class_name, DB_AUTH au_type)
Definition: load_db.c:1290
DB_ATTRIBUTE * db_get_attributes(DB_OBJECT *obj)
Definition: db_info.c:908
static int ldr_compare_attribute_with_meta(char *table_name, char *meta, DB_ATTRIBUTE *attribute)
Definition: load_db.c:298
int db_login(const char *name, const char *password)
Definition: db_admin.c:804
void logddl_set_db_name(const char *db_name)
Definition: ddl_log.c:205
DB_OBJECT * db_get_owner(DB_OBJECT *class_obj)
Definition: db_admin.c:1892
std::string error_message
std::string object_file
static int ldr_exec_query_from_file(const char *file_name, FILE *input_stream, int *start_line, load_args *args)
Definition: load_db.c:954
#define LOAD_CS_FORCE_LOAD_S
Definition: utility.h:1274
int parse_int(int *ret_p, const char *str_p, int base)
Definition: porting.c:2290
#define ER_FAILED
Definition: error_code.h:47
#define AU_DISABLE_PASSWORDS
Definition: authenticate.h:140
std::string ignore_class_file
static FILE * ldr_check_file(std::string &file_name, int &error_code)
Definition: load_db.c:197
static int ldr_compare_storage_order(FILE *schema_file)
Definition: load_db.c:377
#define ASSERT_ERROR_AND_SET(error_code)
int db_query_end(DB_QUERY_RESULT *result)
Definition: db_query.c:3362
int db_attribute_order(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1144
static void ldr_server_load(load_args *args, int *exit_status, bool *interrupted)
Definition: load_db.c:1153
int db_shutdown(void)
Definition: db_admin.c:964
std::string input_file
Definition: load_common.hpp:94
bool au_is_dba_group_member(MOP user)
void util_arm_signal_handlers(SIG_HANDLER sigint_handler, SIG_HANDLER sigquit_handler)
Definition: util_func.c:222
int loaddb_destroy()
void log_set_interrupt(int set)
#define LOAD_IGNORE_LOGGING_S
Definition: utility.h:1256
static void ldr_exec_query_interrupt_handler(void)
Definition: load_db.c:938
int sm_update_catalog_statistics(const char *class_name, bool with_fullscan)
static int ldr_validate_object_file(const char *argv0, load_args *args)
Definition: load_db.c:160
static int ldr_get_start_line_no(std::string &file_name)
Definition: load_db.c:218
static const int PERIODIC_COMMIT_DEFAULT_VALUE
int er_errid(void)
#define LOAD_IGNORE_CLASS_S
Definition: utility.h:1264
#define LOAD_NO_STATISTICS_S
Definition: utility.h:1246
void logddl_set_logging_enabled(bool enable)
Definition: ddl_log.c:995
int util_log_write_errid(int message_id,...)
Definition: util_func.c:468
#define LOAD_TRIGGER_FILE_L
Definition: utility.h:1261
const char * db_attribute_name(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1065
int db_attribute_is_shared(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1429
bool db_disable_trigger(void)
Definition: db_admin.c:570
std::string index_file
int er_init(const char *msglog_filename, int exit_ask)
#define LOAD_INDEX_FILE_S
Definition: utility.h:1254
#define MSGCAT_GENERAL_ARG_DUPLICATE
int utility_get_option_int_value(UTIL_ARG_MAP *arg_map, int arg_ch)
Definition: util_common.c:227
void logddl_write_end()
Definition: ddl_log.c:668
DB_SESSION_ERROR * db_get_next_error(DB_SESSION_ERROR *errors, int *line, int *col)
Definition: db_vdb.c:953
#define LOAD_CHECK_ONLY_L
Definition: utility.h:1239
#define LOAD_COMPARE_STORAGE_ORDER_S
Definition: utility.h:1272
int db_restart(const char *program, int print_version, const char *volume)
Definition: db_admin.c:868
int db_parse_one_statement(DB_SESSION *session)
Definition: db_vdb.c:298
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
static char * ldr_get_token(char *str, char **out_str, char start, char end)
Definition: load_db.c:259
bool utility_get_option_bool_value(UTIL_ARG_MAP *arg_map, int arg_ch)
Definition: util_common.c:245
#define assert(x)
int prm_get_integer_value(PARAM_ID prm_id)
std::string table_name
#define ER_GENERIC_ERROR
Definition: error_code.h:49
static int load_object_file(load_args *args, int *exit_status)
Definition: load_db.c:1328
int loaddb_install_class(const cubload::batch &batch, bool &class_is_ignored, std::string &class_name)
int db_end_session(void)
Definition: db_admin.c:1029
int loaddb_user(UTIL_FUNCTION_ARG *arg)
Definition: load_db.c:927
#define LOAD_ESTIMATED_SIZE_S
Definition: utility.h:1242
std::function< int64_t(const batch &)> batch_handler
Definition: load_common.hpp:77
DB_SESSION * db_make_session_for_one_statement_execution(FILE *file)
Definition: db_vdb.c:276
#define LOAD_TABLE_NAME_S
Definition: utility.h:1270
int interrupt_query
Definition: load_db.c:50
int sysprm_load_and_init(const char *db_name, const char *conf_file, const int load_flags)
void logddl_set_commit_count(int count)
Definition: ddl_log.c:413
const char * LOAD_INDEX_MIN_SORT_BUFFER_PAGES_STRING
Definition: load_db.c:43
void ldr_sa_load(load_args *args, int *status, bool *interrupted)
const char * db_error_string(int level)
Definition: db_admin.c:2116
#define LOAD_LOAD_ONLY_S
Definition: utility.h:1240
DB_ATTRIBUTE * db_attribute_next(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1020
const char * LOADDB_LOG_FILENAME_SUFFIX
Definition: load_db.c:44
void logddl_set_load_filename(const char *load_filename)
Definition: ddl_log.c:326
void logddl_destroy()
Definition: ddl_log.c:185
int au_check_authorization(MOP op, DB_AUTH auth)
int loaddb_interrupt()
int db_abort_transaction(void)
Definition: db_admin.c:1114
std::vector< stats > & get_load_stats()
int loaddb_update_stats()
int db_execute_statement(DB_SESSION *session, int stmt_ndx, DB_QUERY_RESULT **result)
Definition: db_vdb.c:2978
int char_isdigit(int c)
Definition: chartype.c:73
#define CT_INDEX_NAME
Definition: transform.h:128
#define NULL
Definition: freelistheap.h:34
const char * er_msg(void)
int db_compile_statement(DB_SESSION *session)
Definition: db_vdb.c:766
void db_close_session(DB_SESSION *session)
Definition: db_vdb.c:3319
int64_t last_committed_line
bool load_interrupted
Definition: load_db.c:51
const int LOAD_INDEX_MIN_SORT_BUFFER_PAGES
Definition: load_db.c:42
static void load_usage(const char *argv0)
Definition: load_db.c:147
#define LOAD_CHECK_ONLY_S
Definition: utility.h:1238
#define MSGCAT_SET_GENERAL
#define LOAD_TRIGGER_FILE_S
Definition: utility.h:1260
#define MSGCAT_CATALOG_CUBRID
DB_OBJECT * db_get_user(void)
Definition: db_admin.c:1974
#define CT_TRIGGER_NAME
Definition: transform.h:139
#define AU_INSERT
Definition: authenticate.h:70
FILE * fopen_ex(const char *filename, const char *type)
Definition: util_common.c:322
void(* SIG_HANDLER)(void)
Definition: util_func.h:60
std::string schema_file
#define LOAD_DATA_FILE_S
Definition: utility.h:1258
MOP Au_user
Definition: authenticate.c:343
#define LOAD_SCHEMA_FILE_S
Definition: utility.h:1252
static void error(const char *msg)
Definition: gencat.c:331
int db_get_statement_type(DB_SESSION *session, int stmt)
Definition: db_vdb.c:1473
#define ER_INTERRUPTED
Definition: error_code.h:51
#define ER_AU_INVALID_PASSWORD
Definition: error_code.h:235
void logddl_init()
Definition: ddl_log.c:119
DB_AUTH
Definition: dbtype_def.h:239
#define ARG_FILE_LINE
Definition: error_manager.h:44
static FILE * loaddb_log_file
Definition: load_db.c:48
#define LOAD_USER_S
Definition: utility.h:1234
bool er_has_error(void)
#define LOAD_CS_MODE_S
Definition: utility.h:1268
void print_log_msg(int verbose, const char *fmt,...)
Definition: load_db.c:82
UTIL_ARG_MAP * arg_map
Definition: utility.h:1698
#define AU_ENABLE(save)
Definition: authenticate.h:113
void logddl_set_pid(const int pid)
Definition: ddl_log.c:241
int sm_update_all_catalog_statistics(bool with_fullscan)
static int loaddb_internal(UTIL_FUNCTION_ARG *arg, int dba_mode)
Definition: load_db.c:475
void logddl_set_loaddb_file_type(T_LOADDB_FILE_TYPE file_type)
Definition: ddl_log.c:308
#define LOAD_LOAD_ONLY_L
Definition: utility.h:1241
#define strlen(s1)
Definition: intl_support.c:43
std::string user_name
Definition: load_common.hpp:95
#define STATS_WITH_FULLSCAN
Definition: statistics.h:34
void logddl_set_app_name(T_APP_NAME app_name)
Definition: ddl_log.c:196
#define LOAD_PASSWORD_S
Definition: utility.h:1236
bool obt_Enable_autoincrement
static void print_stats(std::vector< cubload::stats > &stats, cubload::load_args &args, int *status)
Definition: load_db.c:109
bool prm_get_bool_value(PARAM_ID prm_id)
static void print_er_msg()
Definition: load_db.c:132
int util_log_write_errstr(const char *format,...)
Definition: util_func.c:493
int loaddb_load_batch(const cubload::batch &batch, bool use_temp_batch, bool &is_batch_accepted, load_status &status)
char * basename(const char *path)
Definition: porting.c:1132
#define CT_INDEXKEY_NAME
Definition: transform.h:129
#define LOAD_VERBOSE_S
Definition: utility.h:1244
std::function< int64_t(const batch &, bool &)> class_handler
Definition: load_common.hpp:78
#define LOAD_NO_OID_S
Definition: utility.h:1250
DB_TYPE db_attribute_type(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1000
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)
Definition: load_object.c:1801
#define LOAD_ERROR_CONTROL_FILE_L
Definition: utility.h:1263
int64_t rows_committed
void logddl_set_user_name(const char *user_name)
Definition: ddl_log.c:223
#define OPTION_STRING_TABLE
Definition: utility.h:813
void logddl_set_err_code(int err_code)
Definition: ddl_log.c:361
int loaddb_init(cubload::load_args &args)
std::string volume
Definition: load_common.hpp:93
static void register_signal_handlers()
Definition: load_db.c:1275
DB_SESSION_ERROR * db_get_errors(DB_SESSION *session)
Definition: db_vdb.c:926
std::string trigger_file
const char * command_name
Definition: utility.h:1699
const char ** p
Definition: dynamic_load.c:945
char * utility_get_option_string_value(UTIL_ARG_MAP *arg_map, int arg_ch, int index)
Definition: util_common.c:266
std::string password
Definition: load_common.hpp:96
void logddl_set_file_line(int file_line)
Definition: ddl_log.c:335
int db_commit_transaction(void)
Definition: db_admin.c:1091
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)
Definition: ddl_log.c:370
int er_filter_fileset(FILE *ef)
Definition: load_object.c:1680
int db_get_line_of_statement(DB_SESSION *session, int stmt_id)
Definition: db_vdb.c:4236
#define MSGCAT_CATALOG_UTILS