CUBRID Engine  latest
boot_cl.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  * boot_cl.c - Boot management in the client
21  */
22 
23 #ident "$Id$"
24 
25 #include "config.h"
26 
27 #include <stdio.h>
28 #include <string.h>
29 #if !defined(WINDOWS)
30 #include <sys/time.h>
31 #endif /* WINDOWS */
32 
33 #if !defined(WINDOWS)
34 #include <stdio.h>
35 #include <unistd.h>
36 #endif /* !WINDOWS */
37 
38 #if defined(SOLARIS)
39 #include <netdb.h> /* for MAXHOSTNAMELEN */
40 #endif /* SOLARIS */
41 
42 #include <assert.h>
43 
44 #include "porting.h"
45 #if !defined(HPUX)
46 #include "util_func.h"
47 #endif /* !HPUX */
48 #include "boot_cl.h"
49 #include "memory_alloc.h"
50 #include "area_alloc.h"
51 #include "storage_common.h"
52 #include "oid.h"
53 #include "error_manager.h"
54 #include "work_space.h"
55 #include "schema_manager.h"
56 #include "authenticate.h"
57 #include "trigger_manager.h"
58 #include "db.h"
59 #if !defined(WINDOWS)
60 #include "dynamic_load.h"
61 #endif /* !WINDOWS */
62 #include "transaction_cl.h"
63 #include "log_comm.h"
64 #include "server_interface.h"
65 #include "release_string.h"
66 #include "system_parameter.h"
67 #include "locator_cl.h"
68 #include "databases_file.h"
69 #include "db_query.h"
70 #include "language_support.h"
71 #include "message_catalog.h"
72 #include "parser.h"
73 #include "perf_monitor.h"
74 #include "set_object.h"
75 #include "cnv.h"
76 #include "environment_variable.h"
77 #include "locator.h"
78 #include "transform.h"
79 #include "jansson.h"
80 #include "jsp_cl.h"
81 #include "client_support.h"
82 #include "es.h"
83 #include "tsc_timer.h"
84 #include "show_meta.h"
85 #include "tz_support.h"
86 #include "dbtype.h"
87 #include "object_primitive.h"
88 #include "connection_globals.h"
89 
90 #if defined(CS_MODE)
91 #include "network.h"
92 #include "connection_cl.h"
93 #endif /* CS_MODE */
94 #include "network_interface_cl.h"
95 
96 #if defined(WINDOWS)
97 #include "wintcp.h"
98 #else /* WINDOWS */
99 #include "tcp.h"
100 #endif /* WINDOWS */
101 
102 #if defined (SUPPRESS_STRLEN_WARNING)
103 #define strlen(s1) ((int) strlen(s1))
104 #endif /* defined (SUPPRESS_STRLEN_WARNING) */
105 
106 /* TODO : Move .h */
107 #if defined(SA_MODE)
108 extern bool catcls_Enable;
109 extern int catcls_compile_catalog_classes (THREAD_ENTRY * thread_p);
110 #endif /* SA_MODE */
111 
112 #define BOOT_FORMAT_MAX_LENGTH 500
113 
114 /* for optional capability check */
115 #define BOOT_NO_OPT_CAP 0
116 #define BOOT_CHECK_HA_DELAY_CAP NET_CAP_HA_REPL_DELAY
117 
118 typedef int (*DEF_FUNCTION) ();
119 typedef int (*DEF_CLASS_FUNCTION) (MOP);
120 
121 typedef struct column COLUMN;
122 struct column
123 {
124  const char *name;
125  const char *type;
126 };
127 
128 
130  /* db_full_name */ NULL, /* host_name */ NULL, /* lob_path */ NULL,
131  /* process_id */ -1,
132  /* root_class_oid */ {NULL_PAGEID, NULL_SLOTID, NULL_VOLID},
133  /* root_class_hfid */ {{NULL_FILEID, NULL_VOLID}, NULL_PAGEID},
134  /* data page_size */ -1, /* log page_size */ -1,
135  /* disk_compatibility */ 0.0,
136  /* ha_server_state */ HA_SERVER_STATE_NA,
137  /* server_session_key */ {(char) 0xFF, (char) 0xFF, (char) 0xFF, (char) 0xFF, (char) 0xFF, (char) 0xFF, (char) 0xFF,
138  (char) 0xFF},
140  NULL
141 };
142 
143 static const char *boot_Client_no_user_string = "(nouser)";
144 static const char *boot_Client_id_unknown_string = "(unknown)";
145 
147 static char boot_Db_path_buf[PATH_MAX];
148 static char boot_Log_path_buf[PATH_MAX];
149 static char boot_Lob_path_buf[PATH_MAX];
151 
152 /* Volume assigned for new files/objects (e.g., heap files) */
153 VOLID boot_User_volid = 0; /* todo: boot_User_volid looks deprecated */
154 #if defined(CS_MODE)
155 /* Server host connected */
156 char boot_Host_connected[CUB_MAXHOSTNAMELEN] = "";
157 #endif /* CS_MODE */
159 
160 static char boot_Volume_label[PATH_MAX] = " ";
161 static bool boot_Is_client_all_final = true;
162 static bool boot_Set_client_at_exit = false;
163 static int boot_Process_id = -1;
164 
165 static int boot_client (int tran_index, int lock_wait, TRAN_ISOLATION tran_isolation);
166 static void boot_shutdown_client_at_exit (void);
167 #if defined(CS_MODE)
168 static int boot_client_initialize_css (DB_INFO * db, int client_type, bool check_capabilities, int opt_cap,
169  bool discriminative, int connect_order, bool is_preferred_host);
170 #endif /* CS_MODE */
171 static int boot_define_class (MOP class_mop);
172 static int boot_define_attribute (MOP class_mop);
173 static int boot_define_domain (MOP class_mop);
174 static int boot_define_method (MOP class_mop);
175 static int boot_define_meth_sig (MOP class_mop);
176 static int boot_define_meth_argument (MOP class_mop);
177 static int boot_define_meth_file (MOP class_mop);
178 static int boot_define_query_spec (MOP class_mop);
179 static int boot_define_index (MOP class_mop);
180 static int boot_define_index_key (MOP class_mop);
181 static int boot_define_class_authorization (MOP class_mop);
182 static int boot_define_partition (MOP class_mop);
183 static int boot_add_data_type (MOP class_mop);
184 static int boot_define_data_type (MOP class_mop);
185 static int boot_define_stored_procedure (MOP class_mop);
186 static int boot_define_stored_procedure_arguments (MOP class_mop);
187 static int boot_define_serial (MOP class_mop);
188 static int boot_define_ha_apply_info (MOP class_mop);
189 static int boot_define_collations (MOP class_mop);
190 static int boot_add_charsets (MOP class_mop);
191 static int boot_define_charsets (MOP class_mop);
192 static int boot_define_dual (MOP class_mop);
193 static int boot_define_view_class (void);
194 static int boot_define_view_super_class (void);
195 static int boot_define_view_vclass (void);
196 static int boot_define_view_attribute (void);
197 static int boot_define_view_attribute_set_domain (void);
198 static int boot_define_view_method (void);
199 static int boot_define_view_method_argument (void);
201 static int boot_define_view_method_file (void);
202 static int boot_define_view_index (void);
203 static int boot_define_view_index_key (void);
204 static int boot_define_view_authorization (void);
205 static int boot_define_view_trigger (void);
206 static int boot_define_view_partition (void);
207 static int boot_define_view_stored_procedure (void);
209 static int boot_define_view_db_collation (void);
210 static int catcls_class_install (void);
211 static int catcls_vclass_install (void);
212 #if defined(CS_MODE)
213 static int boot_check_locales (BOOT_CLIENT_CREDENTIAL * client_credential);
214 #endif /* CS_MODE */
215 #if defined(CS_MODE)
216 static int boot_check_timezone_checksum (BOOT_CLIENT_CREDENTIAL * client_credential);
217 #endif
218 static int boot_client_find_and_cache_class_oids (void);
219 
220 /*
221  * boot_client () -
222  *
223  * return :
224  *
225  * tran_index(in) : transaction index
226  * lock_wait(in) :
227  * tran_isolation(in):
228  *
229  * Note: macros that find if the cubrid client is restarted
230  */
231 static int
232 boot_client (int tran_index, int lock_wait, TRAN_ISOLATION tran_isolation)
233 {
234  tran_cache_tran_settings (tran_index, lock_wait, tran_isolation);
235 
237  {
238  return NO_ERROR;
239  }
240 
242  boot_Process_id = getpid ();
244 
245  return NO_ERROR;
246 }
247 
248 /*
249  * boot_initialize_client () -
250  *
251  * returns : NO_ERROR if all OK, ER_ status otherwise
252  *
253  * client_credential(in): Contains database access information such as :
254  * database name, user name and password, client type
255  * db_path_info(in) : Directory where the database is created. It allows you
256  * to specify the exact pathname of a directory in which
257  * to create the new database.
258  * db_overwrite(in) : Wheater to overwrite the database if it already exist.
259  * file_addmore_vols(in): More volumes are created during the initialization
260  * process.
261  * npages(in) : Total number of pages to allocate for the database.
262  * db_desired_pagesize(in): Desired pagesize for the new database.
263  * The given size must be power of 2 and greater or
264  * equal than 512.
265  * log_npages(in) : Number of log pages. If log_npages <=0, default value
266  * of system parameter is used.
267  * db_desired_log_page_size(in):
268  * lang_charset(in): language and charset to set on DB
269  *
270  * Note:
271  * The first step of any CUBRID application is to initialize a
272  * database. A database is composed of data volumes (or Unix file
273  * system files), database backup files, and log files. A data
274  * volume contains information on attributes, classes, indexes,
275  * and objects created in the database. A database backup is a
276  * fuzzy snapshot of the entire database. The backup is fuzzy
277  * since it can be taken online when other transactions are
278  * updating the database. The logs contain records that reflect
279  * changes to the database. The log and backup files are used by
280  * the system to recover committed and uncommitted transactions
281  * in the event of system and media crashes. Logs are also used
282  * to support user-initiated rollbacks. This function also
283  * initializes the database with built-in CUBRID classes.
284  *
285  * The rest of this function is identical to the restart. The
286  * transaction for the current client session is automatically
287  * started.
288  */
289 int
290 boot_initialize_client (BOOT_CLIENT_CREDENTIAL * client_credential, BOOT_DB_PATH_INFO * db_path_info, bool db_overwrite,
291  const char *file_addmore_vols, DKNPAGES npages, PGLENGTH db_desired_pagesize,
292  DKNPAGES log_npages, PGLENGTH db_desired_log_page_size, const char *lang_charset)
293 {
294  OID rootclass_oid; /* Oid of root class */
295  HFID rootclass_hfid; /* Heap for classes */
296  int tran_index; /* Assigned transaction index */
297  TRAN_ISOLATION tran_isolation; /* Desired client Isolation level */
298  int tran_lock_wait_msecs; /* Default lock waiting */
299  unsigned int length;
300  int error_code = NO_ERROR;
301  DB_INFO *db = NULL;
302 #if !defined(WINDOWS)
303  bool dl_initialized = false;
304 #endif /* !WINDOWS */
305  const char *hosts[2];
306 #if defined (CS_MODE)
307  char format[BOOT_FORMAT_MAX_LENGTH];
308 #endif
309 
310  assert (client_credential != NULL);
311  assert (db_path_info != NULL);
312 
313  /* If the client is restarted, shutdown the client */
315  {
316  (void) boot_shutdown_client (true);
317  }
318 
320  {
322  }
323 
324 #if defined(WINDOWS)
325  /* set up the WINDOWS stream emulations */
326  pc_init ();
327 #endif /* WINDOWS */
328 
329  /*
330  * initialize language parameters */
331  if (lang_init () != NO_ERROR)
332  {
333  if (er_errid () == NO_ERROR)
334  {
335  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_LOC_INIT, 1, "Failed to initialize language module");
336  }
337  error_code = ER_LOC_INIT;
338  goto error_exit;
339  }
340 
341  if (lang_set_charset_lang (lang_charset) != NO_ERROR)
342  {
343  error_code = ER_LOC_INIT;
344  goto error_exit;
345  }
346 
347  /* database name must be specified */
348  if (client_credential->db_name.empty ())
349  {
351  error_code = ER_BO_UNKNOWN_DATABASE;
352  goto error_exit;
353  }
354 
355  /* open the system message catalog, before prm_ ? */
356  if (msgcat_init () != NO_ERROR)
357  {
360  goto error_exit;
361  }
362 
363  /* initialize system parameters */
364  if (sysprm_load_and_init_client (client_credential->get_db_name (), NULL) != NO_ERROR)
365  {
367  error_code = ER_BO_CANT_LOAD_SYSPRM;
368  goto error_exit;
369  }
370 
371  /* initialize the "areas" memory manager */
372  area_init ();
374 
375  (void) db_set_page_size (db_desired_pagesize, db_desired_log_page_size);
376 
377  /* If db_path and/or log_path are NULL find the defaults */
378 
379  if (db_path_info->db_path == NULL)
380  {
381  db_path_info->db_path = getcwd (boot_Db_path_buf, PATH_MAX);
382  if (db_path_info->db_path == NULL)
383  {
385  error_code = ER_BO_CWD_FAIL;
386  goto error_exit;
387  }
388  }
389  if (db_path_info->log_path == NULL)
390  {
391  /* assign the data volume directory */
392  strcpy (boot_Log_path_buf, db_path_info->db_path);
393  db_path_info->log_path = boot_Log_path_buf;
394  }
395  if (db_path_info->lob_path == NULL)
396  {
397  /* assign the data volume directory */
398  snprintf (boot_Lob_path_buf, sizeof (boot_Lob_path_buf), "%s%s%clob", LOB_PATH_DEFAULT_PREFIX,
399  db_path_info->db_path, PATH_SEPARATOR);
400  db_path_info->lob_path = boot_Lob_path_buf;
401  }
402  else
403  {
404  ES_TYPE es_type = es_get_type (db_path_info->lob_path);
405 
406  switch (es_type)
407  {
408  case ES_NONE:
409  /* prepend default prefix */
410  snprintf (boot_Lob_path_buf, sizeof (boot_Lob_path_buf), "%s%s", LOB_PATH_DEFAULT_PREFIX,
411  db_path_info->lob_path);
412  db_path_info->lob_path = boot_Lob_path_buf;
413  break;
414 #if !defined (CUBRID_OWFS)
415  case ES_OWFS:
417  error_code = ER_ES_INVALID_PATH;
418  goto error_exit;
419 #endif /* !CUBRID_OWFS */
420  default:
421  break;
422  }
423  }
424 
425  /* make sure that the full path for the database is not too long */
426  length = (unsigned int) (client_credential->db_name.length () + strlen (db_path_info->db_path) + 2);
427  if (length > (unsigned) PATH_MAX)
428  {
429  /* db_path + db_name is too long */
431  client_credential->get_db_name (), length, PATH_MAX);
432 
434  goto error_exit;
435  }
436 
437  /* If a host was not given, assume the current host */
438  if (db_path_info->db_host == NULL)
439  {
440 #if 0 /* use Unix-domain socket for localhost */
441  if (GETHOSTNAME (db_host_buf, CUB_MAXHOSTNAMELEN) != 0)
442  {
444  error_code = ER_BO_UNABLE_TO_FIND_HOSTNAME;
445  goto error_exit;
446  }
447  db_host_buf[CUB_MAXHOSTNAMELEN] = '\0';
448 #else
449  strcpy (boot_Db_host_buf, "localhost");
450 #endif
451  db_path_info->db_host = boot_Db_host_buf;
452  }
453 
454  /* make new DB_INFO */
455  hosts[0] = db_path_info->db_host;
456  hosts[1] = NULL;
457  db =
458  cfg_new_db (client_credential->get_db_name (), db_path_info->db_path, db_path_info->log_path,
459  db_path_info->lob_path, hosts);
460  if (db == NULL)
461  {
463  error_code = ER_BO_UNKNOWN_DATABASE;
464  goto error_exit;
465  }
466 
467  /* Get the absolute path name */
469  client_credential->get_db_name ());
470 
471  er_clear ();
472 
473  /* Get the user name */
474  if (client_credential->db_user.empty ())
475  {
476  char *user_name = au_user_name_dup ();
477  int upper_case_name_size;
478  char *upper_case_name;
479 
480  if (user_name != NULL)
481  {
482  upper_case_name_size = intl_identifier_upper_string_size (user_name);
483  upper_case_name = (char *) malloc (upper_case_name_size + 1);
484  if (upper_case_name == NULL)
485  {
487  (size_t) (upper_case_name_size + 1));
488  }
489  else
490  {
491  intl_identifier_upper (user_name, upper_case_name);
492  client_credential->db_user = upper_case_name;
493  }
494  free_and_init (user_name);
495  }
496  upper_case_name = NULL;
497 
498  if (client_credential->db_user.empty ())
499  {
500  client_credential->db_user = boot_Client_no_user_string;
501  }
502  }
503  /* Get the login name, host, and process identifier */
504  if (client_credential->login_name.empty ())
505  {
506  if (getuserid (boot_Client_id_buffer, L_cuserid) != (char *) NULL)
507  {
508  client_credential->login_name = boot_Client_id_buffer;
509  }
510  else
511  {
512  client_credential->login_name = boot_Client_id_unknown_string;
513  }
514  }
515 
516  if (client_credential->host_name.empty ())
517  {
518  client_credential->host_name = boot_get_host_name ();
519  }
520 
521  /*
522  * Initialize the dynamic loader. Don't care about failures. If dynamic
523  * loader fails, methods will fail when they are invoked
524  */
525 #if !defined(WINDOWS)
526 #if !defined (SOLARIS) && !defined(LINUX) && !defined(AIX)
527  (void) dl_initiate_module (client_credential->get_program_name ());
528 #else /* !SOLARIS && !LINUX && !AIX */
529  (void) dl_initiate_module ();
530 #endif /* !SOLARIS && !LINUX && !AIX */
531  dl_initialized = true;
532 #endif /* !WINDOWS */
533 
534 #if defined(CS_MODE)
535  /* Initialize the communication subsystem */
536  error_code =
537  boot_client_initialize_css (db, client_credential->client_type, false, BOOT_NO_OPT_CAP, false,
538  DB_CONNECT_ORDER_SEQ, false);
539  if (error_code != NO_ERROR)
540  {
541  goto error_exit;
542  }
543 #endif /* CS_MODE */
544  boot_User_volid = 0;
546  tran_lock_wait_msecs = prm_get_integer_value (PRM_ID_LK_TIMEOUT_SECS);
547 
548  /* this must be done before the init_server because recovery steps may need domains. */
549  error_code = tp_init ();
550  if (error_code != NO_ERROR)
551  {
552  goto error_exit;
553  }
554 
555  /* Initialize tsc-timer */
556  tsc_init ();
557 
558  if (tran_lock_wait_msecs > 0)
559  {
560  tran_lock_wait_msecs = tran_lock_wait_msecs * 1000;
561  }
562 
563  error_code = perfmon_initialize (MAX_NTRANS);
564  if (error_code != NO_ERROR)
565  {
566  ASSERT_ERROR ();
567  goto error_exit;
568  }
569 
570  /* Initialize the disk and the server part */
571  tran_index =
572  boot_initialize_server (client_credential, db_path_info, db_overwrite, file_addmore_vols, npages,
573  db_desired_pagesize, log_npages, db_desired_log_page_size, &rootclass_oid, &rootclass_hfid,
574  tran_lock_wait_msecs, tran_isolation);
575 
576  if (tran_index == NULL_TRAN_INDEX)
577  {
578  assert (er_errid () != NO_ERROR);
579  error_code = er_errid ();
580  if (error_code == NO_ERROR)
581  {
582  error_code = ER_GENERIC_ERROR;
583  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 0);
584  }
585  goto error_exit;
586  }
587 
588  // create session
589  (void) db_find_or_create_session (client_credential->get_db_user (), client_credential->get_program_name ());
590 
591  oid_set_root (&rootclass_oid);
592  OID_INIT_TEMPID ();
593 
594  error_code = ws_init ();
595 
596  if (error_code == NO_ERROR)
597  {
598  /* Create system classes such as the root and authorization classes */
599 
600  sm_create_root (&rootclass_oid, &rootclass_hfid);
601  au_init ();
602 
603  /* Create authorization classes and enable authorization */
604  error_code = au_install ();
605  if (error_code == NO_ERROR)
606  {
607  error_code = au_start ();
608  }
609  if (error_code == NO_ERROR)
610  {
611  tr_init ();
612  error_code = tr_install ();
613  if (error_code == NO_ERROR)
614  {
615  error_code = catcls_class_install ();
616  if (error_code == NO_ERROR)
617  {
618  error_code = catcls_vclass_install ();
619  }
620  if (error_code == NO_ERROR)
621  {
622  /*
623  * mark all classes created during the initialization as "system"
624  * classes,
625  */
627  error_code = tran_commit (false);
628  }
629  }
630  }
631  }
632 
633  if (error_code != NO_ERROR)
634  {
635  (void) boot_shutdown_client (false);
636  }
637  else
638  {
639  boot_client (tran_index, tran_lock_wait_msecs, tran_isolation);
640 #if defined (CS_MODE)
641  /* print version string */
644  (void) fprintf (stdout, format, rel_name ());
645 #endif /* CS_MODE */
646  }
647 
648  if (db != NULL)
649  {
650  cfg_free_directory (db);
651  db = NULL;
652  }
653  return error_code;
654 
655 error_exit:
656  if (db != NULL)
657  {
658  cfg_free_directory (db);
659  db = NULL;
660  }
661 
663  {
664  er_log_debug (ARG_FILE_LINE, "boot_initialize_client: unregister client { tran %d }\n", tm_Tran_index);
665  boot_shutdown_client (false);
666  }
667  else
668  {
669  if (boot_Server_credential.db_full_name)
670  {
671  db_private_free_and_init (NULL, boot_Server_credential.db_full_name);
672  }
673  if (boot_Server_credential.host_name)
674  {
675  db_private_free_and_init (NULL, boot_Server_credential.host_name);
676  }
677 
680  set_final ();
681  tr_final ();
682  au_final ();
683  sm_final ();
684  ws_final ();
685  es_final ();
686  tp_final ();
687 
688 #if !defined(WINDOWS)
689  if (dl_initialized == true)
690  {
691  (void) dl_destroy_module ();
692  dl_initialized = false;
693  }
694 #endif /* !WINDOWS */
695 
697  sysprm_final ();
698  area_final ();
699 
700  lang_final ();
701  tz_unload ();
702  perfmon_finalize ();
703 
704 #if defined(WINDOWS)
705  pc_final ();
706 #endif /* WINDOWS */
707 
708  memset (&boot_Server_credential, 0, sizeof (boot_Server_credential));
709  memset (boot_Server_credential.server_session_key, 0xFF, SERVER_SESSION_KEY_SIZE);
710  }
711 
712  return error_code;
713 }
714 
715 /*
716  * boot_restart_client () - restart client
717  *
718  * returns : NO_ERROR if all OK, ER_ status otherwise
719  *
720  * client_credential(in) : Information required to start as client, such as:
721  * database name, user name and password, client
722  * type.
723  *
724  * Note:
725  * An application must restart the database system with the
726  * desired database (the database must have already been created)
727  * before the application start invoking the CUBRID functional
728  * interface. This function restarts the CUBRID client. It also
729  * initializes all client modules for the execution of the client
730  * interface. A transaction for the current client session is
731  * automatically started.
732  *
733  * It is very important that the application check for success
734  * of this function before calling any other CUBRID function.
735  */
736 
737 int
739 {
740  int tran_index;
741  TRAN_ISOLATION tran_isolation;
742  int tran_lock_wait_msecs;
743  TRAN_STATE transtate;
744  int error_code = NO_ERROR;
745  DB_INFO *db = NULL;
746 #if !defined(WINDOWS)
747  bool dl_initialized = false;
748 #endif /* !WINDOWS */
749  char *ptr;
750 #if defined(CS_MODE)
751  const char *hosts[2];
752 
753  char **ha_hosts;
754  int num_hosts;
755  int i, optional_cap;
756  char *ha_node_list = NULL;
757  bool check_capabilities;
758  bool skip_preferred_hosts = false;
759  bool skip_db_info = false;
760 #endif /* CS_MODE */
761 
762  assert (client_credential != NULL);
763 
764  /* If the client is restarted, shutdown the client */
766  {
767  (void) boot_shutdown_client (true);
768  }
769 
771  {
773  }
774 
775 #if defined(WINDOWS)
776  /* set up the WINDOWS stream emulations */
777  pc_init ();
778 #endif /* WINDOWS */
779 
780  /* initialize language parameters */
781  if (lang_init () != NO_ERROR)
782  {
783  if (er_errid () == NO_ERROR)
784  {
785  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_LOC_INIT, 1, "Failed to initialize language module");
786  }
787  return ER_LOC_INIT;
788  }
789 
790  /* initialize time zone data - optional module */
791  if (tz_load () != NO_ERROR)
792  {
793  if (er_errid () == NO_ERROR)
794  {
795  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_TZ_LOAD_ERROR, 1, "Failed to initialize timezone module");
796  }
797  error_code = ER_TZ_LOAD_ERROR;
798  goto error;
799  }
800 
801  /* database name must be specified */
802  if (client_credential->get_db_name () == NULL)
803  {
805  error_code = ER_BO_UNKNOWN_DATABASE;
806  goto error;
807  }
808 
809  /* open the system message catalog, before prm_ ? */
810  if (msgcat_init () != NO_ERROR)
811  {
813  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 0);
814  goto error;
815  }
816 
817  /* initialize system parameters */
818  if (sysprm_load_and_init_client (client_credential->get_db_name (), NULL) != NO_ERROR)
819  {
820  error_code = ER_BO_CANT_LOAD_SYSPRM;
821  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 0);
822  goto error;
823  }
824 
825  // reload with update file name
827  {
828  assert_release (false);
829  goto error;
830  }
831 
833 
834  /* initialize the "areas" memory manager, requires prm_ */
835  area_init ();
837 
838  error_code = perfmon_initialize (1); /* 1 transaction for SA_MODE */
839  if (error_code != NO_ERROR)
840  {
841  ASSERT_ERROR ();
842  goto error;
843  }
844 
845  ptr = (char *) strstr (client_credential->get_db_name (), "@");
846  if (ptr == NULL)
847  {
848  /* Find the location of the database and the log from the database.txt */
849  db = cfg_find_db (client_credential->get_db_name ());
850 #if defined(CS_MODE)
851  if (db == NULL)
852  {
853  /* if not found, use secondary host lists */
854  db = cfg_new_db (client_credential->get_db_name (), NULL, NULL, NULL, NULL);
855  }
856 
857  if (db == NULL
858  || (db->num_hosts > 1
859  && (BOOT_ADMIN_CLIENT_TYPE (client_credential->client_type)
860  || BOOT_LOG_REPLICATOR_TYPE (client_credential->client_type)
861  || BOOT_CSQL_CLIENT_TYPE (client_credential->client_type))))
862  {
863  error_code = ER_NET_NO_EXPLICIT_SERVER_HOST;
864  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 0);
865  goto error;
866  }
867 #endif /* CS_MODE */
868  }
869  else
870  {
871  /* db_name@host_name */
872 #if defined(CS_MODE)
873  *ptr = '\0'; /* screen 'db@host' */
874  if (BOOT_BROKER_AND_DEFAULT_CLIENT_TYPE (client_credential->client_type))
875  {
876  ha_node_list = ptr + 1;
877  ha_hosts = cfg_get_hosts (ha_node_list, &num_hosts, false);
878 
879  db = cfg_new_db (client_credential->get_db_name (), NULL, NULL, NULL, (const char **) ha_hosts);
880 
881  if (ha_hosts)
882  {
883  cfg_free_hosts (ha_hosts);
884  }
885  }
886  else
887  {
888  hosts[0] = ptr + 1;
889  hosts[1] = NULL;
890 
891  db = cfg_new_db (client_credential->get_db_name (), NULL, NULL, NULL, hosts);
892  }
893  *ptr = (char) '@';
894 #else /* CS_MODE */
895  error_code = ER_NOT_IN_STANDALONE;
896  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 1, client_credential->get_db_name ());
897  goto error;
898 #endif /* !CS_MODE */
899  }
900 
901  if (db == NULL)
902  {
903  error_code = ER_BO_UNKNOWN_DATABASE;
904  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 1, client_credential->get_db_name ());
905  goto error;
906  }
907 
908  er_clear ();
909 
910  /* Get the user name */
911  if (client_credential->db_user.empty ())
912  {
913  if (au_has_user_name ())
914  {
915  const char *name = au_user_name (); // while establishing a connection, never use db_get_user_name.
916  if (name != NULL)
917  {
918  client_credential->db_user = name;
919  ws_free_string (name);
920  }
921  }
922  else
923  {
924  // default is PUBLIC
925  client_credential->db_user = AU_PUBLIC_USER_NAME;
926  }
927  }
928  /* Get the login name, host, and process identifier */
929  if (client_credential->login_name.empty ())
930  {
931  if (getuserid (boot_Client_id_buffer, L_cuserid) != (char *) NULL)
932  {
933  client_credential->login_name = boot_Client_id_buffer;
934  }
935  else
936  {
937  client_credential->login_name = boot_Client_id_unknown_string;
938  }
939  }
940  if (client_credential->host_name.empty ())
941  {
942  client_credential->host_name = boot_get_host_name ();
943  }
944  client_credential->process_id = getpid ();
945 
946  /*
947  * Initialize the dynamic loader. Don't care about failures. If dynamic
948  * loader fails, methods will fail when they are invoked
949  */
950 #if !defined(WINDOWS)
951 #if !defined (SOLARIS) && !defined(LINUX) && !defined(AIX)
952  (void) dl_initiate_module (client_credential->get_program_name ());
953 #else /* !SOLARIS && !LINUX && !AIX */
954  (void) dl_initiate_module ();
955 #endif /* !SOLARIS && !LINUX && !AIX */
956  dl_initialized = true;
957 #endif /* !WINDOWS */
958 
959  /* read only mode? */
961  {
963  }
964 
965 #if defined(CS_MODE)
966  /* Initialize the communication subsystem */
968 
969  for (i = 0; i < 2; i++)
970  {
971  if (BOOT_IS_PREFERRED_HOSTS_SET (client_credential) && skip_preferred_hosts == false)
972  {
973  char **hosts;
974  DB_INFO *tmp_db;
975 
976  check_capabilities = true;
977 
978  if (i == 0) /* first */
979  {
980  optional_cap = BOOT_CHECK_HA_DELAY_CAP;
981  }
982  else /* second */
983  {
984  if (!BOOT_REPLICA_ONLY_BROKER_CLIENT_TYPE (client_credential->client_type)
985  && BOOT_NORMAL_CLIENT_TYPE (client_credential->client_type))
986  {
987  check_capabilities = false;
988  }
989 
990  optional_cap = BOOT_NO_OPT_CAP;
991  }
992 
993  hosts = util_split_string (client_credential->preferred_hosts, ":");
994  if (hosts == NULL)
995  {
996  error_code = ER_GENERIC_ERROR;
997  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 0);
998  goto error;
999  }
1000 
1001  tmp_db = cfg_new_db (db->name, NULL, NULL, NULL, (const char **) hosts);
1002  if (tmp_db == NULL)
1003  {
1004  util_free_string_array (hosts);
1005  error_code = ER_BO_UNKNOWN_DATABASE;
1007  goto error;
1008  }
1009 
1010  boot_Host_connected[0] = '\0';
1011 
1012  /* connect to preferred hosts in a sequential order even though a user sets CONNECT_ORDER to RANDOM */
1013  error_code =
1014  boot_client_initialize_css (tmp_db, client_credential->client_type, check_capabilities,
1015  optional_cap, false, DB_CONNECT_ORDER_SEQ, true);
1016 
1017  if (error_code != NO_ERROR)
1018  {
1019  if (error_code == ER_NET_SERVER_HAND_SHAKE)
1020  {
1022  "boot_restart_client: boot_client_initialize_css () ER_NET_SERVER_HAND_SHAKE\n");
1023 
1024  boot_Host_connected[0] = '\0';
1025  }
1026  else
1027  {
1028  skip_preferred_hosts = true;
1029  }
1030  }
1031 
1032  util_free_string_array (hosts);
1033  cfg_free_directory (tmp_db);
1034  }
1035 
1036  if (skip_db_info == true)
1037  {
1038  continue;
1039  }
1040 
1041  if (BOOT_IS_PREFERRED_HOSTS_SET (client_credential) && error_code == NO_ERROR)
1042  {
1043  /* connected to any preferred hosts successfully */
1044  break;
1045  }
1046  else if (BOOT_REPLICA_ONLY_BROKER_CLIENT_TYPE (client_credential->client_type)
1047  || client_credential->client_type == DB_CLIENT_TYPE_SLAVE_ONLY_BROKER)
1048 
1049  {
1050  check_capabilities = true;
1051  if (i == 0) /* first */
1052  {
1053  optional_cap = BOOT_CHECK_HA_DELAY_CAP;
1054  }
1055  else /* second */
1056  {
1057  optional_cap = BOOT_NO_OPT_CAP;
1058  }
1059 
1060  error_code =
1061  boot_client_initialize_css (db, client_credential->client_type, check_capabilities,
1062  optional_cap, false, client_credential->connect_order, false);
1063  }
1064  else if (BOOT_CSQL_CLIENT_TYPE (client_credential->client_type))
1065  {
1066  assert (!BOOT_IS_PREFERRED_HOSTS_SET (client_credential));
1067 
1068  check_capabilities = false;
1069  optional_cap = BOOT_NO_OPT_CAP;
1070 
1071  error_code =
1072  boot_client_initialize_css (db, client_credential->client_type, check_capabilities,
1073  optional_cap, false, DB_CONNECT_ORDER_SEQ, false);
1074  break; /* dont retry */
1075  }
1076  else if (BOOT_NORMAL_CLIENT_TYPE (client_credential->client_type))
1077  {
1078  if (i == 0) /* first */
1079  {
1080  check_capabilities = true;
1081  optional_cap = BOOT_CHECK_HA_DELAY_CAP;
1082  }
1083  else /* second */
1084  {
1085  check_capabilities = false;
1086  optional_cap = BOOT_NO_OPT_CAP;
1087  }
1088 
1089  error_code =
1090  boot_client_initialize_css (db, client_credential->client_type, check_capabilities,
1091  optional_cap, false, client_credential->connect_order, false);
1092 
1093  }
1094  else
1095  {
1096  assert (!BOOT_IS_PREFERRED_HOSTS_SET (client_credential));
1097 
1098  check_capabilities = false;
1099  optional_cap = BOOT_NO_OPT_CAP;
1100  error_code =
1101  boot_client_initialize_css (db, client_credential->client_type, check_capabilities,
1102  optional_cap, false, client_credential->connect_order, false);
1103  break; /* dont retry */
1104  }
1105 
1106  if (error_code == NO_ERROR)
1107  {
1108  if (BOOT_IS_PREFERRED_HOSTS_SET (client_credential))
1109  {
1110  db_set_host_status (boot_Host_connected, DB_HS_NON_PREFFERED_HOSTS);
1111  }
1112  break;
1113  }
1114  else if (error_code == ER_NET_SERVER_HAND_SHAKE)
1115  {
1116  er_log_debug (ARG_FILE_LINE, "boot_restart_client: boot_client_initialize_css () ER_NET_SERVER_HAND_SHAKE\n");
1117  }
1118  else
1119  {
1120  skip_db_info = true;
1121  }
1122  }
1123 
1124  if (error_code != NO_ERROR)
1125  {
1126  er_log_debug (ARG_FILE_LINE, "boot_restart_client: boot_client_initialize_css () error %d\n", error_code);
1127  goto error;
1128  }
1129 
1131  client_credential->get_program_name (), client_credential->process_id,
1132  client_credential->get_db_name (), boot_Host_connected, prm_get_integer_value (PRM_ID_TCP_PORT_ID));
1133 
1134  /* tune some client parameters with the value from the server */
1136 #else /* CS_MODE */
1137 #if defined(WINDOWS)
1139 #endif /* WINDOWS */
1140 #endif /* !CS_MODE */
1141 
1142  /* Free the information about the database */
1143  cfg_free_directory (db);
1144  db = NULL;
1145 
1146  /* this must be done before the register_client because recovery steps may need domains. */
1147  error_code = tp_init ();
1148  if (error_code != NO_ERROR)
1149  {
1150  goto error;
1151  }
1152 
1153  /* Initialize tsc-timer */
1154  tsc_init ();
1155 
1156  error_code = ws_init ();
1157  if (error_code != NO_ERROR)
1158  {
1159  goto error;
1160  }
1161 
1162  /*
1163  * At this moment, we should use the default isolation level and wait
1164  * timeout, since the client fetches objects during the restart process.
1165  * This values are reset at a later point, once the client has been fully
1166  * restarted.
1167  */
1168 
1169  tran_isolation = TRAN_DEFAULT_ISOLATION_LEVEL ();
1170 
1171  tran_lock_wait_msecs = TRAN_LOCK_INFINITE_WAIT;
1172 
1174  "boot_restart_client: register client { type %d db %s user %s password %s "
1175  "program %s login %s host %s pid %d }\n", client_credential->client_type,
1176  client_credential->get_db_name (), client_credential->get_db_user (),
1177  client_credential->db_password.empty ()? "(null)" : client_credential->get_db_password (),
1178  client_credential->get_program_name (),
1179  client_credential->get_login_name (), client_credential->get_host_name (),
1180  client_credential->process_id);
1181 
1182  tran_index =
1183  boot_register_client (client_credential, tran_lock_wait_msecs, tran_isolation, &transtate, &boot_Server_credential);
1184 
1185  if (tran_index == NULL_TRAN_INDEX)
1186  {
1187  assert (er_errid () != NO_ERROR);
1188  error_code = er_errid ();
1189  goto error;
1190  }
1191 
1192 #if defined(CS_MODE)
1193  if (lang_set_charset ((INTL_CODESET) boot_Server_credential.db_charset) != NO_ERROR)
1194  {
1195  assert (er_errid () != NO_ERROR);
1196  error_code = er_errid ();
1197  goto error;
1198  }
1199  if (lang_set_language (boot_Server_credential.db_lang) != NO_ERROR)
1200  {
1201  assert (er_errid () != NO_ERROR);
1202  error_code = er_errid ();
1203  goto error;
1204  }
1205 
1206  /* Reset the pagesize according to server.. */
1207  if (db_set_page_size (boot_Server_credential.page_size, boot_Server_credential.log_page_size) != NO_ERROR)
1208  {
1209  assert (er_errid () != NO_ERROR);
1210  error_code = er_errid ();
1211  goto error;
1212  }
1213 
1214  /* Reset the disk_level according to server.. */
1215  if (rel_disk_compatible () != boot_Server_credential.disk_compatibility)
1216  {
1217  rel_set_disk_compatible (boot_Server_credential.disk_compatibility);
1218  }
1219 #endif /* CS_MODE */
1220  if (sysprm_init_intl_param () != NO_ERROR)
1221  {
1222  error_code = er_errid ();
1223  goto error;
1224  }
1225 
1226  /* Initialize client modules for execution */
1227  boot_client (tran_index, tran_lock_wait_msecs, tran_isolation);
1228 
1229  oid_set_root (&boot_Server_credential.root_class_oid);
1230  OID_INIT_TEMPID ();
1231 
1232  sm_init (&boot_Server_credential.root_class_oid, &boot_Server_credential.root_class_hfid);
1233  au_init (); /* initialize authorization globals */
1234 
1235  /* start authorization and make sure the logged in user has access */
1236  error_code = au_start ();
1237  if (error_code != NO_ERROR)
1238  {
1239  goto error;
1240  }
1241  error_code = boot_client_find_and_cache_class_oids ();
1242  if (error_code != NO_ERROR)
1243  {
1244  goto error;
1245  }
1246 
1247  (void) db_find_or_create_session (client_credential->get_db_user (), client_credential->get_program_name ());
1248 
1249 #if defined(CS_MODE)
1250  error_code = boot_check_locales (client_credential);
1251  if (error_code != NO_ERROR)
1252  {
1253  goto error;
1254  }
1255 
1256  error_code = boot_check_timezone_checksum (client_credential);
1257  if (error_code != NO_ERROR)
1258  {
1259  goto error;
1260  }
1261 #endif /* CS_MODE */
1262 
1263  tr_init (); /* initialize trigger manager */
1264 
1265  jsp_init ();
1266 
1267  /* TODO: how about to call es_init() only for normal client? */
1268  if (boot_Server_credential.lob_path[0] != '\0')
1269  {
1270  error_code = es_init (boot_Server_credential.lob_path);
1271  if (error_code != NO_ERROR)
1272  {
1273  goto error;
1274  }
1275  }
1276  else
1277  {
1279  }
1280  /* Does not care if was committed/aborted .. */
1281  (void) tran_commit (false);
1282 
1283  /*
1284  * If there is a need to change the isolation level and the lock wait,
1285  * do it at this moment
1286  */
1287 
1289  tran_lock_wait_msecs = prm_get_integer_value (PRM_ID_LK_TIMEOUT_SECS);
1290  if (tran_isolation != TRAN_DEFAULT_ISOLATION_LEVEL ())
1291  {
1292  error_code = tran_reset_isolation (tran_isolation, TM_TRAN_ASYNC_WS ());
1293  if (error_code != NO_ERROR)
1294  {
1295  goto error;
1296  }
1297  }
1298  if (tran_lock_wait_msecs >= 0)
1299  {
1300  (void) tran_reset_wait_times (tran_lock_wait_msecs * 1000);
1301  }
1302 
1303  error_code = showstmt_metadata_init ();
1304  if (error_code != NO_ERROR)
1305  {
1306  goto error;
1307  }
1308  json_set_alloc_funcs (malloc, free);
1309 
1310  return error_code;
1311 
1312 error:
1313 
1314  /* Protect against falsely returning NO_ERROR to caller */
1315  if (error_code == NO_ERROR)
1316  {
1317  error_code = ER_GENERIC_ERROR;
1318  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 0);
1319  }
1320 
1321  if (db != NULL)
1322  {
1323  cfg_free_directory (db);
1324  }
1325 
1326  if (BOOT_IS_CLIENT_RESTARTED ())
1327  {
1328  er_log_debug (ARG_FILE_LINE, "boot_restart_client: unregister client { tran %d }\n", tm_Tran_index);
1329  boot_shutdown_client (false);
1330  }
1331  else
1332  {
1333  if (boot_Server_credential.db_full_name)
1334  {
1335  db_private_free_and_init (NULL, boot_Server_credential.db_full_name);
1336  }
1337  if (boot_Server_credential.host_name)
1338  {
1339  db_private_free_and_init (NULL, boot_Server_credential.host_name);
1340  }
1341 
1344  set_final ();
1345  tr_final ();
1346  au_final ();
1347  sm_final ();
1348  ws_final ();
1349  es_final ();
1350  tp_final ();
1351 
1352 #if !defined(WINDOWS)
1353  if (dl_initialized == true)
1354  {
1355  (void) dl_destroy_module ();
1356  dl_initialized = false;
1357  }
1358 #endif /* !WINDOWS */
1359 
1360  locator_free_areas ();
1361  sysprm_final ();
1362  area_final ();
1363 
1364  lang_final ();
1365  tz_unload ();
1366 
1367 #if defined(WINDOWS)
1368  pc_final ();
1369 #endif /* WINDOWS */
1370 
1371  memset (&boot_Server_credential, 0, sizeof (boot_Server_credential));
1372  memset (boot_Server_credential.server_session_key, 0xFF, SERVER_SESSION_KEY_SIZE);
1373  }
1374 
1375  return error_code;
1376 }
1377 
1378 /*
1379  * boot_shutdown_client () - shutdown client
1380  *
1381  * returns : NO_ERROR if all OK, ER_ status otherwise
1382  *
1383  * is_er_final(in) :
1384  *
1385  * Note:
1386  * This function should be called before the CUBRID
1387  * application is finished. This function will notify the
1388  * recovery manager that the application has finished and will
1389  * terminate all client modules (e.g., allocation of memory is
1390  * deallocated).If there are active transactions, they are either
1391  * committed or aborted according to the commit_on_shutdown
1392  * system parameter.
1393  */
1394 
1395 int
1396 boot_shutdown_client (bool is_er_final)
1397 {
1398  if (BOOT_IS_CLIENT_RESTARTED ())
1399  {
1400  /*
1401  * wait for other server request to finish.
1402  * if db_shutdown() is called by signal handler or atexit handler,
1403  * the server request may be running.
1404  */
1406 
1407  /*
1408  * Either Abort or commit the current transaction depending upon the value
1409  * of the commit_on_shutdown system parameter.
1410  */
1412  {
1414  {
1415  (void) tran_commit (false);
1416  }
1417  else
1418  {
1419  (void) tran_abort ();
1420  }
1421  }
1422 
1423  /*
1424  * Make sure that we are still up. For example, if the server died, we do
1425  * not need to call the following stuff any longer.
1426  */
1427 
1428  if (BOOT_IS_CLIENT_RESTARTED ())
1429  {
1431 #if defined(CS_MODE)
1432  (void) net_client_final ();
1433 #else /* CS_MODE */
1434 #if defined(WINDOWS)
1436 #endif /* WINDOWS */
1437 #endif /* !CS_MODE */
1438  }
1439 
1440  boot_client_all_finalize (is_er_final);
1442  }
1443 
1444  return NO_ERROR;
1445 }
1446 
1447 /*
1448  * boot_shutdown_client_at_exit () - make sure that the client is shutdown at exit
1449  *
1450  * return : nothing
1451  *
1452  * Note:
1453  * This function is called when the invoked program terminates
1454  * normally. This function make sure that the client is shutdown
1455  * in a nice way.
1456  */
1457 static void
1459 {
1460  if (BOOT_IS_CLIENT_RESTARTED () && boot_Process_id == getpid ())
1461  {
1462  /* Avoid infinite looping if someone calls exit during shutdown */
1463  boot_Process_id++;
1464 
1465  if (!er_is_initialized ())
1466  {
1467  // we need error manager initialized
1469  }
1470 
1471  (void) boot_shutdown_client (true);
1472  }
1473 }
1474 
1475 /*
1476  * boot_donot_shutdown_client_at_exit: do not shutdown client at exist.
1477  *
1478  * return : nothing
1479  *
1480  * This function must be called when the system needs to exit
1481  * without shutting down the client (e.g., in case of fatal
1482  * failure).
1483  */
1484 void
1486 {
1487  if (BOOT_IS_CLIENT_RESTARTED () && boot_Process_id == getpid ())
1488  {
1489  boot_Process_id++;
1490  }
1491 }
1492 
1493 /*
1494  * boot_server_die_or_reject: shutdown client when the server is dead
1495  *
1496  * return : nothing
1497  *
1498  * Note: The server has been terminated for circumstances beyond the client
1499  * control. All active client transactions have been unilaterally
1500  * aborted as a consequence of the termination of server.
1501  */
1502 void
1504 {
1505  /*
1506  * If the client is restarted, abort the active transaction in the client and
1507  * terminate the client modules
1508  */
1509  if (BOOT_IS_CLIENT_RESTARTED ())
1510  {
1511  (void) tran_abort_only_client (true);
1513  boot_Is_client_all_final = false;
1514 #if defined(CS_MODE)
1515  css_terminate (true);
1516 #endif /* !CS_MODE */
1518  {
1519  er_print_callstack (ARG_FILE_LINE, "boot_server_die_or_changed() terminated\n");
1520  }
1521  }
1522 }
1523 
1524 /*
1525  * boot_client_all_finalize () - terminate every single client
1526  *
1527  * return : nothing
1528  *
1529  * is_er_final(in): Terminate the error module..
1530  *
1531  *
1532  * Note: Terminate every single module of the client. This function is called
1533  * during the shutdown of the client.
1534  */
1535 void
1536 boot_client_all_finalize (bool is_er_final)
1537 {
1539  {
1540  if (boot_Server_credential.db_full_name)
1541  {
1542  db_private_free_and_init (NULL, boot_Server_credential.db_full_name);
1543  }
1544  if (boot_Server_credential.host_name)
1545  {
1546  db_private_free_and_init (NULL, boot_Server_credential.host_name);
1547  }
1548  if (boot_Server_credential.lob_path)
1549  {
1550  db_private_free_and_init (NULL, boot_Server_credential.lob_path);
1551  }
1552  if (boot_Server_credential.db_lang)
1553  {
1554  db_private_free_and_init (NULL, boot_Server_credential.db_lang);
1555  }
1556 
1560  set_final ();
1561  parser_final ();
1562  tr_final ();
1563  au_final ();
1564  sm_final ();
1565  ws_final ();
1566  es_final ();
1567  tp_final ();
1568 
1569 #if !defined(WINDOWS)
1570  (void) dl_destroy_module ();
1571 #endif /* !WINDOWS */
1572 
1573  locator_free_areas ();
1574  sysprm_final ();
1575  perfmon_finalize ();
1576  area_final ();
1577 
1578  msgcat_final ();
1579  if (is_er_final)
1580  {
1582  }
1583  lang_final ();
1584  tz_unload ();
1585 
1586  /* adj_arrays & lex buffers in the cnv formatting library. */
1587  cnv_cleanup ();
1588 
1589 #if defined(WINDOWS)
1590  pc_final ();
1591 #endif /* WINDOWS */
1592 
1593  /* Clean up stuff allocated by the utilities library too. Not really necessary but avoids warnings from memory
1594  * tracking tools that customers might be using. */
1595  co_final ();
1596 
1597  memset (&boot_Server_credential, 0, sizeof (boot_Server_credential));
1598  memset (boot_Server_credential.server_session_key, 0xFF, SERVER_SESSION_KEY_SIZE);
1599 
1601  boot_Is_client_all_final = true;
1602  }
1603 
1604 }
1605 
1606 #if defined(CS_MODE)
1607 /*
1608  * boot_client_initialize_css () - Attempts to connect to hosts
1609  * in list
1610  *
1611  * returns : NO_ERROR if all OK, ER_ status otherwise
1612  *
1613  * db(in) : host information
1614  * connect_order(in): whether to randomly or sequentially traverse host list
1615  * opt_cap(in): optional capability
1616  * discriminative(in): deprecated
1617  *
1618  * Note: This function will try an initialize the communications with the hosts
1619  * in hostlist until success or the end of list is reached.
1620  */
1621 static int
1622 boot_client_initialize_css (DB_INFO * db, int client_type, bool check_capabilities, int opt_cap, bool discriminative,
1623  int connect_order, bool is_preferred_host)
1624 {
1626  int hn, n;
1627  char *hostlist[MAX_NUM_DB_HOSTS];
1628  char strbuf[(CUB_MAXHOSTNAMELEN + 1) * MAX_NUM_DB_HOSTS];
1629  bool cap_error = false, boot_host_connected_exist = false;
1630  int max_num_delayed_hosts_lookup;
1631 
1632  assert (db != NULL);
1633  assert (db->num_hosts > 0);
1634 
1635  if (db->hosts == NULL)
1636  {
1637  db->hosts = cfg_get_hosts (NULL, &db->num_hosts, false);
1638  if (db->hosts == NULL)
1639  {
1641  return ER_GENERIC_ERROR;
1642  }
1643  }
1644 
1645  max_num_delayed_hosts_lookup = db_get_max_num_delayed_hosts_lookup ();
1646  if (is_preferred_host == false && max_num_delayed_hosts_lookup == 0 && (opt_cap & BOOT_CHECK_HA_DELAY_CAP))
1647  {
1648  /* if max_num_delayed_hosts_lookup is zero, move on to 2nd try */
1649  return ER_NET_SERVER_HAND_SHAKE;
1650  }
1651 
1652  memset (hostlist, 0, sizeof (hostlist));
1653  hn = 0;
1654  /* try the connected host first */
1655  if (boot_Host_connected[0] != '\0')
1656  {
1657  boot_host_connected_exist = true;
1658  hostlist[hn++] = boot_Host_connected;
1659  }
1660  for (n = 0; hn < MAX_NUM_DB_HOSTS && n < db->num_hosts; n++)
1661  {
1662  hostlist[hn++] = db->hosts[n];
1663  }
1664 
1665  if (connect_order == DB_CONNECT_ORDER_RANDOM)
1666  {
1667  if (boot_Host_connected[0] != '\0')
1668  {
1669  /* leave boot_Host_connected at the front and shuffle the others */
1670  util_shuffle_string_array (hostlist + 1, hn - 1);
1671  }
1672  else
1673  {
1674  util_shuffle_string_array (hostlist, hn);
1675  }
1676  }
1677 
1679 
1680  for (n = 0; n < hn; n++)
1681  {
1683  {
1684  if (css_check_server_alive_fn (db->name, hostlist[n]) == false)
1685  {
1686  er_log_debug (ARG_FILE_LINE, "skip '%s@%s'\n", db->name, hostlist[n]);
1688  continue;
1689  }
1690  }
1691 
1692  er_log_debug (ARG_FILE_LINE, "trying to connect '%s@%s'\n", db->name, hostlist[n]);
1693  error = net_client_init (db->name, hostlist[n]);
1694  if (error != NO_ERROR)
1695  {
1696  if (error == ERR_CSS_TCP_CONNECT_TIMEDOUT)
1697  {
1699  }
1700  else
1701  {
1702  db_set_host_status (hostlist[n], DB_HS_CONN_FAILURE);
1703  }
1704  }
1705  else
1706  {
1707  /* save the hostname for the use of calling functions */
1708  if (boot_Host_connected != hostlist[n])
1709  {
1710  strncpy_bufsize (boot_Host_connected, hostlist[n]);
1711  }
1712  db_set_connected_host_status (hostlist[n]);
1713 
1714  er_log_debug (ARG_FILE_LINE, "ping server with handshake\n");
1715  /* ping to validate availability and to check compatibility */
1716  er_clear ();
1717  error = net_client_ping_server_with_handshake (client_type, check_capabilities, opt_cap);
1718  if (error != NO_ERROR)
1719  {
1720  css_terminate (false);
1721  }
1722  }
1723 
1724  /* connect error to the db at the host */
1725  switch (error)
1726  {
1727  case NO_ERROR:
1728  return NO_ERROR;
1729 
1732  cap_error = true;
1733  /* FALLTHRU */
1735  case ER_NET_NO_SERVER_HOST:
1737  case ER_NET_NO_MASTER:
1743  /* try to connect to next host */
1744  er_log_debug (ARG_FILE_LINE, "error %d. try to connect to next host\n", error);
1745  break;
1746  default:
1747  /* ?? */
1749  }
1750 
1751  if (error == ER_NET_SERVER_HAND_SHAKE && is_preferred_host == false && (opt_cap & BOOT_CHECK_HA_DELAY_CAP)
1752  && max_num_delayed_hosts_lookup > 0)
1753  {
1754  /* do not count delayed boot_Host_connected */
1755  if (boot_host_connected_exist == true && n == 0)
1756  {
1758  }
1759 
1760  if (db_get_delayed_hosts_count () >= max_num_delayed_hosts_lookup)
1761  {
1762  hn = n + 1;
1763  break;
1764  }
1765  }
1766  } /* for (tn) */
1767 
1768  /* failed to connect all hosts; write an error message */
1769  strbuf[0] = '\0';
1770  for (n = 0; n < hn - 1 && n < (MAX_NUM_DB_HOSTS - 1); n++)
1771  {
1772  strncat (strbuf, hostlist[n], CUB_MAXHOSTNAMELEN);
1773  strcat (strbuf, ":");
1774  }
1775  strncat (strbuf, hostlist[n], CUB_MAXHOSTNAMELEN);
1777 
1778  if (check_capabilities == true && cap_error == true)
1779  {
1780  /*
1781  * There'a a live host which has cause handshake error,
1782  * so adjust the return value
1783  */
1784  error = ER_NET_SERVER_HAND_SHAKE;
1785  }
1786 
1787  return (error);
1788 }
1789 #endif /* CS_MODE */
1790 
1791 /*
1792  * boot_define_class :
1793  *
1794  * returns : NO_ERROR if all OK, ER_ status otherwise
1795  *
1796  * class(IN) :
1797  */
1798 static int
1800 {
1801  SM_TEMPLATE *def;
1802  char domain_string[32];
1803  int error_code = NO_ERROR;
1804  const char *index_col_names[2] = { "class_name", NULL };
1805 
1806  def = smt_edit_class_mop (class_mop, AU_ALTER);
1807 
1808  error_code = smt_add_attribute (def, "class_of", "object", NULL);
1809  if (error_code != NO_ERROR)
1810  {
1811  return error_code;
1812  }
1813 
1814  error_code = smt_add_attribute (def, "class_name", "varchar(255)", NULL);
1815  if (error_code != NO_ERROR)
1816  {
1817  return error_code;
1818  }
1819 
1820  error_code = smt_add_attribute (def, "class_type", "integer", NULL);
1821  if (error_code != NO_ERROR)
1822  {
1823  return error_code;
1824  }
1825 
1826  error_code = smt_add_attribute (def, "is_system_class", "integer", NULL);
1827  if (error_code != NO_ERROR)
1828  {
1829  return error_code;
1830  }
1831 
1832  error_code = smt_add_attribute (def, "owner", AU_USER_CLASS_NAME, NULL);
1833  if (error_code != NO_ERROR)
1834  {
1835  return error_code;
1836  }
1837 
1838  error_code = smt_add_attribute (def, "inst_attr_count", "integer", NULL);
1839  if (error_code != NO_ERROR)
1840  {
1841  return error_code;
1842  }
1843 
1844  error_code = smt_add_attribute (def, "class_attr_count", "integer", NULL);
1845  if (error_code != NO_ERROR)
1846  {
1847  return error_code;
1848  }
1849 
1850  error_code = smt_add_attribute (def, "shared_attr_count", "integer", NULL);
1851  if (error_code != NO_ERROR)
1852  {
1853  return error_code;
1854  }
1855 
1856  error_code = smt_add_attribute (def, "inst_meth_count", "integer", NULL);
1857  if (error_code != NO_ERROR)
1858  {
1859  return error_code;
1860  }
1861 
1862  error_code = smt_add_attribute (def, "class_meth_count", "integer", NULL);
1863  if (error_code != NO_ERROR)
1864  {
1865  return error_code;
1866  }
1867 
1868  error_code = smt_add_attribute (def, "collation_id", "integer", NULL);
1869  if (error_code != NO_ERROR)
1870  {
1871  return error_code;
1872  }
1873 
1874  error_code = smt_add_attribute (def, "tde_algorithm", "integer", NULL);
1875  if (error_code != NO_ERROR)
1876  {
1877  return error_code;
1878  }
1879 
1880  sprintf (domain_string, "sequence of %s", CT_CLASS_NAME);
1881 
1882  error_code = smt_add_attribute (def, "sub_classes", domain_string, NULL);
1883  if (error_code != NO_ERROR)
1884  {
1885  return error_code;
1886  }
1887 
1888  error_code = smt_add_attribute (def, "super_classes", domain_string, NULL);
1889  if (error_code != NO_ERROR)
1890  {
1891  return error_code;
1892  }
1893 
1894  sprintf (domain_string, "sequence of %s", CT_ATTRIBUTE_NAME);
1895 
1896  error_code = smt_add_attribute (def, "inst_attrs", domain_string, NULL);
1897  if (error_code != NO_ERROR)
1898  {
1899  return error_code;
1900  }
1901 
1902  error_code = smt_add_attribute (def, "class_attrs", domain_string, NULL);
1903  if (error_code != NO_ERROR)
1904  {
1905  return error_code;
1906  }
1907 
1908  error_code = smt_add_attribute (def, "shared_attrs", domain_string, NULL);
1909  if (error_code != NO_ERROR)
1910  {
1911  return error_code;
1912  }
1913 
1914  sprintf (domain_string, "sequence of %s", CT_METHOD_NAME);
1915 
1916  error_code = smt_add_attribute (def, "inst_meths", domain_string, NULL);
1917  if (error_code != NO_ERROR)
1918  {
1919  return error_code;
1920  }
1921 
1922  error_code = smt_add_attribute (def, "class_meths", domain_string, NULL);
1923  if (error_code != NO_ERROR)
1924  {
1925  return error_code;
1926  }
1927 
1928  sprintf (domain_string, "sequence of %s", CT_METHFILE_NAME);
1929 
1930  error_code = smt_add_attribute (def, "meth_files", domain_string, NULL);
1931  if (error_code != NO_ERROR)
1932  {
1933  return error_code;
1934  }
1935 
1936  sprintf (domain_string, "sequence of %s", CT_QUERYSPEC_NAME);
1937 
1938  error_code = smt_add_attribute (def, "query_specs", domain_string, NULL);
1939  if (error_code != NO_ERROR)
1940  {
1941  return error_code;
1942  }
1943 
1944  sprintf (domain_string, "sequence of %s", CT_INDEX_NAME);
1945 
1946  error_code = smt_add_attribute (def, "indexes", domain_string, NULL);
1947  if (error_code != NO_ERROR)
1948  {
1949  return error_code;
1950  }
1951 
1952  error_code = smt_add_attribute (def, "comment", "varchar(2048)", NULL);
1953  if (error_code != NO_ERROR)
1954  {
1955  return error_code;
1956  }
1957 
1958  sprintf (domain_string, "sequence of %s", CT_PARTITION_NAME);
1959 
1960  error_code = smt_add_attribute (def, "partition", domain_string, NULL);
1961  if (error_code != NO_ERROR)
1962  {
1963  return error_code;
1964  }
1965 
1966  error_code = sm_update_class (def, NULL);
1967  if (error_code != NO_ERROR)
1968  {
1969  return error_code;
1970  }
1971 
1972  /* add index */
1973  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, index_col_names, 0);
1974  if (error_code != NO_ERROR)
1975  {
1976  return error_code;
1977  }
1978 
1979  if (locator_has_heap (class_mop) == NULL)
1980  {
1981  assert (er_errid () != NO_ERROR);
1982  return er_errid ();
1983  }
1984 
1985  error_code = au_change_owner (class_mop, Au_dba_user);
1986  if (error_code != NO_ERROR)
1987  {
1988  return error_code;
1989  }
1990 
1991  return NO_ERROR;
1992 }
1993 
1994 /*
1995  * boot_define_attribute :
1996  *
1997  * returns : NO_ERROR if all OK, ER_ status otherwise
1998  *
1999  * class(IN) :
2000  */
2001 static int
2003 {
2004  SM_TEMPLATE *def;
2005  char domain_string[32];
2006  int error_code = NO_ERROR;
2007  const char *index_col_names[4] = { "class_of", "attr_name", "attr_type", NULL };
2008 
2009  def = smt_edit_class_mop (class_mop, AU_ALTER);
2010 
2011  error_code = smt_add_attribute (def, "class_of", CT_CLASS_NAME, NULL);
2012  if (error_code != NO_ERROR)
2013  {
2014  return error_code;
2015  }
2016 
2017  error_code = smt_add_attribute (def, "attr_name", "varchar(255)", NULL);
2018  if (error_code != NO_ERROR)
2019  {
2020  return error_code;
2021  }
2022 
2023  error_code = smt_add_attribute (def, "attr_type", "integer", NULL);
2024  if (error_code != NO_ERROR)
2025  {
2026  return error_code;
2027  }
2028 
2029  error_code = smt_add_attribute (def, "from_class_of", CT_CLASS_NAME, NULL);
2030  if (error_code != NO_ERROR)
2031  {
2032  return error_code;
2033  }
2034 
2035  error_code = smt_add_attribute (def, "from_attr_name", "varchar(255)", NULL);
2036  if (error_code != NO_ERROR)
2037  {
2038  return error_code;
2039  }
2040 
2041  error_code = smt_add_attribute (def, "def_order", "integer", NULL);
2042  if (error_code != NO_ERROR)
2043  {
2044  return error_code;
2045  }
2046 
2047  error_code = smt_add_attribute (def, "data_type", "integer", NULL);
2048  if (error_code != NO_ERROR)
2049  {
2050  return error_code;
2051  }
2052 
2053  error_code = smt_add_attribute (def, "default_value", "varchar(255)", NULL);
2054  if (error_code != NO_ERROR)
2055  {
2056  return error_code;
2057  }
2058 
2059  sprintf (domain_string, "sequence of %s", CT_DOMAIN_NAME);
2060 
2061  error_code = smt_add_attribute (def, "domains", domain_string, NULL);
2062  if (error_code != NO_ERROR)
2063  {
2064  return error_code;
2065  }
2066 
2067  error_code = smt_add_attribute (def, "is_nullable", "integer", NULL);
2068  if (error_code != NO_ERROR)
2069  {
2070  return error_code;
2071  }
2072 
2073  error_code = smt_add_attribute (def, "comment", "varchar(1024)", NULL);
2074  if (error_code != NO_ERROR)
2075  {
2076  return error_code;
2077  }
2078 
2079  error_code = sm_update_class (def, NULL);
2080  if (error_code != NO_ERROR)
2081  {
2082  return error_code;
2083  }
2084 
2085  /* add index */
2086  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, index_col_names, 0);
2087  if (error_code != NO_ERROR)
2088  {
2089  return error_code;
2090  }
2091 
2092  if (locator_has_heap (class_mop) == NULL)
2093  {
2094  assert (er_errid () != NO_ERROR);
2095  return er_errid ();
2096  }
2097 
2098  error_code = au_change_owner (class_mop, Au_dba_user);
2099  if (error_code != NO_ERROR)
2100  {
2101  return error_code;
2102  }
2103 
2104  return NO_ERROR;
2105 }
2106 
2107 /*
2108  * boot_define_domain :
2109  *
2110  * returns : NO_ERROR if all OK, ER_ status otherwise
2111  *
2112  * class(IN) :
2113  *
2114  * Note:
2115  *
2116  */
2117 static int
2119 {
2120  SM_TEMPLATE *def;
2121  char domain_string[32];
2122  int error_code = NO_ERROR;
2123  const char *index_col_names[2] = { "object_of", NULL };
2124 
2125  def = smt_edit_class_mop (class_mop, AU_ALTER);
2126 
2127  error_code = smt_add_attribute (def, "object_of", "object", NULL);
2128  if (error_code != NO_ERROR)
2129  {
2130  return error_code;
2131  }
2132 
2133  error_code = smt_add_attribute (def, "data_type", "integer", NULL);
2134  if (error_code != NO_ERROR)
2135  {
2136  return error_code;
2137  }
2138 
2139  error_code = smt_add_attribute (def, "prec", "integer", NULL);
2140  if (error_code != NO_ERROR)
2141  {
2142  return error_code;
2143  }
2144 
2145  error_code = smt_add_attribute (def, "scale", "integer", NULL);
2146  if (error_code != NO_ERROR)
2147  {
2148  return error_code;
2149  }
2150 
2151  error_code = smt_add_attribute (def, "class_of", CT_CLASS_NAME, NULL);
2152  if (error_code != NO_ERROR)
2153  {
2154  return error_code;
2155  }
2156 
2157  error_code = smt_add_attribute (def, "code_set", "integer", NULL);
2158  if (error_code != NO_ERROR)
2159  {
2160  return error_code;
2161  }
2162 
2163  error_code = smt_add_attribute (def, "collation_id", "integer", NULL);
2164  if (error_code != NO_ERROR)
2165  {
2166  return error_code;
2167  }
2168 
2169  error_code = smt_add_attribute (def, "enumeration", "sequence of character varying", NULL);
2170  if (error_code != NO_ERROR)
2171  {
2172  return error_code;
2173  }
2174 
2175  sprintf (domain_string, "sequence of %s", CT_DOMAIN_NAME);
2176 
2177  error_code = smt_add_attribute (def, "set_domains", domain_string, NULL);
2178  if (error_code != NO_ERROR)
2179  {
2180  return error_code;
2181  }
2182 
2183  error_code = smt_add_attribute (def, "json_schema", "string", NULL);
2184  if (error_code != NO_ERROR)
2185  {
2186  return error_code;
2187  }
2188 
2189  error_code = sm_update_class (def, NULL);
2190  if (error_code != NO_ERROR)
2191  {
2192  return error_code;
2193  }
2194 
2195  /* add index */
2196  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, index_col_names, 0);
2197  if (error_code != NO_ERROR)
2198  {
2199  return error_code;
2200  }
2201 
2202  if (locator_has_heap (class_mop) == NULL)
2203  {
2204  assert (er_errid () != NO_ERROR);
2205  return er_errid ();
2206  }
2207 
2208  error_code = au_change_owner (class_mop, Au_dba_user);
2209  if (error_code != NO_ERROR)
2210  {
2211  return error_code;
2212  }
2213 
2214  return NO_ERROR;
2215 }
2216 
2217 /*
2218  * boot_define_method :
2219  *
2220  * returns : NO_ERROR if all OK, ER_ status otherwise
2221  *
2222  * class(IN) :
2223  */
2224 static int
2226 {
2227  SM_TEMPLATE *def;
2228  char domain_string[32];
2229  int error_code = NO_ERROR;
2230  const char *names[3] = { "class_of", "meth_name", NULL };
2231 
2232  def = smt_edit_class_mop (class_mop, AU_ALTER);
2233 
2234  error_code = smt_add_attribute (def, "class_of", CT_CLASS_NAME, NULL);
2235  if (error_code != NO_ERROR)
2236  {
2237  return error_code;
2238  }
2239 
2240  error_code = smt_add_attribute (def, "meth_name", "varchar(255)", NULL);
2241  if (error_code != NO_ERROR)
2242  {
2243  return error_code;
2244  }
2245 
2246  error_code = smt_add_attribute (def, "meth_type", "integer", NULL);
2247  if (error_code != NO_ERROR)
2248  {
2249  return error_code;
2250  }
2251 
2252  error_code = smt_add_attribute (def, "from_class_of", CT_CLASS_NAME, NULL);
2253  if (error_code != NO_ERROR)
2254  {
2255  return error_code;
2256  }
2257 
2258  error_code = smt_add_attribute (def, "from_meth_name", "varchar(255)", NULL);
2259  if (error_code != NO_ERROR)
2260  {
2261  return error_code;
2262  }
2263 
2264  sprintf (domain_string, "sequence of %s", CT_METHSIG_NAME);
2265 
2266  error_code = smt_add_attribute (def, "signatures", domain_string, NULL);
2267  if (error_code != NO_ERROR)
2268  {
2269  return error_code;
2270  }
2271 
2272  error_code = sm_update_class (def, NULL);
2273  if (error_code != NO_ERROR)
2274  {
2275  return error_code;
2276  }
2277 
2278  /* add index */
2279  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, names, 0);
2280  if (error_code != NO_ERROR)
2281  {
2282  return error_code;
2283  }
2284 
2285  if (locator_has_heap (class_mop) == NULL)
2286  {
2287  assert (er_errid () != NO_ERROR);
2288  return er_errid ();
2289  }
2290 
2291  error_code = au_change_owner (class_mop, Au_dba_user);
2292  if (error_code != NO_ERROR)
2293  {
2294  return error_code;
2295  }
2296 
2297  return NO_ERROR;
2298 }
2299 
2300 /*
2301  * boot_define_meth_sig :
2302  *
2303  * returns : NO_ERROR if all OK, ER_ status otherwise
2304  *
2305  * class(IN) :
2306  */
2307 static int
2309 {
2310  SM_TEMPLATE *def;
2311  char domain_string[32];
2312  int error_code = NO_ERROR;
2313  const char *names[2] = { "meth_of", NULL };
2314 
2315  def = smt_edit_class_mop (class_mop, AU_ALTER);
2316 
2317  error_code = smt_add_attribute (def, "meth_of", CT_METHOD_NAME, NULL);
2318  if (error_code != NO_ERROR)
2319  {
2320  return error_code;
2321  }
2322 
2323  error_code = smt_add_attribute (def, "func_name", "varchar(255)", NULL);
2324  if (error_code != NO_ERROR)
2325  {
2326  return error_code;
2327  }
2328 
2329  error_code = smt_add_attribute (def, "arg_count", "integer", NULL);
2330  if (error_code != NO_ERROR)
2331  {
2332  return error_code;
2333  }
2334 
2335  sprintf (domain_string, "sequence of %s", CT_METHARG_NAME);
2336 
2337  error_code = smt_add_attribute (def, "return_value", domain_string, NULL);
2338  if (error_code != NO_ERROR)
2339  {
2340  return error_code;
2341  }
2342 
2343  error_code = smt_add_attribute (def, "arguments", domain_string, NULL);
2344  if (error_code != NO_ERROR)
2345  {
2346  return error_code;
2347  }
2348 
2349  error_code = sm_update_class (def, NULL);
2350  if (error_code != NO_ERROR)
2351  {
2352  return error_code;
2353  }
2354 
2355  /* add index */
2356  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, names, 0);
2357  if (error_code != NO_ERROR)
2358  {
2359  return error_code;
2360  }
2361 
2362  if (locator_has_heap (class_mop) == NULL)
2363  {
2364  assert (er_errid () != NO_ERROR);
2365  return er_errid ();
2366  }
2367 
2368  error_code = au_change_owner (class_mop, Au_dba_user);
2369  if (error_code != NO_ERROR)
2370  {
2371  return error_code;
2372  }
2373 
2374  return NO_ERROR;
2375 }
2376 
2377 /*
2378  * boot_define_meth_argument :
2379  *
2380  * returns : NO_ERROR if all OK, ER_ status otherwise
2381  *
2382  * class(IN) :
2383  */
2384 static int
2386 {
2387  SM_TEMPLATE *def;
2388  char domain_string[32];
2389  int error_code = NO_ERROR;
2390  const char *index_col_names[2] = { "meth_sig_of", NULL };
2391 
2392  def = smt_edit_class_mop (class_mop, AU_ALTER);
2393 
2394  error_code = smt_add_attribute (def, "meth_sig_of", CT_METHSIG_NAME, NULL);
2395  if (error_code != NO_ERROR)
2396  {
2397  return error_code;
2398  }
2399 
2400  error_code = smt_add_attribute (def, "data_type", "integer", NULL);
2401  if (error_code != NO_ERROR)
2402  {
2403  return error_code;
2404  }
2405 
2406  error_code = smt_add_attribute (def, "index_of", "integer", NULL);
2407  if (error_code != NO_ERROR)
2408  {
2409  return error_code;
2410  }
2411 
2412  sprintf (domain_string, "sequence of %s", CT_DOMAIN_NAME);
2413 
2414  error_code = smt_add_attribute (def, "domains", domain_string, NULL);
2415  if (error_code != NO_ERROR)
2416  {
2417  return error_code;
2418  }
2419 
2420  error_code = sm_update_class (def, NULL);
2421  if (error_code != NO_ERROR)
2422  {
2423  return error_code;
2424  }
2425 
2426  /* add index */
2427  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, index_col_names, 0);
2428  if (error_code != NO_ERROR)
2429  {
2430  return error_code;
2431  }
2432 
2433  if (locator_has_heap (class_mop) == NULL)
2434  {
2435  assert (er_errid () != NO_ERROR);
2436  return er_errid ();
2437  }
2438 
2439  error_code = au_change_owner (class_mop, Au_dba_user);
2440  if (error_code != NO_ERROR)
2441  {
2442  return error_code;
2443  }
2444 
2445  return NO_ERROR;
2446 }
2447 
2448 /*
2449  * boot_define_meth_file :
2450  *
2451  * returns : NO_ERROR if all OK, ER_ status otherwise
2452  *
2453  * class(IN) :
2454  */
2455 static int
2457 {
2458  SM_TEMPLATE *def;
2459  int error_code = NO_ERROR;
2460  const char *index_col_names[2] = { "class_of", NULL };
2461 
2462  def = smt_edit_class_mop (class_mop, AU_ALTER);
2463 
2464  error_code = smt_add_attribute (def, "class_of", CT_CLASS_NAME, NULL);
2465  if (error_code != NO_ERROR)
2466  {
2467  return error_code;
2468  }
2469 
2470  error_code = smt_add_attribute (def, "from_class_of", CT_CLASS_NAME, NULL);
2471  if (error_code != NO_ERROR)
2472  {
2473  return error_code;
2474  }
2475 
2476  error_code = smt_add_attribute (def, "path_name", "varchar(255)", NULL);
2477  if (error_code != NO_ERROR)
2478  {
2479  return error_code;
2480  }
2481 
2482  error_code = sm_update_class (def, NULL);
2483  if (error_code != NO_ERROR)
2484  {
2485  return error_code;
2486  }
2487 
2488  /* add index */
2489  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, index_col_names, 0);
2490  if (error_code != NO_ERROR)
2491  {
2492  return error_code;
2493  }
2494 
2495  if (locator_has_heap (class_mop) == NULL)
2496  {
2497  assert (er_errid () != NO_ERROR);
2498  return er_errid ();
2499  }
2500 
2501  error_code = au_change_owner (class_mop, Au_dba_user);
2502  if (error_code != NO_ERROR)
2503  {
2504  return error_code;
2505  }
2506 
2507  return NO_ERROR;
2508 }
2509 
2510 /*
2511  * boot_define_query_spec :
2512  *
2513  * returns : NO_ERROR if all OK, ER_ status otherwise
2514  *
2515  * class(IN) :
2516  */
2517 static int
2519 {
2520  SM_TEMPLATE *def;
2521  int error_code = NO_ERROR;
2522  const char *index_col_names[2] = { "class_of", NULL };
2523 
2524  def = smt_edit_class_mop (class_mop, AU_ALTER);
2525 
2526  error_code = smt_add_attribute (def, "class_of", CT_CLASS_NAME, NULL);
2527  if (error_code != NO_ERROR)
2528  {
2529  return error_code;
2530  }
2531 
2532  error_code = smt_add_attribute (def, "spec", "varchar(1073741823)", NULL);
2533  if (error_code != NO_ERROR)
2534  {
2535  return error_code;
2536  }
2537 
2538  error_code = sm_update_class (def, NULL);
2539  if (error_code != NO_ERROR)
2540  {
2541  return error_code;
2542  }
2543 
2544  /* add index */
2545  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, index_col_names, 0);
2546  if (error_code != NO_ERROR)
2547  {
2548  return error_code;
2549  }
2550 
2551  if (locator_has_heap (class_mop) == NULL)
2552  {
2553  assert (er_errid () != NO_ERROR);
2554  return er_errid ();
2555  }
2556 
2557  error_code = au_change_owner (class_mop, Au_dba_user);
2558  if (error_code != NO_ERROR)
2559  {
2560  return error_code;
2561  }
2562 
2563  return NO_ERROR;
2564 }
2565 
2566 /*
2567  * boot_define_index :
2568  *
2569  * returns : NO_ERROR if all OK, ER_ status otherwise
2570  *
2571  * class(IN) :
2572  */
2573 static int
2575 {
2576  SM_TEMPLATE *def;
2577  char domain_string[32];
2578  int error_code = NO_ERROR;
2579  const char *index_col_names[2] = { "class_of", NULL };
2580 
2581  def = smt_edit_class_mop (class_mop, AU_ALTER);
2582 
2583  error_code = smt_add_attribute (def, "class_of", CT_CLASS_NAME, NULL);
2584  if (error_code != NO_ERROR)
2585  {
2586  return error_code;
2587  }
2588 
2589  error_code = smt_add_attribute (def, "index_name", "varchar(255)", NULL);
2590  if (error_code != NO_ERROR)
2591  {
2592  return error_code;
2593  }
2594 
2595  error_code = smt_add_attribute (def, "is_unique", "integer", NULL);
2596  if (error_code != NO_ERROR)
2597  {
2598  return error_code;
2599  }
2600 
2601  error_code = smt_add_attribute (def, "key_count", "integer", NULL);
2602  if (error_code != NO_ERROR)
2603  {
2604  return error_code;
2605  }
2606 
2607  sprintf (domain_string, "sequence of %s", CT_INDEXKEY_NAME);
2608 
2609  error_code = smt_add_attribute (def, "key_attrs", domain_string, NULL);
2610  if (error_code != NO_ERROR)
2611  {
2612  return error_code;
2613  }
2614 
2615  error_code = smt_add_attribute (def, "is_reverse", "integer", NULL);
2616  if (error_code != NO_ERROR)
2617  {
2618  return error_code;
2619  }
2620 
2621  error_code = smt_add_attribute (def, "is_primary_key", "integer", NULL);
2622  if (error_code != NO_ERROR)
2623  {
2624  return error_code;
2625  }
2626 
2627  error_code = smt_add_attribute (def, "is_foreign_key", "integer", NULL);
2628  if (error_code != NO_ERROR)
2629  {
2630  return error_code;
2631  }
2632 
2633  error_code = smt_add_attribute (def, "filter_expression", "varchar(255)", NULL);
2634  if (error_code != NO_ERROR)
2635  {
2636  return error_code;
2637  }
2638 
2639  error_code = smt_add_attribute (def, "have_function", "integer", NULL);
2640  if (error_code != NO_ERROR)
2641  {
2642  return error_code;
2643  }
2644 
2645  error_code = smt_add_attribute (def, "comment", "varchar(1024)", NULL);
2646  if (error_code != NO_ERROR)
2647  {
2648  return error_code;
2649  }
2650 
2651  error_code = smt_add_attribute (def, "status", "integer", NULL);
2652  if (error_code != NO_ERROR)
2653  {
2654  return error_code;
2655  }
2656 
2657  error_code = sm_update_class (def, NULL);
2658  if (error_code != NO_ERROR)
2659  {
2660  return error_code;
2661  }
2662 
2663  /* add index */
2664  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, index_col_names, 0);
2665  if (error_code != NO_ERROR)
2666  {
2667  return error_code;
2668  }
2669 
2670  if (locator_has_heap (class_mop) == NULL)
2671  {
2672  assert (er_errid () != NO_ERROR);
2673  return er_errid ();
2674  }
2675 
2676  error_code = au_change_owner (class_mop, Au_dba_user);
2677  if (error_code != NO_ERROR)
2678  {
2679  return error_code;
2680  }
2681 
2682  return NO_ERROR;
2683 }
2684 
2685 /*
2686  * boot_define_meth_argument :
2687  *
2688  * returns : NO_ERROR if all OK, ER_ status otherwise
2689  *
2690  * class(IN) :
2691  */
2692 static int
2694 {
2695  SM_TEMPLATE *def;
2696  DB_VALUE prefix_default;
2697  int error_code = NO_ERROR;
2698  const char *index_col_names[2] = { "index_of", NULL };
2699 
2700  def = smt_edit_class_mop (class_mop, AU_ALTER);
2701  if (def == NULL)
2702  {
2703  assert (er_errid () != NO_ERROR);
2704  return er_errid ();
2705  }
2706 
2707  error_code = smt_add_attribute (def, "index_of", CT_INDEX_NAME, NULL);
2708  if (error_code != NO_ERROR)
2709  {
2710  return error_code;
2711  }
2712 
2713  error_code = smt_add_attribute (def, "key_attr_name", "varchar(255)", NULL);
2714  if (error_code != NO_ERROR)
2715  {
2716  return error_code;
2717  }
2718 
2719  error_code = smt_add_attribute (def, "key_order", "integer", NULL);
2720  if (error_code != NO_ERROR)
2721  {
2722  return error_code;
2723  }
2724 
2725  error_code = smt_add_attribute (def, "asc_desc", "integer", NULL);
2726  if (error_code != NO_ERROR)
2727  {
2728  return error_code;
2729  }
2730 
2731  error_code = smt_add_attribute (def, "key_prefix_length", "integer", NULL);
2732  if (error_code != NO_ERROR)
2733  {
2734  return error_code;
2735  }
2736 
2737  db_make_int (&prefix_default, -1);
2738 
2739  error_code = smt_set_attribute_default (def, "key_prefix_length", 0, &prefix_default, NULL);
2740  if (error_code != NO_ERROR)
2741  {
2742  return error_code;
2743  }
2744 
2745  error_code = smt_add_attribute (def, "func", "varchar(255)", NULL);
2746  if (error_code != NO_ERROR)
2747  {
2748  return error_code;
2749  }
2750 
2751  error_code = sm_update_class (def, NULL);
2752  if (error_code != NO_ERROR)
2753  {
2754  return error_code;
2755  }
2756 
2757  /* add index */
2758  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, index_col_names, 0);
2759  if (error_code != NO_ERROR)
2760  {
2761  return error_code;
2762  }
2763 
2764  if (locator_has_heap (class_mop) == NULL)
2765  {
2766  return error_code;
2767  }
2768 
2769  error_code = au_change_owner (class_mop, Au_dba_user);
2770  if (error_code != NO_ERROR)
2771  {
2772  return error_code;
2773  }
2774 
2775  return NO_ERROR;
2776 }
2777 
2778 /*
2779  * boot_define_class_authorization :
2780  *
2781  * returns : NO_ERROR if all OK, ER_ status otherwise
2782  *
2783  * class(IN) :
2784  */
2785 static int
2787 {
2788  SM_TEMPLATE *def;
2789  int error_code = NO_ERROR;
2790  const char *index_col_names[2] = { "grantee", NULL };
2791 
2792  def = smt_edit_class_mop (class_mop, AU_ALTER);
2793 
2794  error_code = smt_add_attribute (def, "grantor", AU_USER_CLASS_NAME, NULL);
2795  if (error_code != NO_ERROR)
2796  {
2797  return error_code;
2798  }
2799 
2800  error_code = smt_add_attribute (def, "grantee", AU_USER_CLASS_NAME, NULL);
2801  if (error_code != NO_ERROR)
2802  {
2803  return error_code;
2804  }
2805 
2806  error_code = smt_add_attribute (def, "class_of", CT_CLASS_NAME, NULL);
2807  if (error_code != NO_ERROR)
2808  {
2809  return error_code;
2810  }
2811 
2812  error_code = smt_add_attribute (def, "auth_type", "varchar(7)", NULL);
2813  if (error_code != NO_ERROR)
2814  {
2815  return error_code;
2816  }
2817 
2818  error_code = smt_add_attribute (def, "is_grantable", "integer", NULL);
2819  if (error_code != NO_ERROR)
2820  {
2821  return error_code;
2822  }
2823 
2824  error_code = sm_update_class (def, NULL);
2825  if (error_code != NO_ERROR)
2826  {
2827  return error_code;
2828  }
2829 
2830  /* add index */
2831  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, index_col_names, 0);
2832  if (error_code != NO_ERROR)
2833  {
2834  return error_code;
2835  }
2836 
2837  if (locator_has_heap (class_mop) == NULL)
2838  {
2839  assert (er_errid () != NO_ERROR);
2840  return er_errid ();
2841  }
2842 
2843  error_code = au_change_owner (class_mop, Au_dba_user);
2844  if (error_code != NO_ERROR)
2845  {
2846  return error_code;
2847  }
2848 
2849  return NO_ERROR;
2850 }
2851 
2852 /*
2853  * boot_define_partition :
2854  *
2855  * returns : NO_ERROR if all OK, ER_ status otherwise
2856  *
2857  * class(IN) :
2858  */
2859 static int
2861 {
2862  SM_TEMPLATE *def;
2863  int error_code = NO_ERROR;
2864  const char *index_col_names[] = { "class_of", "pname", NULL };
2865 
2866  def = smt_edit_class_mop (class_mop, AU_ALTER);
2867 
2868  error_code = smt_add_attribute (def, "class_of", CT_CLASS_NAME, NULL);
2869  if (error_code != NO_ERROR)
2870  {
2871  return error_code;
2872  }
2873 
2874  error_code = smt_add_attribute (def, "pname", "varchar(255)", NULL);
2875  if (error_code != NO_ERROR)
2876  {
2877  return error_code;
2878  }
2879 
2880  error_code = smt_add_attribute (def, "ptype", "integer", NULL);
2881  if (error_code != NO_ERROR)
2882  {
2883  return error_code;
2884  }
2885 
2886  error_code = smt_add_attribute (def, "pexpr", "varchar(2048)", NULL);
2887  if (error_code != NO_ERROR)
2888  {
2889  return error_code;
2890  }
2891 
2892  error_code = smt_add_attribute (def, "pvalues", "sequence of", NULL);
2893  if (error_code != NO_ERROR)
2894  {
2895  return error_code;
2896  }
2897 
2898  error_code = smt_add_attribute (def, "comment", "varchar(1024)", NULL);
2899  if (error_code != NO_ERROR)
2900  {
2901  return error_code;
2902  }
2903 
2904  error_code = sm_update_class (def, NULL);
2905  if (error_code != NO_ERROR)
2906  {
2907  return error_code;
2908  }
2909 
2910  /* add index */
2911  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, index_col_names, 0);
2912  if (error_code != NO_ERROR)
2913  {
2914  return error_code;
2915  }
2916 
2917  if (locator_has_heap (class_mop) == NULL)
2918  {
2919  assert (er_errid () != NO_ERROR);
2920  return er_errid ();
2921  }
2922 
2923  error_code = au_change_owner (class_mop, Au_dba_user);
2924  if (error_code != NO_ERROR)
2925  {
2926  return error_code;
2927  }
2928 
2929  return NO_ERROR;
2930 }
2931 
2932 /*
2933  * boot_add_data_type :
2934  *
2935  * returns : NO_ERROR if all OK, ER_ status otherwise
2936  *
2937  * class(IN) :
2938  *
2939  * Note:
2940  *
2941  */
2942 static int
2944 {
2945  DB_OBJECT *obj;
2946  DB_VALUE val;
2947  int i;
2948 
2949  const char *names[DB_TYPE_LAST] = {
2950  "INTEGER", "FLOAT", "DOUBLE", "STRING", "OBJECT",
2951  "SET", "MULTISET", "SEQUENCE", "ELO", "TIME",
2952  "TIMESTAMP", "DATE", "MONETARY", NULL /* VARIABLE */ , NULL /* SUB */ ,
2953  NULL /* POINTER */ , NULL /* ERROR */ , "SHORT", NULL /* VOBJ */ ,
2954  NULL /* OID */ ,
2955  NULL /* VALUE */ , "NUMERIC", "BIT", "VARBIT", "CHAR",
2956  "NCHAR", "VARNCHAR", NULL /* RESULTSET */ , NULL /* MIDXKEY */ ,
2957  NULL /* TABLE */ ,
2958  "BIGINT", "DATETIME",
2959  "BLOB", "CLOB", "ENUM",
2960  "TIMESTAMPTZ", "TIMESTAMPLTZ", "DATETIMETZ", "DATETIMELTZ",
2961  "JSON"
2962  };
2963 
2964  for (i = 0; i < DB_TYPE_LAST; i++)
2965  {
2966 
2967  if (names[i] != NULL)
2968  {
2969  obj = db_create_internal (class_mop);
2970  if (obj == NULL)
2971  {
2972  assert (er_errid () != NO_ERROR);
2973  return er_errid ();
2974  }
2975 
2976  db_make_int (&val, i + 1);
2977  db_put_internal (obj, "type_id", &val);
2978 
2979  db_make_varchar (&val, 16, names[i], strlen (names[i]), LANG_SYS_CODESET, LANG_SYS_COLLATION);
2980  db_put_internal (obj, "type_name", &val);
2981  }
2982  }
2983 
2984  return NO_ERROR;
2985 }
2986 
2987 /*
2988  * boot_define_data_type :
2989  *
2990  * returns : NO_ERROR if all OK, ER_ status otherwise
2991  *
2992  * class(IN) :
2993  */
2994 static int
2996 {
2997  SM_TEMPLATE *def;
2998  int error_code = NO_ERROR;
2999 
3000  def = smt_edit_class_mop (class_mop, AU_ALTER);
3001 
3002  error_code = smt_add_attribute (def, "type_id", "integer", NULL);
3003  if (error_code != NO_ERROR)
3004  {
3005  return error_code;
3006  }
3007 
3008  /* TODO : DB migration tool */
3009  error_code = smt_add_attribute (def, "type_name", "varchar(16)", NULL);
3010  if (error_code != NO_ERROR)
3011  {
3012  return error_code;
3013  }
3014 
3015  error_code = sm_update_class (def, NULL);
3016  if (error_code != NO_ERROR)
3017  {
3018  return error_code;
3019  }
3020 
3021  if (locator_has_heap (class_mop) == NULL)
3022  {
3023  assert (er_errid () != NO_ERROR);
3024  return er_errid ();
3025  }
3026 
3027  error_code = au_change_owner (class_mop, Au_dba_user);
3028  if (error_code != NO_ERROR)
3029  {
3030  return error_code;
3031  }
3032 
3033  error_code = boot_add_data_type (class_mop);
3034  if (error_code != NO_ERROR)
3035  {
3036  return error_code;
3037  }
3038 
3039  return NO_ERROR;
3040 }
3041 
3042 /*
3043  * boot_define_stored_procedure :
3044  *
3045  * returns : NO_ERROR if all OK, ER_ status otherwise
3046  *
3047  * class(IN) :
3048  */
3049 static int
3051 {
3052  SM_TEMPLATE *def;
3053  char args_string[64];
3054  int error_code = NO_ERROR;
3055  const char *index_col_names[2] = { "sp_name", NULL };
3056 
3057  def = smt_edit_class_mop (class_mop, AU_ALTER);
3058 
3059  error_code = smt_add_attribute (def, "sp_name", "varchar(255)", NULL);
3060  if (error_code != NO_ERROR)
3061  {
3062  return error_code;
3063  }
3064 
3065  error_code = smt_add_attribute (def, "sp_type", "integer", NULL);
3066  if (error_code != NO_ERROR)
3067  {
3068  return error_code;
3069  }
3070 
3071  error_code = smt_add_attribute (def, "return_type", "integer", NULL);
3072  if (error_code != NO_ERROR)
3073  {
3074  return error_code;
3075  }
3076 
3077  error_code = smt_add_attribute (def, "arg_count", "integer", NULL);
3078  if (error_code != NO_ERROR)
3079  {
3080  return error_code;
3081  }
3082 
3083  sprintf (args_string, "sequence of %s", CT_STORED_PROC_ARGS_NAME);
3084  error_code = smt_add_attribute (def, "args", args_string, NULL);
3085  if (error_code != NO_ERROR)
3086  {
3087  return error_code;
3088  }
3089 
3090  error_code = smt_add_attribute (def, "lang", "integer", NULL);
3091  if (error_code != NO_ERROR)
3092  {
3093  return error_code;
3094  }
3095 
3096  error_code = smt_add_attribute (def, "target", "varchar(4096)", NULL);
3097  if (error_code != NO_ERROR)
3098  {
3099  return error_code;
3100  }
3101 
3102  error_code = smt_add_attribute (def, "owner", AU_USER_CLASS_NAME, NULL);
3103  if (error_code != NO_ERROR)
3104  {
3105  return error_code;
3106  }
3107 
3108  error_code = smt_add_attribute (def, "comment", "varchar(1024)", NULL);
3109  if (error_code != NO_ERROR)
3110  {
3111  return error_code;
3112  }
3113 
3114  error_code = sm_update_class (def, NULL);
3115  if (error_code != NO_ERROR)
3116  {
3117  return error_code;
3118  }
3119 
3120  /* add index */
3121  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_UNIQUE, NULL, index_col_names, 0);
3122  if (error_code != NO_ERROR)
3123  {
3124  return error_code;
3125  }
3126 
3127  if (locator_has_heap (class_mop) == NULL)
3128  {
3129  assert (er_errid () != NO_ERROR);
3130  return er_errid ();
3131  }
3132 
3133  error_code = au_change_owner (class_mop, Au_dba_user);
3134  if (error_code != NO_ERROR)
3135  {
3136  return error_code;
3137  }
3138 
3139  return NO_ERROR;
3140 }
3141 
3142 /*
3143  * boot_define_stored_procedure_arguments :
3144  *
3145  * returns : NO_ERROR if all OK, ER_ status otherwise
3146  *
3147  * class(IN) :
3148  */
3149 static int
3151 {
3152  SM_TEMPLATE *def;
3153  int error_code = NO_ERROR;
3154  const char *index_col_names[2] = { "sp_name", NULL };
3155 
3156  def = smt_edit_class_mop (class_mop, AU_ALTER);
3157 
3158  error_code = smt_add_attribute (def, "sp_name", "varchar(255)", NULL);
3159  if (error_code != NO_ERROR)
3160  {
3161  return error_code;
3162  }
3163 
3164  error_code = smt_add_attribute (def, "index_of", "integer", NULL);
3165  if (error_code != NO_ERROR)
3166  {
3167  return error_code;
3168  }
3169 
3170  error_code = smt_add_attribute (def, "arg_name", "varchar(255)", NULL);
3171  if (error_code != NO_ERROR)
3172  {
3173  return error_code;
3174  }
3175 
3176  error_code = smt_add_attribute (def, "data_type", "integer", NULL);
3177  if (error_code != NO_ERROR)
3178  {
3179  return error_code;
3180  }
3181 
3182  error_code = smt_add_attribute (def, "mode", "integer", NULL);
3183  if (error_code != NO_ERROR)
3184  {
3185  return error_code;
3186  }
3187 
3188  error_code = smt_add_attribute (def, "comment", "varchar(1024)", NULL);
3189  if (error_code != NO_ERROR)
3190  {
3191  return error_code;
3192  }
3193 
3194  error_code = sm_update_class (def, NULL);
3195  if (error_code != NO_ERROR)
3196  {
3197  return error_code;
3198  }
3199 
3200  /* add index */
3201  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_INDEX, NULL, index_col_names, 0);
3202  if (error_code != NO_ERROR)
3203  {
3204  return error_code;
3205  }
3206 
3207  if (locator_has_heap (class_mop) == NULL)
3208  {
3209  assert (er_errid () != NO_ERROR);
3210  return er_errid ();
3211  }
3212 
3213  error_code = au_change_owner (class_mop, Au_dba_user);
3214  if (error_code != NO_ERROR)
3215  {
3216  return error_code;
3217  }
3218 
3219  return NO_ERROR;
3220 }
3221 
3222 /*
3223  * boot_define_serial :
3224  *
3225  * returns : NO_ERROR if all OK, ER_ status otherwise
3226  *
3227  * class(IN) :
3228  */
3229 static int
3231 {
3232  SM_TEMPLATE *def;
3233  char domain_string[32];
3234  unsigned char num[DB_NUMERIC_BUF_SIZE]; /* Copy of a DB_C_NUMERIC */
3236  int error_code = NO_ERROR;
3237  const char *index_col_names[] = { "name", NULL };
3238 
3239  def = smt_edit_class_mop (class_mop, AU_ALTER);
3240 
3241  error_code = smt_add_attribute (def, "name", "string", NULL);
3242  if (error_code != NO_ERROR)
3243  {
3244  return error_code;
3245  }
3246 
3247  error_code = smt_add_attribute (def, "owner", AU_USER_CLASS_NAME, NULL);
3248  if (error_code != NO_ERROR)
3249  {
3250  return error_code;
3251  }
3252 
3253  sprintf (domain_string, "numeric(%d,0)", DB_MAX_NUMERIC_PRECISION);
3254  numeric_coerce_int_to_num (1, num);
3255  db_make_numeric (&default_value, num, DB_MAX_NUMERIC_PRECISION, 0);
3256 
3257  error_code = smt_add_attribute (def, "current_val", domain_string, NULL);
3258  if (error_code != NO_ERROR)
3259  {
3260  return error_code;
3261  }
3262  error_code = smt_set_attribute_default (def, "current_val", 0, &default_value, NULL);
3263  if (error_code != NO_ERROR)
3264  {
3265  return error_code;
3266  }
3267 
3268  error_code = smt_add_attribute (def, "increment_val", domain_string, NULL);
3269  if (error_code != NO_ERROR)
3270  {
3271  return error_code;
3272  }
3273  error_code = smt_set_attribute_default (def, "increment_val", 0, &default_value, NULL);
3274  if (error_code != NO_ERROR)
3275  {
3276  return error_code;
3277  }
3278 
3279  error_code = smt_add_attribute (def, "max_val", domain_string, NULL);
3280  if (error_code != NO_ERROR)
3281  {
3282  return error_code;
3283  }
3284 
3285  error_code = smt_add_attribute (def, "min_val", domain_string, NULL);
3286  if (error_code != NO_ERROR)
3287  {
3288  return error_code;
3289  }
3290 
3291  db_make_int (&default_value, 0);
3292 
3293  error_code = smt_add_attribute (def, "cyclic", "integer", NULL);
3294  if (error_code != NO_ERROR)
3295  {
3296  return error_code;
3297  }
3298  error_code = smt_set_attribute_default (def, "cyclic", 0, &default_value, NULL);
3299  if (error_code != NO_ERROR)
3300  {
3301  return error_code;
3302  }
3303 
3304  error_code = smt_add_attribute (def, "started", "integer", NULL);
3305  if (error_code != NO_ERROR)
3306  {
3307  return error_code;
3308  }
3309  error_code = smt_set_attribute_default (def, "started", 0, &default_value, NULL);
3310  if (error_code != NO_ERROR)
3311  {
3312  return error_code;
3313  }
3314 
3315  error_code = smt_add_attribute (def, "class_name", "string", NULL);
3316  if (error_code != NO_ERROR)
3317  {
3318  return error_code;
3319  }
3320 
3321  error_code = smt_add_attribute (def, "att_name", "string", NULL);
3322  if (error_code != NO_ERROR)
3323  {
3324  return error_code;
3325  }
3326 
3327  error_code = smt_add_class_method (def, "change_serial_owner", "au_change_serial_owner_method");
3328  if (error_code != NO_ERROR)
3329  {
3330  return error_code;
3331  }
3332 
3333  error_code = smt_add_attribute (def, "cached_num", "integer", NULL);
3334  if (error_code != NO_ERROR)
3335  {
3336  return error_code;
3337  }
3338  error_code = smt_set_attribute_default (def, "cached_num", 0, &default_value, NULL);
3339  if (error_code != NO_ERROR)
3340  {
3341  return error_code;
3342  }
3343 
3344  error_code = smt_add_attribute (def, "comment", "varchar(1024)", NULL);
3345  if (error_code != NO_ERROR)
3346  {
3347  return error_code;
3348  }
3349 
3350  error_code = sm_update_class (def, NULL);
3351  if (error_code != NO_ERROR)
3352  {
3353  return error_code;
3354  }
3355 
3356  /* add index */
3357  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_PRIMARY_KEY, NULL, index_col_names, 0);
3358  if (error_code != NO_ERROR)
3359  {
3360  return error_code;
3361  }
3362 
3363  error_code = db_constrain_non_null (class_mop, "current_val", 0, 1);
3364  if (error_code != NO_ERROR)
3365  {
3366  return error_code;
3367  }
3368 
3369  error_code = db_constrain_non_null (class_mop, "increment_val", 0, 1);
3370  if (error_code != NO_ERROR)
3371  {
3372  return error_code;
3373  }
3374 
3375  error_code = db_constrain_non_null (class_mop, "max_val", 0, 1);
3376  if (error_code != NO_ERROR)
3377  {
3378  return error_code;
3379  }
3380 
3381  error_code = db_constrain_non_null (class_mop, "min_val", 0, 1);
3382  if (error_code != NO_ERROR)
3383  {
3384  return error_code;
3385  }
3386 
3387  if (locator_has_heap (class_mop) == NULL)
3388  {
3389  assert (er_errid () != NO_ERROR);
3390  return er_errid ();
3391  }
3392 
3393  error_code = au_change_owner (class_mop, Au_dba_user);
3394  if (error_code != NO_ERROR)
3395  {
3396  return error_code;
3397  }
3398 
3399  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
3400  if (error_code != NO_ERROR)
3401  {
3402  return error_code;
3403  }
3404 
3405  return NO_ERROR;
3406 }
3407 
3408 /*
3409  * boot_define_ha_apply_info :
3410  *
3411  * returns : NO_ERROR if all OK, ER_ status otherwise
3412  *
3413  * class(IN) :
3414  */
3415 static int
3417 {
3418  SM_TEMPLATE *def;
3419  int error_code = NO_ERROR;
3420  const char *index_col_names[] = { "db_name", "copied_log_path", NULL };
3421 
3422  def = smt_edit_class_mop (class_mop, AU_ALTER);
3423 
3424  error_code = smt_add_attribute (def, "db_name", "varchar(255)", NULL);
3425  if (error_code != NO_ERROR)
3426  {
3427  return error_code;
3428  }
3429 
3430  error_code = smt_add_attribute (def, "db_creation_time", "datetime", NULL);
3431  if (error_code != NO_ERROR)
3432  {
3433  return error_code;
3434  }
3435 
3436  error_code = smt_add_attribute (def, "copied_log_path", "varchar(4096)", NULL);
3437  if (error_code != NO_ERROR)
3438  {
3439  return error_code;
3440  }
3441 
3442  error_code = smt_add_attribute (def, "committed_lsa_pageid", "bigint", NULL);
3443  if (error_code != NO_ERROR)
3444  {
3445  return error_code;
3446  }
3447 
3448  error_code = smt_add_attribute (def, "committed_lsa_offset", "integer", NULL);
3449  if (error_code != NO_ERROR)
3450  {
3451  return error_code;
3452  }
3453 
3454  error_code = smt_add_attribute (def, "committed_rep_pageid", "bigint", NULL);
3455  if (error_code != NO_ERROR)
3456  {
3457  return error_code;
3458  }
3459 
3460  error_code = smt_add_attribute (def, "committed_rep_offset", "integer", NULL);
3461  if (error_code != NO_ERROR)
3462  {
3463  return error_code;
3464  }
3465 
3466  error_code = smt_add_attribute (def, "append_lsa_pageid", "bigint", NULL);
3467  if (error_code != NO_ERROR)
3468  {
3469  return error_code;
3470  }
3471 
3472  error_code = smt_add_attribute (def, "append_lsa_offset", "integer", NULL);
3473  if (error_code != NO_ERROR)
3474  {
3475  return error_code;
3476  }
3477 
3478  error_code = smt_add_attribute (def, "eof_lsa_pageid", "bigint", NULL);
3479  if (error_code != NO_ERROR)
3480  {
3481  return error_code;
3482  }
3483 
3484  error_code = smt_add_attribute (def, "eof_lsa_offset", "integer", NULL);
3485  if (error_code != NO_ERROR)
3486  {
3487  return error_code;
3488  }
3489 
3490  error_code = smt_add_attribute (def, "final_lsa_pageid", "bigint", NULL);
3491  if (error_code != NO_ERROR)
3492  {
3493  return error_code;
3494  }
3495 
3496  error_code = smt_add_attribute (def, "final_lsa_offset", "integer", NULL);
3497  if (error_code != NO_ERROR)
3498  {
3499  return error_code;
3500  }
3501 
3502  error_code = smt_add_attribute (def, "required_lsa_pageid", "bigint", NULL);
3503  if (error_code != NO_ERROR)
3504  {
3505  return error_code;
3506  }
3507 
3508  error_code = smt_add_attribute (def, "required_lsa_offset", "integer", NULL);
3509  if (error_code != NO_ERROR)
3510  {
3511  return error_code;
3512  }
3513 
3514  error_code = smt_add_attribute (def, "log_record_time", "datetime", NULL);
3515  if (error_code != NO_ERROR)
3516  {
3517  return error_code;
3518  }
3519 
3520  error_code = smt_add_attribute (def, "log_commit_time", "datetime", NULL);
3521  if (error_code != NO_ERROR)
3522  {
3523  return error_code;
3524  }
3525 
3526  error_code = smt_add_attribute (def, "last_access_time", "datetime", NULL);
3527  if (error_code != NO_ERROR)
3528  {
3529  return error_code;
3530  }
3531 
3532  error_code = smt_add_attribute (def, "status", "integer", NULL);
3533  if (error_code != NO_ERROR)
3534  {
3535  return error_code;
3536  }
3537 
3538  error_code = smt_add_attribute (def, "insert_counter", "bigint", NULL);
3539  if (error_code != NO_ERROR)
3540  {
3541  return error_code;
3542  }
3543 
3544  error_code = smt_add_attribute (def, "update_counter", "bigint", NULL);
3545  if (error_code != NO_ERROR)
3546  {
3547  return error_code;
3548  }
3549 
3550  error_code = smt_add_attribute (def, "delete_counter", "bigint", NULL);
3551  if (error_code != NO_ERROR)
3552  {
3553  return error_code;
3554  }
3555 
3556  error_code = smt_add_attribute (def, "schema_counter", "bigint", NULL);
3557  if (error_code != NO_ERROR)
3558  {
3559  return error_code;
3560  }
3561 
3562  error_code = smt_add_attribute (def, "commit_counter", "bigint", NULL);
3563  if (error_code != NO_ERROR)
3564  {
3565  return error_code;
3566  }
3567 
3568  error_code = smt_add_attribute (def, "fail_counter", "bigint", NULL);
3569  if (error_code != NO_ERROR)
3570  {
3571  return error_code;
3572  }
3573 
3574  error_code = smt_add_attribute (def, "start_time", "datetime", NULL);
3575  if (error_code != NO_ERROR)
3576  {
3577  return error_code;
3578  }
3579 
3580  error_code = sm_update_class (def, NULL);
3581  if (error_code != NO_ERROR)
3582  {
3583  return error_code;
3584  }
3585 
3586  /* add constraints */
3587  error_code = db_add_constraint (class_mop, DB_CONSTRAINT_UNIQUE, NULL, index_col_names, 0);
3588  if (error_code != NO_ERROR)
3589  {
3590  return error_code;
3591  }
3592 
3593  error_code = db_constrain_non_null (class_mop, "db_name", 0, 1);
3594  if (error_code != NO_ERROR)
3595  {
3596  return error_code;
3597  }
3598 
3599  error_code = db_constrain_non_null (class_mop, "copied_log_path", 0, 1);
3600  if (error_code != NO_ERROR)
3601  {
3602  return error_code;
3603  }
3604 
3605  error_code = db_constrain_non_null (class_mop, "committed_lsa_pageid", 0, 1);
3606  if (error_code != NO_ERROR)
3607  {
3608  return error_code;
3609  }
3610 
3611  error_code = db_constrain_non_null (class_mop, "committed_lsa_offset", 0, 1);
3612  if (error_code != NO_ERROR)
3613  {
3614  return error_code;
3615  }
3616 
3617  error_code = db_constrain_non_null (class_mop, "required_lsa_pageid", 0, 1);
3618  if (error_code != NO_ERROR)
3619  {
3620  return error_code;
3621  }
3622 
3623  error_code = db_constrain_non_null (class_mop, "required_lsa_offset", 0, 1);
3624  if (error_code != NO_ERROR)
3625  {
3626  return error_code;
3627  }
3628 
3629  if (locator_has_heap (class_mop) == NULL)
3630  {
3631  assert (er_errid () != NO_ERROR);
3632  return er_errid ();
3633  }
3634 
3635  error_code = au_change_owner (class_mop, Au_dba_user);
3636  if (error_code != NO_ERROR)
3637  {
3638  return error_code;
3639  }
3640 
3641  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
3642  if (error_code != NO_ERROR)
3643  {
3644  return error_code;
3645  }
3646 
3647  return NO_ERROR;
3648 }
3649 
3650 /*
3651  * boot_add_collations :
3652  *
3653  * returns : NO_ERROR if all OK, ER_ status otherwise
3654  *
3655  * class(IN) :
3656  *
3657  * Note:
3658  *
3659  */
3660 int
3662 {
3663  int i;
3664  int count_collations;
3665  int found_coll = 0;
3666 
3667  count_collations = lang_collation_count ();
3668 
3669  for (i = 0; i < LANG_MAX_COLLATIONS; i++)
3670  {
3671  LANG_COLLATION *lang_coll = lang_get_collation (i);
3672  DB_OBJECT *obj;
3673  DB_VALUE val;
3674 
3675  assert (lang_coll != NULL);
3676 
3677  if (i != 0 && lang_coll->coll.coll_id == LANG_COLL_DEFAULT)
3678  {
3679  /* iso88591 binary collation added only once */
3680  continue;
3681  }
3682  found_coll++;
3683 
3684  obj = db_create_internal (class_mop);
3685  if (obj == NULL)
3686  {
3687  assert (er_errid () != NO_ERROR);
3688  return er_errid ();
3689  }
3690 
3691  assert (lang_coll->coll.coll_id == i);
3692 
3693  db_make_int (&val, i);
3695 
3696  db_make_varchar (&val, 32, lang_coll->coll.coll_name, strlen (lang_coll->coll.coll_name), LANG_SYS_CODESET,
3699 
3700  db_make_int (&val, (int) (lang_coll->codeset));
3702 
3703  db_make_int (&val, lang_coll->built_in);
3705 
3706  db_make_int (&val, lang_coll->coll.uca_opt.sett_expansions ? 1 : 0);
3708 
3709  db_make_int (&val, lang_coll->coll.count_contr);
3711 
3712  db_make_int (&val, (int) (lang_coll->coll.uca_opt.sett_strength));
3714 
3715  assert (strlen (lang_coll->coll.checksum) == 32);
3716  db_make_varchar (&val, 32, lang_coll->coll.checksum, 32, LANG_SYS_CODESET, LANG_SYS_COLLATION);
3718  }
3719 
3720  assert (found_coll == count_collations);
3721 
3722  return NO_ERROR;
3723 }
3724 
3725 /*
3726  * boot_define_collations :
3727  *
3728  * returns : NO_ERROR if all OK, ER_ status otherwise
3729  *
3730  * class(IN) :
3731  */
3732 static int
3734 {
3735  SM_TEMPLATE *def;
3736  int error_code = NO_ERROR;
3737 
3738  def = smt_edit_class_mop (class_mop, AU_ALTER);
3739 
3740  error_code = smt_add_attribute (def, CT_DBCOLL_COLL_ID_COLUMN, "integer", NULL);
3741  if (error_code != NO_ERROR)
3742  {
3743  return error_code;
3744  }
3745 
3746  error_code = smt_add_attribute (def, CT_DBCOLL_COLL_NAME_COLUMN, "varchar(32)", NULL);
3747  if (error_code != NO_ERROR)
3748  {
3749  return error_code;
3750  }
3751 
3752  error_code = smt_add_attribute (def, CT_DBCOLL_CHARSET_ID_COLUMN, "integer", NULL);
3753  if (error_code != NO_ERROR)
3754  {
3755  return error_code;
3756  }
3757 
3758  error_code = smt_add_attribute (def, CT_DBCOLL_BUILT_IN_COLUMN, "integer", NULL);
3759  if (error_code != NO_ERROR)
3760  {
3761  return error_code;
3762  }
3763 
3764  error_code = smt_add_attribute (def, CT_DBCOLL_EXPANSIONS_COLUMN, "integer", NULL);
3765  if (error_code != NO_ERROR)
3766  {
3767  return error_code;
3768  }
3769 
3770  error_code = smt_add_attribute (def, CT_DBCOLL_CONTRACTIONS_COLUMN, "integer", NULL);
3771  if (error_code != NO_ERROR)
3772  {
3773  return error_code;
3774  }
3775 
3776  error_code = smt_add_attribute (def, CT_DBCOLL_UCA_STRENGTH, "integer", NULL);
3777  if (error_code != NO_ERROR)
3778  {
3779  return error_code;
3780  }
3781 
3782  error_code = smt_add_attribute (def, CT_DBCOLL_CHECKSUM_COLUMN, "varchar(32)", NULL);
3783  if (error_code != NO_ERROR)
3784  {
3785  return error_code;
3786  }
3787 
3788  error_code = sm_update_class (def, NULL);
3789  if (error_code != NO_ERROR)
3790  {
3791  return error_code;
3792  }
3793 
3794  if (locator_has_heap (class_mop) == NULL)
3795  {
3796  assert (er_errid () != NO_ERROR);
3797  return er_errid ();
3798  }
3799 
3800  error_code = au_change_owner (class_mop, Au_dba_user);
3801  if (error_code != NO_ERROR)
3802  {
3803  return error_code;
3804  }
3805 
3806  error_code = boot_add_collations (class_mop);
3807  if (error_code != NO_ERROR)
3808  {
3809  return error_code;
3810  }
3811 
3812  return NO_ERROR;
3813 }
3814 
3815 #define CT_DBCHARSET_CHARSET_ID "charset_id"
3816 #define CT_DBCHARSET_CHARSET_NAME "charset_name"
3817 #define CT_DBCHARSET_DEFAULT_COLLATION "default_collation"
3818 #define CT_DBCHARSET_CHAR_SIZE "char_size"
3819 
3820 /*
3821  * boot_add_charsets :
3822  *
3823  * returns : NO_ERROR if all OK, ER_ status otherwise
3824  *
3825  * class(IN) :
3826  *
3827  * Note:
3828  *
3829  */
3830 static int
3832 {
3833  int i;
3834  int count_collations;
3835 
3836  count_collations = lang_collation_count ();
3837 
3838  for (i = INTL_CODESET_BINARY; i <= INTL_CODESET_LAST; i++)
3839  {
3840  DB_OBJECT *obj;
3841  DB_VALUE val;
3842  char *charset_name;
3843 
3844  obj = db_create_internal (class_mop);
3845  if (obj == NULL)
3846  {
3847  assert (er_errid () != NO_ERROR);
3848  return er_errid ();
3849  }
3850 
3851  db_make_int (&val, i);
3853 
3854  charset_name = (char *) lang_charset_cubrid_name ((INTL_CODESET) i);
3855  if (charset_name == NULL)
3856  {
3858  }
3859 
3860  db_make_varchar (&val, 32, charset_name, strlen (charset_name), LANG_SYS_CODESET, LANG_SYS_COLLATION);
3862 
3865 
3866  db_make_int (&val, INTL_CODESET_MULT (i));
3868  }
3869 
3870  return NO_ERROR;
3871 }
3872 
3873 /*
3874  * boot_define_charsets :
3875  *
3876  * returns : NO_ERROR if all OK, ER_ status otherwise
3877  *
3878  * class(IN) :
3879  */
3880 static int
3882 {
3883  SM_TEMPLATE *def;
3884  int error_code = NO_ERROR;
3885 
3886  def = smt_edit_class_mop (class_mop, AU_ALTER);
3887 
3888  error_code = smt_add_attribute (def, CT_DBCHARSET_CHARSET_ID, "integer", NULL);
3889  if (error_code != NO_ERROR)
3890  {
3891  return error_code;
3892  }
3893 
3894  error_code = smt_add_attribute (def, CT_DBCHARSET_CHARSET_NAME, "varchar(32)", NULL);
3895  if (error_code != NO_ERROR)
3896  {
3897  return error_code;
3898  }
3899 
3900  error_code = smt_add_attribute (def, CT_DBCHARSET_DEFAULT_COLLATION, "integer", NULL);
3901  if (error_code != NO_ERROR)
3902  {
3903  return error_code;
3904  }
3905 
3906  error_code = smt_add_attribute (def, CT_DBCHARSET_CHAR_SIZE, "integer", NULL);
3907  if (error_code != NO_ERROR)
3908  {
3909  return error_code;
3910  }
3911 
3912  error_code = sm_update_class (def, NULL);
3913  if (error_code != NO_ERROR)
3914  {
3915  return error_code;
3916  }
3917 
3918  if (locator_has_heap (class_mop) == NULL)
3919  {
3920  assert (er_errid () != NO_ERROR);
3921  return er_errid ();
3922  }
3923 
3924  error_code = au_change_owner (class_mop, Au_dba_user);
3925  if (error_code != NO_ERROR)
3926  {
3927  return error_code;
3928  }
3929 
3930  error_code = boot_add_charsets (class_mop);
3931  if (error_code != NO_ERROR)
3932  {
3933  return error_code;
3934  }
3935 
3936  return NO_ERROR;
3937 }
3938 
3939 #define CT_DUAL_DUMMY "dummy"
3940 
3941  /*
3942  * boot_define_dual :
3943  *
3944  * returns : NO_ERROR if all OK, ER_ status otherwise
3945  *
3946  * class(IN) :
3947  */
3948 
3949 static int
3951 {
3952  SM_TEMPLATE *def;
3953  int error_code = NO_ERROR;
3954  DB_OBJECT *obj;
3955  DB_VALUE val;
3956  const char *dummy = "X";
3957 
3958  def = smt_edit_class_mop (class_mop, AU_ALTER);
3959  if (def == NULL)
3960  {
3961  assert (er_errid () != NO_ERROR);
3962  return er_errid ();
3963  }
3964 
3965  error_code = smt_add_attribute (def, CT_DUAL_DUMMY, "varchar(1)", NULL);
3966  if (error_code != NO_ERROR)
3967  {
3968  return error_code;
3969  }
3970 
3971  error_code = sm_update_class (def, NULL);
3972  if (error_code != NO_ERROR)
3973  {
3974  return error_code;
3975  }
3976 
3977  if (locator_has_heap (class_mop) == NULL)
3978  {
3979  assert (er_errid () != NO_ERROR);
3980  return er_errid ();
3981  }
3982 
3983  error_code = au_change_owner (class_mop, Au_dba_user);
3984  if (error_code != NO_ERROR)
3985  {
3986  return error_code;
3987  }
3988 
3989  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
3990  if (error_code != NO_ERROR)
3991  {
3992  return error_code;
3993  }
3994 
3995  obj = db_create_internal (class_mop);
3996  if (obj == NULL)
3997  {
3998  assert (er_errid () != NO_ERROR);
3999  return er_errid ();
4000  }
4001  error_code = db_make_varchar (&val, 1, dummy, strlen (dummy), LANG_SYS_CODESET, LANG_SYS_COLLATION);
4002  if (error_code != NO_ERROR)
4003  {
4004  return error_code;
4005  }
4006 
4007  error_code = db_put_internal (obj, CT_DUAL_DUMMY, &val);
4008  if (error_code != NO_ERROR)
4009  {
4010  return error_code;
4011  }
4012 
4013  return NO_ERROR;
4014 }
4015 
4016 /*
4017  * catcls_class_install :
4018  *
4019  * returns : NO_ERROR if all OK, ER_ status otherwise
4020  */
4021 static int
4023 {
4024  // *INDENT-OFF*
4025  struct catcls_function
4026  {
4027  const char *name;
4028  const DEF_CLASS_FUNCTION function;
4029  }
4030  clist[] =
4031  {
4052  };
4053  // *INDENT-ON*
4054 
4055  MOP class_mop[sizeof (clist) / sizeof (clist[0])];
4056  int i, save;
4057  int error_code = NO_ERROR;
4058  int num_classes = sizeof (clist) / sizeof (clist[0]);
4059 
4060  AU_DISABLE (save);
4061 
4062  for (i = 0; i < num_classes; i++)
4063  {
4064  class_mop[i] = db_create_class (clist[i].name);
4065  if (class_mop[i] == NULL)
4066  {
4067  assert (er_errid () != NO_ERROR);
4068  error_code = er_errid ();
4069  goto end;
4070  }
4071  sm_mark_system_class (class_mop[i], 1);
4072  }
4073 
4074  for (i = 0; i < num_classes; i++)
4075  {
4076  error_code = (clist[i].function) (class_mop[i]);
4077  if (error_code != NO_ERROR)
4078  {
4079  assert (er_errid () != NO_ERROR);
4080  error_code = er_errid ();
4081  goto end;
4082  }
4083  }
4084 
4085 end:
4086  AU_ENABLE (save);
4087 
4088  return error_code;
4089 }
4090 
4091 /*
4092  * boot_define_view_class :
4093  *
4094  * returns : NO_ERROR if all OK, ER_ status otherwise
4095  *
4096  */
4097 static int
4099 {
4100  MOP class_mop;
4101  COLUMN columns[] = {
4102  {"class_name", "varchar(255)"},
4103  {"owner_name", "varchar(255)"},
4104  {"class_type", "varchar(6)"},
4105  {"is_system_class", "varchar(3)"},
4106  {"tde_algorithm", "varchar(32)"},
4107  {"partitioned", "varchar(3)"},
4108  {"is_reuse_oid_class", "varchar(3)"},
4109  {"collation", "varchar(32)"},
4110  {"comment", "varchar(2048)"}
4111  };
4112  int num_cols = sizeof (columns) / sizeof (columns[0]);
4113  int i;
4114  char stmt[2048];
4115  int error_code = NO_ERROR;
4116 
4117  class_mop = db_create_vclass (CTV_CLASS_NAME);
4118  if (class_mop == NULL)
4119  {
4120  assert (er_errid () != NO_ERROR);
4121  error_code = er_errid ();
4122  return error_code;
4123  }
4124 
4125  for (i = 0; i < num_cols; i++)
4126  {
4127  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
4128  if (error_code != NO_ERROR)
4129  {
4130  return error_code;
4131  }
4132  }
4133 
4134  sprintf (stmt,
4135  "SELECT [c].[class_name], CAST([c].[owner].[name] AS VARCHAR(255)),"
4136  " CASE [c].[class_type] WHEN 0 THEN 'CLASS' WHEN 1 THEN 'VCLASS' ELSE 'UNKNOW' END,"
4137  " CASE WHEN MOD([c].[is_system_class], 2) = 1 THEN 'YES' ELSE 'NO' END,"
4138  " CASE [c].[tde_algorithm] WHEN 0 THEN 'NONE' WHEN 1 THEN 'AES' WHEN 2 THEN 'ARIA' END,"
4139  " CASE WHEN [c].[sub_classes] IS NULL THEN 'NO' ELSE NVL((SELECT 'YES'"
4140  " FROM [%s] [p] WHERE [p].[class_of] = [c] and [p].[pname] IS NULL), 'NO') END,"
4141  " CASE WHEN MOD([c].[is_system_class] / 8, 2) = 1 THEN 'YES' ELSE 'NO' END,"
4142  " [coll].[coll_name], [c].[comment] FROM [%s] [c], [%s] [coll]"
4143  " WHERE [c].[collation_id] = [coll].[coll_id] AND (CURRENT_USER = 'DBA' OR"
4144  " {[c].[owner].[name]} SUBSETEQ (SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4145  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) OR {[c]} SUBSETEQ ("
4146  " SELECT SUM(SET{[au].[class_of]}) FROM [%s] [au] WHERE {[au].[grantee].[name]} SUBSETEQ ("
4147  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4148  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) AND"
4149  " [au].[auth_type] = 'SELECT'))", CT_PARTITION_NAME, CT_CLASS_NAME, CT_COLLATION_NAME, AU_USER_CLASS_NAME,
4151 
4152  error_code = db_add_query_spec (class_mop, stmt);
4153  if (error_code != NO_ERROR)
4154  {
4155  return error_code;
4156  }
4157 
4158  error_code = au_change_owner (class_mop, Au_dba_user);
4159  if (error_code != NO_ERROR)
4160  {
4161  return error_code;
4162  }
4163 
4164  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
4165  if (error_code != NO_ERROR)
4166  {
4167  return error_code;
4168  }
4169 
4170  return NO_ERROR;
4171 }
4172 
4173 /*
4174  * boot_define_view_super_class :
4175  *
4176  * returns : NO_ERROR if all OK, ER_ status otherwise
4177  */
4178 static int
4180 {
4181  MOP class_mop;
4182  COLUMN columns[] = {
4183  {"class_name", "varchar(255)"},
4184  {"super_class_name", "varchar(255)"}
4185  };
4186  int num_cols = sizeof (columns) / sizeof (columns[0]);
4187  int i;
4188  char stmt[2048];
4189  int error_code = NO_ERROR;
4190 
4191  class_mop = db_create_vclass (CTV_SUPER_CLASS_NAME);
4192  if (class_mop == NULL)
4193  {
4194  assert (er_errid () != NO_ERROR);
4195  error_code = er_errid ();
4196  return error_code;
4197  }
4198 
4199  for (i = 0; i < num_cols; i++)
4200  {
4201  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
4202  if (error_code != NO_ERROR)
4203  {
4204  return error_code;
4205  }
4206  }
4207 
4208  sprintf (stmt,
4209  "SELECT [c].[class_name], [s].[class_name] FROM [%s] [c], TABLE([c].[super_classes]) AS [t]([s])"
4210  " WHERE CURRENT_USER = 'DBA' OR {[c].[owner].[name]} SUBSETEQ ("
4211  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4212  " FROM [%s] [u], TABLE([groups]) AS t([g]) WHERE [u].[name] = CURRENT_USER) OR {[c]} SUBSETEQ ("
4213  " SELECT SUM(SET{[au].[class_of]}) FROM [%s] [au] WHERE {[au].[grantee].[name]} SUBSETEQ ("
4214  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4215  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) AND"
4216  " [au].[auth_type] = 'SELECT')", CT_CLASS_NAME, AU_USER_CLASS_NAME, CT_CLASSAUTH_NAME, AU_USER_CLASS_NAME);
4217 
4218  error_code = db_add_query_spec (class_mop, stmt);
4219  if (error_code != NO_ERROR)
4220  {
4221  return error_code;
4222  }
4223 
4224  error_code = au_change_owner (class_mop, Au_dba_user);
4225  if (error_code != NO_ERROR)
4226  {
4227  return error_code;
4228  }
4229 
4230  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
4231  if (error_code != NO_ERROR)
4232  {
4233  return error_code;
4234  }
4235 
4236  return NO_ERROR;
4237 }
4238 
4239 /*
4240  * boot_define_view_vclass :
4241  *
4242  * returns : NO_ERROR if all OK, ER_ status otherwise
4243  */
4244 static int
4246 {
4247  MOP class_mop;
4248  COLUMN columns[] = {
4249  {"vclass_name", "varchar(255)"},
4250  {"vclass_def", "varchar(4096)"},
4251  {"comment", "varchar(2048)"}
4252  };
4253  int num_cols = sizeof (columns) / sizeof (columns[0]);
4254  int i;
4255  char stmt[2048];
4256  int error_code = NO_ERROR;
4257 
4258  class_mop = db_create_vclass (CTV_VCLASS_NAME);
4259  if (class_mop == NULL)
4260  {
4261  assert (er_errid () != NO_ERROR);
4262  error_code = er_errid ();
4263  return error_code;
4264  }
4265 
4266  for (i = 0; i < num_cols; i++)
4267  {
4268  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
4269  if (error_code != NO_ERROR)
4270  {
4271  return error_code;
4272  }
4273  }
4274 
4275  sprintf (stmt,
4276  "SELECT [q].[class_of].[class_name], [q].[spec], [c].[comment] FROM [%s] [q], [%s] [c]"
4277  " WHERE ([q].[class_of].[class_name] = [c].[class_name]) AND (CURRENT_USER = 'DBA' OR"
4278  " {[q].[class_of].[owner].[name]} SUBSETEQ ("
4279  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4280  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) OR"
4281  " {[q].[class_of]} SUBSETEQ (SELECT SUM(SET{[au].[class_of]}) FROM [%s] [au]"
4282  " WHERE {[au].[grantee].[name]} SUBSETEQ ("
4283  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4284  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER ) AND"
4285  " [au].[auth_type] = 'SELECT'))", CT_QUERYSPEC_NAME, CT_CLASS_NAME, AU_USER_CLASS_NAME, CT_CLASSAUTH_NAME,
4287 
4288  error_code = db_add_query_spec (class_mop, stmt);
4289  if (error_code != NO_ERROR)
4290  {
4291  return error_code;
4292  }
4293 
4294  error_code = au_change_owner (class_mop, Au_dba_user);
4295  if (error_code != NO_ERROR)
4296  {
4297  return error_code;
4298  }
4299 
4300  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
4301  if (error_code != NO_ERROR)
4302  {
4303  return error_code;
4304  }
4305 
4306  return NO_ERROR;
4307 }
4308 
4309 /*
4310  * boot_define_view_attribute :
4311  *
4312  * returns : NO_ERROR if all OK, ER_ status otherwise
4313  */
4314 static int
4316 {
4317  MOP class_mop;
4318  COLUMN columns[] = {
4319  {"attr_name", "varchar(255)"},
4320  {"class_name", "varchar(255)"},
4321  {"attr_type", "varchar(8)"},
4322  {"def_order", "integer"},
4323  {"from_class_name", "varchar(255)"},
4324  {"from_attr_name", "varchar(255)"},
4325  {"data_type", "varchar(9)"},
4326  {"prec", "integer"},
4327  {"scale", "integer"},
4328  {"charset", "varchar(32)"},
4329  {"collation", "varchar(32)"},
4330  {"domain_class_name", "varchar(255)"},
4331  {"default_value", "varchar(255)"},
4332  {"is_nullable", "varchar(3)"},
4333  {"comment", "varchar(1024)"}
4334  };
4335  int num_cols = sizeof (columns) / sizeof (columns[0]);
4336  int i;
4337  char stmt[2048];
4338  int error_code = NO_ERROR;
4339 
4340  class_mop = db_create_vclass (CTV_ATTRIBUTE_NAME);
4341  if (class_mop == NULL)
4342  {
4343  assert (er_errid () != NO_ERROR);
4344  error_code = er_errid ();
4345  return error_code;
4346  }
4347 
4348  for (i = 0; i < num_cols; i++)
4349  {
4350  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
4351  if (error_code != NO_ERROR)
4352  {
4353  return error_code;
4354  }
4355  }
4356 
4357  sprintf (stmt,
4358  "SELECT [a].[attr_name], [c].[class_name], CASE WHEN [a].[attr_type] = 0 THEN 'INSTANCE'"
4359  " WHEN [a].[attr_type] = 1 THEN 'CLASS' ELSE 'SHARED' END,"
4360  " [a].[def_order], [a].[from_class_of].[class_name],"
4361  " [a].[from_attr_name], [t].[type_name], [d].[prec], [d].[scale],"
4362  " IF ([a].[data_type] IN (4, 25, 26, 27, 35), (SELECT [ch].[charset_name] FROM [%s] [ch]"
4363  " WHERE [d].[code_set] = [ch].[charset_id]), 'Not applicable'), "
4364  " IF ([a].[data_type] IN (4, 25, 26, 27, 35), (SELECT [coll].[coll_name]"
4365  " FROM [%s] [coll] WHERE [d].[collation_id] = [coll].[coll_id]), 'Not applicable'), "
4366  " [d].[class_of].[class_name], [a].[default_value],"
4367  " CASE WHEN [a].[is_nullable] = 1 THEN 'YES' ELSE 'NO' END, [a].[comment]"
4368  " FROM [%s] [c], [%s] [a], [%s] [d], [%s] [t]"
4369  " WHERE [a].[class_of] = [c] AND [d].[object_of] = [a] AND [d].[data_type] = [t].[type_id] AND"
4370  " (CURRENT_USER = 'DBA' OR {[c].[owner].[name]} SUBSETEQ ("
4371  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4372  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) OR"
4373  " {[c]} SUBSETEQ (SELECT SUM(SET{[au].[class_of]}) FROM [%s] [au]"
4374  " WHERE {[au].[grantee].[name]} SUBSETEQ ("
4375  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4376  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) AND"
4377  " [au].[auth_type] = 'SELECT'))", CT_CHARSET_NAME, CT_COLLATION_NAME, CT_CLASS_NAME, CT_ATTRIBUTE_NAME,
4379 
4380  error_code = db_add_query_spec (class_mop, stmt);
4381  if (error_code != NO_ERROR)
4382  {
4383  return error_code;
4384  }
4385 
4386  error_code = au_change_owner (class_mop, Au_dba_user);
4387  if (error_code != NO_ERROR)
4388  {
4389  return error_code;
4390  }
4391 
4392  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
4393  if (error_code != NO_ERROR)
4394  {
4395  return error_code;
4396  }
4397 
4398  return NO_ERROR;
4399 }
4400 
4401 /*
4402  * boot_define_view_attribute_set_domain :
4403  *
4404  * returns : NO_ERROR if all OK, ER_ status otherwise
4405  */
4406 static int
4408 {
4409  MOP class_mop;
4410  COLUMN columns[] = {
4411  {"attr_name", "varchar(255)"},
4412  {"class_name", "varchar(255)"},
4413  {"attr_type", "varchar(8)"},
4414  {"data_type", "varchar(9)"},
4415  {"prec", "integer"},
4416  {"scale", "integer"},
4417  {"code_set", "integer"},
4418  {"domain_class_name", "varchar(255)"}
4419  };
4420  int num_cols = sizeof (columns) / sizeof (columns[0]);
4421  int i;
4422  char stmt[2048];
4423  int error_code = NO_ERROR;
4424 
4425  class_mop = db_create_vclass (CTV_ATTR_SD_NAME);
4426  if (class_mop == NULL)
4427  {
4428  assert (er_errid () != NO_ERROR);
4429  error_code = er_errid ();
4430  return error_code;
4431  }
4432 
4433  for (i = 0; i < num_cols; i++)
4434  {
4435  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
4436  if (error_code != NO_ERROR)
4437  {
4438  return error_code;
4439  }
4440  }
4441 
4442  sprintf (stmt,
4443  "SELECT [a].[attr_name], [c].[class_name], CASE WHEN [a].[attr_type] = 0 THEN 'INSTANCE'"
4444  " WHEN [a].[attr_type] = 1 THEN 'CLASS' ELSE 'SHARED' END,"
4445  " [et].[type_name], [e].[prec], [e].[scale], [e].[code_set], [e].[class_of].[class_name]"
4446  " FROM [%s] [c], [%s] [a], [%s] [d], TABLE([d].[set_domains]) AS [t]([e]), [%s] [et]"
4447  " WHERE [a].[class_of] = [c] AND [d].[object_of] = [a] AND [e].[data_type] = [et].[type_id] AND"
4448  " (CURRENT_USER = 'DBA' OR {[c].[owner].[name]} SUBSETEQ ("
4449  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4450  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) OR"
4451  " {[c]} SUBSETEQ (SELECT SUM(SET{[au].[class_of]}) FROM [%s] [au]"
4452  " WHERE {[au].[grantee].[name]} SUBSETEQ ("
4453  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4454  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) AND"
4455  " [au].[auth_type] = 'SELECT'))", CT_CLASS_NAME, CT_ATTRIBUTE_NAME, CT_DOMAIN_NAME, CT_DATATYPE_NAME,
4457 
4458  error_code = db_add_query_spec (class_mop, stmt);
4459  if (error_code != NO_ERROR)
4460  {
4461  return error_code;
4462  }
4463 
4464  error_code = au_change_owner (class_mop, Au_dba_user);
4465  if (error_code != NO_ERROR)
4466  {
4467  return error_code;
4468  }
4469 
4470  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
4471  if (error_code != NO_ERROR)
4472  {
4473  return error_code;
4474  }
4475 
4476  return NO_ERROR;
4477 }
4478 
4479 /*
4480  * boot_define_view_method :
4481  *
4482  * returns : NO_ERROR if all OK, ER_ status otherwise
4483  */
4484 static int
4486 {
4487  MOP class_mop;
4488  COLUMN columns[] = {
4489  {"meth_name", "varchar(255)"},
4490  {"class_name", "varchar(255)"},
4491  {"meth_type", "varchar(8)"},
4492  {"from_class_name", "varchar(255)"},
4493  {"from_meth_name", "varchar(255)"},
4494  {"func_name", "varchar(255)"}
4495  };
4496  int num_cols = sizeof (columns) / sizeof (columns[0]);
4497  int i;
4498  char stmt[2048];
4499  int error_code = NO_ERROR;
4500 
4501  class_mop = db_create_vclass (CTV_METHOD_NAME);
4502  if (class_mop == NULL)
4503  {
4504  assert (er_errid () != NO_ERROR);
4505  error_code = er_errid ();
4506  return error_code;
4507  }
4508 
4509  for (i = 0; i < num_cols; i++)
4510  {
4511  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
4512  if (error_code != NO_ERROR)
4513  {
4514  return error_code;
4515  }
4516  }
4517 
4518  sprintf (stmt,
4519  "SELECT [m].[meth_name], [m].[class_of].[class_name],"
4520  " CASE WHEN [m].[meth_type] = 0 THEN 'INSTANCE' ELSE 'CLASS' END,"
4521  " [m].[from_class_of].[class_name], [m].[from_meth_name], [s].[func_name] FROM [%s] [m], [%s] [s]"
4522  " WHERE [s].[meth_of] = [m] AND (CURRENT_USER = 'DBA' OR {[m].[class_of].[owner].[name]} SUBSETEQ ("
4523  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4524  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) OR"
4525  " {[m].[class_of]} SUBSETEQ (SELECT SUM(set{[au].[class_of]}) FROM [%s] [au]"
4526  " WHERE {[au].[grantee].[name]} SUBSETEQ ("
4527  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4528  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) AND"
4529  " [au].[auth_type] = 'SELECT'))", CT_METHOD_NAME, CT_METHSIG_NAME, AU_USER_CLASS_NAME, CT_CLASSAUTH_NAME,
4531 
4532  error_code = db_add_query_spec (class_mop, stmt);
4533  if (error_code != NO_ERROR)
4534  {
4535  return error_code;
4536  }
4537 
4538  error_code = au_change_owner (class_mop, Au_dba_user);
4539  if (error_code != NO_ERROR)
4540  {
4541  return error_code;
4542  }
4543 
4544  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
4545  if (error_code != NO_ERROR)
4546  {
4547  return error_code;
4548  }
4549 
4550  return NO_ERROR;
4551 }
4552 
4553 /*
4554  * boot_define_view_method_argument :
4555  *
4556  * returns : NO_ERROR if all OK, ER_ status otherwise
4557  */
4558 static int
4560 {
4561  MOP class_mop;
4562  COLUMN columns[] = {
4563  {"meth_name", "varchar(255)"},
4564  {"class_name", "varchar(255)"},
4565  {"meth_type", "varchar(8)"},
4566  {"index_of", "integer"},
4567  {"data_type", "varchar(9)"},
4568  {"prec", "integer"},
4569  {"scale", "integer"},
4570  {"code_set", "integer"},
4571  {"domain_class_name", "varchar(255)"}
4572  };
4573  int num_cols = sizeof (columns) / sizeof (columns[0]);
4574  int i;
4575  char stmt[2048];
4576  int error_code = NO_ERROR;
4577 
4578  class_mop = db_create_vclass (CTV_METHARG_NAME);
4579  if (class_mop == NULL)
4580  {
4581  assert (er_errid () != NO_ERROR);
4582  error_code = er_errid ();
4583  return error_code;
4584  }
4585 
4586  for (i = 0; i < num_cols; i++)
4587  {
4588  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
4589  if (error_code != NO_ERROR)
4590  {
4591  return error_code;
4592  }
4593  }
4594 
4595  sprintf (stmt,
4596  "SELECT [s].[meth_of].[meth_name], [s].[meth_of].[class_of].[class_name],"
4597  " CASE WHEN [s].[meth_of].[meth_type] = 0 THEN 'INSTANCE' ELSE 'CLASS' END,"
4598  " [a].[index_of], [t].[type_name], [d].[prec], [d].[scale], [d].[code_set], [d].[class_of].[class_name]"
4599  " FROM [%s] [s], [%s] [a], [%s] [d], [%s] [t]"
4600  " WHERE [a].[meth_sig_of] = [s] AND [d].[object_of] = [a] AND [d].[data_type] = [t].[type_id] AND"
4601  " (CURRENT_USER = 'DBA' OR {[s].[meth_of].[class_of].[owner].[name]} SUBSETEQ ("
4602  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4603  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) OR"
4604  " {[s].[meth_of].[class_of]} SUBSETEQ (SELECT sum(set{[au].[class_of]}) FROM [%s] [au]"
4605  " WHERE {[au].[grantee].[name]} SUBSETEQ ("
4606  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4607  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) AND"
4608  " [au].[auth_type] = 'SELECT'))", CT_METHSIG_NAME, CT_METHARG_NAME, CT_DOMAIN_NAME, CT_DATATYPE_NAME,
4610 
4611  error_code = db_add_query_spec (class_mop, stmt);
4612  if (error_code != NO_ERROR)
4613  {
4614  return error_code;
4615  }
4616 
4617  error_code = au_change_owner (class_mop, Au_dba_user);
4618  if (error_code != NO_ERROR)
4619  {
4620  return error_code;
4621  }
4622 
4623  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
4624  if (error_code != NO_ERROR)
4625  {
4626  return error_code;
4627  }
4628 
4629  return NO_ERROR;
4630 }
4631 
4632 /*
4633  * boot_define_view_method_argument_set_domain :
4634  *
4635  * returns : NO_ERROR if all OK, ER_ status otherwise
4636  *
4637  * Note:
4638  *
4639  */
4640 static int
4642 {
4643  MOP class_mop;
4644  COLUMN columns[] = {
4645  {"meth_name", "varchar(255)"},
4646  {"class_name", "varchar(255)"},
4647  {"meth_type", "varchar(8)"},
4648  {"index_of", "integer"},
4649  {"data_type", "varchar(9)"},
4650  {"prec", "integer"},
4651  {"scale", "integer"},
4652  {"code_set", "integer"},
4653  {"domain_class_name", "varchar(255)"}
4654  };
4655  int num_cols = sizeof (columns) / sizeof (columns[0]);
4656  int i;
4657  char stmt[2048];
4658  int error_code = NO_ERROR;
4659 
4660  class_mop = db_create_vclass (CTV_METHARG_SD_NAME);
4661  if (class_mop == NULL)
4662  {
4663  assert (er_errid () != NO_ERROR);
4664  error_code = er_errid ();
4665  return error_code;
4666  }
4667 
4668  for (i = 0; i < num_cols; i++)
4669  {
4670  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
4671  if (error_code != NO_ERROR)
4672  {
4673  return error_code;
4674  }
4675  }
4676 
4677  sprintf (stmt,
4678  "SELECT [s].[meth_of].[meth_name], [s].[meth_of].[class_of].[class_name],"
4679  " CASE WHEN [s].[meth_of].[meth_type] = 0 THEN 'INSTANCE' ELSE 'CLASS' END,"
4680  " [a].[index_of], [et].[type_name], [e].[prec], [e].[scale], [e].[code_set], [e].[class_of].[class_name]"
4681  " FROM [%s] [s], [%s] [a], [%s] [d], TABLE([d].[set_domains]) AS [t]([e]), [%s] [et]"
4682  " WHERE [a].[meth_sig_of] = [s] AND [d].[object_of] = [a] AND [e].[data_type] = [et].[type_id] AND"
4683  " (CURRENT_USER = 'DBA' OR {[s].[meth_of].[class_of].[owner].[name]} SUBSETEQ ("
4684  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4685  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) OR"
4686  " {[s].[meth_of].[class_of]} SUBSETEQ (SELECT sum(set{[au].[class_of]}) FROM [%s] [au]"
4687  " WHERE {[au].[grantee].[name]} SUBSETEQ ("
4688  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4689  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) AND"
4690  " [au].[auth_type] = 'SELECT'))", CT_METHSIG_NAME, CT_METHARG_NAME, CT_DOMAIN_NAME, CT_DATATYPE_NAME,
4692 
4693  error_code = db_add_query_spec (class_mop, stmt);
4694  if (error_code != NO_ERROR)
4695  {
4696  return error_code;
4697  }
4698 
4699  error_code = au_change_owner (class_mop, Au_dba_user);
4700  if (error_code != NO_ERROR)
4701  {
4702  return error_code;
4703  }
4704 
4705  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
4706  if (error_code != NO_ERROR)
4707  {
4708  return error_code;
4709  }
4710 
4711  return NO_ERROR;
4712 }
4713 
4714 /*
4715  * boot_define_view_method_file :
4716  *
4717  * returns : NO_ERROR if all OK, ER_ status otherwise
4718  */
4719 static int
4721 {
4722  MOP class_mop;
4723  COLUMN columns[] = {
4724  {"class_name", "varchar(255)"},
4725  {"path_name", "varchar(255)"},
4726  {"from_class_name", "varchar(255)"}
4727  };
4728  int num_cols = sizeof (columns) / sizeof (columns[0]);
4729  int i;
4730  char stmt[2048];
4731  int error_code = NO_ERROR;
4732 
4733  class_mop = db_create_vclass (CTV_METHFILE_NAME);
4734  if (class_mop == NULL)
4735  {
4736  assert (er_errid () != NO_ERROR);
4737  error_code = er_errid ();
4738  return error_code;
4739  }
4740 
4741  for (i = 0; i < num_cols; i++)
4742  {
4743  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
4744  if (error_code != NO_ERROR)
4745  {
4746  return error_code;
4747  }
4748  }
4749 
4750  sprintf (stmt,
4751  "SELECT [f].[class_of].[class_name], [f].[path_name], [f].[from_class_of].[class_name] FROM [%s] [f]"
4752  " WHERE CURRENT_USER = 'DBA' OR {[f].[class_of].[owner].[name]} SUBSETEQ ("
4753  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4754  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) OR"
4755  " {[f].[class_of]} SUBSETEQ (SELECT SUM(SET{[au].[class_of]}) FROM [%s] [au]"
4756  " WHERE {[au].[grantee].[name]} SUBSETEQ ("
4757  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4758  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) AND"
4759  " [au].[auth_type] = 'SELECT')", CT_METHFILE_NAME, AU_USER_CLASS_NAME, CT_CLASSAUTH_NAME,
4761 
4762  error_code = db_add_query_spec (class_mop, stmt);
4763  if (error_code != NO_ERROR)
4764  {
4765  return error_code;
4766  }
4767 
4768  error_code = au_change_owner (class_mop, Au_dba_user);
4769  if (error_code != NO_ERROR)
4770  {
4771  return error_code;
4772  }
4773 
4774  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
4775  if (error_code != NO_ERROR)
4776  {
4777  return error_code;
4778  }
4779 
4780  return NO_ERROR;
4781 }
4782 
4783 /*
4784  * boot_define_view_index :
4785  *
4786  * returns : NO_ERROR if all OK, ER_ status otherwise
4787  */
4788 static int
4790 {
4791  MOP class_mop;
4792  COLUMN columns[] = {
4793  {"index_name", "varchar(255)"},
4794  {"is_unique", "varchar(3)"},
4795  {"is_reverse", "varchar(3)"},
4796  {"class_name", "varchar(255)"},
4797  {"key_count", "integer"},
4798  {"is_primary_key", "varchar(3)"},
4799  {"is_foreign_key", "varchar(3)"},
4800  {"filter_expression", "varchar(255)"},
4801  {"have_function", "varchar(3)"},
4802  {"comment", "varchar(1024)"},
4803  {"status", "varchar(255)"}
4804  };
4805  int num_cols = sizeof (columns) / sizeof (columns[0]);
4806  int i;
4807  char stmt[2048];
4808  int error_code = NO_ERROR;
4809 
4810  class_mop = db_create_vclass (CTV_INDEX_NAME);
4811  if (class_mop == NULL)
4812  {
4813  assert (er_errid () != NO_ERROR);
4814  error_code = er_errid ();
4815  return error_code;
4816  }
4817 
4818  for (i = 0; i < num_cols; i++)
4819  {
4820  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
4821  if (error_code != NO_ERROR)
4822  {
4823  return error_code;
4824  }
4825  }
4826 
4827  sprintf (stmt,
4828  "SELECT [i].[index_name], CASE WHEN [i].[is_unique] = 0 THEN 'NO' ELSE 'YES' END,"
4829  " CASE WHEN [i].[is_reverse] = 0 THEN 'NO' ELSE 'YES' END, [i].[class_of].[class_name], [i].[key_count],"
4830  " CASE WHEN [i].[is_primary_key] = 0 THEN 'NO' ELSE 'YES' END,"
4831  " CASE WHEN [i].[is_foreign_key] = 0 THEN 'NO' ELSE 'YES' END, [i].[filter_expression],"
4832  " CASE WHEN [i].[have_function] = 0 THEN 'NO' ELSE 'YES' END, [i].[comment],"
4833  " CASE WHEN [i].[status] = 0 THEN 'NO_INDEX' "
4834  " WHEN [i].[status] = 1 THEN 'NORMAL INDEX' "
4835  " WHEN [i].[status] = 2 THEN 'INVISIBLE INDEX'"
4836  " WHEN [i].[status] = 3 THEN 'INDEX IS IN ONLINE BUILDING' "
4837  " ELSE 'NULL' END "
4838  " FROM [%s] [i]"
4839  " WHERE CURRENT_USER = 'DBA' OR {[i].[class_of].[owner].[name]} SUBSETEQ ("
4840  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4841  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) OR"
4842  " {[i].[class_of]} SUBSETEQ (SELECT SUM(SET{[au].[class_of]}) FROM [%s] [au]"
4843  " WHERE {[au].[grantee].[name]} SUBSETEQ ("
4844  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4845  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) AND"
4846  " [au].[auth_type] = 'SELECT')", CT_INDEX_NAME, AU_USER_CLASS_NAME, CT_CLASSAUTH_NAME, AU_USER_CLASS_NAME);
4847 
4848  error_code = db_add_query_spec (class_mop, stmt);
4849  if (error_code != NO_ERROR)
4850  {
4851  return error_code;
4852  }
4853 
4854  error_code = au_change_owner (class_mop, Au_dba_user);
4855  if (error_code != NO_ERROR)
4856  {
4857  return error_code;
4858  }
4859 
4860  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
4861  if (error_code != NO_ERROR)
4862  {
4863  return error_code;
4864  }
4865 
4866  return NO_ERROR;
4867 }
4868 
4869 /*
4870  * boot_define_view_index_key :
4871  *
4872  * returns : NO_ERROR if all OK, ER_ status otherwise
4873  */
4874 static int
4876 {
4877  MOP class_mop;
4878  COLUMN columns[] = {
4879  {"index_name", "varchar(255)"},
4880  {"class_name", "varchar(255)"},
4881  {"key_attr_name", "varchar(255)"},
4882  {"key_order", "integer"},
4883  {"asc_desc", "varchar(4)"},
4884  {"key_prefix_length", "integer"},
4885  {"func", "varchar(255)"}
4886  };
4887  int num_cols = sizeof (columns) / sizeof (columns[0]);
4888  int i;
4889  char stmt[2048];
4890  int error_code = NO_ERROR;
4891 
4892  class_mop = db_create_vclass (CTV_INDEXKEY_NAME);
4893  if (class_mop == NULL)
4894  {
4895  assert (er_errid () != NO_ERROR);
4896  error_code = er_errid ();
4897  return error_code;
4898  }
4899 
4900  for (i = 0; i < num_cols; i++)
4901  {
4902  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
4903  if (error_code != NO_ERROR)
4904  {
4905  return error_code;
4906  }
4907  }
4908 
4909  sprintf (stmt,
4910  "SELECT [k].[index_of].[index_name], [k].[index_of].[class_of].[class_name],"
4911  " [k].[key_attr_name], [k].[key_order], CASE [k].[asc_desc] WHEN 0 THEN 'ASC' WHEN 1 THEN 'DESC'"
4912  " ELSE 'UNKN' END, [k].[key_prefix_length], [k].[func] FROM [%s] [k]"
4913  " WHERE CURRENT_USER = 'DBA' OR {[k].[index_of].[class_of].[owner].[name]} SUBSETEQ ("
4914  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4915  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) OR"
4916  " {[k].[index_of].[class_of]} SUBSETEQ (SELECT SUM(SET{[au].[class_of]}) FROM [%s] [au]"
4917  " WHERE {[au].[grantee].[name]} SUBSETEQ ("
4918  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4919  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) AND"
4920  " [au].[auth_type] = 'SELECT')", CT_INDEXKEY_NAME, AU_USER_CLASS_NAME, CT_CLASSAUTH_NAME,
4922 
4923  error_code = db_add_query_spec (class_mop, stmt);
4924  if (error_code != NO_ERROR)
4925  {
4926  return error_code;
4927  }
4928 
4929  error_code = au_change_owner (class_mop, Au_dba_user);
4930  if (error_code != NO_ERROR)
4931  {
4932  return error_code;
4933  }
4934 
4935  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
4936  if (error_code != NO_ERROR)
4937  {
4938  return error_code;
4939  }
4940 
4941  return NO_ERROR;
4942 }
4943 
4944 /*
4945  * boot_define_view_authorization :
4946  *
4947  * returns : NO_ERROR if all OK, ER_ status otherwise
4948  */
4949 static int
4951 {
4952  MOP class_mop;
4953  COLUMN columns[] = {
4954  {"grantor_name", "varchar(255)"},
4955  {"grantee_name", "varchar(255)"},
4956  {"class_name", "varchar(255)"},
4957  {"auth_type", "varchar(7)"},
4958  {"is_grantable", "varchar(3)"}
4959  };
4960  int num_cols = sizeof (columns) / sizeof (columns[0]);
4961  int i;
4962  char stmt[2048];
4963  int error_code = NO_ERROR;
4964 
4965  class_mop = db_create_vclass (CTV_AUTH_NAME);
4966  if (class_mop == NULL)
4967  {
4968  assert (er_errid () != NO_ERROR);
4969  error_code = er_errid ();
4970  return error_code;
4971  }
4972 
4973  for (i = 0; i < num_cols; i++)
4974  {
4975  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
4976  if (error_code != NO_ERROR)
4977  {
4978  return error_code;
4979  }
4980  }
4981 
4982  sprintf (stmt,
4983  "SELECT CAST([a].[grantor].[name] AS VARCHAR(255)),"
4984  " CAST([a].[grantee].[name] AS VARCHAR(255)), [a].[class_of].[class_name], [a].[auth_type],"
4985  " CASE WHEN [a].[is_grantable] = 0 THEN 'NO' ELSE 'YES' END FROM [%s] [a]"
4986  " WHERE CURRENT_USER = 'DBA' OR {[a].[class_of].[owner].[name]} SUBSETEQ ("
4987  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4988  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) OR"
4989  " {[a].[class_of]} SUBSETEQ (SELECT SUM(SET{[au].[class_of]}) FROM [%s] [au]"
4990  " WHERE {[au].[grantee].[name]} SUBSETEQ ("
4991  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
4992  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) AND"
4993  " [au].[auth_type] = 'SELECT')", CT_CLASSAUTH_NAME, AU_USER_CLASS_NAME, CT_CLASSAUTH_NAME,
4995 
4996  error_code = db_add_query_spec (class_mop, stmt);
4997  if (error_code != NO_ERROR)
4998  {
4999  return error_code;
5000  }
5001 
5002  error_code = au_change_owner (class_mop, Au_dba_user);
5003  if (error_code != NO_ERROR)
5004  {
5005  return error_code;
5006  }
5007 
5008  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
5009  if (error_code != NO_ERROR)
5010  {
5011  return error_code;
5012  }
5013 
5014  return NO_ERROR;
5015 }
5016 
5017 /*
5018  * boot_define_view_trigger :
5019  *
5020  * returns : NO_ERROR if all OK, ER_ status otherwise
5021  */
5022 static int
5024 {
5025  MOP class_mop;
5026  COLUMN columns[] = {
5027  {"trigger_name", "varchar(255)"},
5028  {"target_class_name", "varchar(255)"},
5029  {"target_attr_name", "varchar(255)"},
5030  {"target_attr_type", "varchar(8)"},
5031  {"action_type", "integer"},
5032  {"action_time", "integer"},
5033  {"comment", "varchar(1024)"}
5034  };
5035  int num_cols = sizeof (columns) / sizeof (columns[0]);
5036  int i;
5037  char stmt[2048];
5038  int error_code = NO_ERROR;
5039 
5040  class_mop = db_create_vclass (CTV_TRIGGER_NAME);
5041  if (class_mop == NULL)
5042  {
5043  assert (er_errid () != NO_ERROR);
5044  error_code = er_errid ();
5045  return error_code;
5046  }
5047 
5048  for (i = 0; i < num_cols; i++)
5049  {
5050  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
5051  if (error_code != NO_ERROR)
5052  {
5053  return error_code;
5054  }
5055  }
5056 
5057  sprintf (stmt,
5058  "SELECT CAST([t].[name] AS VARCHAR(255)), [c].[class_name], CAST([t].[target_attribute] AS VARCHAR(255)),"
5059  " CASE [t].[target_class_attribute] WHEN 0 THEN 'INSTANCE' ELSE 'CLASS' END,"
5060  " [t].[action_type], [t].[action_time], [t].[comment]"
5061  " FROM [%s] [t] LEFT OUTER JOIN [%s] [c] ON [t].[target_class] = [c].[class_of]"
5062  " WHERE CURRENT_USER = 'DBA' OR {[t].[owner].[name]} SUBSETEQ (SELECT SET{CURRENT_USER} +"
5063  " COALESCE(SUM(SET{[t].[g].[name]}), SET{}) FROM [%s] [u], TABLE([groups]) AS [t]([g])"
5064  " WHERE [u].[name] = CURRENT_USER ) OR {[c]} SUBSETEQ (SELECT SUM(SET{[au].[class_of]}) FROM [%s] [au]"
5065  " WHERE {[au].[grantee].[name]} SUBSETEQ (SELECT SET{CURRENT_USER} +"
5066  " COALESCE(SUM(SET{[t].[g].[name]}), SET{}) FROM [%s] [u], TABLE([groups]) AS [t]([g])"
5067  " WHERE [u].[name] = CURRENT_USER) AND [au].[auth_type] = 'SELECT')", TR_CLASS_NAME, CT_CLASS_NAME,
5069 
5070  error_code = db_add_query_spec (class_mop, stmt);
5071  if (error_code != NO_ERROR)
5072  {
5073  return error_code;
5074  }
5075 
5076  error_code = au_change_owner (class_mop, Au_dba_user);
5077  if (error_code != NO_ERROR)
5078  {
5079  return error_code;
5080  }
5081 
5082  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
5083  if (error_code != NO_ERROR)
5084  {
5085  return error_code;
5086  }
5087 
5088  return NO_ERROR;
5089 }
5090 
5091 /*
5092  * boot_define_view_partition :
5093  *
5094  * returns : NO_ERROR if all OK, ER_ status otherwise
5095  */
5096 static int
5098 {
5099  MOP class_mop;
5100  COLUMN columns[] = {
5101  {"class_name", "varchar(255)"},
5102  {"partition_name", "varchar(255)"},
5103  {"partition_class_name", "varchar(255)"},
5104  {"partition_type", "varchar(32)"},
5105  {"partition_expr", "varchar(2048)"},
5106  {"partition_values", "sequence of"},
5107  {"comment", "varchar(1024)"}
5108  };
5109  int num_cols = sizeof (columns) / sizeof (columns[0]);
5110  int i;
5111  char stmt[2048];
5112  int error_code = NO_ERROR;
5113 
5114  class_mop = db_create_vclass (CTV_PARTITION_NAME);
5115  if (class_mop == NULL)
5116  {
5117  assert (er_errid () != NO_ERROR);
5118  error_code = er_errid ();
5119  return error_code;
5120  }
5121 
5122  for (i = 0; i < num_cols; i++)
5123  {
5124  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
5125  if (error_code != NO_ERROR)
5126  {
5127  return error_code;
5128  }
5129  }
5130 
5131  sprintf (stmt,
5132  "SELECT [pp].[super_class_name] AS [class_name], [p].[pname] AS [partition_name],"
5133  " CONCAT([pp].[super_class_name], '__p__', [p].[pname]) AS [partition_class_name],"
5134  " CASE WHEN [p].[ptype] = 0 THEN 'HASH'"
5135  " WHEN [p].[ptype] = 1 THEN 'RANGE' ELSE 'LIST' END AS [partition_type],"
5136  " TRIM(SUBSTRING([pi].[pexpr] FROM 8 FOR (POSITION(' FROM ' IN [pi].[pexpr])-8)))"
5137  " AS [partition_expression], [p].[pvalues] AS [partition_values], [p].[comment] AS [comment]"
5138  " FROM [%s] [p],"
5139  " (SELECT * FROM [%s] [sc], [%s] [sp] WHERE [sc].[class_name] = [sp].[class_of].[class_name]) [pp],"
5140  " (SELECT [tt].[ss].[pexpr] AS [pexpr], [ss].[class_name] AS [class_name]"
5141  " FROM [%s] [ss], TABLE ([ss].[partition]) AS [tt]([ss])) [pi]"
5142  " WHERE [pp].[class_name] = [p].[class_of].[class_name] AND"
5143  " [pi].[class_name] = [pp].[super_class_name] AND (CURRENT_USER = 'DBA' OR"
5144  " {[p].[class_of].[owner].[name]} SUBSETEQ ("
5145  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
5146  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) OR"
5147  " {[p].[class_of]} SUBSETEQ (SELECT SUM(SET{[au].[class_of]}) FROM [%s] [au]"
5148  " WHERE {[au].[grantee].[name]} SUBSETEQ ("
5149  " SELECT SET{CURRENT_USER} + COALESCE(SUM(SET{[t].[g].[name]}), SET{})"
5150  " FROM [%s] [u], TABLE([groups]) AS [t]([g]) WHERE [u].[name] = CURRENT_USER) AND"
5151  " [au].[auth_type] = 'SELECT'))", CT_PARTITION_NAME, CTV_SUPER_CLASS_NAME, CT_PARTITION_NAME, CT_CLASS_NAME,
5153 
5154  error_code = db_add_query_spec (class_mop, stmt);
5155  if (error_code != NO_ERROR)
5156  {
5157  return error_code;
5158  }
5159 
5160  error_code = au_change_owner (class_mop, Au_dba_user);
5161  if (error_code != NO_ERROR)
5162  {
5163  return error_code;
5164  }
5165 
5166  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
5167  if (error_code != NO_ERROR)
5168  {
5169  return error_code;
5170  }
5171 
5172  return NO_ERROR;
5173 }
5174 
5175 /*
5176  * boot_define_view_stored_procedure :
5177  *
5178  * returns : NO_ERROR if all OK, ER_ status otherwise
5179  */
5180 static int
5182 {
5183  MOP class_mop;
5184  COLUMN columns[] = {
5185  {"sp_name", "varchar(255)"},
5186  {"sp_type", "varchar(16)"},
5187  {"return_type", "varchar(16)"},
5188  {"arg_count", "integer"},
5189  {"lang", "varchar(16)"},
5190  {"target", "varchar(4096)"},
5191  {"owner", "varchar(256)"},
5192  {"comment", "varchar(1024)"}
5193  };
5194  int num_cols = sizeof (columns) / sizeof (columns[0]);
5195  int i;
5196  char stmt[2048];
5197  int error_code = NO_ERROR;
5198 
5199  class_mop = db_create_vclass (CTV_STORED_PROC_NAME);
5200  if (class_mop == NULL)
5201  {
5202  assert (er_errid () != NO_ERROR);
5203  error_code = er_errid ();
5204  return error_code;
5205  }
5206 
5207  for (i = 0; i < num_cols; i++)
5208  {
5209  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
5210  if (error_code != NO_ERROR)
5211  {
5212  return error_code;
5213  }
5214  }
5215 
5216  sprintf (stmt,
5217  "SELECT [sp].[sp_name], CASE [sp].[sp_type] WHEN 1 THEN 'PROCEDURE' ELSE 'FUNCTION' END,"
5218  " CASE WHEN [sp].[return_type] = 0 THEN 'void' WHEN [sp].[return_type] = 28 THEN 'CURSOR'"
5219  " ELSE (SELECT [dt].[type_name] FROM [%s] [dt] WHERE [sp].[return_type] = [dt].[type_id]) END,"
5220  " [sp].[arg_count], CASE [sp].[lang] WHEN 1 THEN 'JAVA' ELSE '' END,"
5221  " [sp].[target], [sp].[owner].[name], [sp].[comment] FROM [%s] [sp]", CT_DATATYPE_NAME, CT_STORED_PROC_NAME);
5222 
5223  error_code = db_add_query_spec (class_mop, stmt);
5224  if (error_code != NO_ERROR)
5225  {
5226  return error_code;
5227  }
5228 
5229  error_code = au_change_owner (class_mop, Au_dba_user);
5230  if (error_code != NO_ERROR)
5231  {
5232  return error_code;
5233  }
5234 
5235  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
5236  if (error_code != NO_ERROR)
5237  {
5238  return error_code;
5239  }
5240 
5241  return NO_ERROR;
5242 }
5243 
5244 /*
5245  * boot_define_view_stored_procedure_arguments :
5246  *
5247  * returns : NO_ERROR if all OK, ER_ status otherwise
5248  */
5249 static int
5251 {
5252  MOP class_mop;
5253  COLUMN columns[] = {
5254  {"sp_name", "varchar(255)"},
5255  {"index_of", "integer"},
5256  {"arg_name", "varchar(256)"},
5257  {"data_type", "varchar(16)"},
5258  {"mode", "varchar(6)"},
5259  {"comment", "varchar(1024)"}
5260  };
5261  int num_cols = sizeof (columns) / sizeof (columns[0]);
5262  int i;
5263  char stmt[2048];
5264  int error_code = NO_ERROR;
5265 
5267  if (class_mop == NULL)
5268  {
5269  assert (er_errid () != NO_ERROR);
5270  error_code = er_errid ();
5271  return error_code;
5272  }
5273 
5274  for (i = 0; i < num_cols; i++)
5275  {
5276  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
5277  if (error_code != NO_ERROR)
5278  {
5279  return error_code;
5280  }
5281  }
5282 
5283  sprintf (stmt,
5284  "SELECT [sp].[sp_name], [sp].[index_of], [sp].[arg_name], CASE [sp].[data_type]"
5285  " WHEN 28 THEN 'CURSOR'"
5286  " ELSE (SELECT [dt].[type_name] FROM [%s] [dt] WHERE [sp].[data_type] = [dt].[type_id]) END, CASE"
5287  " WHEN [sp].[mode] = 1 THEN 'IN' WHEN [sp].[mode] = 2 THEN 'OUT' ELSE 'INOUT' END,"
5288  " [sp].[comment] FROM [%s] [sp] ORDER BY [sp].[sp_name], [sp].[index_of]", CT_DATATYPE_NAME,
5290 
5291  error_code = db_add_query_spec (class_mop, stmt);
5292  if (error_code != NO_ERROR)
5293  {
5294  return error_code;
5295  }
5296 
5297  error_code = au_change_owner (class_mop, Au_dba_user);
5298  if (error_code != NO_ERROR)
5299  {
5300  return error_code;
5301  }
5302 
5303  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
5304  if (error_code != NO_ERROR)
5305  {
5306  return error_code;
5307  }
5308 
5309  return NO_ERROR;
5310 }
5311 
5312 /*
5313  * boot_define_view_db_collation :
5314  *
5315  * returns : NO_ERROR if all OK, ER_ status otherwise
5316  */
5317 static int
5319 {
5320  MOP class_mop;
5321  COLUMN columns[] = {
5322  {"coll_id", "integer"},
5323  {"coll_name", "varchar(255)"},
5324  {"charset_name", "varchar(255)"},
5325  {"is_builtin", "varchar(3)"},
5326  {"has_expansions", "varchar(3)"},
5327  {"contractions", "integer"},
5328  {"uca_strength", "varchar(255)"}
5329  };
5330 
5331  int num_cols = sizeof (columns) / sizeof (columns[0]);
5332  int i;
5333  char stmt[2048];
5334  int error_code = NO_ERROR;
5335 
5337  if (class_mop == NULL)
5338  {
5339  assert (er_errid () != NO_ERROR);
5340  error_code = er_errid ();
5341  return error_code;
5342  }
5343 
5344  for (i = 0; i < num_cols; i++)
5345  {
5346  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
5347  if (error_code != NO_ERROR)
5348  {
5349  return error_code;
5350  }
5351  }
5352 
5353  sprintf (stmt,
5354  "SELECT [c].[coll_id], [c].[coll_name], [ch].[charset_name], CASE [c].[built_in] WHEN 0 THEN 'No'"
5355  " WHEN 1 THEN 'Yes' ELSE 'ERROR' END, CASE [c].[expansions] WHEN 0 THEN 'No'"
5356  " WHEN 1 THEN 'Yes' ELSE 'ERROR' END, [c].[contractions], CASE [c].[uca_strength]"
5357  " WHEN 0 THEN 'Not applicable' WHEN 1 THEN 'Primary' WHEN 2 THEN 'Secondary'"
5358  " WHEN 3 THEN 'Tertiary' WHEN 4 THEN 'Quaternary' WHEN 5 THEN 'Identity' ELSE 'Unknown' END"
5359  " FROM [%s] [c] JOIN [%s] [ch] ON [c].[charset_id] = [ch].[charset_id] ORDER BY [c].[coll_id]",
5361 
5362  error_code = db_add_query_spec (class_mop, stmt);
5363  if (error_code != NO_ERROR)
5364  {
5365  return error_code;
5366  }
5367 
5368  error_code = au_change_owner (class_mop, Au_dba_user);
5369  if (error_code != NO_ERROR)
5370  {
5371  return error_code;
5372  }
5373 
5374  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
5375  if (error_code != NO_ERROR)
5376  {
5377  return error_code;
5378  }
5379 
5380  return NO_ERROR;
5381 }
5382 
5383 /*
5384  * boot_define_view_db_charset :
5385  *
5386  * returns : NO_ERROR if all OK, ER_ status otherwise
5387  */
5388 static int
5390 {
5391  MOP class_mop;
5392  COLUMN columns[] = {
5393  {CT_DBCHARSET_CHARSET_ID, "integer"},
5394  {CT_DBCHARSET_CHARSET_NAME, "varchar(32)"},
5395  {CT_DBCHARSET_DEFAULT_COLLATION, "varchar(32)"},
5396  {CT_DBCHARSET_CHAR_SIZE, "int"}
5397  };
5398 
5399  int num_cols = sizeof (columns) / sizeof (columns[0]);
5400  int i;
5401  char stmt[2048];
5402  int error_code = NO_ERROR;
5403 
5404  class_mop = db_create_vclass (CTV_DB_CHARSET_NAME);
5405  if (class_mop == NULL)
5406  {
5407  assert (er_errid () != NO_ERROR);
5408  error_code = er_errid ();
5409  return error_code;
5410  }
5411 
5412  for (i = 0; i < num_cols; i++)
5413  {
5414  error_code = db_add_attribute (class_mop, columns[i].name, columns[i].type, NULL);
5415  if (error_code != NO_ERROR)
5416  {
5417  return error_code;
5418  }
5419  }
5420 
5421  sprintf (stmt,
5422  "SELECT [ch].[charset_id], [ch].[charset_name], [coll].[coll_name], [ch].[char_size] "
5423  "FROM [%s] [ch] JOIN [%s] [coll] ON [ch].[default_collation] = [coll].[coll_id] "
5424  "ORDER BY [ch].[charset_id]", CT_CHARSET_NAME, CT_COLLATION_NAME);
5425 
5426  error_code = db_add_query_spec (class_mop, stmt);
5427  if (error_code != NO_ERROR)
5428  {
5429  return error_code;
5430  }
5431 
5432  error_code = au_change_owner (class_mop, Au_dba_user);
5433  if (error_code != NO_ERROR)
5434  {
5435  return error_code;
5436  }
5437 
5438  error_code = au_grant (Au_public_user, class_mop, AU_SELECT, false);
5439  if (error_code != NO_ERROR)
5440  {
5441  return error_code;
5442  }
5443 
5444  return NO_ERROR;
5445 }
5446 
5447 /*
5448  * catcls_vclass_install :
5449  *
5450  * returns : NO_ERROR if all OK, ER_ status otherwise
5451  */
5452 static int
5454 {
5455  // *INDENT-OFF*
5456  struct catcls_function
5457  {
5458  const char *name;
5459  const DEF_FUNCTION function;
5460  }
5461  clist[] =
5462  {
5463  {"CTV_CLASS_NAME", boot_define_view_class},
5464  {"CTV_SUPER_CLASS_NAME", boot_define_view_super_class},
5465  {"CTV_VCLASS_NAME", boot_define_view_vclass},
5466  {"CTV_ATTRIBUTE_NAME", boot_define_view_attribute},
5467  {"CTV_ATTR_SD_NAME", boot_define_view_attribute_set_domain},
5468  {"CTV_METHOD_NAME", boot_define_view_method},
5469  {"CTV_METHARG_NAME", boot_define_view_method_argument},
5470  {"CTV_METHARG_SD_NAME", boot_define_view_method_argument_set_domain},
5471  {"CTV_METHFILE_NAME", boot_define_view_method_file},
5472  {"CTV_INDEX_NAME", boot_define_view_index},
5473  {"CTV_INDEXKEY_NAME", boot_define_view_index_key},
5474  {"CTV_AUTH_NAME", boot_define_view_authorization},
5475  {"CTV_TRIGGER_NAME", boot_define_view_trigger},
5476  {"CTV_PARTITION_NAME", boot_define_view_partition},
5477  {"CTV_STORED_PROC_NAME", boot_define_view_stored_procedure},
5478  {"CTV_STORED_PROC_ARGS_NAME", boot_define_view_stored_procedure_arguments},
5479  {"CTV_DB_COLLATION_NAME", boot_define_view_db_collation},
5480  {"CTV_DB_CHARSET_NAME", boot_define_view_db_charset}
5481  };
5482  // *INDENT-ON*
5483 
5484  int save;
5485  size_t i;
5486  size_t num_vclasses = sizeof (clist) / sizeof (clist[0]);
5487  int error_code = NO_ERROR;
5488 
5489  AU_DISABLE (save);
5490 
5491  for (i = 0; i < num_vclasses; i++)
5492  {
5493  error_code = (clist[i].function) ();
5494  if (error_code != NO_ERROR)
5495  {
5496  goto end;
5497  }
5498  }
5499 
5500 end:
5501  AU_ENABLE (save);
5502 
5503  return error_code;
5504 }
5505 
5506 #if defined (SA_MODE)
5507 #if defined (ENABLE_UNUSED_FUNCTION)
5508 /*
5509  * boot_build_catalog_classes :
5510  *
5511  * returns : NO_ERROR if all OK, ER_ status otherwise
5512  *
5513  * dbname(in) :
5514  */
5515 int
5516 boot_build_catalog_classes (const char *dbname)
5517 {
5518  int error_code = NO_ERROR;
5519 
5520  /* check if an old version database */
5522  {
5523  fprintf (stdout, "Database %s already has system catalog class/vclass\n", dbname);
5524  return 1;
5525  }
5526  else
5527  {
5528  bool cc_save;
5529 
5530  /* save and catcls_Enable */
5531  cc_save = catcls_Enable;
5532  catcls_Enable = false;
5533 
5534  error_code = catcls_class_install ();
5535  if (error_code == NO_ERROR)
5536  {
5537  error_code = catcls_vclass_install ();
5538  }
5539  if (error_code == NO_ERROR)
5540  {
5541  /* add method to db_authorization */
5543 
5544  /* mark catalog class/view as a system class */
5545  sm_mark_system_class_for_catalog ();
5546 
5547  if (!tf_Metaclass_class.n_variable)
5548  {
5550  }
5551  if (catcls_Enable != true)
5552  {
5553  error_code = catcls_compile_catalog_classes (NULL);
5554  if (error_code == NO_ERROR)
5555  {
5556  error_code = sm_force_write_all_classes ();
5557  if (error_code == NO_ERROR)
5558  {
5559  error_code = au_force_write_new_auth ();
5560  }
5561  }
5562  }
5563  }
5564  /* restore catcls_Enable */
5565  catcls_Enable = cc_save;
5566  }
5567 
5568  return error_code;
5569 }
5570 
5571 /*
5572  * boot_destroy_catalog_classes :
5573  *
5574  * returns : NO_ERROR if all OK, ER_ status otherwise
5575  *
5576  * dbname(in) :
5577  *
5578  * Note: destroy catalog by reverse order of building
5579  *
5580  */
5581 int
5582 boot_destroy_catalog_classes (void)
5583 {
5584  int error_code = NO_ERROR;
5585  bool cc_save, save;
5586 
5587  int i;
5588  MOP classmop;
5589  const char *classes[] = {
5601  };
5602 
5603  /* check if catalog exists */
5604  if (locator_find_class (CT_CLASS_NAME) == NULL)
5605  {
5606  /* catalog does not exists */
5607  return NO_ERROR;
5608  }
5609 
5610  /* save and off catcls_Enable */
5611  cc_save = catcls_Enable;
5612  catcls_Enable = false;
5613 
5614  AU_DISABLE (save);
5615 
5616  /* drop method of db_authorization */
5617  error_code = db_drop_class_method (locator_find_class ("db_authorization"), "check_authorization");
5618  /* error checking */
5619  if (error_code != NO_ERROR)
5620  {
5621  goto exit_on_error;
5622  }
5623 
5624  /* drop catalog class/vclass */
5625  for (i = 0; classes[i] != NULL; i++)
5626  {
5627  classmop = locator_find_class (classes[i]);
5628  if (!classmop)
5629  {
5630  continue; /* not found */
5631  }
5632  /* for vclass, revoke before drop */
5633  if (db_is_vclass (classmop))
5634  {
5635  error_code = db_revoke (Au_public_user, classmop, AU_SELECT);
5636  if (error_code != NO_ERROR)
5637  {
5638  goto exit_on_error;
5639  }
5640  }
5641 
5642  /* drop class/view */
5643  error_code = db_drop_class (classmop);
5644  if (error_code == ER_OBJ_INVALID_ARGUMENTS)
5645  {
5646  continue;
5647  }
5648 
5649  /* error checking */
5650  if (error_code != NO_ERROR)
5651  {
5652  goto exit_on_error;
5653  }
5654  }
5655 
5656 exit_on_error:
5657 
5658  AU_ENABLE (save);
5659 
5660  /* restore catcls_Enable */
5661  catcls_Enable = cc_save;
5662 
5663  return error_code;
5664 }
5665 
5666 /*
5667  * boot_rebuild_catalog_classes :
5668  *
5669  * returns : NO_ERROR if all OK, ER_ status otherwise
5670  *
5671  * dbname(in) :
5672  */
5673 int
5674 boot_rebuild_catalog_classes (const char *dbname)
5675 {
5676  int error_code = NO_ERROR;
5677 
5678  error_code = boot_destroy_catalog_classes ();
5679 
5680  if (error_code != NO_ERROR)
5681  {
5682  return error_code;
5683  }
5684 
5685  return boot_build_catalog_classes (dbname);
5686 }
5687 #endif /* ENABLE_UNUSED_FUNCTION */
5688 #endif /* SA_MODE */
5689 
5690 #if defined(CS_MODE)
5691 char *
5692 boot_get_host_connected (void)
5693 {
5694  return boot_Host_connected;
5695 }
5696 
5698 boot_get_ha_server_state (void)
5699 {
5700  return boot_Server_credential.ha_server_state;
5701 }
5702 
5703 /*
5704  * boot_get_lob_path - return the lob path which is received from the server
5705  */
5706 const char *
5707 boot_get_lob_path (void)
5708 {
5709  return boot_Server_credential.lob_path;
5710 }
5711 #endif /* CS_MODE */
5712 
5713 /*
5714  * boot_clear_host_connected () -
5715  */
5716 void
5718 {
5719 #if defined(CS_MODE)
5720  boot_Host_connected[0] = '\0';
5721 #endif
5722 }
5723 
5724 char *
5726 {
5727  if (boot_Host_name[0] == '\0')
5728  {
5730  {
5732  }
5733  boot_Host_name[CUB_MAXHOSTNAMELEN - 1] = '\0'; /* bullet proof */
5734  }
5735 
5736  return boot_Host_name;
5737 }
5738 
5739 #if defined(CS_MODE)
5740 /*
5741  * boot_check_locales () - checks that client locales are compatible with
5742  * server locales
5743  *
5744  * return : error code
5745  *
5746  */
5747 static int
5748 boot_check_locales (BOOT_CLIENT_CREDENTIAL * client_credential)
5749 {
5750  int error_code = NO_ERROR;
5751  LANG_COLL_COMPAT *server_collations = NULL;
5752  LANG_LOCALE_COMPAT *server_locales = NULL;
5753  int server_coll_cnt, server_locales_cnt;
5754  char cli_text[PATH_MAX];
5755  char srv_text[DB_MAX_IDENTIFIER_LENGTH + 10];
5756 
5757  error_code = boot_get_server_locales (&server_collations, &server_locales, &server_coll_cnt, &server_locales_cnt);
5758  if (error_code != NO_ERROR)
5759  {
5760  goto exit;
5761  }
5762 
5763  (void) basename_r (client_credential->get_program_name (), cli_text, sizeof (cli_text));
5764  snprintf (srv_text, sizeof (srv_text) - 1, "server '%s'", client_credential->get_db_name ());
5765 
5766  error_code = lang_check_coll_compat (server_collations, server_coll_cnt, cli_text, srv_text);
5767  if (error_code != NO_ERROR)
5768  {
5769  goto exit;
5770  }
5771 
5772  error_code = lang_check_locale_compat (server_locales, server_locales_cnt, cli_text, srv_text);
5773 
5774 exit:
5775  if (server_collations != NULL)
5776  {
5777  free_and_init (server_collations);
5778  }
5779  if (server_locales != NULL)
5780  {
5781  free_and_init (server_locales);
5782  }
5783 
5784  return error_code;
5785 }
5786 #endif /* CS_MODE */
5787 
5788 /*
5789  * boot_get_server_session_key () -
5790  */
5791 char *
5793 {
5794  return boot_Server_credential.server_session_key;
5795 }
5796 
5797 /*
5798  * boot_set_server_session_key () -
5799  */
5800 void
5802 {
5803  memcpy (boot_Server_credential.server_session_key, key, SERVER_SESSION_KEY_SIZE);
5804 }
5805 
5806 
5807 #if defined(CS_MODE)
5808 /*
5809  * boot_check_timezone_checksum () - checks that client timezone library is
5810  * compatible with server timezone library
5811  *
5812  * return : error code
5813  *
5814  */
5815 static int
5816 boot_check_timezone_checksum (BOOT_CLIENT_CREDENTIAL * client_credential)
5817 {
5818  int error_code = NO_ERROR;
5819  char timezone_checksum[TZ_CHECKSUM_SIZE + 1];
5820  const TZ_DATA *tzd;
5821  char cli_text[PATH_MAX];
5822  char srv_text[DB_MAX_IDENTIFIER_LENGTH + 10];
5823 
5824  error_code = boot_get_server_timezone_checksum (timezone_checksum);
5825  if (error_code != NO_ERROR)
5826  {
5827  goto exit;
5828  }
5829 
5830  (void) basename_r (client_credential->get_program_name (), cli_text, sizeof (cli_text));
5831  snprintf (srv_text, sizeof (srv_text) - 1, "server '%s'", client_credential->get_db_name ());
5832 
5833  tzd = tz_get_data ();
5834  assert (tzd != NULL);
5835  error_code = check_timezone_compat (tzd->checksum, timezone_checksum, cli_text, srv_text);
5836 exit:
5837  return error_code;
5838 }
5839 #endif /* CS_MODE */
5840 
5841 /*
5842  * boot_client_find_and_cache_class_oids () - Cache class OID's on client for
5843  * fast class mop identifying.
5844  *
5845  * return : Error code.
5846  */
5847 static int
5849 {
5850  MOP class_mop = NULL;
5851  int error;
5852 
5853  class_mop = sm_find_class (CT_SERIAL_NAME);
5854  if (class_mop == NULL)
5855  {
5856  error = er_errid ();
5857  if (error != NO_ERROR)
5858  {
5859  return error;
5860  }
5862  return ER_FAILED;
5863  }
5865 
5866  class_mop = sm_find_class (CT_HA_APPLY_INFO_NAME);
5867  if (class_mop == NULL)
5868  {
5869  error = er_errid ();
5870  if (error != NO_ERROR)
5871  {
5872  return error;
5873  }
5874 
5876  return ER_FAILED;
5877  }
5879  return NO_ERROR;
5880 }
#define CT_ATTRIBUTE_NAME
Definition: transform.h:120
#define BOOT_READ_ONLY_CLIENT_TYPE(client_type)
Definition: boot.h:43
int lang_set_charset(const INTL_CODESET codeset)
static int boot_define_method(MOP class_mop)
Definition: boot_cl.c:2225
void au_final(void)
#define LANG_MAX_COLLATIONS
#define CT_DATATYPE_NAME
Definition: transform.h:131
int lang_set_language(const char *lang_str)
const char * name
Definition: boot_cl.c:124
char * lob_path
Definition: boot.h:107
void tran_free_savepoint_list(void)
#define CT_CLASSAUTH_NAME
Definition: transform.h:130
void parser_final(void)
#define NO_ERROR
Definition: error_code.h:46
const char * get_db_password() const
int check_timezone_compat(const char *client_checksum, const char *server_checksum, const char *client_text, const char *server_text)
Definition: tz_support.c:5043
#define AU_DISABLE(save)
Definition: authenticate.h:106
DB_INFO * cfg_find_db(const char *db_name)
int pr_Enable_string_compression
int db_drop_class_method(MOP class_, const char *name)
Definition: db_class.c:852
#define LANG_SYS_COLLATION
#define LANG_GET_BINARY_COLLATION(c)
int lang_init(void)
static int boot_define_class(MOP class_mop)
Definition: boot_cl.c:1799
char * db_path
Definition: boot.h:104
#define CTV_METHFILE_NAME
Definition: transform.h:156
int net_client_ping_server_with_handshake(int client_type, bool check_capabilities, int opt_cap)
Definition: network_cl.c:3782
int dl_destroy_module(void)
#define ER_NET_DIFFERENT_RELEASE
Definition: error_code.h:642
#define ASSERT_ERROR()
static int boot_define_view_trigger(void)
Definition: boot_cl.c:5023
#define ER_BO_CONNECTED_TO
Definition: error_code.h:1211
float rel_disk_compatible(void)
bool sett_expansions
char ** cfg_get_hosts(const char *prim_host, int *count, bool include_local_host)
static int catcls_vclass_install(void)
Definition: boot_cl.c:5453
DB_TRAN_ISOLATION TRAN_ISOLATION
Definition: log_comm.h:81
static int boot_define_view_db_collation(void)
Definition: boot_cl.c:5318
#define L_cuserid
Definition: porting.h:58
float disk_compatibility
Definition: boot.h:146
META_CLASS tf_Metaclass_class
Definition: transform.c:221
#define CT_METHOD_NAME
Definition: transform.h:122
int sm_mark_system_class(MOP classop, int on_or_off)
#define BOOT_LOG_REPLICATOR_TYPE(client_type)
Definition: boot.h:57
int tp_init(void)
static int boot_define_view_index(void)
Definition: boot_cl.c:4789
#define CT_DBCOLL_CHECKSUM_COLUMN
Definition: transform.h:174
PAGEID DKNPAGES
#define BOOT_ADMIN_CLIENT_TYPE(client_type)
Definition: boot.h:50
#define ER_ES_INVALID_PATH
Definition: error_code.h:1272
void cfg_free_hosts(char **host_array)
#define BOOT_CSQL_CLIENT_TYPE(client_type)
Definition: boot.h:61
int tm_Tran_index
int db_is_vclass(DB_OBJECT *op)
Definition: db_virt.c:681
const char * boot_get_lob_path(void)
Definition: boot_sr.c:479
#define CTV_ATTR_SD_NAME
Definition: transform.h:152
#define ER_FAILED
Definition: error_code.h:47
int showstmt_metadata_init(void)
Definition: show_meta.c:937
const TZ_DATA * tz_get_data(void)
Definition: tz_support.c:687
int db_make_varchar(DB_VALUE *value, const int max_char_length, DB_CONST_C_CHAR str, const int char_str_byte_size, const int codeset, const int collation_id)
#define BOOT_BROKER_AND_DEFAULT_CLIENT_TYPE(client_type)
Definition: boot.h:69
int au_force_write_new_auth(void)
void oid_set_cached_class_oid(const int cache_id, const OID *oid)
Definition: oid.c:339
#define CT_DBCOLL_BUILT_IN_COLUMN
Definition: transform.h:170
static int boot_define_stored_procedure(MOP class_mop)
Definition: boot_cl.c:3050
#define ER_NET_NO_EXPLICIT_SERVER_HOST
Definition: error_code.h:1234
#define BOOT_REPLICA_ONLY_BROKER_CLIENT_TYPE(client_type)
Definition: boot.h:76
static void boot_shutdown_client_at_exit(void)
Definition: boot_cl.c:1458
#define BOOT_IS_PREFERRED_HOSTS_SET(credential)
Definition: boot.h:97
#define CTV_DB_CHARSET_NAME
Definition: transform.h:165
#define TRAN_DEFAULT_ISOLATION_LEVEL()
Definition: dbtran_def.h:58
static int boot_client_find_and_cache_class_oids(void)
Definition: boot_cl.c:5848
void boot_client_all_finalize(bool is_er_final)
Definition: boot_cl.c:1536
void db_clear_delayed_hosts_count(void)
Definition: db_admin.c:546
static int boot_define_view_vclass(void)
Definition: boot_cl.c:4245
#define CTV_CLASS_NAME
Definition: transform.h:148
int lang_check_locale_compat(const LANG_LOCALE_COMPAT *loc_array, const int loc_cnt, const char *client_text, const char *server_text)
int db_make_numeric(DB_VALUE *value, const DB_C_NUMERIC num, const int precision, const int scale)
#define MSGCAT_GENERAL_DATABASE_INIT
#define CT_DOMAIN_NAME
Definition: transform.h:121
#define CT_METHSIG_NAME
Definition: transform.h:123
void db_clear_host_status(void)
Definition: db_admin.c:580
#define assert_release(e)
Definition: error_manager.h:96
#define ER_BO_CANT_LOAD_SYSPRM
Definition: error_code.h:1346
#define ER_NET_CANT_CONNECT_SERVER
Definition: error_code.h:261
const char * get_host_name() const
int db_add_query_spec(MOP vclass, const char *query)
Definition: db_virt.c:458
#define BOOT_IS_CLIENT_RESTARTED()
Definition: boot_cl.h:42
void locator_free_areas(void)
Definition: locator.c:206
int intl_identifier_upper_string_size(const char *src)
INT16 VOLID
static int boot_define_view_class(void)
Definition: boot_cl.c:4098
int(* DEF_FUNCTION)()
Definition: boot_cl.c:118
static int boot_client(int tran_index, int lock_wait, TRAN_ISOLATION tran_isolation)
Definition: boot_cl.c:232
char * db_host
Definition: boot.h:108
const char * type
Definition: boot_cl.c:125
#define ER_BO_FULL_DATABASE_NAME_IS_TOO_LONG
Definition: error_code.h:178
const char * AU_USER_CLASS_NAME
Definition: authenticate.c:107
#define NULL_SLOTID
MOP locator_find_class(const char *classname)
Definition: locator_cl.c:3142
void cnv_cleanup(void)
Definition: cnv.c:8692
int tz_load(void)
Definition: tz_support.c:337
#define CTV_METHARG_SD_NAME
Definition: transform.h:155
bool tran_is_active_and_has_updated(void)
static int boot_define_view_method(void)
Definition: boot_cl.c:4485
DB_OBJECT * db_create_vclass(const char *name)
Definition: db_virt.c:140
#define CT_DBCOLL_UCA_STRENGTH
Definition: transform.h:173
MOBJ locator_has_heap(MOP class_mop)
Definition: locator_cl.c:5761
#define ER_NET_NO_SERVER_HOST
Definition: error_code.h:260
static int boot_define_data_type(MOP class_mop)
Definition: boot_cl.c:2995
#define MAX_NTRANS
int er_errid(void)
#define DB_HS_CONN_FAILURE
Definition: connection_cl.h:39
int tran_abort(void)
static int boot_define_view_index_key(void)
Definition: boot_cl.c:4875
void oid_set_root(const OID *oid)
Definition: oid.c:118
int sysprm_load_and_init_client(const char *db_name, const char *conf_file)
int sysprm_init_intl_param(void)
#define CT_STORED_PROC_NAME
Definition: transform.h:132
MOP Au_public_user
Definition: authenticate.c:333
static int boot_define_collations(MOP class_mop)
Definition: boot_cl.c:3733
static char boot_Client_id_buffer[L_cuserid+1]
Definition: boot_cl.c:146
#define er_log_debug(...)
#define CT_METHFILE_NAME
Definition: transform.h:125
static int boot_define_class_authorization(MOP class_mop)
Definition: boot_cl.c:2786
static int boot_Process_id
Definition: boot_cl.c:163
char * getuserid(char *string, int size)
Definition: porting.c:1271
#define CT_DUAL_NAME
Definition: transform.h:145
static int boot_define_view_authorization(void)
Definition: boot_cl.c:4950
void sysprm_final(void)
#define CT_CLASS_NAME
Definition: transform.h:119
DB_OBJECT * db_create_class(const char *name)
Definition: db_class.c:70
#define CT_PARTITION_NAME
Definition: transform.h:134
const char * AU_PUBLIC_USER_NAME
Definition: authenticate.c:112
#define AU_ALTER
Definition: authenticate.h:73
void jsp_init(void)
Definition: jsp_cl.c:185
int er_init(const char *msglog_filename, int exit_ask)
static int boot_define_view_method_file(void)
Definition: boot_cl.c:4720
static char boot_Db_path_buf[PATH_MAX]
Definition: boot_cl.c:147
void ws_free_string(const char *str)
Definition: work_space.c:3480
#define CT_DBCHARSET_CHARSET_ID
Definition: boot_cl.c:3815
int boot_register_client(BOOT_CLIENT_CREDENTIAL *client_credential, int client_lock_wait, TRAN_ISOLATION client_isolation, TRAN_STATE *tran_state, BOOT_SERVER_CREDENTIAL *server_credential)
int tr_install(void)
static bool boot_Set_client_at_exit
Definition: boot_cl.c:162
int ws_init(void)
Definition: work_space.c:2299
int net_client_init(const char *dbname, const char *hostname)
Definition: network_cl.c:3921
UCA_OPTIONS uca_opt
void area_init(void)
Definition: area_alloc.c:100
int au_install(void)
void THREAD_ENTRY
#define TZ_CHECKSUM_SIZE
#define NULL_PAGEID
#define CT_SERIAL_NAME
Definition: transform.h:135
char server_session_key[SERVER_SESSION_KEY_SIZE]
Definition: boot.h:148
void sysprm_tune_client_parameters(void)
#define OID_INIT_TEMPID()
Definition: oid.h:43
int boot_restart_client(BOOT_CLIENT_CREDENTIAL *client_credential)
Definition: boot_cl.c:738
static int boot_define_view_attribute_set_domain(void)
Definition: boot_cl.c:4407
#define CT_STORED_PROC_ARGS_NAME
Definition: transform.h:133
INTL_CODESET lang_charset(void)
DB_OBJECT * db_create_internal(DB_OBJECT *obj)
Definition: db_obj.c:93
void es_final(void)
Definition: es.c:116
PGLENGTH log_page_size
Definition: boot.h:145
#define ER_BO_UNKNOWN_DATABASE
Definition: error_code.h:177
int tran_reset_wait_times(int wait_in_msecs)
#define CT_HA_APPLY_INFO_NAME
Definition: transform.h:136
static int boot_define_partition(MOP class_mop)
Definition: boot_cl.c:2860
MOP Au_dba_user
Definition: authenticate.c:334
void boot_donot_shutdown_client_at_exit(void)
Definition: boot_cl.c:1485
static int boot_define_view_super_class(void)
Definition: boot_cl.c:4179
PGLENGTH page_size
Definition: boot.h:144
#define DB_CONNECT_ORDER_SEQ
Definition: connection_cl.h:33
#define ER_NET_HS_UNKNOWN_SERVER_REL
Definition: error_code.h:1460
static int boot_define_dual(MOP class_mop)
Definition: boot_cl.c:3950
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
INTL_CODESET codeset
db_client_type client_type
LANG_COLLATION * lang_get_collation(const int coll_id)
#define ERR_CSS_TCP_CONNECT_TIMEDOUT
Definition: error_code.h:1462
CSS_CHECK_SERVER_ALIVE_FN css_check_server_alive_fn
#define DB_MAX_NUMERIC_PRECISION
Definition: dbtype_def.h:522
const char * get_program_name() const
#define BOOT_NORMAL_CLIENT_TYPE(client_type)
Definition: boot.h:33
#define assert(x)
void er_final(ER_FINAL_CODE do_global_final)
#define ER_LANG_CODESET_NOT_AVAILABLE
Definition: error_code.h:1382
#define BOOT_CHECK_HA_DELAY_CAP
Definition: boot_cl.c:116
#define CT_DBCOLL_EXPANSIONS_COLUMN
Definition: transform.h:171
static int boot_define_view_stored_procedure(void)
Definition: boot_cl.c:5181
#define CTV_DB_COLLATION_NAME
Definition: transform.h:164
int boot_initialize_client(BOOT_CLIENT_CREDENTIAL *client_credential, BOOT_DB_PATH_INFO *db_path_info, bool db_overwrite, const char *file_addmore_vols, DKNPAGES npages, PGLENGTH db_desired_pagesize, DKNPAGES log_npages, PGLENGTH db_desired_log_page_size, const char *lang_charset)
Definition: boot_cl.c:290
void ws_final(void)
Definition: work_space.c:2429
void sm_create_root(OID *rootclass_oid, HFID *rootclass_hfid)
int prm_get_integer_value(PARAM_ID prm_id)
#define ER_GENERIC_ERROR
Definition: error_code.h:49
int db_add_attribute(MOP obj, const char *name, const char *domain, DB_VALUE *default_value)
Definition: db_class.c:248
int db_constrain_non_null(MOP class_, const char *name, int class_attribute, int on_or_off)
Definition: db_class.c:1455
#define CTV_INDEX_NAME
Definition: transform.h:157
void util_shuffle_string_array(char **array, int count)
Definition: util_func.c:412
#define ER_OUT_OF_VIRTUAL_MEMORY
Definition: error_code.h:50
void jsp_close_connection(void)
Definition: jsp_cl.c:209
int tran_commit(bool retain_lock)
#define CTV_AUTH_NAME
Definition: transform.h:159
#define DB_MAX_IDENTIFIER_LENGTH
Definition: dbtype_def.h:495
#define TM_TRAN_WAIT_MSECS()
void rel_set_disk_compatible(float level)
void tp_final(void)
#define TRAN_LOCK_INFINITE_WAIT
Definition: log_comm.h:29
DB_TRAN_ISOLATION
Definition: dbtran_def.h:26
void sm_flush_static_methods()
bool au_has_user_name(void)
int au_change_owner(MOP classmop, MOP owner)
#define CTV_METHARG_NAME
Definition: transform.h:154
static int boot_add_charsets(MOP class_mop)
Definition: boot_cl.c:3831
int db_get_delayed_hosts_count(void)
Definition: db_admin.c:540
void boot_server_die_or_changed(void)
Definition: boot_cl.c:1503
std::string db_user
void sm_final()
int lang_collation_count(void)
#define BOOT_NO_OPT_CAP
Definition: boot_cl.c:115
#define DB_HS_CONN_TIMEOUT
Definition: connection_cl.h:38
#define BOOT_FORMAT_MAX_LENGTH
Definition: boot_cl.c:112
static int boot_define_meth_argument(MOP class_mop)
Definition: boot_cl.c:2385
VID_OID oid_info
Definition: work_space.h:120
int perfmon_initialize(int num_trans)
void lang_final(void)
const char * rel_name(void)
int tran_abort_only_client(bool is_server_down)
void locator_initialize_areas(void)
Definition: locator.c:166
#define CT_INDEX_NAME
Definition: transform.h:128
#define NULL
Definition: freelistheap.h:34
OID oid
Definition: work_space.h:65
#define CT_DBCOLL_COLL_ID_COLUMN
Definition: transform.h:167
#define strncpy_bufsize(buf, str)
Definition: porting.h:340
char checksum[32+1]
#define CT_DBCHARSET_CHARSET_NAME
Definition: boot_cl.c:3816
int boot_unregister_client(int tran_index)
#define CTV_STORED_PROC_ARGS_NAME
Definition: transform.h:162
#define DB_HS_NON_PREFFERED_HOSTS
Definition: connection_cl.h:42
static BOOT_SERVER_CREDENTIAL boot_Server_credential
Definition: boot_cl.c:129
static char * dbname
void numeric_coerce_int_to_num(int arg, DB_C_NUMERIC answer)
#define CTV_TRIGGER_NAME
Definition: transform.h:160
int sm_force_write_all_classes(void)
char * boot_get_server_session_key(void)
Definition: boot_cl.c:5792
#define ER_LOC_INIT
Definition: error_code.h:1370
void util_free_string_array(char **array)
Definition: util_func.c:292
#define CT_METHARG_NAME
Definition: transform.h:124
#define CTV_SUPER_CLASS_NAME
Definition: transform.h:149
static int boot_define_meth_sig(MOP class_mop)
Definition: boot_cl.c:2308
void tr_final(void)
#define db_private_free_and_init(thrd, ptr)
Definition: memory_alloc.h:141
int es_init(const char *uri)
Definition: es.c:53
static int boot_define_view_db_charset(void)
Definition: boot_cl.c:5389
void perfmon_finalize(void)
SM_TEMPLATE * smt_edit_class_mop(MOP op, DB_AUTH db_auth_type)
static int boot_define_index(MOP class_mop)
Definition: boot_cl.c:2574
HA_SERVER_STATE ha_server_state
Definition: boot.h:147
void boot_set_server_session_key(const char *key)
Definition: boot_cl.c:5801
static int boot_define_domain(MOP class_mop)
Definition: boot_cl.c:2118
int msgcat_init(void)
#define NULL_FILEID
int db_put_internal(DB_OBJECT *obj, const char *name, DB_VALUE *value)
Definition: db_obj.c:347
#define CT_QUERYSPEC_NAME
Definition: transform.h:126
static int boot_define_view_attribute(void)
Definition: boot_cl.c:4315
void COMPOSE_FULL_NAME(char *buf, size_t buf_size, const char *path, const char *name)
Definition: boot.h:161
int catcls_compile_catalog_classes(THREAD_ENTRY *thread_p)
#define MSGCAT_SET_GENERAL
int au_grant(MOP user, MOP class_mop, DB_AUTH type, bool grant_option)
ES_TYPE
Definition: es_common.h:28
#define CT_COLLATION_NAME
Definition: transform.h:137
void er_set_with_oserror(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
static int boot_define_charsets(MOP class_mop)
Definition: boot_cl.c:3881
#define MSGCAT_CATALOG_CUBRID
static int boot_define_view_method_argument(void)
Definition: boot_cl.c:4559
const char * lang_charset_cubrid_name(const INTL_CODESET codeset)
char ** util_split_string(const char *str, const char *delim)
Definition: util_func.c:247
static int boot_define_view_partition(void)
Definition: boot_cl.c:5097
#define ER_BO_UNABLE_TO_FIND_HOSTNAME
Definition: error_code.h:180
#define CTV_METHOD_NAME
Definition: transform.h:153
void set_final(void)
Definition: set_object.c:297
#define CT_DUAL_DUMMY
Definition: boot_cl.c:3939
void db_set_connected_host_status(char *host_connected)
Definition: db_admin.c:681
int tran_reset_isolation(TRAN_ISOLATION isolation, bool async_ws)
static int boot_define_view_method_argument_set_domain(void)
Definition: boot_cl.c:4641
void tf_compile_meta_classes()
Definition: transform.c:550
#define NULL_TRAN_INDEX
const char * TR_CLASS_NAME
static char boot_Lob_path_buf[PATH_MAX]
Definition: boot_cl.c:149
static void error(const char *msg)
Definition: gencat.c:331
#define ER_CSS_CLIENTS_EXCEEDED
Definition: error_code.h:809
#define ER_NET_SERVER_HAND_SHAKE
Definition: error_code.h:922
static int boot_define_query_spec(MOP class_mop)
Definition: boot_cl.c:2518
int lang_set_charset_lang(const char *lang_charset)
static char boot_Db_host_buf[CUB_MAXHOSTNAMELEN+1]
Definition: boot_cl.c:150
int db_drop_class(MOP class_)
Definition: db_class.c:110
void co_final(void)
void showstmt_metadata_final(void)
Definition: show_meta.c:994
void tran_cache_tran_settings(int tran_index, int lock_timeout, TRAN_ISOLATION tran_isolation)
#define AU_SELECT
Definition: authenticate.h:69
#define ARG_FILE_LINE
Definition: error_manager.h:44
#define CTV_ATTRIBUTE_NAME
Definition: transform.h:151
void tsc_init(void)
Definition: tsc_timer.c:67
#define ER_NOT_IN_STANDALONE
Definition: error_code.h:942
int dl_initiate_module(const char *module_name)
void er_print_callstack(const char *file_name, const int line_no, const char *fmt,...)
static char boot_Volume_label[PATH_MAX]
Definition: boot_cl.c:160
#define ER_NET_NO_MASTER
Definition: error_code.h:267
int net_client_final(void)
Definition: network_cl.c:3991
#define AU_ENABLE(save)
Definition: authenticate.h:113
INT16 PGLENGTH
int css_windows_startup(void)
Definition: wintcp.c:94
#define DB_HS_UNUSABLE_DATABASES
Definition: connection_cl.h:43
char * boot_get_host_name(void)
Definition: boot_cl.c:5725
void tr_init(void)
#define CT_DBCOLL_CONTRACTIONS_COLUMN
Definition: transform.h:172
const char * get_login_name() const
static int boot_define_ha_apply_info(MOP class_mop)
Definition: boot_cl.c:3416
void css_terminate(bool server_error)
const char * get_db_user() const
int db_disable_modification(void)
Definition: db_admin.c:1001
int boot_shutdown_client(bool is_er_final)
Definition: boot_cl.c:1396
int msgcat_final(void)
#define free_and_init(ptr)
Definition: memory_alloc.h:147
#define CT_DBCOLL_CHARSET_ID_COLUMN
Definition: transform.h:169
#define strlen(s1)
Definition: intl_support.c:43
#define CTV_INDEXKEY_NAME
Definition: transform.h:158
char * prm_get_string_value(PARAM_ID prm_id)
#define ER_OBJ_INVALID_ARGUMENTS
Definition: error_code.h:275
#define TM_TRAN_ASYNC_WS()
static int boot_define_view_stored_procedure_arguments(void)
Definition: boot_cl.c:5250
int(* DEF_CLASS_FUNCTION)(MOP)
Definition: boot_cl.c:119
static int boot_define_meth_file(MOP class_mop)
Definition: boot_cl.c:2456
enum intl_codeset INTL_CODESET
Definition: intl_support.h:190
void css_windows_shutdown(void)
Definition: wintcp.c:140
static int catcls_class_install(void)
Definition: boot_cl.c:4022
bool prm_get_bool_value(PARAM_ID prm_id)
char * au_user_name_dup(void)
int boot_get_server_timezone_checksum(char *timezone_checksum)
static const char * boot_Client_id_unknown_string
Definition: boot_cl.c:144
static const char * boot_Client_no_user_string
Definition: boot_cl.c:143
#define ER_BO_CWD_FAIL
Definition: error_code.h:179
int au_start(void)
#define CT_INDEXKEY_NAME
Definition: transform.h:129
void er_clear(void)
char boot_Host_name[CUB_MAXHOSTNAMELEN]
Definition: boot_cl.c:158
bool catcls_Enable
T_LEVEL sett_strength
int au_add_method_check_authorization(void)
static int boot_add_data_type(MOP class_mop)
Definition: boot_cl.c:2943
int i
Definition: dynamic_load.c:954
#define ERR_CSS_ERROR_FROM_SERVER
Definition: error_code.h:442
#define CTV_STORED_PROC_NAME
Definition: transform.h:161
char * msgcat_message(int cat_id, int set_id, int msg_id)
struct db_object * MOP
Definition: dbtype_def.h:409
#define ERR_CSS_TCP_CANNOT_CONNECT_TO_MASTER
Definition: error_code.h:429
std::string host_name
static int boot_define_attribute(MOP class_mop)
Definition: boot_cl.c:2002
int boot_add_collations(MOP class_mop)
Definition: boot_cl.c:3661
#define CT_DBCHARSET_DEFAULT_COLLATION
Definition: boot_cl.c:3817
int smt_add_attribute(SM_TEMPLATE *template_, const char *name, const char *domain_string, DB_DOMAIN *domain)
#define CT_DBCOLL_COLL_NAME_COLUMN
Definition: transform.h:168
int db_find_or_create_session(const char *db_user, const char *program_name)
Definition: db_admin.c:2885
#define SERVER_SESSION_KEY_SIZE
#define NULL_VOLID
TRAN_STATE
Definition: log_comm.h:36
#define DB_NUMERIC_BUF_SIZE
Definition: dbtype_def.h:573
char coll_name[COLL_NAME_SIZE]
void area_final(void)
Definition: area_alloc.c:119
int db_make_int(DB_VALUE *value, const int num)
int db_get_max_num_delayed_hosts_lookup(void)
Definition: db_admin.c:534
int db_revoke(MOP user, MOP class_mop, AU_TYPE auth)
Definition: db_admin.c:1821
static bool boot_Is_client_all_final
Definition: boot_cl.c:161
MOP sm_find_class(const char *name)
enum ha_server_state HA_SERVER_STATE
Definition: boot.h:126
#define ER_BO_CANNOT_ACCESS_MESSAGE_CATALOG
Definition: error_code.h:183
int smt_set_attribute_default(SM_TEMPLATE *template_, const char *name, int class_attribute, DB_VALUE *proposed_value, DB_DEFAULT_EXPR *default_expr)
int lang_check_coll_compat(const LANG_COLL_COMPAT *coll_array, const int coll_cnt, const char *client_text, const char *server_text)
#define LANG_SYS_CODESET
static int boot_define_index_key(MOP class_mop)
Definition: boot_cl.c:2693
const char * au_user_name(void)
#define CUB_MAXHOSTNAMELEN
Definition: porting.h:379
void sm_mark_system_classes(void)
DB_VALUE * default_value
Definition: esql_cli.c:348
int tran_wait_server_active_trans(void)
void db_set_host_status(char *hostname, int status)
Definition: db_admin.c:649
int smt_add_class_method(SM_TEMPLATE *template_, const char *name, const char *function)
#define CTV_PARTITION_NAME
Definition: transform.h:163
char * db_full_name
Definition: boot.h:138
#define MAX_NUM_DB_HOSTS
#define DB_CONNECT_ORDER_RANDOM
Definition: connection_cl.h:34
#define LOB_PATH_DEFAULT_PREFIX
Definition: boot.h:156
void sm_init(OID *rootclass_oid, HFID *rootclass_hfid)
void au_init(void)
std::string login_name
#define INTL_CODESET_MULT(codeset)
Definition: intl_support.h:77
bool er_is_initialized(void)
#define ER_TZ_LOAD_ERROR
Definition: error_code.h:1487
static int boot_define_stored_procedure_arguments(MOP class_mop)
Definition: boot_cl.c:3150
#define CTV_VCLASS_NAME
Definition: transform.h:150
static char boot_Log_path_buf[PATH_MAX]
Definition: boot_cl.c:148
static int boot_define_serial(MOP class_mop)
Definition: boot_cl.c:3230
void cfg_free_directory(DB_INFO *databases)
#define PATH_SEPARATOR
Definition: porting.h:347
void tz_unload(void)
Definition: tz_support.c:381
#define GETHOSTNAME(p, l)
Definition: porting.h:381
int boot_get_server_locales(LANG_COLL_COMPAT **server_collations, LANG_LOCALE_COMPAT **server_locales, int *server_coll_cnt, int *server_locales_cnt)
ES_TYPE es_get_type(const char *uri)
Definition: es_common.c:43
#define CT_DBCHARSET_CHAR_SIZE
Definition: boot_cl.c:3818
int db_set_page_size(PGLENGTH io_page_size, PGLENGTH log_page_size)
int db_add_constraint(MOP classmop, DB_CONSTRAINT_TYPE constraint_type, const char *constraint_name, const char **att_names, int class_attributes)
Definition: db_class.c:1777
int intl_identifier_upper(const char *src, char *dst)
#define ER_ES_NO_LOB_PATH
Definition: error_code.h:1274
#define TM_TRAN_ISOLATION()
int boot_initialize_server(const BOOT_CLIENT_CREDENTIAL *client_credential, BOOT_DB_PATH_INFO *db_path_info, bool db_overwrite, const char *file_addmore_vols, DKNPAGES db_npages, PGLENGTH db_desired_pagesize, DKNPAGES log_npages, PGLENGTH db_desired_log_page_size, OID *rootclass_oid, HFID *rootclass_hfid, int client_lock_wait, TRAN_ISOLATION client_isolation)
const char * get_db_name() const
int basename_r(const char *path, char *pathbuf, size_t buflen)
Definition: porting.c:1082
char * log_path
Definition: boot.h:106
void boot_clear_host_connected(void)
Definition: boot_cl.c:5717
DB_INFO * cfg_new_db(const char *name, const char *path, const char *logpath, const char *lobpath, const char **hosts)
int sm_update_class(SM_TEMPLATE *template_, MOP *classmop)
VOLID boot_User_volid
Definition: boot_cl.c:153
#define ER_BO_CONNECT_FAILED
Definition: error_code.h:821
#define CT_CHARSET_NAME
Definition: transform.h:144