CUBRID Engine  latest
unload_schema.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include "db.h"
#include "extract_schema.hpp"
#include "authenticate.h"
#include "schema_manager.h"
#include "trigger_description.hpp"
#include "load_object.h"
#include "object_primitive.h"
#include "parser.h"
#include "printer.hpp"
#include "message_catalog.h"
#include "utility.h"
#include "unloaddb.h"
#include "execute_schema.h"
#include "set_object.h"
#include "jsp_cl.h"
#include "class_object.h"
#include "object_print.h"
#include "dbtype.h"
#include "tde.h"

Go to the source code of this file.

Macros

#define CLASS_NAME_MAX   80
 
#define SCHEMA_SUFFIX   "_schema"
 
#define TRIGGER_SUFFIX   "_trigger"
 
#define INDEX_SUFFIX   "_indexes"
 
#define EX_ERROR_CHECK(c, d, m)
 

Enumerations

enum  ATTRIBUTE_QUALIFIER { INSTANCE_ATTRIBUTE, SHARED_ATTRIBUTE, CLASS_ATTRIBUTE }
 
enum  METHOD_QUALIFIER { INSTANCE_METHOD, CLASS_METHOD }
 
enum  RESOLUTION_QUALIFIER { INSTANCE_RESOLUTION, CLASS_RESOLUTION }
 
enum  SERIAL_VALUE_INDEX {
  SERIAL_NAME, SERIAL_OWNER_NAME, SERIAL_CURRENT_VAL, SERIAL_INCREMENT_VAL,
  SERIAL_MAX_VAL, SERIAL_MIN_VAL, SERIAL_CYCLIC, SERIAL_STARTED,
  SERIAL_CACHED_NUM, SERIAL_COMMENT, SERIAL_VALUE_INDEX_MAX
}
 

Functions

static void filter_system_classes (DB_OBJLIST **class_list)
 
static void filter_unrequired_classes (DB_OBJLIST **class_list)
 
static int is_dependent_class (DB_OBJECT *class_, DB_OBJLIST *unordered, DB_OBJLIST *ordered)
 
static int check_domain_dependencies (DB_DOMAIN *domain, DB_OBJECT *this_class, DB_OBJLIST *unordered, DB_OBJLIST *ordered)
 
static int has_dependencies (DB_OBJECT *class_, DB_OBJLIST *unordered, DB_OBJLIST *ordered, int conservative)
 
static int order_classes (DB_OBJLIST **class_list, DB_OBJLIST **order_list, int conservative)
 
static void emit_cycle_warning (print_output &output_ctx)
 
static void force_one_class (print_output &output_ctx, DB_OBJLIST **class_list, DB_OBJLIST **order_list)
 
static DB_OBJLISTget_ordered_classes (print_output &output_ctx, MOP *class_table)
 
static void emit_class_owner (print_output &output_ctx, MOP class_)
 
static int export_serial (print_output &output_ctx)
 
static int emit_indexes (print_output &output_ctx, DB_OBJLIST *classes, int has_indexes, DB_OBJLIST *vclass_list_has_using_index)
 
static int emit_schema (print_output &output_ctx, DB_OBJLIST *classes, int do_auth, DB_OBJLIST **vclass_list_has_using_index, EMIT_STORAGE_ORDER emit_storage_order)
 
static bool has_vclass_domains (DB_OBJECT *vclass)
 
static DB_OBJLISTemit_query_specs (print_output &output_ctx, DB_OBJLIST *classes)
 
static int emit_query_specs_has_using_index (print_output &output_ctx, DB_OBJLIST *vclass_list_has_using_index)
 
static bool emit_superclasses (print_output &output_ctx, DB_OBJECT *class_, const char *class_type)
 
static bool emit_resolutions (print_output &output_ctx, DB_OBJECT *class_, const char *class_type)
 
static void emit_resolution_def (print_output &output_ctx, DB_RESOLUTION *resolution, RESOLUTION_QUALIFIER qualifier)
 
static bool emit_instance_attributes (print_output &output_ctx, DB_OBJECT *class_, const char *class_type, int *has_indexes, EMIT_STORAGE_ORDER storage_order)
 
static bool emit_class_attributes (print_output &output_ctx, DB_OBJECT *class_, const char *class_type)
 
static bool emit_all_attributes (print_output &output_ctx, DB_OBJECT *class_, const char *class_type, int *has_indexes, EMIT_STORAGE_ORDER storage_order)
 
static bool emit_class_meta (print_output &output_ctx, DB_OBJECT *table)
 
static void emit_method_files (print_output &output_ctx, DB_OBJECT *class_)
 
static bool emit_methods (print_output &output_ctx, DB_OBJECT *class_, const char *class_type)
 
static int ex_contains_object_reference (DB_VALUE *value)
 
