CUBRID Engine  latest
compactdb.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  * compactdb.c: utility that compacts a database
21  */
22 
23 #ident "$Id$"
24 
25 #include "config.h"
26 
27 #include <stdio.h>
28 #include <errno.h>
29 #include <string.h>
30 #include <assert.h>
31 
32 #include "porting.h"
33 #include "dbtype.h"
34 #include "load_object.h"
35 #include "db.h"
36 #include "locator_cl.h"
37 #include "locator_sr.h"
38 #include "schema_manager.h"
39 #include "heap_file.h"
40 #include "system_catalog.h"
41 #include "object_accessor.h"
42 #include "set_object.h"
43 #include "btree.h"
44 #include "message_catalog.h"
45 #include "network_interface_cl.h"
46 #include "server_interface.h"
47 #include "system_parameter.h"
48 #include "utility.h"
49 #include "authenticate.h"
50 #include "transaction_cl.h"
51 
52 #include "dbtype.h"
53 #include "thread_manager.hpp"
54 
55 static int class_objects = 0;
56 static int total_objects = 0;
57 static int failed_objects = 0;
58 static RECDES *Diskrec = NULL;
59 
60 static int compactdb_start (bool verbose_flag, char *input_filename, char **input_class_name, int input_class_length);
61 static void process_class (THREAD_ENTRY * thread_p, DB_OBJECT * class_, bool verbose_flag);
62 static void process_object (THREAD_ENTRY * thread_p, DESC_OBJ * desc_obj, OID * obj_oid, bool verbose_flag);
63 static int process_set (THREAD_ENTRY * thread_p, DB_SET * set);
64 static int process_value (THREAD_ENTRY * thread_p, DB_VALUE * value);
65 static DB_OBJECT *is_class (OID * obj_oid, OID * class_oid);
66 static int disk_update_instance (MOP classop, DESC_OBJ * obj, OID * oid);
67 static RECDES *alloc_recdes (int length);
68 static void free_recdes (RECDES * rec);
69 static void disk_init (void);
70 static void disk_final (void);
71 static int update_indexes (OID * class_oid, OID * obj_oid, RECDES * rec);
72 static void compact_usage (const char *argv0);
73 
74 extern int get_class_mops (char **class_names, int num_class, MOP ** class_list, int *num_class_list);
75 extern int get_class_mops_from_file (const char *input_filename, MOP ** class_list, int *num_class_mops);
76 
77 /*
78  * compact_usage() - print an usage of the backup-utility
79  * return: void
80  * exec_name(in): a name of this application
81  */
82 static void
83 compact_usage (const char *argv0)
84 {
85  const char *exec_name;
86 
87  exec_name = basename ((char *) argv0);
90 }
91 
92 /*
93  * compactdb - compactdb main routine
94  * return: 0 if successful, error code otherwise
95  * arg(in): a map of command line arguments
96  */
97 int
99 {
100  UTIL_ARG_MAP *arg_map = arg->arg_map;
101  const char *exec_name = arg->command_name;
102  int error;
103  int status = 0;
104  const char *database_name;
105  bool verbose_flag = 0;
106  char *input_filename = NULL;
107  char **tables = NULL;
108  int table_size = 0;
109  int i = 0;
110 
111  database_name = utility_get_option_string_value (arg_map, OPTION_STRING_TABLE, 0);
112  verbose_flag = utility_get_option_bool_value (arg_map, COMPACT_VERBOSE_S);
113 
114  if (database_name == NULL || database_name[0] == '\0' || utility_get_option_string_table_size (arg_map) < 1)
115  {
116  compact_usage (arg->argv0);
117  return ER_GENERIC_ERROR;
118  }
119 
120  input_filename = utility_get_option_string_value (arg_map, COMPACT_INPUT_CLASS_FILE_S, 0);
121 
122  table_size = utility_get_option_string_table_size (arg_map);
123  if (table_size > 1 && input_filename != NULL)
124  {
125  compact_usage (arg->argv0);
126  return ER_GENERIC_ERROR;
127  }
128  else if (table_size > 1)
129  {
130  tables = (char **) malloc (sizeof (char *) * (table_size - 1));
131  if (tables == NULL)
132  {
135  return ER_GENERIC_ERROR;
136  }
137 
138  for (i = 1; i < table_size; i++)
139  {
140  tables[i - 1] = utility_get_option_string_value (arg_map, OPTION_STRING_TABLE, i);
141  }
142  }
143 
145 
148  if ((error = db_login ("DBA", NULL)) || (error = db_restart (arg->argv0, TRUE, database_name)))
149  {
150  PRINT_AND_LOG_ERR_MSG ("%s: %s.\n\n", exec_name, db_error_string (3));
151  status = error;
152  }
153  else
154  {
155  status = compactdb_start (verbose_flag, input_filename, tables, table_size - 1);
156  if (status != 0)
157  {
159  }
160  if ((error = db_shutdown ()))
161  {
162  PRINT_AND_LOG_ERR_MSG ("%s: %s.\n", exec_name, db_error_string (3));
163  status = error;
164  }
165  }
166  return status;
167 }
168 
169 /*
170  * compactdb_start - compact database
171  * return: 0 if successful, error code otherwise
172  * verbose_flag(in)
173  */
174 static int
175 compactdb_start (bool verbose_flag, char *input_filename, char **input_class_names, int input_class_length)
176 {
178  int i;
179  MOBJ object = NULL;
180  HFID *hfid = NULL;
181  int status = 0;
182  THREAD_ENTRY *thread_p = NULL;
183  MOP *class_mops = NULL;
184  int num_class_mops = 0;
185  bool skip_phase3 = false;
186 
187  /*
188  * Build class name table
189  */
190 
192  {
193  if (input_filename && input_class_names && input_class_length > 0)
194  {
195  return ER_FAILED;
196  }
197 
198  if (input_class_names && input_class_length > 0)
199  {
200  status = get_class_mops (input_class_names, input_class_length, &class_mops, &num_class_mops);
201  if (status != NO_ERROR)
202  {
203  goto clean;
204  }
205  skip_phase3 = true;
206  }
207  else if (input_filename)
208  {
209  status = get_class_mops_from_file (input_filename, &class_mops, &num_class_mops);
210  if (status != NO_ERROR)
211  {
212  goto clean;
213  }
214  skip_phase3 = true;
215  }
216  else
217  {
219  if (class_table == NULL)
220  {
221  goto clean; /* error */
222  }
223  num_class_mops = class_table->num;
224  class_mops = class_table->mops;
225  }
226  }
227 
229  {
230  goto phase2;
231  }
233  {
234  goto phase3;
235  }
236 
237  if (verbose_flag)
238  {
240  }
241 
242  thread_p = thread_get_thread_entry_info ();
243 
244  /*
245  * Dump the object definitions
246  */
247  disk_init ();
248  for (i = 0; i < num_class_mops; i++)
249  {
250  if (!WS_IS_DELETED (class_mops[i]) && class_mops[i] != sm_Root_class_mop)
251  {
252  process_class (thread_p, class_mops[i], verbose_flag);
253  }
254  }
255  disk_final ();
256 
258 
259  if (failed_objects != 0)
260  {
263  status = 1;
264  /*
265  * TODO Processing should not continue in this case as we cannot be sure
266  * that all references to deleted objects have been set to NULL. Most of
267  * the code in the offline compactdb should be modified to check for
268  * error conditions.
269  */
270  }
271  else
272  {
273  if (verbose_flag)
274  {
276  total_objects);
277  }
278  }
279 
280 phase2:
281  if (verbose_flag)
282  {
283  printf ("\n");
285  }
286 
287  for (i = 0; i < num_class_mops; i++)
288  {
289  ws_find (class_mops[i], &object);
290  if (object == NULL)
291  {
292  continue;
293  }
294 
295  if (verbose_flag)
296  {
298  sm_ch_name (object));
299  }
300  hfid = sm_ch_heap (object);
301  if (hfid->vfid.fileid == NULL_FILEID)
302  {
303  continue;
304  }
305  (void) heap_reclaim_addresses (hfid);
306 
307  }
308 
309 phase3:
310  if (skip_phase3)
311  {
312  goto clean;
313  }
314 
315  if (verbose_flag)
316  {
317  printf ("\n");
319  }
320 
321  catalog_reclaim_space (thread_p);
323 
324  if (file_tracker_reclaim_marked_deleted (thread_p) != NO_ERROR)
325  {
326  /* how to handle error? */
327  ASSERT_ERROR ();
329  }
331 
332  /*
333  * Cleanup
334  */
335 clean:
336  if (class_table)
337  {
338  locator_free_list_mops (class_table);
339  }
340  else
341  {
342  if (class_mops)
343  {
344  for (i = 0; i < num_class_mops; i++)
345  {
346  class_mops[i] = NULL;
347  }
348 
349  free_and_init (class_mops);
350  }
351  }
352 
353  return status;
354 }
355 
356 
357 /*
358  * process_class - dump objects for given class
359  * return: void
360  * cl_no(in): class table index
361  * verbose_flag(in)
362  */
363 static void
364 process_class (THREAD_ENTRY * thread_p, DB_OBJECT * class_, bool verbose_flag)
365 {
366  int i = 0;
367  SM_CLASS *class_ptr;
368  LC_COPYAREA *fetch_area; /* Area where objects are received */
369  HFID *hfid;
370  OID *class_oid;
371  OID last_oid;
372  LOCK lock = S_LOCK; /* Lock to acquire for the above purpose */
373  int nobjects, nfetched;
374  LC_COPYAREA_MANYOBJS *mobjs; /* Describe multiple objects in area */
375  LC_COPYAREA_ONEOBJ *obj; /* Describe on object in area */
376  RECDES recdes; /* Record descriptor */
377  DESC_OBJ *desc_obj; /* The object described by obj */
378 
379  class_objects = 0;
380 
381  /* Get the class data */
382  ws_find (class_, (MOBJ *) (&class_ptr));
383  if (class_ptr == NULL)
384  {
385  return;
386  }
387 
388  class_oid = ws_oid (class_);
389 
390  if (verbose_flag)
391  {
393  sm_ch_name ((MOBJ) class_ptr));
394  }
395 
396 #if defined(CUBRID_DEBUG)
398  class_oid->pageid, class_oid->slotid);
399 #endif
400 
401  /* Find the heap where the instances are stored */
402  hfid = sm_ch_heap ((MOBJ) class_ptr);
403  if (hfid->vfid.fileid == NULL_FILEID)
404  {
405  if (verbose_flag)
406  {
408  }
409  return;
410  }
411 
412  /* Flush all the instances */
413 
415  {
416  if (verbose_flag)
417  {
419  }
420  return;
421  }
422 
423  nobjects = 0;
424  nfetched = -1;
425  OID_SET_NULL (&last_oid);
426 
427  /* Now start fetching all the instances */
428  desc_obj = make_desc_obj (class_ptr);
429  while (nobjects != nfetched)
430  {
431  if (locator_fetch_all (hfid, &lock, LC_FETCH_MVCC_VERSION, class_oid, &nobjects, &nfetched, &last_oid,
432  &fetch_area) == NO_ERROR)
433  {
434  if (fetch_area != NULL)
435  {
436  mobjs = LC_MANYOBJS_PTR_IN_COPYAREA (fetch_area);
437  obj = LC_START_ONEOBJ_PTR_IN_COPYAREA (mobjs);
438 
439  for (i = 0; i < mobjs->num_objs; i++)
440  {
441  class_objects++;
442  total_objects++;
443  LC_RECDES_TO_GET_ONEOBJ (fetch_area, obj, &recdes);
444  if (desc_disk_to_obj (class_, class_ptr, &recdes, desc_obj) == NO_ERROR)
445  {
446  process_object (thread_p, desc_obj, &obj->oid, verbose_flag);
447  }
448  else
449  {
450  failed_objects++;
451  }
452 
453  obj = LC_NEXT_ONEOBJ_PTR_IN_COPYAREA (obj);
454  }
455  locator_free_copy_area (fetch_area);
456  }
457  else
458  {
459  /* No more objects */
460  break;
461  }
462  }
463  }
464  desc_free (desc_obj);
465 
466  /*
467  * Now that the class has been processed, we can reclaim space in the catalog
468  * and the schema.
469  * Might be able to ignore failed objects here if we're sure that's
470  * indicative of a corrupted object.
471  */
472  if (failed_objects == 0)
473  {
474  if (catalog_drop_old_representations (thread_p, class_oid) == NO_ERROR)
475  {
476  (void) sm_destroy_representations (class_);
477  }
478  }
479  /* else, should have some sort of warning message ? */
480 
481  if (verbose_flag)
483 
484 }
485 
486 /*
487  * process_object - process one object. update instance if needed
488  * return: void
489  * desc_obj(in): object data
490  * obj_oid(in): object oid
491  * recdes(in): record descriptor
492  * verbose_flag(in)
493  */
494 static void
496 {
497  SM_CLASS *class_ptr;
498  SM_ATTRIBUTE *attribute;
499  DB_VALUE *value;
500  OID *class_oid;
501  int v = 0;
502  int update_flag = 0;
503 
504  class_ptr = desc_obj->class_;
505  class_oid = ws_oid (desc_obj->classop);
506 
507 #if defined(CUBRID_DEBUG)
509  obj_oid->pageid, obj_oid->slotid);
510 #endif
511 
512  attribute = class_ptr->attributes;
513  while (attribute)
514  {
515  value = &desc_obj->values[v++];
516  update_flag += process_value (thread_p, value);
517  attribute = (SM_ATTRIBUTE *) attribute->header.next;
518  }
519 
520  if ((desc_obj->updated_flag) || (update_flag))
521  {
522  if (verbose_flag)
523  {
525  }
526  disk_update_instance (desc_obj->classop, desc_obj, obj_oid);
527  }
528 }
529 
530 
531 /*
532  * process_value - process one value
533  * return: whether the object should be updated.
534  * value(in): the value to process
535  */
536 static int
537 process_value (THREAD_ENTRY * thread_p, DB_VALUE * value)
538 {
539  int return_value = 0;
540 
541  switch (DB_VALUE_TYPE (value))
542  {
543  case DB_TYPE_OID:
544  case DB_TYPE_OBJECT:
545  {
546  OID *ref_oid;
547  SCAN_CODE scan_code;
548  HEAP_SCANCACHE scan_cache;
549 
550  if (DB_VALUE_TYPE (value) == DB_TYPE_OID)
551  {
552  ref_oid = db_get_oid (value);
553  }
554  else
555  {
556  ref_oid = WS_OID (db_get_object (value));
557  }
558 
559  if (OID_ISNULL (ref_oid))
560  {
561  break;
562  }
563 
564  heap_scancache_quick_start (&scan_cache);
565  scan_cache.mvcc_snapshot = logtb_get_mvcc_snapshot (thread_p);
566  scan_code = heap_get_visible_version (thread_p, ref_oid, NULL, NULL, &scan_cache, PEEK, NULL_CHN);
567  heap_scancache_end (thread_p, &scan_cache);
568 
569 #if defined(CUBRID_DEBUG)
571  ref_oid->pageid, ref_oid->slotid, ref_class_oid.volid, ref_class_oid.pageid, ref_class_oid.slotid);
572 #endif
573 
574  if (scan_code != S_SUCCESS)
575  {
576  /* Set NULL link. */
577  OID_SET_NULL (ref_oid);
578  return_value = 1;
579  break;
580  }
581 
582  /* No updates */
583  break;
584  }
585 
586  case DB_TYPE_POINTER:
587  case DB_TYPE_SET:
588  case DB_TYPE_MULTISET:
589  case DB_TYPE_SEQUENCE:
590  {
591  return_value = process_set (thread_p, db_get_set (value));
592  break;
593  }
594 
595  case DB_TYPE_NULL:
596  case DB_TYPE_BLOB:
597  case DB_TYPE_CLOB:
598  default:
599  break;
600  }
601 
602  return return_value;
603 }
604 
605 
606 /*
607  * process_set - process one set
608  * return: whether the object should be updated.
609  * set(in): the set to process
610  */
611 static int
612 process_set (THREAD_ENTRY * thread_p, DB_SET * set)
613 {
614  SET_ITERATOR *it;
615  DB_VALUE *element_value;
616  int return_value = 0;
617 
618  it = set_iterate (set);
619  while ((element_value = set_iterator_value (it)) != NULL)
620  {
621  return_value += process_value (thread_p, element_value);
622  set_iterator_next (it);
623  }
624  set_iterator_free (it);
625 
626  return return_value;
627 }
628 
629 
630 /*
631  * is_class - determine whether the object is actually a class.
632  * return: return the MOP of the object, otherwise NULL
633  * obj_oid(in): the object oid
634  * class_oid(in): the class oid
635  */
636 static DB_OBJECT *
637 is_class (OID * obj_oid, OID * class_oid)
638 {
639  if (OID_EQ (class_oid, WS_OID (sm_Root_class_mop)))
640  {
641  return ws_mop (obj_oid, NULL);
642  }
643  return NULL;
644 }
645 
646 /*
647  * disk_update_instance - update object instance
648  * return: number of processed instance. 0 is error.
649  * classop(in): class object
650  * obj(in): object instance
651  * oid(in): oid
652  */
653 static int
654 disk_update_instance (MOP classop, DESC_OBJ * obj, OID * oid)
655 {
656  HEAP_OPERATION_CONTEXT update_context;
657  HFID *hfid;
658  int save_newsize;
659  bool has_indexes;
660 
661  assert (oid != NULL);
662 
663  Diskrec->length = 0;
664  if (desc_obj_to_disk (obj, Diskrec, &has_indexes))
665  {
666  if (Diskrec->length >= 0) /* OID_ISTEMP */
667  {
668  return 0;
669  }
670  else
671  {
672  save_newsize = -Diskrec->length + DB_PAGESIZE;
673  /* make the record larger */
674  free_recdes (Diskrec);
675  Diskrec = alloc_recdes (save_newsize);
676  if (Diskrec == NULL)
677  {
678  return 0;
679  }
680  /* try one more time */
681  if (desc_obj_to_disk (obj, Diskrec, &has_indexes))
682  {
684  return (0);
685  }
686  }
687  }
688 
689  hfid = sm_ch_heap ((MOBJ) (obj->class_));
690  if (HFID_IS_NULL (hfid))
691  {
693  return (0);
694  }
695 
696  if (has_indexes)
697  {
698  update_indexes (WS_OID (classop), oid, Diskrec);
699  }
700 
701  heap_create_update_context (&update_context, hfid, oid, WS_OID (classop), Diskrec, NULL,
703  if (heap_update_logical (NULL, &update_context) != NO_ERROR)
704  {
706  return (0);
707  }
708 
709  return 1;
710 }
711 
712 /*
713  * alloc_recdes - allocate a DECDES
714  * return: DECDES allocated
715  * length(in): additional length in addition to RECDES itself.
716  */
717 static RECDES *
718 alloc_recdes (int length)
719 {
720  RECDES *rec;
721 
722  if ((rec = (RECDES *) malloc (sizeof (RECDES) + length)) != NULL)
723  {
724  rec->area_size = length;
725  rec->length = 0;
726  rec->type = 0;
727  rec->data = ((char *) rec) + sizeof (RECDES);
728  }
729  return rec;
730 }
731 
732 /*
733  * free_recdes - free a DECDES allocatd by alloc_recdes
734  * return: void
735  * rec(out): DECDES
736  */
737 static void
739 {
740  free_and_init (rec);
741 }
742 
743 /*
744  * disk_init - initialize Diskrec file scope variable
745  * return: void
746  */
747 static void
748 disk_init (void)
749 {
750  Diskrec = alloc_recdes (DB_PAGESIZE * 4);
751 }
752 
753 /*
754  * disk_final - free Diskrec file scope variable
755  * return: void
756  */
757 static void
759 {
760  free_recdes (Diskrec);
761  Diskrec = NULL;
762 }
763 
764 /*
765  * update_indexes - update index for given OID
766  * return: NO_ERROR or error code
767  * class_oid(in): class oid
768  * obj_oid(in): object oid
769  * rec(in): RECDES instance having new value
770  */
771 static int
772 update_indexes (OID * class_oid, OID * obj_oid, RECDES * rec)
773 {
774  RECDES oldrec = { 0, 0, 0, NULL };
775  bool old_object;
776  int success;
777  HEAP_GET_CONTEXT context;
778  HEAP_SCANCACHE scan_cache;
779 
780  (void) heap_scancache_quick_start (&scan_cache);
781  heap_init_get_context (NULL, &context, obj_oid, class_oid, &oldrec, &scan_cache, COPY, NULL_CHN);
782 
783  old_object = (heap_get_last_version (NULL, &context) == S_SUCCESS);
784 
785  if (old_object)
786  {
787  /*
788  * 4th arg -> give up setting updated attr info
789  * for replication..
790  * 9rd arg -> data or schema, 10th arg -> max repl. log or not
791  */
792  success =
793  locator_update_index (NULL, rec, &oldrec, NULL, 0, obj_oid, class_oid, SINGLE_ROW_UPDATE,
794  (HEAP_SCANCACHE *) NULL, NULL);
795  }
796  else
797  {
798  success = ER_FAILED;
799  }
800 
801  heap_clean_get_context (NULL, &context);
802  (void) heap_scancache_end (NULL, &scan_cache);
803 
804  return success;
805 }
int sm_destroy_representations(MOP op)
#define WS_IS_DELETED(mop)
Definition: work_space.h:284
int compactdb(UTIL_FUNCTION_ARG *arg)
Definition: compactdb.c:98
cubthread::entry * thread_get_thread_entry_info(void)
#define NO_ERROR
Definition: error_code.h:46
int area_size
#define TRUE
Definition: broker_admin.c:49
DB_COLLECTION * db_get_set(const DB_VALUE *value)
MVCC_SNAPSHOT * logtb_get_mvcc_snapshot(THREAD_ENTRY *thread_p)
SM_CLASS * class_
Definition: load_object.h:57
void db_set_client_type(int client_type)
Definition: db_admin.c:495
int catalog_reclaim_space(THREAD_ENTRY *thread_p)
#define ASSERT_ERROR()
SCAN_CODE
#define PRINT_AND_LOG_ERR_MSG(...)
Definition: util_func.h:49
int sysprm_set_force(const char *pname, const char *pvalue)
MOP ws_mop(const OID *oid, MOP class_mop)
Definition: work_space.c:614
int db_login(const char *name, const char *password)
Definition: db_admin.c:804
char * MOBJ
Definition: work_space.h:174
SCAN_CODE heap_get_visible_version(THREAD_ENTRY *thread_p, const OID *oid, OID *class_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, int ispeeking, int old_chn)
Definition: heap_file.c:24272
static int compactdb_start(bool verbose_flag, char *input_filename, char **input_class_name, int input_class_length)
Definition: compactdb.c:175
void locator_free_copy_area(LC_COPYAREA *copyarea)
Definition: locator.c:534
int get_class_mops_from_file(const char *input_filename, MOP **class_list, int *num_class_mops)
static void process_class(THREAD_ENTRY *thread_p, DB_OBJECT *class_, bool verbose_flag)
Definition: compactdb.c:364
#define ER_FAILED
Definition: error_code.h:47
#define AU_DISABLE_PASSWORDS
Definition: authenticate.h:140
#define LC_START_ONEOBJ_PTR_IN_COPYAREA(manyobjs_ptr)
Definition: locator.h:44
void set_iterator_free(SET_ITERATOR *it)
Definition: set_object.c:4188
int updated_flag
Definition: load_object.h:58
int desc_obj_to_disk(DESC_OBJ *obj, RECDES *record, bool *index_flag)
Definition: load_object.c:532
SM_ATTRIBUTE * attributes
Definition: class_object.h:721
DESC_OBJ * make_desc_obj(SM_CLASS *class_)
Definition: load_object.c:87
int get_class_mops(char **class_names, int num_class, MOP **class_list, int *num_class_list)
static RECDES * Diskrec
Definition: compactdb.c:58
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 set_iterator_next(SET_ITERATOR *it)
Definition: set_object.c:4236
char * data
SCAN_CODE heap_get_last_version(THREAD_ENTRY *thread_p, HEAP_GET_CONTEXT *context)
Definition: heap_file.c:24546
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
int heap_scancache_end(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
Definition: heap_file.c:7195
int util_log_write_errid(int message_id,...)
Definition: util_func.c:468
void THREAD_ENTRY
static void compact_usage(const char *argv0)
Definition: compactdb.c:83
static DB_OBJECT * is_class(OID *obj_oid, OID *class_oid)
Definition: compactdb.c:637
LOCK
#define LC_RECDES_TO_GET_ONEOBJ(copy_area_ptr, oneobj_ptr, recdes_ptr)
Definition: locator.h:54
int db_restart(const char *program, int print_version, const char *volume)
Definition: db_admin.c:868
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
static void disk_init(void)
Definition: compactdb.c:748
Definition: db_set.h:35
const char * sm_ch_name(const MOBJ clobj)
static int class_objects
Definition: compactdb.c:55
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)
static void free_recdes(RECDES *rec)
Definition: compactdb.c:738
static int process_value(THREAD_ENTRY *thread_p, DB_VALUE *value)
Definition: compactdb.c:537
int32_t fileid
Definition: dbtype_def.h:886
int desc_disk_to_obj(MOP classop, SM_CLASS *class_, RECDES *record, DESC_OBJ *obj)
Definition: load_object.c:930
void heap_clean_get_context(THREAD_ENTRY *thread_p, HEAP_GET_CONTEXT *context)
Definition: heap_file.c:24657
int prm_get_integer_value(PARAM_ID prm_id)
#define ER_GENERIC_ERROR
Definition: error_code.h:49
#define SINGLE_ROW_UPDATE
Definition: btree.h:54
HFID * sm_ch_heap(MOBJ clobj)
static int update_indexes(OID *class_oid, OID *obj_oid, RECDES *rec)
Definition: compactdb.c:772
int heap_update_logical(THREAD_ENTRY *thread_p, HEAP_OPERATION_CONTEXT *context)
Definition: heap_file.c:22771
void heap_create_update_context(HEAP_OPERATION_CONTEXT *context, HFID *hfid_p, OID *oid_p, OID *class_oid_p, RECDES *recdes_p, HEAP_SCANCACHE *scancache_p, UPDATE_INPLACE_STYLE in_place)
Definition: heap_file.c:22378
struct recdes RECDES
const char * db_error_string(int level)
Definition: db_admin.c:2116
DB_OBJECT * db_get_object(const DB_VALUE *value)
#define OID_EQ(oidp1, oidp2)
Definition: oid.h:92
VFID vfid
#define NULL
Definition: freelistheap.h:34
static int total_objects
Definition: compactdb.c:56
static int success()
#define LC_NEXT_ONEOBJ_PTR_IN_COPYAREA(oneobj_ptr)
Definition: locator.h:48
int catalog_drop_old_representations(THREAD_ENTRY *thread_p, OID *class_id_p)
#define DONT_DECACHE
Definition: locator_cl.h:49
static int failed_objects
Definition: compactdb.c:57
#define NULL_FILEID
DB_VALUE * values
Definition: load_object.h:61
static int process_set(THREAD_ENTRY *thread_p, DB_SET *set)
Definition: compactdb.c:612
static void disk_final(void)
Definition: compactdb.c:758
char * input_filename
Definition: unloaddb.c:47
int utility_get_option_string_table_size(UTIL_ARG_MAP *arg_map)
Definition: util_common.c:305
static void error(const char *msg)
Definition: gencat.c:331
MOP classop
Definition: load_object.h:56
#define HFID_IS_NULL(hfid)
static void process_object(THREAD_ENTRY *thread_p, DESC_OBJ *desc_obj, OID *obj_oid, bool verbose_flag)
Definition: compactdb.c:495
static int disk_update_instance(MOP classop, DESC_OBJ *obj, OID *oid)
Definition: compactdb.c:654
#define ARG_FILE_LINE
Definition: error_manager.h:44
bool verbose_flag
Definition: unloaddb.c:57
static char database_name[MAX_HA_DBINFO_LENGTH]
Definition: cas_execute.c:387
static const bool COPY
OID * db_get_oid(const DB_VALUE *value)
static RECDES * alloc_recdes(int length)
Definition: compactdb.c:718
void heap_init_get_context(THREAD_ENTRY *thread_p, HEAP_GET_CONTEXT *context, const OID *oid, OID *class_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, int ispeeking, int old_chn)
Definition: heap_file.c:24697
#define WS_OID(mop)
Definition: work_space.h:293
UTIL_ARG_MAP * arg_map
Definition: utility.h:1698
MVCC_SNAPSHOT * mvcc_snapshot
Definition: heap_file.h:154
#define free_and_init(ptr)
Definition: memory_alloc.h:147
int locator_update_index(THREAD_ENTRY *thread_p, RECDES *new_recdes, RECDES *old_recdes, ATTR_ID *att_id, int n_att_id, OID *oid, OID *class_oid, int op_type, HEAP_SCANCACHE *scan_cache, REPL_INFO *repl_info)
Definition: locator_sr.c:8147
SM_COMPONENT header
Definition: class_object.h:441
#define DB_PAGESIZE
MOP mops[1]
Definition: locator_cl.h:67
#define LC_MANYOBJS_PTR_IN_COPYAREA(copy_areaptr)
Definition: locator.h:39
int util_log_write_errstr(const char *format,...)
Definition: util_func.c:493
char * basename(const char *path)
Definition: porting.c:1132
DB_VALUE * set_iterator_value(SET_ITERATOR *it)
Definition: set_object.c:4201
int locator_fetch_all(const HFID *hfid, LOCK *lock, LC_FETCH_VERSION_TYPE fetch_version_type, OID *class_oidp, int *nobjects, int *nfetched, OID *last_oidp, LC_COPYAREA **fetch_copyarea)
#define DB_VALUE_TYPE(value)
Definition: dbtype.h:72
int i
Definition: dynamic_load.c:954
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)
INT16 type
MOP sm_Root_class_mop
void desc_free(DESC_OBJ *obj)
Definition: load_object.c:138
#define OPTION_STRING_TABLE
Definition: utility.h:813
int heap_scancache_quick_start(HEAP_SCANCACHE *scan_cache)
Definition: heap_file.c:7040
#define OID_ISNULL(oidp)
Definition: oid.h:81
#define COMPACT_INPUT_CLASS_FILE_S
Definition: utility.h:1320
int ws_find(MOP mop, MOBJ *obj)
Definition: work_space.c:3112
#define PEEK
Definition: file_io.h:74
const char * command_name
Definition: utility.h:1699
SET_ITERATOR * set_iterate(DB_COLLECTION *set)
Definition: set_object.c:4146
char * utility_get_option_string_value(UTIL_ARG_MAP *arg_map, int arg_ch, int index)
Definition: util_common.c:266
int db_commit_transaction(void)
Definition: db_admin.c:1091
#define COMPACT_VERBOSE_S
Definition: utility.h:1318
#define MSGCAT_CATALOG_UTILS