CUBRID Engine  latest
compactdb_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 #include "config.h"
21 
22 #include <stdio.h>
23 #include <errno.h>
24 #include <string.h>
25 #include <assert.h>
26 
27 #include "porting.h"
28 #include "dbtype.h"
29 #include "load_object.h"
30 #include "db.h"
31 #include "locator_cl.h"
32 #include "schema_manager.h"
33 #include "object_accessor.h"
34 #include "set_object.h"
35 #include "message_catalog.h"
36 #include "network_interface_cl.h"
37 #include "server_interface.h"
38 #include "system_parameter.h"
39 #include "utility.h"
40 #include "authenticate.h"
41 #include "transaction_cl.h"
42 #include "execute_schema.h"
43 #include "object_primitive.h"
44 
45 #define COMPACT_MIN_PAGES 1
46 #define COMPACT_MAX_PAGES 20
47 
48 #define COMPACT_INSTANCE_MIN_LOCK_TIMEOUT 1
49 #define COMPACT_INSTANCE_MAX_LOCK_TIMEOUT 10
50 
51 #define COMPACT_CLASS_MIN_LOCK_TIMEOUT 1
52 #define COMPACT_CLASS_MAX_LOCK_TIMEOUT 10
53 
54 static int is_not_system_class (MOBJ class_);
55 static int do_reclaim_addresses (OID * const *class_oids, const int num_class_oids,
56  int *const num_classes_fully_processed, const bool verbose,
57  const int class_lock_timeout);
58 static int do_reclaim_class_addresses (const OID class_oid, char **clas_name, bool * const any_class_can_be_referenced,
59  bool * const correctly_processed, bool * const addresses_reclaimed,
60  int *const error_while_processing);
61 static int class_instances_can_be_referenced (MOP mop, MOP parent_mop, bool * const class_can_be_referenced,
62  bool * const any_class_can_be_referenced, MOP * const all_mops,
63  const int num_mops);
64 static int class_referenced_by_class (MOP referenced_mop, MOP parent_mop, MOP referring_mop,
65  bool * const class_can_be_referenced, bool * const any_class_can_be_referenced);
66 static int class_referenced_by_attributes (MOP referenced_class, MOP parent_mop, SM_ATTRIBUTE * const attributes_list,
67  bool * const class_can_be_referenced,
68  bool * const any_class_can_be_referenced);
69 static void class_referenced_by_domain (MOP referenced_class, TP_DOMAIN * const domain,
70  bool * const class_can_be_referenced, bool * const any_class_can_be_referenced);
71 extern int get_class_mops (char **class_names, int num_class, MOP ** class_list, int *num_class_list);
72 extern int get_class_mops_from_file (const char *input_filename, MOP ** class_list, int *num_class_mops);
73 
74 
75 /*
76  * compact_usage() - print an usage of the compactdb-utility
77  * return: void
78  * exec_name(in): a name of this application
79  */
80 static void
81 compactdb_usage (const char *argv0)
82 {
83  const char *exec_name;
84 
85  exec_name = basename ((char *) argv0);
88 }
89 
90 /*
91  * find_oid - search an oid in a list of oids
92  * return: the index of the oid on success, -1 otherwise
93  * oid(in): the searched oid
94  * oids_list(in): the list where oid is searched
95  * num_class_mops(in): the length of oids_list
96  */
97 static int
98 find_oid (OID * oid, OID ** oids_list, int num_oids)
99 {
100  int i;
101  if (oid == NULL || oids_list == NULL || num_oids <= 0)
102  {
103  return -1;
104  }
105 
106  for (i = 0; i < num_oids; i++)
107  {
108  if (oids_list[i] == NULL)
109  {
110  continue;
111  }
112 
113  if (OID_EQ (oid, oids_list[i]))
114  {
115  return i;
116  }
117  }
118 
119  return -1;
120 }
121 
122 /*
123  * show_statistics - show the statistics for specified class oids
124  * return:
125  * class_oid(in) : class oid
126  * unlocked_class(in) : true if the class was not locked
127  * valid_class(in): true if the class was valid
128  * processed_class(in): true if the class was processed
129  * total_objects(in): total class objects
130  * failed_objects(in): failed class objects
131  * modified_objects(in): modified class objects
132  * big_objects(in): big class objects
133  * delete_old_repr_flag: delete old representation flag
134  * old_repr_deleted(in): old class representations removed from catalog
135  */
136 static void
137 show_statistics (OID * class_oid, bool unlocked_class, bool valid_class, bool processed_class, int total_objects,
138  int failed_objects, int modified_objects, int big_objects, bool delete_old_repr_flag,
139  bool old_repr_deleted)
140 {
141  MOP class_mop = NULL;
142  char *temp_class_name;
143 
144  class_mop = db_object (class_oid);
145  if (class_mop == NULL)
146  {
148  return;
149  }
150 
151  temp_class_name = (char *) db_get_class_name (class_mop);
152  if (temp_class_name == NULL || strlen (temp_class_name) == 0)
153  {
155  }
156  else
157  {
159  }
160 
161  if (!valid_class)
162  {
164 
165  return;
166  }
167 
168  if (!processed_class)
169  {
171 
172  }
173 
174  if (!unlocked_class)
175  {
177  }
178 
180 
182  failed_objects);
183 
185  modified_objects);
186 
188 
189  if (delete_old_repr_flag)
190  {
191  if (old_repr_deleted)
192  {
194  }
195  else
196  {
198  }
199  }
200 }
201 
202 /*
203  * get_name_from_class_oid - get the name of the class from class oid
204  * return: the name of the class
205  * class_oid(in) : class oid
206  */
207 static char *
209 {
210  MOP class_mop = NULL;
211  char *temp_class_name;
212  char *result;
213 
214  if (!class_oid)
215  {
216  return NULL;
217  }
218 
219  class_mop = db_object (class_oid);
220  if (class_mop == NULL)
221  {
222  return NULL;
223  }
224 
225  temp_class_name = (char *) db_get_class_name (class_mop);
226  if (temp_class_name == NULL)
227  {
228  return NULL;
229  }
230 
231  result = (char *) malloc (sizeof (char) * (strlen (temp_class_name) + 1));
232  if (result == NULL)
233  {
234  return NULL;
235  }
236 
237  strcpy (result, temp_class_name);
238 
239  return result;
240 }
241 
242 /*
243  * compactdb_start - Compact classes
244  * return: error code
245  * verbose_flag(in):
246  * delete_old_repr_flag(in): delete old class representations from catalog
247  * input_filename(in): classes file name
248  * input_class_names(in): classes list
249  * input_class_length(in): classes list length
250  * max_processed_space(in): maximum space to process for one iteration
251  */
252 static int
253 compactdb_start (bool verbose_flag, bool delete_old_repr_flag, char *input_filename, char **input_class_names,
254  int input_class_length, int max_processed_space, int instance_lock_timeout, int class_lock_timeout,
255  DB_TRAN_ISOLATION tran_isolation)
256 {
257  int status = NO_ERROR;
258  OID **class_oids = NULL;
259  int i, num_classes = 0;
261  OID last_processed_class_oid, last_processed_oid;
262  int *total_objects = NULL, *iteration_total_objects = NULL;
263  int *failed_objects = NULL, *iteration_failed_objects = NULL;
264  int *modified_objects = NULL, *iteration_modified_objects = NULL;
265  char *incomplete_processing = NULL;
266  int *big_objects = NULL, *iteration_big_objects = NULL;
267  int *initial_last_repr = NULL;
268  MOP *class_mops = NULL;
269  int last_completed_class_index, temp_index;
270  int num_class_mops = 0;
271  SM_CLASS *class_ptr = NULL;
272  int num_classes_fully_compacted = 0;
273  char *class_name = NULL;
274  MOP *processed_class_mops = NULL;
275 
276  if (input_filename && input_class_names && input_class_length > 0)
277  {
278  return ER_FAILED;
279  }
280 
281  status = compact_db_start ();
282  if (status != NO_ERROR)
283  {
284  if (status == ER_COMPACTDB_ALREADY_STARTED)
285  {
287  }
288 
289  return ER_FAILED;
290  }
291 
292  tran_reset_wait_times (class_lock_timeout);
293 
294  if (input_class_names && input_class_length > 0)
295  {
296  status = get_class_mops (input_class_names, input_class_length, &class_mops, &num_class_mops);
297  if (status != NO_ERROR)
298  {
299  goto error;
300  }
301  }
302  else if (input_filename)
303  {
304  status = get_class_mops_from_file (input_filename, &class_mops, &num_class_mops);
305  if (status != NO_ERROR)
306  {
307  goto error;
308  }
309  }
310  else
311  {
313  if (!class_table)
314  {
315  status = ER_FAILED;
316  goto error;
317  }
318 
319  class_mops = class_table->mops;
320  num_class_mops = class_table->num;
321  }
322 
323  class_oids = (OID **) malloc (DB_SIZEOF (OID *) * (num_class_mops));
324  if (class_oids == NULL)
325  {
326  status = ER_FAILED;
327  goto error;
328  }
329 
330  for (i = 0; i < num_class_mops; i++)
331  {
332  class_oids[i] = NULL;
333  }
334 
335  processed_class_mops = (DB_OBJECT **) malloc (DB_SIZEOF (DB_OBJECT *) * (num_class_mops));
336  if (processed_class_mops == NULL)
337  {
338  status = ER_FAILED;
339  goto error;
340  }
341 
342  for (i = 0; i < num_class_mops; i++)
343  {
344  processed_class_mops[i] = NULL;
345  }
346 
347  num_classes = 0;
348  for (i = 0; i < num_class_mops; i++)
349  {
350  ws_find (class_mops[i], (MOBJ *) (&class_ptr));
351  if (class_ptr == NULL)
352  {
353  continue;
354  }
355 
356  if (class_ptr->class_type != SM_CLASS_CT)
357  {
358  continue;
359  }
360 
361  class_oids[num_classes] = ws_oid (class_mops[i]);
362  if (class_oids[num_classes] != NULL)
363  {
364  processed_class_mops[num_classes] = class_mops[i];
365  num_classes++;
366  }
367  }
368 
369  if (num_classes == 0)
370  {
372  goto error;
373  }
374 
375  total_objects = (int *) malloc (num_classes * sizeof (int));
376  if (total_objects == NULL)
377  {
378  status = ER_FAILED;
379  goto error;
380  }
381 
382  iteration_total_objects = (int *) malloc (num_classes * sizeof (int));
383  if (iteration_total_objects == NULL)
384  {
385  status = ER_FAILED;
386  goto error;
387  }
388 
389  failed_objects = (int *) malloc (num_classes * sizeof (int));
390  if (failed_objects == NULL)
391  {
392  status = ER_FAILED;
393  goto error;
394  }
395 
396  iteration_failed_objects = (int *) malloc (num_classes * sizeof (int));
397  if (iteration_failed_objects == NULL)
398  {
399  status = ER_FAILED;
400  goto error;
401  }
402 
403  modified_objects = (int *) malloc (num_classes * sizeof (int));
404  if (modified_objects == NULL)
405  {
406  status = ER_FAILED;
407  goto error;
408  }
409 
410  iteration_modified_objects = (int *) malloc (num_classes * sizeof (int));
411  if (iteration_modified_objects == NULL)
412  {
413  status = ER_FAILED;
414  goto error;
415  }
416 
417  big_objects = (int *) malloc (num_classes * sizeof (int));
418  if (big_objects == NULL)
419  {
420  status = ER_FAILED;
421  goto error;
422  }
423 
424  iteration_big_objects = (int *) malloc (num_classes * sizeof (int));
425  if (iteration_big_objects == NULL)
426  {
427  status = ER_FAILED;
428  goto error;
429  }
430 
431  initial_last_repr = (int *) malloc (num_classes * sizeof (int));
432  if (initial_last_repr == NULL)
433  {
434  status = ER_FAILED;
435  goto error;
436  }
437 
438  incomplete_processing = (char *) malloc (num_classes * sizeof (char));
439  if (incomplete_processing == NULL)
440  {
441  status = ER_FAILED;
442  goto error;
443  }
444 
445  for (i = 0; i < num_classes; i++)
446  {
447  total_objects[i] = 0;
448  failed_objects[i] = 0;
449  modified_objects[i] = 0;
450  big_objects[i] = 0;
451  incomplete_processing[i] = 0;
452  initial_last_repr[i] = NULL_REPRID;
453  }
454 
455  for (i = 0; i < num_class_mops; i++)
456  {
457  status = locator_flush_all_instances (class_mops[i], DECACHE);
458  if (status != NO_ERROR)
459  {
460  goto error;
461  }
462  }
463 
464  status = db_commit_transaction ();
465  if (status != NO_ERROR)
466  {
467  goto error;
468  }
469 
470  COPY_OID (&last_processed_class_oid, class_oids[0]);
471  OID_SET_NULL (&last_processed_oid);
472  temp_index = -1;
473  last_completed_class_index = -1;
474 
475  if (verbose_flag)
476  {
478  }
479 
480  while (true)
481  {
482  status = db_set_isolation (tran_isolation);
483  if (status != NO_ERROR)
484  {
485  if (verbose_flag)
486  {
487  printf (msgcat_message
489  }
490 
491  status = ER_FAILED;
492  goto error;
493  }
494 
495  status =
496  boot_compact_classes (class_oids, num_classes, max_processed_space, instance_lock_timeout, class_lock_timeout,
497  delete_old_repr_flag, &last_processed_class_oid, &last_processed_oid,
498  iteration_total_objects, iteration_failed_objects, iteration_modified_objects,
499  iteration_big_objects, initial_last_repr);
500 
501  if (OID_ISNULL (&last_processed_class_oid))
502  {
503  temp_index = num_classes;
504  }
505  else
506  {
507  temp_index = find_oid (&last_processed_class_oid, class_oids, num_classes);
508  }
509 
510  switch (status)
511  {
512  case NO_ERROR:
513  if (delete_old_repr_flag && temp_index - 1 > last_completed_class_index)
514  {
515  for (i = last_completed_class_index + 1; i < temp_index; i++)
516  {
517  if (initial_last_repr[i] == COMPACTDB_REPR_DELETED)
518  {
519  sm_destroy_representations (processed_class_mops[i]);
520  }
521  }
522  }
523 
524  status = db_commit_transaction ();
525  if (status != NO_ERROR)
526  {
527  goto error;
528  }
529  break;
530 
532  status = tran_abort_only_client (false);
533  if (status != NO_ERROR)
534  {
535  goto error;
536  }
537  break;
538 
539  case ER_FAILED:
540  status = db_abort_transaction ();
541  if (status != NO_ERROR)
542  {
543  goto error;
544  }
545  break;
546 
547  default:
549  status = ER_FAILED;
550  goto error;
551  }
552 
553  for (i = 0; i < num_classes; i++)
554  {
555  if (iteration_total_objects[i] >= 0)
556  {
557  total_objects[i] += iteration_total_objects[i];
558  failed_objects[i] += iteration_failed_objects[i];
559  modified_objects[i] += iteration_modified_objects[i];
560  big_objects[i] += iteration_big_objects[i];
561  }
562  else
563  {
564  incomplete_processing[i] = iteration_total_objects[i];
565  }
566  }
567 
568  if (temp_index - 1 > last_completed_class_index)
569  {
570  for (i = last_completed_class_index + 1; i < temp_index; i++)
571  {
572  status = db_set_isolation (tran_isolation);
573  if (status != NO_ERROR)
574  {
575  if (verbose_flag)
576  {
577  printf (msgcat_message
579  }
580 
581  status = ER_FAILED;
582  goto error;
583  }
584 
585  tran_reset_wait_times (class_lock_timeout);
586 
587  show_statistics (class_oids[i], incomplete_processing[i] != COMPACTDB_LOCKED_CLASS,
588  incomplete_processing[i] != COMPACTDB_INVALID_CLASS,
589  incomplete_processing[i] != COMPACTDB_UNPROCESSED_CLASS, total_objects[i],
590  failed_objects[i], modified_objects[i], big_objects[i], delete_old_repr_flag,
591  initial_last_repr[i] == COMPACTDB_REPR_DELETED);
592 
594  }
595 
596  last_completed_class_index = temp_index - 1;
597  }
598 
599  if (OID_ISNULL (&last_processed_class_oid))
600  {
601  break;
602  }
603  }
604 
605  if (verbose_flag)
606  {
608  }
609  status = do_reclaim_addresses (class_oids, num_classes, &num_classes_fully_compacted, verbose_flag,
610  class_lock_timeout);
611  if (status != NO_ERROR)
612  {
613  goto error;
614  }
615 
616  if (verbose_flag)
617  {
619  }
620 
621  for (i = 0; i < num_classes; i++)
622  {
623  status = db_set_isolation (tran_isolation);
624  if (status != NO_ERROR)
625  {
626  if (verbose_flag)
627  {
628  printf (msgcat_message
630  }
631 
632  status = ER_FAILED;
633  goto error;
634  }
635 
636  tran_reset_wait_times (class_lock_timeout);
637 
638  status = boot_heap_compact (class_oids[i]);
639  switch (status)
640  {
641  case NO_ERROR:
642  status = db_commit_transaction ();
643  if (status != NO_ERROR)
644  {
645  goto error;
646  }
647  break;
648 
650  status = tran_abort_only_client (false);
651  if (status != NO_ERROR)
652  {
653  goto error;
654  }
655  break;
656 
657  default:
658  status = db_abort_transaction ();
659  if (status != NO_ERROR)
660  {
661  goto error;
662  }
663  break;
664  }
665 
666  class_name = get_name_from_class_oid (class_oids[i]);
667  if (class_name == NULL)
668  {
670  }
671  else
672  {
674  }
675 
676  if (status != NO_ERROR)
677  {
679  }
680  else
681  {
682  printf (msgcat_message
684  }
685 
686  if (class_name)
687  {
688  free (class_name);
689  class_name = NULL;
690  }
691 
693  }
694 
695 error:
696  if (class_oids)
697  {
698  free_and_init (class_oids);
699  }
700 
701  if (processed_class_mops)
702  {
703  free_and_init (processed_class_mops);
704  }
705 
706  if (total_objects)
707  {
708  free_and_init (total_objects);
709  }
710 
711  if (iteration_total_objects)
712  {
713  free_and_init (iteration_total_objects);
714  }
715 
716  if (failed_objects)
717  {
718  free_and_init (failed_objects);
719  }
720 
721  if (iteration_failed_objects)
722  {
723  free_and_init (iteration_failed_objects);
724  }
725 
726  if (modified_objects)
727  {
728  free_and_init (modified_objects);
729  }
730 
731  if (iteration_modified_objects)
732  {
733  free_and_init (iteration_modified_objects);
734  }
735 
736  if (big_objects)
737  {
738  free_and_init (big_objects);
739  }
740 
741  if (iteration_big_objects)
742  {
743  free_and_init (iteration_big_objects);
744  }
745 
746  if (initial_last_repr)
747  {
748  free_and_init (initial_last_repr);
749  }
750 
751  if (incomplete_processing)
752  {
753  free_and_init (incomplete_processing);
754  }
755 
756  if (class_table)
757  {
758  locator_free_list_mops (class_table);
759  }
760  else
761  {
762  if (class_mops)
763  {
764  for (i = 0; i < num_class_mops; i++)
765  {
766  class_mops[i] = NULL;
767  }
768 
769  free_and_init (class_mops);
770  }
771  }
772 
773  compact_db_stop ();
774 
775  return status;
776 }
777 
778 /*
779  * compactdb - compactdb main routine
780  * return: 0 if successful, error code otherwise
781  * arg(in): a map of command line arguments
782  */
783 int
785 {
786  UTIL_ARG_MAP *arg_map = arg->arg_map;
787  const char *exec_name = arg->command_name;
788  int error;
789  int i, status = 0;
790  const char *database_name;
791  bool verbose_flag = 0, delete_old_repr_flag = 0, standby_compactdb_flag = 0;
792  char *input_filename = NULL;
793  int maximum_processed_space = 10 * DB_PAGESIZE, pages;
794  int instance_lock_timeout, class_lock_timeout;
795  char **tables = NULL;
796  int table_size = 0;
797 
798  database_name = utility_get_option_string_value (arg_map, OPTION_STRING_TABLE, 0);
799  verbose_flag = utility_get_option_bool_value (arg_map, COMPACT_VERBOSE_S);
800  standby_compactdb_flag = utility_get_option_bool_value (arg_map, COMPACT_STANDBY_CS_MODE_S);
801  input_filename = utility_get_option_string_value (arg_map, COMPACT_INPUT_CLASS_FILE_S, 0);
802 
804  if (pages < COMPACT_MIN_PAGES || pages > COMPACT_MAX_PAGES)
805  {
809  COMPACT_MIN_PAGES, COMPACT_MAX_PAGES);
810 
811  return ER_GENERIC_ERROR;
812  }
813 
814  if (database_name == NULL || database_name[0] == '\0' || utility_get_option_string_table_size (arg_map) < 1)
815  {
816  compactdb_usage (arg->argv0);
817  return ER_GENERIC_ERROR;
818  }
819 
820  table_size = utility_get_option_string_table_size (arg_map);
821  if (table_size > 1 && input_filename != NULL)
822  {
823  compactdb_usage (arg->argv0);
824  return ER_GENERIC_ERROR;
825  }
826 
827  instance_lock_timeout = utility_get_option_int_value (arg_map, COMPACT_INSTANCE_LOCK_TIMEOUT_S);
828  if (instance_lock_timeout < COMPACT_INSTANCE_MIN_LOCK_TIMEOUT
829  || instance_lock_timeout > COMPACT_INSTANCE_MAX_LOCK_TIMEOUT)
830  {
832 
837 
838  return ER_GENERIC_ERROR;
839  }
840 
841  class_lock_timeout = utility_get_option_int_value (arg_map, COMPACT_CLASS_LOCK_TIMEOUT_S);
842  if (class_lock_timeout < COMPACT_CLASS_MIN_LOCK_TIMEOUT || class_lock_timeout > COMPACT_CLASS_MAX_LOCK_TIMEOUT)
843  {
845 
849  COMPACT_CLASS_MAX_LOCK_TIMEOUT);
850 
851  return ER_GENERIC_ERROR;
852  }
853 
854  delete_old_repr_flag = utility_get_option_bool_value (arg_map, COMPACT_DELETE_OLD_REPR_S);
855 
856  maximum_processed_space = pages * DB_PAGESIZE;
857 
858  if (table_size > 1)
859  {
860  tables = (char **) malloc (sizeof (char *) * (table_size - 1));
861  if (tables == NULL)
862  {
865  return ER_GENERIC_ERROR;
866  }
867 
868  for (i = 1; i < table_size; i++)
869  {
870  tables[i - 1] = utility_get_option_string_value (arg_map, OPTION_STRING_TABLE, i);
871  }
872  }
873 
875 
877 
878  if (standby_compactdb_flag)
879  {
881  }
882  else
883  {
885  }
886 
887  if ((error = db_login ("DBA", NULL)) || (error = db_restart (arg->argv0, TRUE, database_name)))
888  {
889  PRINT_AND_LOG_ERR_MSG ("%s: %s.\n", exec_name, db_error_string (3));
890  status = error;
891  }
892  else
893  {
895 
896  if (status == NO_ERROR)
897  {
898  if (class_lock_timeout > 0)
899  {
900  class_lock_timeout = class_lock_timeout * 1000;
901  }
902  if (instance_lock_timeout > 0)
903  {
904  instance_lock_timeout = instance_lock_timeout * 1000;
905  }
906  status =
907  compactdb_start (verbose_flag, delete_old_repr_flag, input_filename, tables, table_size - 1,
908  maximum_processed_space, instance_lock_timeout, class_lock_timeout,
910 
911  if (status == ER_FAILED)
912  {
915  }
916  }
917 
918  db_shutdown ();
919  }
920 
921  if (tables)
922  {
923  free (tables);
924  tables = NULL;
925  }
926  return status;
927 }
928 
929 static int
930 do_reclaim_addresses (OID * const *class_oids, const int num_class_oids, int *const num_classes_fully_processed,
931  const bool verbose, const int class_lock_timeout)
932 {
933  bool any_class_can_be_referenced = false;
934  int i = 0;
935  int error_code = NO_ERROR;
936 
937  assert (num_class_oids >= 0);
938  assert (class_oids != NULL);
939 
940  assert (num_classes_fully_processed != NULL);
941  *num_classes_fully_processed = 0;
942 
943  tran_reset_wait_times (class_lock_timeout);
944 
945  for (i = 0; i < num_class_oids; ++i)
946  {
947  char *class_name = NULL;
948  int error_while_processing = NO_ERROR;
949  bool correctly_processed = false;
950  bool addresses_reclaimed = false;
951 
952  error_code =
953  do_reclaim_class_addresses (*class_oids[i], &class_name, &any_class_can_be_referenced, &correctly_processed,
954  &addresses_reclaimed, &error_while_processing);
955  if (correctly_processed)
956  {
957  assert (error_code == NO_ERROR);
958  assert (error_while_processing == NO_ERROR);
959  (*num_classes_fully_processed)++;
960  }
961 
962  if (verbose)
963  {
964  if (class_name == NULL || strlen (class_name) == 0)
965  {
966  printf (msgcat_message
968  }
969  else
970  {
972  class_name);
973  }
974  if (correctly_processed)
975  {
976  if (addresses_reclaimed)
977  {
979  }
980  else
981  {
982  printf (msgcat_message
984  }
985  }
986  else
987  {
989  }
990  }
991 
992  if (class_name != NULL)
993  {
994  free_and_init (class_name);
995  }
996  if (error_code != NO_ERROR)
997  {
998  goto error_exit;
999  }
1000  }
1001 
1002  return error_code;
1003 
1004 error_exit:
1005  return error_code;
1006 }
1007 
1008 static int
1010 {
1011  return !(((SM_CLASS *) class_)->flags & SM_CLASSFLAG_SYSTEM);
1012 }
1013 
1014 static int
1015 do_reclaim_class_addresses (const OID class_oid, char **class_name, bool * const any_class_can_be_referenced,
1016  bool * const correctly_processed, bool * const addresses_reclaimed,
1017  int *const error_while_processing)
1018 {
1019  DB_OBJECT *class_mop = NULL;
1020  DB_OBJECT *parent_mop = NULL;
1021  SM_CLASS *class_ = NULL;
1022  SM_CLASS *parent_class_ = NULL;
1023  int error_code = NO_ERROR;
1024  int skipped_error_code = NO_ERROR;
1025  bool do_abort_on_error = true;
1026  bool can_reclaim_addresses = true;
1027  LIST_MOPS *lmops = NULL;
1028  HFID *hfid = NULL;
1029  int is_class = 0;
1030 
1031  assert (!OID_ISNULL (&class_oid));
1032  assert (any_class_can_be_referenced != NULL);
1033  assert (correctly_processed != NULL);
1034  assert (addresses_reclaimed != NULL);
1035  assert (error_while_processing != NULL);
1036  assert (class_name != NULL);
1037 
1038  *correctly_processed = false;
1039  *addresses_reclaimed = false;
1040  *error_while_processing = NO_ERROR;
1041 
1042  error_code = db_commit_transaction ();
1043  if (error_code != NO_ERROR)
1044  {
1045  goto error_exit;
1046  }
1047 
1048  error_code = db_set_isolation (TRAN_READ_COMMITTED);
1049  if (error_code != NO_ERROR)
1050  {
1051  goto error_exit;
1052  }
1053 
1054  /*
1055  * Trying to force an ISX_LOCK on the root class. It somehow happens that
1056  * we are left with an IX_LOCK in the end...
1057  */
1059  {
1060  error_code = ER_FAILED;
1061  goto error_exit;
1062  }
1063 
1064  class_mop = db_object ((OID *) (&class_oid));
1065  if (class_mop == NULL)
1066  {
1067  skipped_error_code = ER_FAILED;
1068  goto error_exit;
1069  }
1070 
1071  is_class = locator_is_class (class_mop, DB_FETCH_WRITE);
1072  if (is_class < 0)
1073  {
1074  skipped_error_code = is_class;
1075  goto error_exit;
1076  }
1077  if (!is_class)
1078  {
1079  skipped_error_code = ER_FAILED;
1080  goto error_exit;
1081  }
1082 
1083  /*
1084  * We need an SCH-M lock on the class to process as early as possible so that
1085  * other transactions don't add references to it in the schema.
1086  */
1087  class_ = (SM_CLASS *) locator_fetch_class (class_mop, DB_FETCH_WRITE);
1088  if (class_ == NULL)
1089  {
1090  assert (er_errid () != NO_ERROR);
1091  skipped_error_code = er_errid ();
1092  goto error_exit;
1093  }
1094 
1095  assert (*class_name == NULL);
1096  *class_name = strdup (sm_ch_name ((MOBJ) class_));
1097  if (*class_name == NULL)
1098  {
1099  error_code = ER_FAILED;
1100  goto error_exit;
1101  }
1102 
1103  if (class_->partition != NULL)
1104  {
1105  /*
1106  * If the current class is a partition of a partitioned class we need
1107  * to get its parent partitioned table and check for references to its
1108  * parent too. If table tbl has partition tbl__p__p0, a reference to tbl
1109  * can point to tbl__p__p0 instances too.
1110  */
1111  skipped_error_code = do_get_partition_parent (class_mop, &parent_mop);
1112  if (skipped_error_code != NO_ERROR)
1113  {
1114  goto error_exit;
1115  }
1116  if (parent_mop != NULL)
1117  {
1118  parent_class_ = (SM_CLASS *) locator_fetch_class (parent_mop, DB_FETCH_WRITE);
1119  if (parent_class_ == NULL)
1120  {
1121  assert (er_errid () != NO_ERROR);
1122  skipped_error_code = er_errid ();
1123  goto error_exit;
1124  }
1125  }
1126  }
1127 
1128  skipped_error_code = locator_flush_all_instances (class_mop, DECACHE);
1129  if (skipped_error_code != NO_ERROR)
1130  {
1131  goto error_exit;
1132  }
1133 
1134  if (class_->class_type != SM_CLASS_CT)
1135  {
1136  can_reclaim_addresses = false;
1137  }
1138  else
1139  {
1140  hfid = sm_ch_heap ((MOBJ) class_);
1141  if (HFID_IS_NULL (hfid))
1142  {
1143  can_reclaim_addresses = false;
1144  }
1145  }
1146 
1147  if (class_->flags & SM_CLASSFLAG_SYSTEM)
1148  {
1149  /*
1150  * It should be safe to process system classes also but we skip them for
1151  * now. Please note that class_instances_can_be_referenced () does not
1152  * check for references from system classes.
1153  * If this is ever changed please consider the impact of reusing system
1154  * objects OIDs.
1155  */
1156  can_reclaim_addresses = false;
1157  }
1158  else if (class_->flags & SM_CLASSFLAG_REUSE_OID)
1159  {
1160  /*
1161  * Nobody should be able to hold references to reusable OID tables so it
1162  * should be safe to reclaim their OIDs and pages no matter what.
1163  */
1164  can_reclaim_addresses = true;
1165  }
1166  else
1167  {
1168  if (*any_class_can_be_referenced)
1169  {
1170  /*
1171  * Some class attribute has OBJECT or SET OF OBJECT as the domain.
1172  * This means it can point to instances of any class so we're not
1173  * safe reclaiming OIDs.
1174  */
1175  can_reclaim_addresses = false;
1176  }
1177  else
1178  {
1179  bool class_can_be_referenced = false;
1180 
1181  /*
1182  * IS_LOCK should be enough for what we need but
1183  * locator_get_all_class_mops seems to lock the instances with the
1184  * lock that it has on their class. So we end up with IX_LOCK on all
1185  * classes in the schema...
1186  */
1187 
1189  if (lmops == NULL)
1190  {
1191  skipped_error_code = ER_FAILED;
1192  goto error_exit;
1193  }
1194 
1195  skipped_error_code =
1196  class_instances_can_be_referenced (class_mop, parent_mop, &class_can_be_referenced,
1197  any_class_can_be_referenced, lmops->mops, lmops->num);
1198  if (skipped_error_code != NO_ERROR)
1199  {
1200  goto error_exit;
1201  }
1202  /*
1203  * If some attribute has OBJECT or the current class as its domain
1204  * then it's not safe to reclaim the OIDs as some of the references
1205  * might point to deleted objects. We skipped the system classes as
1206  * they should not point to any instances of the non-system classes.
1207  */
1208  can_reclaim_addresses = !class_can_be_referenced && !*any_class_can_be_referenced;
1209  if (lmops != NULL)
1210  {
1211  /*
1212  * It should be safe now to release all the locks we hold on the
1213  * schema classes (except for the X_LOCK on the current class).
1214  * However, we don't currently have a way of releasing those
1215  * locks so we're stuck with them till the end of the current
1216  * transaction.
1217  */
1218  locator_free_list_mops (lmops);
1219  lmops = NULL;
1220  }
1221  }
1222  }
1223 
1224  if (can_reclaim_addresses)
1225  {
1226  assert (hfid != NULL && !HFID_IS_NULL (hfid));
1227 
1228  skipped_error_code = heap_reclaim_addresses (hfid);
1229  if (skipped_error_code != NO_ERROR)
1230  {
1231  goto error_exit;
1232  }
1233  *addresses_reclaimed = true;
1234  }
1235 
1236  error_code = db_commit_transaction ();
1237  if (error_code != NO_ERROR)
1238  {
1239  goto error_exit;
1240  }
1241 
1242  assert (error_code == NO_ERROR && skipped_error_code == NO_ERROR);
1243  *correctly_processed = true;
1244  class_mop = NULL;
1245  class_ = NULL;
1246  parent_mop = NULL;
1247  parent_class_ = NULL;
1248  return error_code;
1249 
1250 error_exit:
1251  *error_while_processing = skipped_error_code;
1252  class_mop = NULL;
1253  class_ = NULL;
1254  parent_mop = NULL;
1255  parent_class_ = NULL;
1256  if (lmops != NULL)
1257  {
1258  locator_free_list_mops (lmops);
1259  lmops = NULL;
1260  }
1261  if (do_abort_on_error)
1262  {
1263  int tmp_error_code = NO_ERROR;
1264 
1265  if (skipped_error_code == ER_LK_UNILATERALLY_ABORTED || error_code == ER_LK_UNILATERALLY_ABORTED)
1266  {
1267  tmp_error_code = tran_abort_only_client (false);
1268  }
1269  else
1270  {
1271  tmp_error_code = db_abort_transaction ();
1272  }
1273  if (tmp_error_code != NO_ERROR)
1274  {
1275  if (error_code == NO_ERROR)
1276  {
1277  error_code = tmp_error_code;
1278  }
1279  }
1280  }
1281  if (skipped_error_code == NO_ERROR && error_code == NO_ERROR)
1282  {
1283  error_code = ER_FAILED;
1284  }
1285  return error_code;
1286 }
1287 
1288 static int
1289 class_instances_can_be_referenced (MOP mop, MOP parent_mop, bool * const class_can_be_referenced,
1290  bool * const any_class_can_be_referenced, MOP * const all_mops, const int num_mops)
1291 {
1292  int error_code = NO_ERROR;
1293  int i = 0;
1294 
1295  assert (mop != NULL);
1296  assert (class_can_be_referenced != NULL);
1297  assert (any_class_can_be_referenced != NULL);
1298  assert (all_mops != NULL);
1299  assert (num_mops > 0);
1300 
1301  *class_can_be_referenced = false;
1302 
1303  for (i = 0; i < num_mops; ++i)
1304  {
1305  error_code =
1306  class_referenced_by_class (mop, parent_mop, all_mops[i], class_can_be_referenced, any_class_can_be_referenced);
1307  if (error_code != NO_ERROR)
1308  {
1309  goto error_exit;
1310  }
1311  if (*any_class_can_be_referenced)
1312  {
1313  break;
1314  }
1315  }
1316 
1317  return error_code;
1318 
1319 error_exit:
1320  return error_code;
1321 }
1322 
1323 static int
1324 class_referenced_by_class (MOP referenced_mop, MOP parent_mop, MOP referring_mop, bool * const class_can_be_referenced,
1325  bool * const any_class_can_be_referenced)
1326 {
1327  SM_CLASS *referring_class = NULL;
1328  int error_code = NO_ERROR;
1329  SM_ATTRIBUTE *attributes_list = NULL;
1330 
1331  referring_class = (SM_CLASS *) locator_fetch_class (referring_mop, DB_FETCH_READ);
1332  if (referring_class == NULL)
1333  {
1334  assert (er_errid () != NO_ERROR);
1335  error_code = er_errid ();
1336  goto error_exit;
1337  }
1338 
1339  /*
1340  * System classes should not point to any instances of the non-system
1341  * classes.
1342  */
1343  if (referring_class->flags & SM_CLASSFLAG_SYSTEM)
1344  {
1345  goto end;
1346  }
1347 
1348  attributes_list = referring_class->attributes;
1349  if (referring_class->class_type == SM_CLASS_CT)
1350  {
1351  error_code =
1352  class_referenced_by_attributes (referenced_mop, parent_mop, attributes_list, class_can_be_referenced,
1353  any_class_can_be_referenced);
1354  if (error_code != NO_ERROR)
1355  {
1356  goto error_exit;
1357  }
1358  if (*any_class_can_be_referenced)
1359  {
1360  goto end;
1361  }
1362  }
1363  else
1364  {
1365  /*
1366  * View attributes are not "real" references so we can safely ignore
1367  * them.
1368  */
1369  }
1370 
1371  attributes_list = referring_class->class_attributes;
1372  error_code =
1373  class_referenced_by_attributes (referenced_mop, parent_mop, attributes_list, class_can_be_referenced,
1374  any_class_can_be_referenced);
1375  if (error_code != NO_ERROR)
1376  {
1377  goto error_exit;
1378  }
1379  if (*any_class_can_be_referenced)
1380  {
1381  goto end;
1382  }
1383 
1384  attributes_list = referring_class->shared;
1385  error_code =
1386  class_referenced_by_attributes (referenced_mop, parent_mop, attributes_list, class_can_be_referenced,
1387  any_class_can_be_referenced);
1388  if (error_code != NO_ERROR)
1389  {
1390  goto error_exit;
1391  }
1392  if (*any_class_can_be_referenced)
1393  {
1394  goto end;
1395  }
1396 
1397 end:
1398  return error_code;
1399 
1400 error_exit:
1401  if (error_code == NO_ERROR)
1402  {
1403  error_code = ER_FAILED;
1404  }
1405  return error_code;
1406 }
1407 
1408 static int
1409 class_referenced_by_attributes (MOP referenced_class, MOP parent_mop, SM_ATTRIBUTE * const attributes_list,
1410  bool * const class_can_be_referenced, bool * const any_class_can_be_referenced)
1411 {
1412  SM_ATTRIBUTE *crt_attr = NULL;
1413 
1414  for (crt_attr = attributes_list; crt_attr != NULL; crt_attr = (SM_ATTRIBUTE *) crt_attr->header.next)
1415  {
1416  class_referenced_by_domain (referenced_class, crt_attr->domain, class_can_be_referenced,
1417  any_class_can_be_referenced);
1418  if (*any_class_can_be_referenced)
1419  {
1420  goto end;
1421  }
1422  if (parent_mop != NULL)
1423  {
1424  class_referenced_by_domain (parent_mop, crt_attr->domain, class_can_be_referenced,
1425  any_class_can_be_referenced);
1426  if (*any_class_can_be_referenced)
1427  {
1428  goto end;
1429  }
1430  }
1431  }
1432 
1433 end:
1434  return NO_ERROR;
1435 }
1436 
1437 static void
1438 class_referenced_by_domain (MOP referenced_class, TP_DOMAIN * const domain, bool * const class_can_be_referenced,
1439  bool * const any_class_can_be_referenced)
1440 {
1441  TP_DOMAIN *crt_domain = NULL;
1442 
1443  assert (domain != NULL);
1444 
1445  for (crt_domain = domain; crt_domain != NULL; crt_domain = db_domain_next (crt_domain))
1446  {
1447  const DB_TYPE type = TP_DOMAIN_TYPE (crt_domain);
1448 
1449  if (type == DB_TYPE_OBJECT)
1450  {
1451  DB_OBJECT *class_ = db_domain_class (crt_domain);
1452  if (class_ == NULL)
1453  {
1454  *any_class_can_be_referenced = true;
1455  }
1456  else if (referenced_class == class_ || db_is_subclass (referenced_class, class_) > 0)
1457  {
1458  *class_can_be_referenced = true;
1459  }
1460  else
1461  {
1462  /* Cannot reference instances of the given class. */
1463  }
1464  }
1465  else if (pr_is_set_type (type))
1466  {
1467  class_referenced_by_domain (referenced_class, db_domain_set (crt_domain), class_can_be_referenced,
1468  any_class_can_be_referenced);
1469  }
1470  else
1471  {
1472  /* Cannot reference an object. */
1473  }
1474 
1475  if (*any_class_can_be_referenced)
1476  {
1477  return;
1478  }
1479  }
1480 }
#define ER_LK_UNILATERALLY_ABORTED
Definition: error_code.h:130
SM_ATTRIBUTE * shared
Definition: class_object.h:722
int sm_destroy_representations(MOP op)
#define NO_ERROR
Definition: error_code.h:46
#define COMPACT_DELETE_OLD_REPR_S
Definition: utility.h:1328
#define TRUE
Definition: broker_admin.c:49
static void show_statistics(OID *class_oid, bool unlocked_class, bool valid_class, bool processed_class, int total_objects, int failed_objects, int modified_objects, int big_objects, bool delete_old_repr_flag, bool old_repr_deleted)
Definition: compactdb_cl.c:137
#define COMPACTDB_INVALID_CLASS
void db_set_client_type(int client_type)
Definition: db_admin.c:495
static char * get_name_from_class_oid(OID *class_oid)
Definition: compactdb_cl.c:208
#define PRINT_AND_LOG_ERR_MSG(...)
Definition: util_func.h:49
const char * db_get_class_name(DB_OBJECT *class_)
Definition: db_info.c:608
int sysprm_set_force(const char *pname, const char *pvalue)
#define COMPACT_CLASS_MAX_LOCK_TIMEOUT
Definition: compactdb_cl.c:52
int db_login(const char *name, const char *password)
Definition: db_admin.c:804
DB_OBJECT * db_object(DB_IDENTIFIER *oid)
Definition: db_admin.c:2641
char * MOBJ
Definition: work_space.h:174
#define COMPACT_MIN_PAGES
Definition: compactdb_cl.c:45
DB_TYPE
Definition: dbtype_def.h:670
#define ER_FAILED
Definition: error_code.h:47
#define AU_DISABLE_PASSWORDS
Definition: authenticate.h:140
int compactdb(UTIL_FUNCTION_ARG *arg)
Definition: compactdb_cl.c:784
TP_DOMAIN * domain
Definition: class_object.h:444
#define TRAN_DEFAULT_ISOLATION_LEVEL()
Definition: dbtran_def.h:58
SM_ATTRIBUTE * attributes
Definition: class_object.h:721
DB_DOMAIN * db_domain_next(const DB_DOMAIN *domain)
Definition: db_macro.c:3974
int db_shutdown(void)
Definition: db_admin.c:964
OID * ws_oid(MOP mop)
Definition: work_space.c:2884
struct sm_component * next
Definition: class_object.h:384
#define OID_SET_NULL(oidp)
Definition: oid.h:85
int er_errid(void)
int db_is_subclass(MOP classmop, MOP supermop)
Definition: db_info.c:445
int do_get_partition_parent(DB_OBJECT *const classop, MOP *const parentop)
int compact_db_start(void)
#define COMPACTDB_LOCKED_CLASS
void locator_free_list_mops(LIST_MOPS *mops)
Definition: locator_cl.c:2978
LIST_MOPS * locator_get_all_mops(MOP class_mop, DB_FETCH_MODE purpose, LC_FETCH_VERSION_TYPE *force_fetch_version_type)
Definition: locator_cl.c:2839
#define COMPACT_INSTANCE_MIN_LOCK_TIMEOUT
Definition: compactdb_cl.c:48
int util_log_write_errid(int message_id,...)
Definition: util_func.c:468
static void class_referenced_by_domain(MOP referenced_class, TP_DOMAIN *const domain, bool *const class_can_be_referenced, bool *const any_class_can_be_referenced)
#define COPY_OID(dest_oid_ptr, src_oid_ptr)
Definition: oid.h:63
#define COMPACT_INSTANCE_MAX_LOCK_TIMEOUT
Definition: compactdb_cl.c:49
int utility_get_option_int_value(UTIL_ARG_MAP *arg_map, int arg_ch)
Definition: util_common.c:227
static int class_referenced_by_class(MOP referenced_mop, MOP parent_mop, MOP referring_mop, bool *const class_can_be_referenced, bool *const any_class_can_be_referenced)
static void compactdb_usage(const char *argv0)
Definition: compactdb_cl.c:81
static DB_OBJECT * is_class(OID *obj_oid, OID *class_oid)
Definition: compactdb.c:637
int boot_heap_compact(OID *class_oid)
MOBJ locator_fetch_class(MOP class_mop, DB_FETCH_MODE purpose)
Definition: locator_cl.c:2293
bool pr_is_set_type(DB_TYPE type)
#define COMPACT_MAX_PAGES
Definition: compactdb_cl.c:46
int tran_reset_wait_times(int wait_in_msecs)
int db_restart(const char *program, int print_version, const char *volume)
Definition: db_admin.c:868
const char * sm_ch_name(const MOBJ clobj)
bool utility_get_option_bool_value(UTIL_ARG_MAP *arg_map, int arg_ch)
Definition: util_common.c:245
#define assert(x)
int heap_reclaim_addresses(const HFID *hfid)
#define ER_GENERIC_ERROR
Definition: error_code.h:49
SM_ATTRIBUTE * class_attributes
Definition: class_object.h:725
HFID * sm_ch_heap(MOBJ clobj)
const char * db_error_string(int level)
Definition: db_admin.c:2116
DB_TRAN_ISOLATION
Definition: dbtran_def.h:26
DB_OBJECT * db_domain_class(const DB_DOMAIN *domain)
Definition: db_macro.c:4030
#define COMPACT_STANDBY_CS_MODE_S
Definition: utility.h:1334
#define OID_EQ(oidp1, oidp2)
Definition: oid.h:92
int db_abort_transaction(void)
Definition: db_admin.c:1114
#define TP_DOMAIN_TYPE(dom)
#define DB_SIZEOF(val)
Definition: memory_alloc.h:54
int tran_abort_only_client(bool is_server_down)
#define NULL
Definition: freelistheap.h:34
static int total_objects
Definition: compactdb.c:56
static int compactdb_start(bool verbose_flag, bool delete_old_repr_flag, char *input_filename, char **input_class_names, int input_class_length, int max_processed_space, int instance_lock_timeout, int class_lock_timeout, DB_TRAN_ISOLATION tran_isolation)
Definition: compactdb_cl.c:253
int get_class_mops(char **class_names, int num_class, MOP **class_list, int *num_class_list)
static int failed_objects
Definition: compactdb.c:57
#define COMPACTDB_UNPROCESSED_CLASS
static int class_referenced_by_attributes(MOP referenced_class, MOP parent_mop, SM_ATTRIBUTE *const attributes_list, bool *const class_can_be_referenced, bool *const any_class_can_be_referenced)
#define COMPACT_CLASS_LOCK_TIMEOUT_S
Definition: utility.h:1332
char * input_filename
Definition: unloaddb.c:47
int db_set_isolation(DB_TRAN_ISOLATION isolation)
Definition: db_admin.c:1535
static int do_reclaim_addresses(OID *const *class_oids, const int num_class_oids, int *const num_classes_fully_processed, const bool verbose, const int class_lock_timeout)
Definition: compactdb_cl.c:930
int utility_get_option_string_table_size(UTIL_ARG_MAP *arg_map)
Definition: util_common.c:305
#define COMPACT_CLASS_MIN_LOCK_TIMEOUT
Definition: compactdb_cl.c:51
#define NULL_REPRID
LIST_MOPS * locator_get_all_class_mops(DB_FETCH_MODE purpose, int(*fun)(MOBJ class_obj))
Definition: locator_cl.c:2861
static void error(const char *msg)
Definition: gencat.c:331
#define HFID_IS_NULL(hfid)
bool verbose_flag
Definition: unloaddb.c:57
static char database_name[MAX_HA_DBINFO_LENGTH]
Definition: cas_execute.c:387
int compact_db_stop(void)
UTIL_ARG_MAP * arg_map
Definition: utility.h:1698
#define free_and_init(ptr)
Definition: memory_alloc.h:147
#define strlen(s1)
Definition: intl_support.c:43
SM_COMPONENT header
Definition: class_object.h:441
#define DB_PAGESIZE
MOP mops[1]
Definition: locator_cl.h:67
SM_CLASS_TYPE class_type
Definition: class_object.h:713
char * basename(const char *path)
Definition: porting.c:1132
int i
Definition: dynamic_load.c:954
#define DECACHE
Definition: locator_cl.h:48
int locator_flush_all_instances(MOP class_mop, bool decache)
Definition: locator_cl.c:5278
char * msgcat_message(int cat_id, int set_id, int msg_id)
const char * prm_get_name(PARAM_ID prm_id)
char * strdup(const char *str)
Definition: porting.c:901
static int do_reclaim_class_addresses(const OID class_oid, char **clas_name, bool *const any_class_can_be_referenced, bool *const correctly_processed, bool *const addresses_reclaimed, int *const error_while_processing)
#define COMPACT_PAGES_COMMITED_ONCE_S
Definition: utility.h:1326
MOP sm_Root_class_mop
#define OPTION_STRING_TABLE
Definition: utility.h:813
#define ER_COMPACTDB_ALREADY_STARTED
Definition: error_code.h:1261
#define OID_ISNULL(oidp)
Definition: oid.h:81
int locator_is_class(MOP mop, DB_FETCH_MODE hint_purpose)
Definition: locator_cl.c:239
#define COMPACT_INSTANCE_LOCK_TIMEOUT_S
Definition: utility.h:1330
#define COMPACT_INPUT_CLASS_FILE_S
Definition: utility.h:1320
#define COMPACTDB_REPR_DELETED
int ws_find(MOP mop, MOBJ *obj)
Definition: work_space.c:3112
int boot_compact_classes(OID **class_oids, int num_classes, int space_to_process, int instance_lock_timeout, int class_lock_timeout, bool delete_old_repr, OID *last_processed_class_oid, OID *last_processed_oid, int *total_objects, int *failed_objects, int *modified_objects, int *big_objects, int *ids_repr)
static int find_oid(OID *oid, OID **oids_list, int num_oids)
Definition: compactdb_cl.c:98
const char * command_name
Definition: utility.h:1699
static int class_instances_can_be_referenced(MOP mop, MOP parent_mop, bool *const class_can_be_referenced, bool *const any_class_can_be_referenced, MOP *const all_mops, const int num_mops)
char * utility_get_option_string_value(UTIL_ARG_MAP *arg_map, int arg_ch, int index)
Definition: util_common.c:266
static int is_not_system_class(MOBJ class_)
DB_DOMAIN * db_domain_set(const DB_DOMAIN *domain)
Definition: db_macro.c:4060
int db_commit_transaction(void)
Definition: db_admin.c:1091
int get_class_mops_from_file(const char *input_filename, MOP **class_list, int *num_class_mops)
#define COMPACT_VERBOSE_S
Definition: utility.h:1318
unsigned int flags
Definition: class_object.h:762
#define MSGCAT_CATALOG_UTILS