static void emit_attribute_def (print_output &output_ctx, DB_ATTRIBUTE *attribute, ATTRIBUTE_QUALIFIER qualifier)
 
static void emit_unique_def (print_output &output_ctx, DB_OBJECT *class_, const char *class_type)
 
static void emit_reverse_unique_def (print_output &output_ctx, DB_OBJECT *class_)
 
static void emit_index_def (print_output &output_ctx, DB_OBJECT *class_)
 
static void emit_domain_def (print_output &output_ctx, DB_DOMAIN *domains)
 
static int emit_autoincrement_def (print_output &output_ctx, DB_ATTRIBUTE *attribute)
 
static void emit_method_def (print_output &output_ctx, DB_METHOD *method, METHOD_QUALIFIER qualifier)
 
static void emit_methfile_def (print_output &output_ctx, DB_METHFILE *methfile)
 
static void emit_partition_parts (print_output &output_ctx, SM_PARTITION *partition_info, int partcnt)
 
static void emit_partition_info (print_output &output_ctx, MOP clsobj)
 
static int emit_stored_procedure_args (print_output &output_ctx, int arg_cnt, DB_SET *arg_set)
 
static int emit_stored_procedure (print_output &output_ctx)
 
static int emit_foreign_key (print_output &output_ctx, DB_OBJLIST *classes)
 
static int create_filename (const char *output_dirname, const char *output_prefix, const char *suffix, char *output_filename_p, const size_t filename_size)
 
int extract_classes_to_file (extract_context &ctxt, const char *output_filename)
 
int extract_classes (extract_context &ctxt, print_output &schema_output_ctx)
 
int extract_triggers_to_file (extract_context &ctxt, const char *output_filename)
 
int extract_triggers (extract_context &ctxt, print_output &output_ctx)
 
int extract_indexes_to_file (extract_context &ctxt, const char *output_filename)
 
int create_filename_schema (const char *output_dirname, const char *output_prefix, char *output_filename_p, const size_t filename_size)
 
int create_filename_trigger (const char *output_dirname, const char *output_prefix, char *output_filename_p, const size_t filename_size)
 
int create_filename_indexes (const char *output_dirname, const char *output_prefix, char *output_filename_p, const size_t filename_size)
 

Macro Definition Documentation

#define CLASS_NAME_MAX   80

Definition at line 60 of file unload_schema.c.

#define EX_ERROR_CHECK (   c,
  d,
 
)
Value:
do { \
if (c) { \
goto error; \
} \
if (!d) { /* if it is not db error check only, */ \
if (m != NULL) { \
fprintf(stderr, "%s: %s.\n\n", \
exec_name, m); \
} \
else { \
fprintf(stderr, "%s: Unknown database error occurs but may not be database error.\n\n", \
exec_name); \
} \
goto error; \
} \
} \
} \
} while (0)
#define NO_ERROR
Definition: error_code.h:46
int db_error_code(void)
Definition: db_admin.c:2143
#define NULL
Definition: freelistheap.h:34
if(extra_options)
Definition: dynamic_load.c:958
static void error(const char *msg)
Definition: gencat.c:331
else

Definition at line 67 of file unload_schema.c.

#define INDEX_SUFFIX   "_indexes"

Definition at line 65 of file unload_schema.c.

Referenced by create_filename_indexes().

#define SCHEMA_SUFFIX   "_schema"

Definition at line 63 of file unload_schema.c.

Referenced by create_filename_schema().

#define TRIGGER_SUFFIX   "_trigger"

Definition at line 64 of file unload_schema.c.

Referenced by create_filename_trigger().

Enumeration Type Documentation

Enumerator
INSTANCE_ATTRIBUTE 
SHARED_ATTRIBUTE 
CLASS_ATTRIBUTE 

Definition at line 89 of file unload_schema.c.

Enumerator
INSTANCE_METHOD 
CLASS_METHOD 

Definition at line 96 of file unload_schema.c.

Enumerator
INSTANCE_RESOLUTION 
CLASS_RESOLUTION 

Definition at line 102 of file unload_schema.c.

Enumerator
SERIAL_NAME 
SERIAL_OWNER_NAME 
SERIAL_CURRENT_VAL 
SERIAL_INCREMENT_VAL 
SERIAL_MAX_VAL 
SERIAL_MIN_VAL 
SERIAL_CYCLIC 
SERIAL_STARTED 
SERIAL_CACHED_NUM 
SERIAL_COMMENT 
SERIAL_VALUE_INDEX_MAX 

Definition at line 108 of file unload_schema.c.

Function Documentation

static int check_domain_dependencies ( DB_DOMAIN domain,
DB_OBJECT this_class,
DB_OBJLIST unordered,
DB_OBJLIST ordered 
)
static

Definition at line 294 of file unload_schema.c.

