CUBRID Engine  latest
load_server_loader.cpp
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_server_loader.cpp: Loader server definitions. Updated using design from fast loaddb prototype
21  */
22 
23 #include "load_server_loader.hpp"
24 
25 #include "btree.h"
26 #include "dbtype.h"
27 #include "load_class_registry.hpp"
29 #include "load_driver.hpp"
30 #include "load_error_handler.hpp"
31 #include "load_session.hpp"
32 #include "locator_sr.h"
33 #include "memory_alloc.h"
34 #include "object_primitive.h"
35 #include "record_descriptor.hpp"
36 #include "set_object.h"
37 #include "string_opfunc.h"
38 #include "thread_manager.hpp"
39 #include "xserver_interface.h"
40 
41 #include <cstring>
42 
43 namespace cubload
44 {
45 
47  : m_session (session)
48  , m_error_handler (error_handler)
49  , m_clsid (NULL_CLASS_ID)
50  {
51  //
52  }
53 
54  void
56  {
57  m_clsid = clsid;
58  }
59 
60  void
61  server_class_installer::check_class (const char *class_name, int class_id)
62  {
63  (void) class_id;
64  OID class_oid;
66 
67  if (is_class_ignored (class_name))
68  {
69  // Silently do nothing.
70  return;
71  }
72 
73  to_lowercase_identifier (class_name, eb);
74 
75  const char *lower_case_class_name = eb.get_read_ptr ();
76 
77  if (locate_class (lower_case_class_name, class_oid) != LC_CLASSNAME_EXIST)
78  {
80  }
81 
83  }
84 
85  int
86  server_class_installer::install_class (const char *class_name)
87  {
88  (void) class_name;
89 
91 
92  return NO_ERROR;
93  }
94 
95  void
97  {
98  if (class_name == NULL || class_name->val == NULL)
99  {
100  return;
101  }
102 
103  if (cmd_spec != NULL && (cmd_spec->attr_type == LDR_ATTRIBUTE_CLASS || cmd_spec->attr_type == LDR_ATTRIBUTE_SHARED))
104  {
106  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, err_code, 0);
108  return;
109  }
110 
111  register_class_with_attributes (class_name->val, cmd_spec);
112  }
113 
115  server_class_installer::locate_class (const char *class_name, OID &class_oid)
116  {
117  cubthread::entry &thread_ref = cubthread::get_entry ();
118  return xlocator_find_class_oid (&thread_ref, class_name, &class_oid, BU_LOCK);
119  }
120 
121  void
123  {
124  OID class_oid;
125  recdes recdes;
126  heap_scancache scancache;
127  heap_cache_attrinfo attrinfo;
128  cubthread::entry &thread_ref = cubthread::get_entry ();
129  bool is_syntax_check_only = m_session.get_args ().syntax_check;
131 
133  OID_SET_NULL (&class_oid);
134 
135  if (m_session.is_failed ())
136  {
137  // return in case when class does not exists
138  return;
139  }
140 
141  // Make the classname lowercase
142  to_lowercase_identifier (class_name, eb);
143 
144  const char *lower_case_class_name = eb.get_read_ptr ();
145 
146  // Check if we have to ignore this class.
147  if (is_class_ignored (lower_case_class_name))
148  {
149  std::string classname (lower_case_class_name);
151  class_entry *cls_entry = new class_entry (classname, m_clsid, true);
153  return;
154  }
155 
156  if (locate_class (lower_case_class_name, class_oid) != LC_CLASSNAME_EXIST)
157  {
158  if (is_syntax_check_only)
159  {
160  // We must have the class installed already.
161  // This translates into a syntax error.
163  }
164  else
165  {
167  }
168  return;
169  }
170 
171  int error_code = heap_attrinfo_start (&thread_ref, &class_oid, -1, NULL, &attrinfo);
172  assert (attrinfo.num_values != -1);
173  if (error_code != NO_ERROR)
174  {
176  return;
177  }
178 
179  heap_scancache_quick_start_root_hfid (&thread_ref, &scancache);
180  SCAN_CODE scan_code = heap_get_class_record (&thread_ref, &class_oid, &recdes, &scancache, PEEK);
181  if (scan_code != S_SUCCESS)
182  {
183  heap_scancache_end (&thread_ref, &scancache);
184  heap_attrinfo_end (&thread_ref, &attrinfo);
186  return;
187  }
188 
189  int n_attributes = -1;
190  or_attribute *or_attributes = NULL;
191  attribute_type attr_type = cmd_spec != NULL ? cmd_spec->attr_type : LDR_ATTRIBUTE_DEFAULT;
192  get_class_attributes (attrinfo, attr_type, or_attributes, &n_attributes);
193 
194  // sort attrib idxs by or_attrib.def_order
195  // attrib_order[i] = the i-th element in or_attributes[:].def_order
196  // or_attributes[:].def_order = [ 2, 0, 3, 10, 5] -> attrib_order = [ 1, 0, 2, 4, 3]
197  std::vector<int> attrib_order (n_attributes);
198  for (size_t i = 0; i < attrib_order.size (); ++i)
199  {
200  attrib_order[i] = i;
201  }
202  std::sort (attrib_order.begin (), attrib_order.end (), [or_attributes] (int a, int b)
203  {
204  return or_attributes[a].def_order < or_attributes[b].def_order;
205  });
206 
207  // collect class attribute names
208  std::map<std::string, or_attribute *> attr_map;
209  std::vector<const attribute *> attributes;
210  attributes.reserve ((std::size_t) n_attributes);
211 
212  for (std::size_t attr_index = 0; attr_index < (std::size_t) n_attributes; ++attr_index)
213  {
214  char *attr_name = NULL;
215  int free_attr_name = 0;
216  or_attribute *attr_repr = NULL;
217 
218  attr_repr = &or_attributes[attrib_order[attr_index]];
219 
220  error_code = or_get_attrname (&recdes, attr_repr->id, &attr_name, &free_attr_name);
221  if (error_code != NO_ERROR)
222  {
223  heap_scancache_end (&thread_ref, &scancache);
224  heap_attrinfo_end (&thread_ref, &attrinfo);
226  return;
227  }
228 
229  std::string attr_name_ (attr_name);
230  if (cmd_spec == NULL)
231  {
232  // if attr_list is NULL then register attributes in default order
233  assert (attr_repr->domain != NULL);
234  const attribute *attr = new attribute (attr_name_, attr_index, attr_repr);
235 
236  attributes.push_back (attr);
237  }
238  else
239  {
240  attr_map.insert (std::make_pair (attr_name_, attr_repr));
241  }
242 
243  // free attr_name if it was allocated
244  if (attr_name != NULL && free_attr_name == 1)
245  {
246  db_private_free_and_init (&thread_ref, attr_name);
247  }
248  }
249 
250  // register attributes in specific order required by attr_list
251  std::size_t attr_index = 0;
252  string_type *str_attr = cmd_spec != NULL ? cmd_spec->attr_list : NULL;
253  for (; str_attr != NULL; str_attr = str_attr->next, ++attr_index)
254  {
255  cubmem::extensible_block attr_eb;
256  to_lowercase_identifier (str_attr->val, attr_eb);
257  std::string attr_name_ (attr_eb.get_read_ptr ());
258 
259  auto found = attr_map.find (attr_name_);
260  if (found == attr_map.end ())
261  {
263  heap_scancache_end (&thread_ref, &scancache);
264  heap_attrinfo_end (&thread_ref, &attrinfo);
266  return;
267  }
268 
269  or_attribute *attr_repr = found->second;
270 
271  assert (attr_repr != NULL && attr_repr->domain != NULL);
272  const attribute *attr = new attribute (attr_name_, attr_index, attr_repr);
273 
274  attributes.push_back (attr);
275  attr_map.erase (attr_name_);
276  }
277 
278  // check missing non null attributes
279  for (const std::pair<const std::string, or_attribute *> &attr : attr_map)
280  {
281  if (attr.second->is_notnull)
282  {
283  char class_attr[512];
284 
285  snprintf (class_attr, 512, "%s.%s", class_name, attr.first.c_str ());
287  heap_scancache_end (&thread_ref, &scancache);
288  heap_attrinfo_end (&thread_ref, &attrinfo);
290  return;
291  }
292  }
293 
294  assert (std::is_sorted (attributes.begin (), attributes.end (), [] (const attribute * a, const attribute * b)
295  {
296  return a->get_index () < b->get_index ();
297  }));
298  m_session.get_class_registry ().register_class (lower_case_class_name, m_clsid, class_oid, attributes);
299 
300  heap_scancache_end (&thread_ref, &scancache);
301  heap_attrinfo_end (&thread_ref, &attrinfo);
302  }
303 
304  void
306  or_attribute *&or_attributes, int *n_attributes)
307  {
308  *n_attributes = -1;
309  switch (attr_type)
310  {
311  case LDR_ATTRIBUTE_CLASS:
312  assert (false);
313  or_attributes = attrinfo.last_classrepr->class_attrs;
314  *n_attributes = attrinfo.last_classrepr->n_class_attrs;
315  break;
317  assert (false);
318  or_attributes = attrinfo.last_classrepr->shared_attrs;
319  *n_attributes = attrinfo.last_classrepr->n_shared_attrs;
320  break;
321  case LDR_ATTRIBUTE_ANY:
323  or_attributes = attrinfo.last_classrepr->attributes;
324  *n_attributes = attrinfo.last_classrepr->n_attributes;
325  break;
326  default:
327  assert (false);
328  break;
329  }
330  assert (*n_attributes >= 0);
331  }
332 
333  bool
335  {
336  if (IS_OLD_GLO_CLASS (classname))
337  {
338  return true;
339  }
340 
341  const std::vector<std::string> &classes_ignored = m_session.get_args ().ignore_classes;
342  bool is_ignored;
344 
345  // Make the classname lowercase
346  to_lowercase_identifier (classname, eb);
347 
348  std::string class_name (eb.get_ptr ());
349 
350  auto result = std::find (classes_ignored.begin (), classes_ignored.end (), class_name);
351 
352  is_ignored = (result != classes_ignored.end ());
353 
354  return is_ignored;
355  }
356 
357  void
359  {
361 
362  // Make the string to be lower case and take into consideration all types of characters.
363  intl_identifier_lower (idname, eb.get_ptr ());
364  }
365 
367  : m_session (session)
368  , m_error_handler (error_handler)
369  , m_thread_ref (NULL)
371  , m_class_entry (NULL)
372  , m_attrinfo_started (false)
373  , m_attrinfo ()
374  , m_db_values ()
375  , m_recdes_collected ()
376  , m_scancache_started (false)
377  , m_scancache ()
378  , m_rows (0)
379  {
380  //
381  }
382 
383  void
385  {
386  m_clsid = clsid;
388 
391  if (m_class_entry == NULL)
392  {
393  return;
394  }
395 
396  const OID &class_oid = m_class_entry->get_class_oid ();
397 
398  start_scancache (class_oid);
399  start_attrinfo (class_oid);
400 
401  // lock class when batch starts, check that the transaction has BU lock
403  }
404 
405  void
407  {
408  stop_attrinfo ();
409  stop_scancache ();
410 
411  m_recdes_collected.clear ();
412 
415  m_thread_ref = NULL;
416  }
417 
418  void
420  {
421  (void) object_id;
422  }
423 
424  void
426  {
427  if (m_session.is_failed ())
428  {
429  return;
430  }
431 
433  {
434  ++m_rows;
435  }
436 
437  std::size_t attr_index = 0;
438  std::size_t attr_size = m_class_entry->get_attributes_size ();
439 
440  if (cons != NULL && attr_size == 0)
441  {
444  return;
445  }
446 
447  for (constant_type *c = cons; c != NULL; c = c->next, attr_index++)
448  {
449  if (attr_index == attr_size)
450  {
453  return;
454  }
455 
456  const attribute &attr = m_class_entry->get_attribute (attr_index);
457  int error_code = process_constant (c, attr);
458  if (error_code != NO_ERROR)
459  {
461  return;
462  }
463 
464  db_value &db_val = get_attribute_db_value (attr_index);
465  error_code = heap_attrinfo_set (&m_class_entry->get_class_oid (), attr.get_repr ().id, &db_val, &m_attrinfo);
466  if (error_code != NO_ERROR)
467  {
469  return;
470  }
471  }
472 
473  if (attr_index < attr_size)
474  {
475  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_LDR_MISSING_ATTRIBUTES, 2, attr_size, attr_index);
477  return;
478  }
479  }
480 
481  void
483  {
485  {
486  return;
487  }
488 
489  bool is_syntax_check_only = m_session.get_args ().syntax_check;
490  if (!is_syntax_check_only)
491  {
492  // Create the record and add it to the array of collected records.
494  RECDES *old_recdes = NULL;
495 
497  != S_SUCCESS)
498  {
500  return;
501  }
502 
503  // Add the recdes to the collected array.
505  {
506  m_recdes_collected.push_back (std::move (new_recdes));
507  }
508  else
509  {
510  // Don't insert the record since we had an error.
512  }
513  }
514 
515  int64_t lineno = m_thread_ref->m_loaddb_driver->get_scanner ().lineno () + 1;
517  clear_db_values ();
518  }
519 
520  void
522  {
523  int force_count = 0;
524  int pruning_type = 0;
525  int op_type = MULTI_ROW_INSERT;
526  int records_inserted = 0;
527  bool insert_errors_filtered = false;
528  OID dummy_oid;
530 
531  // First check if we have any errors set.
532  if (m_session.is_failed ())
533  {
534  return;
535  }
536 
538  {
539  // Safeguard as we do not need to insert any records during syntax check.
540  assert (m_recdes_collected.empty ());
541  return;
542  }
543 
544  // Add the classname to the scancache.
545  if (m_class_entry != NULL)
546  {
548  }
549 
550  if (m_recdes_collected.empty ())
551  {
552  // Nothing to flush.
553  return;
554  }
555 
557 
558  if (insert_errors_filtered)
559  {
560  // In case of possible errors filtered for insert we disable the unique optimization
561  for (size_t i = 0; i < m_recdes_collected.size (); i++)
562  {
564  RECDES local_record = m_recdes_collected[i].get_recdes ();
566  &dummy_oid, &local_record, true, op_type, &m_scancache, &force_count,
567  pruning_type, NULL, NULL, UPDATE_INPLACE_NONE, NULL, has_BU_lock,
568  true, false);
569  if (error_code != NO_ERROR)
570  {
571  ASSERT_ERROR ();
574 
575  if (er_has_error ())
576  {
577  // Error was not filtered, we abort everything.
578  return;
579  }
580 
581  // Error was filtered so we can continue.
582  continue;
583  }
584 
585  // We attach to outer and we continue.
587  ++m_rows;
588  }
589  }
590  else
591  {
594  m_recdes_collected, true, op_type, &m_scancache, &force_count, pruning_type, NULL, NULL,
595  UPDATE_INPLACE_NONE, true);
596  if (error_code != NO_ERROR)
597  {
598  ASSERT_ERROR ();
601  return;
602  }
603  else
604  {
606  m_rows += m_recdes_collected.size ();
607  }
608  }
609  }
610 
611  std::size_t
613  {
614  return m_rows;
615  }
616 
617  int
619  {
620  string_type *str = NULL;
621  int error_code = NO_ERROR;
622 
623  switch (cons->type)
624  {
625  case LDR_NULL:
626  case LDR_INT:
627  case LDR_FLOAT:
628  case LDR_DOUBLE:
629  case LDR_NUMERIC:
630  case LDR_DATE:
631  case LDR_TIME:
632  case LDR_TIMESTAMP:
633  case LDR_TIMESTAMPLTZ:
634  case LDR_TIMESTAMPTZ:
635  case LDR_DATETIME:
636  case LDR_DATETIMELTZ:
637  case LDR_DATETIMETZ:
638  case LDR_STR:
639  case LDR_NSTR:
640  case LDR_BSTR:
641  case LDR_XSTR:
642  case LDR_ELO_INT:
643  case LDR_ELO_EXT:
644  error_code = process_generic_constant (cons, attr);
645  break;
646 
647  case LDR_MONETARY:
648  error_code = process_monetary_constant (cons, attr);
649  break;
650 
651  case LDR_COLLECTION:
652  error_code = process_collection_constant (reinterpret_cast<constant_type *> (cons->val), attr);
653  break;
654 
655  case LDR_SYS_USER:
656  case LDR_SYS_CLASS:
657  {
658  const char *class_name;
659  str = reinterpret_cast<string_type *> (cons->val);
660 
661  if (str != NULL && str->val != NULL)
662  {
663  class_name = str->val;
664  }
665  else
666  {
667  class_name = cons->type == LDR_SYS_USER ? "db_user" : "*system class*";
668  }
669 
670  error_code = ER_FAILED;
672  }
673  break;
674 
675  case LDR_OID:
676  case LDR_CLASS_OID:
677  // Object References and Class Object Reference are not supported by server loaddb implementation
678  error_code = ER_FAILED;
680  break;
681 
682  default:
683  error_code = ER_FAILED;
684  break;
685  }
686 
687  return error_code;
688  }
689 
690  int
692  {
693  string_type *str = reinterpret_cast<string_type *> (cons->val);
694  char *token = str != NULL ? str->val : NULL;
695  size_t str_size = str != NULL ? str->size : 0;
696 
697  db_value &db_val = get_attribute_db_value (attr.get_index ());
698  conv_func &func = get_conv_func (cons->type, attr.get_domain ().type->get_id ());
699 
700  int error_code = func (token, str_size, &attr, &db_val);
701  if (error_code == ER_DATE_CONVERSION)
702  {
704  }
705  else if (error_code == ER_OBJ_ATTRIBUTE_CANT_BE_NULL)
706  {
707  char class_attr[512];
708 
709  snprintf (class_attr, 512, "%s.%s", m_class_entry->get_class_name (), attr.get_name ());
710  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 1, class_attr);
711  }
712 
713  return error_code;
714  }
715 
716  int
718  {
719  int error_code = NO_ERROR;
720  monetary_type *mon = reinterpret_cast<monetary_type *> (cons->val);
721  string_type *str = mon->amount;
722 
723  /* buffer size for monetary : numeric size + grammar currency symbol + string terminator */
724  char full_mon_str[NUM_BUF_SIZE + 3 + 1];
725  char *full_mon_str_p = full_mon_str;
726 
727  /* In Loader grammar always print symbol before value (position of currency symbol is not localized) */
728  char *curr_str = intl_get_money_esc_ISO_symbol ((DB_CURRENCY) mon->currency_type);
729  size_t full_mon_str_len = (str->size + strlen (curr_str));
730 
731  if (full_mon_str_len >= sizeof (full_mon_str))
732  {
733  full_mon_str_p = new char[full_mon_str_len + 1];
734  }
735 
736  std::strcpy (full_mon_str_p, curr_str);
737  std::strcat (full_mon_str_p, str->val);
738 
739  db_value &db_val = get_attribute_db_value (attr.get_index ());
740  conv_func &func = get_conv_func (cons->type, attr.get_domain ().type->get_id ());
741 
742  error_code = func (full_mon_str_p, full_mon_str_len, &attr, &db_val);
743  if (error_code != NO_ERROR)
744  {
745 
746  if (error_code == ER_OBJ_ATTRIBUTE_CANT_BE_NULL)
747  {
748  char class_attr[512];
749 
750  snprintf (class_attr, 512, "%s.%s", m_class_entry->get_class_name (), attr.get_name ());
751  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 1, class_attr);
752  }
753 
754  return error_code;
755  }
756 
757  if (full_mon_str_p != full_mon_str)
758  {
759  delete [] full_mon_str_p;
760  }
761 
762  delete mon;
763 
764  return error_code;
765  }
766 
767  int
769  {
770  int error_code = NO_ERROR;
771  const tp_domain &domain = attr.get_domain ();
772 
773  if (!TP_IS_SET_TYPE (domain.type->get_id ()))
774  {
775  error_code = ER_LDR_DOMAIN_MISMATCH;
777  pr_type_name (DB_TYPE_SET), domain.type->get_name ());
778 
779  return error_code;
780  }
781 
782  DB_COLLECTION *set = set_create_with_domain (const_cast<tp_domain *> (&domain), 0);
783  if (set == NULL)
784  {
785  error_code = er_errid ();
786  assert (error_code != NO_ERROR);
787 
788  return error_code;
789  }
790 
791  db_value &db_val = get_attribute_db_value (attr.get_index ());
792  for (constant_type *c = cons; c != NULL; c = c->next)
793  {
794  switch (c->type)
795  {
796  case LDR_COLLECTION:
797  error_code = ER_LDR_NESTED_SET;
798  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 0);
799  break;
800 
801  case LDR_MONETARY:
802  error_code = process_monetary_constant (c, attr);
803  break;
804 
805  case LDR_OID:
806  case LDR_CLASS_OID:
807  // Object References and Class Object Reference are not supported by server loaddb implementation
808  error_code = ER_FAILED;
810  break;
811 
812  default:
813  error_code = process_generic_constant (c, attr);
814  break;
815  }
816 
817  if (error_code != NO_ERROR)
818  {
819  set_free (set);
820  return error_code;
821  }
822 
823  // add element to the set (db_val will be cloned, so it is safe to reuse same variable)
824  error_code = set_add_element (set, &db_val);
825  if (error_code != NO_ERROR)
826  {
827  set_free (set);
828  return error_code;
829  }
830  }
831 
832  db_make_collection (&db_val, set);
833 
834  return error_code;
835  }
836 
837  void
839  {
840  size_t n_values = m_db_values.size ();
841  if (m_attrinfo.num_values > 0 && m_attrinfo.num_values < (int) m_db_values.size ())
842  {
843  n_values = (size_t) m_attrinfo.num_values;
844  }
845 
846  for (size_t i = 0; i < n_values; ++i)
847  {
849  }
850 
852  }
853 
854  db_value &
856  {
857  assert (attr_index <= m_db_values.size ());
858 
859  if (attr_index == m_db_values.size ())
860  {
861  m_db_values.emplace_back ();
862  }
863 
864  return m_db_values[attr_index];
865  }
866 
867  void
869  {
870  hfid hfid;
871 
872  int error_code = heap_get_class_info (m_thread_ref, &class_oid, &hfid, NULL, NULL);
873  if (error_code != NO_ERROR)
874  {
876  return;
877  }
878 
879  error_code = heap_scancache_start_modify (m_thread_ref, &m_scancache, &hfid, &class_oid, MULTI_ROW_INSERT, NULL);
880  if (error_code != NO_ERROR)
881  {
883  return;
884  }
885 
886  m_scancache_started = true;
887  }
888 
889  void
891  {
892  if (!m_scancache_started)
893  {
894  return;
895  }
896 
898  {
899  for (const auto &it : m_scancache.m_index_stats->get_map ())
900  {
901  if (!it.second.is_unique ())
902  {
903  // We need to throw an error here and abort the load.
905  &m_class_entry->get_class_oid (), &it.first, NULL);
907  break;
908  }
909 
910  int error = logtb_tran_update_unique_stats (thread_get_thread_entry_info (), it.first, it.second, true);
911  if (error != NO_ERROR)
912  {
913  ASSERT_ERROR ();
915  }
916  }
917  }
918 
920  m_scancache_started = false;
921  }
922 
923  void
925  {
926  int error_code = heap_attrinfo_start (m_thread_ref, &class_oid, -1, NULL, &m_attrinfo);
927  if (error_code != NO_ERROR)
928  {
930  return;
931  }
932 
933  m_attrinfo_started = true;
934  }
935 
936  void
938  {
939  if (!m_attrinfo_started)
940  {
941  return;
942  }
943 
945  m_attrinfo_started = false;
946  }
947 
948 } // namespace cubload
#define ER_SM_ATTRIBUTE_NOT_FOUND
Definition: error_code.h:311
void heap_scancache_end_modify(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
Definition: heap_file.c:7230
OID * oid_Root_class_oid
Definition: oid.c:73
cubthread::entry * thread_get_thread_entry_info(void)
#define NO_ERROR
Definition: error_code.h:46
void on_syntax_failure(bool use_scanner_line=false)
#define ASSERT_ERROR()
SCAN_CODE
void register_class_with_attributes(const char *class_name, class_command_spec_type *cmd_spec)
#define ER_LDR_SHARED_NOT_SUPPORTED
Definition: error_code.h:1601
int heap_scancache_start_modify(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache, const HFID *hfid, const OID *class_oid, int op_type, MVCC_SNAPSHOT *mvcc_snapshot)
Definition: heap_file.c:6867
#define TP_IS_SET_TYPE(typenum)
void check_class(const char *class_name, int class_id) override
void set_free(DB_COLLECTION *set)
Definition: set_object.c:2560
#define ER_LDR_CLASS_NOT_SUPPORTED
Definition: error_code.h:1602
#define ER_FAILED
Definition: error_code.h:47
multi_index_unique_stats * m_index_stats
Definition: heap_file.h:151
const char * classname
Definition: heap_file.h:128
void log_date_time_conversion_error(Args &&...args)
int process_collection_constant(constant_type *cons, const attribute &attr)
void log_sysop_start(THREAD_ENTRY *thread_p)
Definition: log_manager.c:3578
int heap_scancache_quick_start_root_hfid(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
Definition: heap_file.c:19255
void start_line(int object_id) override
#define OID_SET_NULL(oidp)
Definition: oid.h:85
void get_class_attributes(heap_cache_attrinfo &attrinfo, attribute_type attr_type, or_attribute *&or_attributes, int *n_attributes)
int er_errid(void)
DB_COLLECTION * set_create_with_domain(TP_DOMAIN *domain, int initial_size)
Definition: set_object.c:2438
#define MULTI_ROW_INSERT
Definition: btree.h:56
const char * get_class_name() const
void init(class_id clsid) override
DB_TYPE get_id() const
const block_allocator STANDARD_BLOCK_ALLOCATOR
Definition: mem_block.cpp:62
int heap_scancache_end(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
Definition: heap_file.c:7195
std::vector< db_value > m_db_values
void start_scancache(const OID &class_oid)
scanner & get_scanner()
HEAP_SCANCACHE_NODE node
Definition: heap_file.h:144
void register_class(const char *class_name, class_id clsid, OID class_oid, std::vector< const attribute * > &attributes)
const class_entry * get_class_entry(class_id clsid)
db_value & get_attribute_db_value(size_t attr_index)
int intl_identifier_lower(const char *src, char *dst)
void append_log_msg(MSGCAT_LOADDB_MSG msg_id, Args &&...args)
DB_CURRENCY
Definition: dbtype_def.h:799
int heap_attrinfo_start(THREAD_ENTRY *thread_p, const OID *class_oid, int requested_num_attrs, const ATTR_ID *attrids, HEAP_CACHE_ATTRINFO *attr_info)
Definition: heap_file.c:9427
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
Definition: db_set.h:35
const attribute & get_attribute(std::size_t index) const
#define assert(x)
conv_func & get_conv_func(const data_type ldr_type, const DB_TYPE db_type)
int set_add_element(DB_COLLECTION *set, DB_VALUE *value)
Definition: set_object.c:2641
std::size_t get_rows_number() override
class_registry & get_class_registry()
LC_FIND_CLASSNAME xlocator_find_class_oid(THREAD_ENTRY *thread_p, const char *classname, OID *class_oid, LOCK lock)
Definition: locator_sr.c:1033
int install_class(const char *class_name) override
const tp_domain & get_domain() const
void start_attrinfo(const OID &class_oid)
cubload::driver * m_loaddb_driver
#define ER_LDR_MISSING_ATTRIBUTES
Definition: error_code.h:670
void register_ignored_class(class_entry *cls_entry, class_id cls_id)
#define IS_OLD_GLO_CLASS(class_name)
#define NULL
Definition: freelistheap.h:34
LC_FIND_CLASSNAME locate_class(const char *class_name, OID &class_oid)
const load_args & get_args()
int heap_attrinfo_clear_dbvalues(HEAP_CACHE_ATTRINFO *attr_info)
Definition: heap_file.c:10022
#define ER_OBJ_ATTRIBUTE_CANT_BE_NULL
Definition: error_code.h:276
const char * get_read_ptr() const
Definition: mem_block.hpp:368
struct pr_type * type
Definition: object_domain.h:76
std::size_t get_index() const
const char * pr_type_name(DB_TYPE id)
void set_class_id(class_id clsid) override
LC_FIND_CLASSNAME
#define db_private_free_and_init(thrd, ptr)
Definition: memory_alloc.h:141
std::vector< record_descriptor > m_recdes_collected
int logtb_tran_update_unique_stats(THREAD_ENTRY *thread_p, const BTID *btid, int n_keys, int n_oids, int n_nulls, bool write_to_log)
#define NUM_BUF_SIZE
Definition: string_opfunc.h:88
int process_monetary_constant(constant_type *cons, const attribute &attr)
bool has_errors_filtered_for_insert(std::vector< int > error_filter_array)
Definition: locator_sr.c:13852
void log_sysop_abort(THREAD_ENTRY *thread_p)
Definition: log_manager.c:4017
#define ER_DATE_CONVERSION
Definition: error_code.h:242
string_type * next
static void error(const char *msg)
Definition: gencat.c:331
#define ER_LDR_NESTED_SET
Definition: error_code.h:662
void to_lowercase_identifier(const char *idname, cubmem::extensible_block &eb)
#define ARG_FILE_LINE
Definition: error_manager.h:44
bool er_has_error(void)
void on_failure_with_line(MSGCAT_LOADDB_MSG msg_id, Args &&...args)
bool is_class_ignored(const char *classname)
int intl_identifier_lower_string_size(const char *src)
int db_make_collection(DB_VALUE *value, DB_C_SET *set)
#define ER_LDR_DOMAIN_MISMATCH
Definition: error_code.h:660
#define strlen(s1)
Definition: intl_support.c:43
int or_get_attrname(RECDES *record, int attrid, char **string, int *alloced_string)
int locator_multi_insert_force(THREAD_ENTRY *thread_p, HFID *hfid, OID *class_oid, const std::vector< record_descriptor > &recdes, int has_index, int op_type, HEAP_SCANCACHE *scan_cache, int *force_count, int pruning_type, PRUNING_CONTEXT *pcontext, FUNC_PRED_UNPACK_INFO *func_preds, UPDATE_INPLACE_STYLE force_in_place, bool dont_check_fk)
Definition: locator_sr.c:13713
const class_id NULL_CLASS_ID
Definition: load_common.hpp:42
const char * get_name() const
int process_generic_constant(constant_type *cons, const attribute &attr)
const char * get_name() const
SCAN_CODE heap_attrinfo_transform_to_disk_except_lob(THREAD_ENTRY *thread_p, HEAP_CACHE_ATTRINFO *attr_info, RECDES *old_recdes, record_descriptor *new_recdes)
Definition: heap_file.c:11547
void set_error_on_current_line(bool has_error)
void log_sysop_attach_to_outer(THREAD_ENTRY *thread_p)
Definition: log_manager.c:4076
size_t get_attributes_size() const
const container_type & get_map() const
int i
Definition: dynamic_load.c:954
void process_line(constant_type *cons) override
int locator_insert_force(THREAD_ENTRY *thread_p, HFID *hfid, OID *class_oid, OID *oid, RECDES *recdes, int has_index, int op_type, HEAP_SCANCACHE *scan_cache, int *force_count, int pruning_type, PRUNING_CONTEXT *pcontext, FUNC_PRED_UNPACK_INFO *func_preds, UPDATE_INPLACE_STYLE force_in_place, PGBUF_WATCHER *home_hint_p, bool has_BU_lock, bool dont_check_fk, bool use_bulk_logging)
Definition: locator_sr.c:4854
void extend_to(size_t total_bytes)
Definition: mem_block.hpp:346
#define ER_LDR_VALUE_OVERFLOW
Definition: error_code.h:657
int lock_has_lock_on_object(const OID *oid, const OID *class_oid, LOCK lock)
std::vector< std::string > ignore_classes
int db_value_clear(DB_VALUE *value)
Definition: db_macro.c:1588
void heap_attrinfo_end(THREAD_ENTRY *thread_p, HEAP_CACHE_ATTRINFO *attr_info)
Definition: heap_file.c:9979
void stats_update_current_line(int64_t current_line)
entry & get_entry(void)
int heap_attrinfo_set(const OID *inst_oid, ATTR_ID attrid, DB_VALUE *attr_val, HEAP_CACHE_ATTRINFO *attr_info)
Definition: heap_file.c:11239
int heap_get_class_info(THREAD_ENTRY *thread_p, const OID *class_oid, HFID *hfid_out, FILE_TYPE *ftype_out, char **classname_out)
Definition: heap_file.c:16733
int(* conv_func)(const char *, const size_t, const attribute *, db_value *)
const or_attribute & get_repr() const
#define PEEK
Definition: file_io.h:74
#define ER_LDR_NO_CLASS_OR_NO_ATTRIBUTE
Definition: error_code.h:667
const OID & get_class_oid() const
int class_id
Definition: load_common.hpp:40
void on_error_with_line(MSGCAT_LOADDB_MSG msg_id, Args &&...args)
int process_constant(constant_type *cons, const attribute &attr)
std::vector< int > m_ignored_errors
#define BTREE_SET_UNIQUE_VIOLATION_ERROR(THREAD, KEY, OID, C_OID, BTID, BTNM)
Definition: btree.h:96
char * intl_get_money_esc_ISO_symbol(const DB_CURRENCY currency)
SCAN_CODE heap_get_class_record(THREAD_ENTRY *thread_p, const OID *class_oid, RECDES *recdes_p, HEAP_SCANCACHE *scan_cache, int ispeeking)
Definition: heap_file.c:24780