CUBRID Engine
latest
|
#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) |
#define CLASS_NAME_MAX 80 |
Definition at line 60 of file unload_schema.c.
#define EX_ERROR_CHECK | ( | c, | |
d, | |||
m | |||
) |
#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().
enum ATTRIBUTE_QUALIFIER |
Enumerator | |
---|---|
INSTANCE_ATTRIBUTE | |
SHARED_ATTRIBUTE | |
CLASS_ATTRIBUTE |
Definition at line 89 of file unload_schema.c.
enum METHOD_QUALIFIER |
Enumerator | |
---|---|
INSTANCE_METHOD | |
CLASS_METHOD |
Definition at line 96 of file unload_schema.c.
enum RESOLUTION_QUALIFIER |
Enumerator | |
---|---|
INSTANCE_RESOLUTION | |
CLASS_RESOLUTION |
Definition at line 102 of file unload_schema.c.
enum SERIAL_VALUE_INDEX |
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.
|
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().
|
static |
Definition at line 3488 of file unload_schema.c.
Referenced by create_filename_indexes(), create_filename_schema(), and create_filename_trigger().
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().
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().
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().
|
static |
Definition at line 2095 of file unload_schema.c.
References emit_class_attributes(), and emit_instance_attributes().
Referenced by emit_schema().
|
static |
Definition at line 2313 of file unload_schema.c.
References CLASS_ATTRIBUTE, sm_attribute::comment, db_attribute_default(), db_attribute_domain(), db_attribute_is_non_null(), db_attribute_name(), db_default_expression_string(), DB_DEFAULT_NONE, DB_IS_NULL, sm_default_value::default_expr, db_default_expr::default_expr_format, db_default_expr::default_expr_op, db_default_expr::default_expr_type, default_value, sm_attribute::default_value, desc_value_print(), emit_autoincrement_def(), emit_domain_def(), ex_contains_object_reference(), help_print_describe_comment(), INSTANCE_ATTRIBUTE, NO_ERROR, NULL, sm_attribute::on_update_default_expr, PRINT_IDENTIFIER, SHARED_ATTRIBUTE, and T_TO_CHAR.
Referenced by emit_class_attributes(), and emit_instance_attributes().
|
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().
|
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().
|
static |
Definition at line 2053 of file unload_schema.c.
References db_attribute_class(), db_attribute_is_shared(), db_attribute_name(), db_attribute_next(), db_attribute_order(), db_attribute_type(), db_get_attributes(), db_get_class_name(), NULL, PRINT_IDENTIFIER, and sm_attribute::storage_order.
Referenced by emit_schema().
|
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().
|
static |
Definition at line 445 of file unload_schema.c.
Referenced by force_one_class().
|
static |
Definition at line 2814 of file unload_schema.c.
References tp_domain::collation_id, cubregex::count(), db_domain_class(), db_domain_next(), db_domain_precision(), db_domain_raw_json_schema(), db_domain_scale(), db_domain_set(), db_get_class_name(), DB_GET_ENUM_ELEM_STRING, DB_MAX_STRING_LENGTH, DB_TYPE_BIT, DB_TYPE_CHAR, DB_TYPE_ENUMERATION, DB_TYPE_JSON, DB_TYPE_MULTISET, DB_TYPE_NCHAR, DB_TYPE_NUMERIC, DB_TYPE_OBJECT, DB_TYPE_SEQUENCE, DB_TYPE_SET, DB_TYPE_VARBIT, DB_TYPE_VARCHAR, DB_TYPE_VARNCHAR, DOM_GET_ENUM_ELEM, DOM_GET_ENUM_ELEMS_COUNT, i, lang_get_collation_name(), pr_type::name, NULL, pr_type_from_id(), PRINT_IDENTIFIER, TP_DOMAIN_TYPE, and TP_FLOATING_PRECISION_VALUE.
Referenced by emit_attribute_def(), and emit_method_def().
|
static |
Definition at line 3396 of file unload_schema.c.
References classobj_describe_foreign_key_action(), sm_class_constraint::comment, db_attribute_class(), db_attribute_name(), db_constraint_attributes(), DB_CONSTRAINT_FOREIGN_KEY, db_constraint_next(), db_constraint_type(), db_get_class_name(), db_get_constraints(), sm_foreign_key_info::delete_action, sm_class_constraint::fk_info, help_print_describe_comment(), sm_class_constraint::name, db_objlist::next, NO_ERROR, NULL, db_objlist::op, PRINT_IDENTIFIER, sm_foreign_key_info::ref_class_oid, sm_foreign_key_info::update_action, and ws_mop().
Referenced by extract_classes().
|
static |
Definition at line 2628 of file unload_schema.c.
References assert, sm_function_info::attr_index_start, AU_DISABLE, AU_ENABLE, au_fetch_class(), AU_FETCH_READ, AU_SELECT, classobj_find_class_index(), sm_function_info::col_id, sm_class_constraint::comment, db_attribute_name(), db_constraint_asc_desc(), db_constraint_attributes(), DB_CONSTRAINT_INDEX, db_constraint_next(), db_constraint_prefix_length(), DB_CONSTRAINT_REVERSE_INDEX, DB_CONSTRAINT_REVERSE_UNIQUE, db_constraint_type(), DB_CONSTRAINT_UNIQUE, db_get_class_name(), db_get_constraints(), do_get_partition_parent(), do_is_partitioned_subclass(), sm_function_info::expr_str, sm_function_info::fi_domain, sm_class_constraint::filter_predicate, sm_class_constraint::func_index_info, help_print_describe_comment(), sm_class_constraint::index_status, tp_domain::is_desc, sm_class_constraint::name, NO_ERROR, NULL, sm_predicate_info::pred_string, PRINT_FUNCTION_INDEX_NAME, PRINT_IDENTIFIER, and SM_ONLINE_INDEX_BUILDING_IN_PROGRESS.
Referenced by emit_indexes().
|
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().
|
static |
Definition at line 1690 of file unload_schema.c.
References assert, sm_attribute::auto_increment, db_attribute_class(), db_attribute_is_indexed(), db_attribute_is_reverse_unique(), db_attribute_is_shared(), db_attribute_is_unique(), db_attribute_name(), db_attribute_next(), db_get(), db_get_attributes(), db_get_class_name(), db_get_int(), db_get_string(), db_make_null(), emit_attribute_def(), emit_reverse_unique_def(), emit_unique_def(), er_clear(), ER_IT_DATA_OVERFLOW, FOLLOW_STORAGE_ORDER, i, INSTANCE_ATTRIBUTE, NO_ERROR, NULL, numeric_db_value_add(), numeric_db_value_compare(), numeric_db_value_print(), numeric_db_value_sub(), NUMERIC_MAX_STRING_SIZE, sm_attribute::order, pr_clear_value(), PRINT_IDENTIFIER, SHARED_ATTRIBUTE, and sm_attribute::storage_order.
Referenced by emit_all_attributes().
|
static |
Definition at line 3053 of file unload_schema.c.
References db_methfile_name().
Referenced by emit_method_files().
|
static |
Definition at line 2976 of file unload_schema.c.
References CLASS_METHOD, db_method_arg_count(), db_method_arg_domain(), db_method_function(), db_method_name(), db_method_return_domain(), emit_domain_def(), i, INSTANCE_METHOD, NULL, and PRINT_IDENTIFIER.
Referenced by emit_methods().
|
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().
|
static |
Definition at line 2161 of file unload_schema.c.
References CLASS_METHOD, db_get_class_methods(), db_get_class_name(), db_get_methods(), db_method_class(), db_method_next(), emit_method_def(), emit_method_files(), INSTANCE_METHOD, NULL, and PRINT_IDENTIFIER.
Referenced by emit_schema().
|
static |
Definition at line 3134 of file unload_schema.c.
References au_fetch_class(), AU_FETCH_READ, AU_SELECT, db_get_class_name(), db_get_int(), emit_partition_parts(), sm_partition::expr, db_objlist::next, NO_ERROR, NULL, db_objlist::op, sm_class::partition, sm_partition::partition_type, PRINT_IDENTIFIER, PT_PARTITION_HASH, PT_PARTITION_LIST, PT_PARTITION_RANGE, set_get_element_nocopy(), sm_class::users, and sm_partition::values.
Referenced by emit_schema().
|
static |
Definition at line 3065 of file unload_schema.c.
References sm_partition::comment, DB_IS_NULL, desc_value_print(), help_print_describe_comment(), NULL, sm_partition::partition_type, sm_partition::pname, PRINT_IDENTIFIER, PT_PARTITION_LIST, PT_PARTITION_RANGE, set_get_element_nocopy(), set_size(), and sm_partition::values.
Referenced by emit_partition_info().
|
static |
Definition at line 1302 of file unload_schema.c.
References db_get_class_name(), db_get_query_specs(), db_is_vclass(), db_query_spec_next(), db_query_spec_string(), has_vclass_domains(), i, ml_append(), ml_find(), db_objlist::next, NULL, db_objlist::op, parser, parser_create_parser(), parser_free_parser(), parser_parse_string(), parser_walk_tree(), PRINT_IDENTIFIER, pt_has_using_index_clause(), and pt_print_query_spec_no_list().
Referenced by emit_schema().
|
static |
Definition at line 1435 of file unload_schema.c.
References db_get_class_name(), db_get_query_specs(), db_is_vclass(), db_query_spec_next(), db_query_spec_string(), has_vclass_domains(), i, db_objlist::next, NO_ERROR, NULL, db_objlist::op, parser, parser_create_parser(), parser_free_parser(), parser_parse_string(), PRINT_IDENTIFIER, and pt_print_query_spec_no_list().
Referenced by emit_indexes().
|
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().
|
static |
Definition at line 1582 of file unload_schema.c.
References CLASS_RESOLUTION, db_get_class_name(), db_get_resolutions(), db_resolution_isclass(), db_resolution_next(), emit_resolution_def(), INSTANCE_RESOLUTION, NULL, and PRINT_IDENTIFIER.
Referenced by emit_schema().
|
static |
Definition at line 2561 of file unload_schema.c.
References db_attribute_class(), db_attribute_name(), db_constraint_attributes(), db_constraint_next(), DB_CONSTRAINT_REVERSE_UNIQUE, db_constraint_type(), db_get_class_name(), db_get_constraints(), sm_class_constraint::index_status, sm_class_constraint::name, NULL, PRINT_IDENTIFIER, and SM_ONLINE_INDEX_BUILDING_IN_PROGRESS.
Referenced by emit_instance_attributes().
|
static |
Definition at line 1095 of file unload_schema.c.
References assert, au_export_grants(), au_fetch_class_force(), AU_FETCH_READ, class_type(), sm_class::collation_id, sm_class::comment, db_get_class_name(), db_is_vclass(), do_is_partitioned_subclass(), emit_all_attributes(), emit_class_meta(), emit_class_owner(), emit_methods(), emit_partition_info(), emit_query_specs(), emit_resolutions(), emit_superclasses(), FOLLOW_STORAGE_ORDER, help_print_describe_comment(), lang_get_collation_name(), db_objlist::next, NO_ERROR, NULL, db_objlist::op, PRINT_IDENTIFIER, SM_CLASSFLAG_LOCALCHECKOPTION, SM_CLASSFLAG_REUSE_OID, SM_CLASSFLAG_WITHCHECKOPTION, sm_get_class_flag(), sm_class::tde_algorithm, TDE_ALGORITHM_NONE, and tde_get_algorithm_name().
Referenced by extract_classes().
|
static |
Definition at line 3292 of file unload_schema.c.
References AU_DISABLE, AU_ENABLE, db_find_class(), db_get(), db_get_all_objects(), db_get_int(), db_get_object(), db_get_set(), db_get_string(), db_get_type_name(), DB_IS_NULL, db_objlist_free(), DB_TYPE_RESULTSET, db_value_clear(), desc_value_print(), emit_stored_procedure_args(), err, db_objlist::next, NO_ERROR, NULL, PRINT_IDENTIFIER, SP_ATTR_ARG_COUNT, SP_ATTR_ARGS, SP_ATTR_COMMENT, SP_ATTR_NAME, SP_ATTR_OWNER, SP_ATTR_RETURN_TYPE, SP_ATTR_SP_TYPE, SP_ATTR_TARGET, SP_CLASS_NAME, SP_TYPE_FUNCTION, and SP_TYPE_PROCEDURE.
Referenced by extract_classes().
|
static |
Definition at line 3222 of file unload_schema.c.
References AU_DISABLE, AU_ENABLE, db_get(), db_get_int(), db_get_object(), db_get_string(), db_get_type_name(), DB_IS_NULL, DB_TYPE_RESULTSET, desc_value_print(), err, i, NO_ERROR, pr_clear_value(), PRINT_IDENTIFIER, set_get_element(), SP_ATTR_ARG_COMMENT, SP_ATTR_ARG_NAME, SP_ATTR_DATA_TYPE, SP_ATTR_MODE, SP_MODE_IN, and SP_MODE_OUT.
Referenced by emit_stored_procedure().
|
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().
|
static |
Definition at line 2438 of file unload_schema.c.
References sm_class_constraint::asc_desc, sm_class_constraint::comment, db_attribute_class(), db_attribute_name(), db_constraint_attributes(), db_constraint_next(), DB_CONSTRAINT_PRIMARY_KEY, db_constraint_type(), DB_CONSTRAINT_UNIQUE, db_get_class_name(), db_get_constraints(), help_print_describe_comment(), i, sm_class_constraint::index_status, sm_class_constraint::name, NULL, PRINT_IDENTIFIER, SM_CONSTRAINT_PRIMARY_KEY, SM_ONLINE_INDEX_BUILDING_IN_PROGRESS, and sm_class_constraint::type.
Referenced by emit_instance_attributes().
|
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().
|
static |
Definition at line 611 of file unload_schema.c.
References ARG_FILE_LINE, db_compile_and_execute_local(), DB_CURSOR_SUCCESS, db_get_int(), db_get_string(), DB_IS_NULL, db_make_null(), db_make_string(), db_query_end(), db_query_first_tuple(), db_query_get_tuple_value(), db_query_next_tuple(), DB_TYPE_INTEGER, DB_TYPE_NUMERIC, DB_TYPE_STRING, db_value_clear(), DB_VALUE_TYPE, desc_value_print(), er_clear(), ER_ERROR_SEVERITY, ER_INVALID_SERIAL_VALUE, ER_IT_DATA_OVERFLOW, er_set(), err, error(), i, NO_ERROR, numeric_db_value_add(), numeric_db_value_compare(), numeric_db_value_print(), numeric_db_value_sub(), NUMERIC_MAX_STRING_SIZE, pr_type_name(), PRINT_IDENTIFIER, SERIAL_CACHED_NUM, SERIAL_COMMENT, SERIAL_CURRENT_VAL, SERIAL_CYCLIC, SERIAL_INCREMENT_VAL, SERIAL_MAX_VAL, SERIAL_MIN_VAL, SERIAL_NAME, SERIAL_OWNER_NAME, SERIAL_STARTED, SERIAL_VALUE_INDEX_MAX, tp_domain_resolve_default(), and TP_DOMAIN_TYPE.
Referenced by extract_classes().
int extract_classes | ( | extract_context & | ctxt, |
print_output & | schema_output_ctx | ||
) |
Definition at line 857 of file unload_schema.c.
References au_export_users(), extract_context::classes, db_error_code(), db_error_string(), extract_context::do_auth, emit_foreign_key(), emit_schema(), emit_stored_procedure(), er_errid(), ER_INVALID_SERIAL_VALUE, extract_context::exec_name, export_serial(), get_ordered_classes(), extract_context::has_indexes, NO_ERROR, NULL, required_class_only, extract_context::storage_order, and extract_context::vclass_list_has_using_index.
Referenced by extract_classes_to_file().
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().
int extract_indexes_to_file | ( | extract_context & | ctxt, |
const char * | output_filename | ||
) |
Definition at line 1000 of file unload_schema.c.
References extract_context::classes, emit_indexes(), extract_context::exec_name, fopen_ex(), extract_context::has_indexes, NULL, output_file, output_filename, and extract_context::vclass_list_has_using_index.
Referenced by unloaddb().
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().
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().
|
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().
|
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().
|
static |
Definition at line 473 of file unload_schema.c.
References emit_cycle_warning(), db_objlist::next, and NULL.
Referenced by get_ordered_classes().
|
static |
Definition at line 506 of file unload_schema.c.
References ARG_FILE_LINE, cubregex::count(), DB_FETCH_READ, ER_ERROR_SEVERITY, ER_NODATA_TOBE_UNLOADED, er_set(), filter_system_classes(), filter_unrequired_classes(), force_one_class(), i, input_filename, ml_ext_add(), ml_ext_free(), NULL, order_classes(), required_class_only, and sm_fetch_all_classes().
Referenced by extract_classes().
|
static |
Definition at line 330 of file unload_schema.c.
References check_domain_dependencies(), db_attribute_domain(), db_attribute_next(), db_get_attributes(), db_get_superclasses(), is_dependent_class(), db_objlist::next, NULL, and db_objlist::op.
Referenced by order_classes().
Definition at line 1286 of file unload_schema.c.
Referenced by emit_query_specs(), and emit_query_specs_has_using_index().
|
static |
Definition at line 278 of file unload_schema.c.
References ml_find().
Referenced by check_domain_dependencies(), and has_dependencies().
|
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().