References db_domain_class(), db_domain_next(), db_domain_set(), is_dependent_class(), and NULL.

Referenced by has_dependencies().

Here is the caller graph for this function:

static int create_filename ( const char *  output_dirname,
const char *  output_prefix,
const char *  suffix,
char *  output_filename_p,
const size_t  filename_size 
)
static

Definition at line 3488 of file unload_schema.c.

References NULL, and strlen.

Referenced by create_filename_indexes(), create_filename_schema(), and create_filename_trigger().

Here is the caller graph for this function:

int create_filename_indexes ( const char *  output_dirname,
const char *  output_prefix,
char *  output_filename_p,
const size_t  filename_size 
)

Definition at line 3481 of file unload_schema.c.

References create_filename(), and INDEX_SUFFIX.

Referenced by unloaddb().

Here is the caller graph for this function:

int create_filename_schema ( const char *  output_dirname,
const char *  output_prefix,
char *  output_filename_p,
const size_t  filename_size 
)

Definition at line 3467 of file unload_schema.c.

References create_filename(), and SCHEMA_SUFFIX.

Referenced by unloaddb().

Here is the caller graph for this function:

int create_filename_trigger ( const char *  output_dirname,
const char *  output_prefix,
char *  output_filename_p,
const size_t  filename_size 
)

Definition at line 3474 of file unload_schema.c.

References create_filename(), and TRIGGER_SUFFIX.

Referenced by unloaddb().

Here is the caller graph for this function:

static bool emit_all_attributes ( print_output output_ctx,
DB_OBJECT class_,
const char *  class_type,
int *  has_indexes,
EMIT_STORAGE_ORDER  storage_order 
)
static

Definition at line 2095 of file unload_schema.c.

References emit_class_attributes(), and emit_instance_attributes().

Referenced by emit_schema().

Here is the caller graph for this function:

static int emit_autoincrement_def ( print_output output_ctx,
DB_ATTRIBUTE attribute 
)
static

Definition at line 2934 of file unload_schema.c.

References sm_attribute::auto_increment, db_get(), db_make_null(), error(), NO_ERROR, NULL, numeric_db_value_print(), NUMERIC_MAX_STRING_SIZE, and pr_clear_value().

Referenced by emit_attribute_def().

Here is the caller graph for this function:

static bool emit_class_attributes ( print_output output_ctx,
DB_OBJECT class_,
const char *  class_type 
)
static

Definition at line 2014 of file unload_schema.c.

References CLASS_ATTRIBUTE, db_attribute_class(), db_attribute_next(), db_get_class_attributes(), db_get_class_name(), emit_attribute_def(), NULL, and PRINT_IDENTIFIER.

Referenced by emit_all_attributes().

Here is the caller graph for this function:

static bool emit_class_meta ( print_output output_ctx,
DB_OBJECT table 
)
static
static void emit_class_owner ( print_output output_ctx,
MOP  class_ 
)
static

Definition at line 580 of file unload_schema.c.

References au_get_class_owner(), db_get(), db_get_class_name(), db_get_string(), DB_TYPE_STRING, db_value_clear(), DB_VALUE_TYPE, NO_ERROR, and NULL.

Referenced by emit_schema().

Here is the caller graph for this function:

static void emit_cycle_warning ( print_output output_ctx)
static

Definition at line 445 of file unload_schema.c.

Referenced by force_one_class().

Here is the caller graph for this function:

static int emit_indexes ( print_output output_ctx,
DB_OBJLIST classes,
int  has_indexes,
DB_OBJLIST vclass_list_has_using_index 
)
static

Definition at line 1065 of file unload_schema.c.

References db_is_vclass(), emit_index_def(), emit_query_specs_has_using_index(), db_objlist::next, NULL, and db_objlist::op.

Referenced by extract_indexes_to_file().

Here is the caller graph for this function:

static void emit_methfile_def ( print_output output_ctx,
DB_METHFILE methfile 
)
static

Definition at line 3053 of file unload_schema.c.

References db_methfile_name().

Referenced by emit_method_files().

Here is the caller graph for this function:

static void emit_method_def ( print_output output_ctx,
DB_METHOD method,
METHOD_QUALIFIER  qualifier 
)
static
static void emit_method_files ( print_output output_ctx,
DB_OBJECT class_ 
)
static

Definition at line 2113 of file unload_schema.c.

References sm_method_file::class_mop, db_get_method_files(), db_methfile_next(), emit_methfile_def(), and NULL.

Referenced by emit_methods().

Here is the caller graph for this function:

static bool emit_methods ( print_output output_ctx,
DB_OBJECT class_,
const char *  class_type 
)
static
static void emit_partition_parts ( print_output output_ctx,
SM_PARTITION partition_info,
int  partcnt 
)
static
static int emit_query_specs_has_using_index ( print_output output_ctx,
DB_OBJLIST vclass_list_has_using_index 
)
static
static void emit_resolution_def ( print_output output_ctx,
DB_RESOLUTION resolution,
RESOLUTION_QUALIFIER  qualifier 
)
static

Definition at line 1623 of file unload_schema.c.

References CLASS_RESOLUTION, db_get_class_name(), db_resolution_alias(), db_resolution_class(), db_resolution_name(), INSTANCE_RESOLUTION, NULL, and PRINT_IDENTIFIER.

Referenced by emit_resolutions().

Here is the caller graph for this function:

static bool emit_resolutions ( print_output output_ctx,
DB_OBJECT class_,
const char *  class_type 
)
static
static int emit_stored_procedure_args ( print_output output_ctx,
int  arg_cnt,
DB_SET arg_set 
)
static
static bool emit_superclasses ( print_output output_ctx,
DB_OBJECT class_,
const char *  class_type 
)
static

Definition at line 1535 of file unload_schema.c.

References db_get_class_name(), db_get_superclasses(), do_is_partitioned_subclass(), db_objlist::next, NULL, db_objlist::op, and PRINT_IDENTIFIER.

Referenced by emit_schema().

Here is the caller graph for this function:

static int ex_contains_object_reference ( DB_VALUE value)
static

Definition at line 2254 of file unload_schema.c.

References db_get_object(), db_get_set(), db_seq_get(), db_set_get(), db_set_size(), db_set_type(), DB_TYPE_OBJECT, DB_TYPE_SEQUENCE, db_value_clear(), DB_VALUE_TYPE, error(), i, NULL, and TP_IS_SET_TYPE.

Referenced by emit_attribute_def().

Here is the caller graph for this function:

int extract_classes_to_file ( extract_context ctxt,
const char *  output_filename 
)

Definition at line 821 of file unload_schema.c.

References extract_context::exec_name, extract_classes(), fopen_ex(), NULL, and output_file.

Referenced by unloaddb().

Here is the caller graph for this function:

int extract_indexes_to_file ( extract_context ctxt,
const char *  output_filename 
)
int extract_triggers ( extract_context ctxt,
print_output output_ctx 
)

Definition at line 977 of file unload_schema.c.

References assert, extract_context::classes, NO_ERROR, NULL, and tr_dump_selective_triggers().

Referenced by extract_triggers_to_file().

Here is the caller graph for this function:

int extract_triggers_to_file ( extract_context ctxt,
const char *  output_filename 
)

Definition at line 928 of file unload_schema.c.

References extract_context::exec_name, extract_triggers(), fopen_ex(), NULL, output_file, and output_filename.

Referenced by unloaddb().

Here is the caller graph for this function:

static void filter_system_classes ( DB_OBJLIST **  class_list)
static

Definition at line 198 of file unload_schema.c.

References db_is_system_class(), ml_ext_free_link(), db_objlist::next, NULL, and db_objlist::op.

Referenced by get_ordered_classes().

Here is the caller graph for this function:

static void filter_unrequired_classes ( DB_OBJLIST **  class_list)
static

Definition at line 234 of file unload_schema.c.

References is_req_class(), ml_ext_free_link(), db_objlist::next, NULL, and db_objlist::op.

Referenced by get_ordered_classes().

Here is the caller graph for this function:

static void force_one_class ( print_output output_ctx,
DB_OBJLIST **  class_list,
DB_OBJLIST **  order_list 
)
static

Definition at line 473 of file unload_schema.c.

References emit_cycle_warning(), db_objlist::next, and NULL.

Referenced by get_ordered_classes().

Here is the caller graph for this function:

static DB_OBJLIST * get_ordered_classes ( print_output output_ctx,
MOP class_table 
)
static
static int has_dependencies ( DB_OBJECT class_,
DB_OBJLIST unordered,
DB_OBJLIST ordered,
int  conservative 
)
static
static bool has_vclass_domains ( DB_OBJECT vclass)
static

Definition at line 1286 of file unload_schema.c.

Referenced by emit_query_specs(), and emit_query_specs_has_using_index().

Here is the caller graph for this function:

static int is_dependent_class ( DB_OBJECT class_,
DB_OBJLIST unordered,
DB_OBJLIST ordered 
)
static

Definition at line 278 of file unload_schema.c.

References ml_find().

Referenced by check_domain_dependencies(), and has_dependencies().

Here is the caller graph for this function:

static int order_classes ( DB_OBJLIST **  class_list,
DB_OBJLIST **  order_list,
int  conservative 
)
static

Definition at line 384 of file unload_schema.c.

References has_dependencies(), db_objlist::next, NULL, and db_objlist::op.

Referenced by get_ordered_classes().

Here is the caller graph for this function: