CUBRID Engine  latest
transform_cl.c File Reference
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "porting.h"
#include "memory_alloc.h"
#include "error_manager.h"
#include "work_space.h"
#include "oid.h"
#include "object_representation.h"
#include "object_domain.h"
#include "object_primitive.h"
#include "class_object.h"
#include "set_object.h"
#include "transform.h"
#include "transform_cl.h"
#include "schema_manager.h"
#include "locator_cl.h"
#include "object_accessor.h"
#include "trigger_manager.h"
#include "locator.h"
#include "server_interface.h"
#include "execute_statement.h"
#include "db_json.hpp"
#include "dbtype.h"

Go to the source code of this file.

Classes

struct  or_tempoid
 
struct  or_fixup
 

Macros

#define TF_FIXUP_REFERENCE_QUANT   32
 

Typedefs

typedef struct or_tempoid OR_TEMPOID
 
typedef struct or_fixup OR_FIXUP
 
typedef int(* LSIZER) (void *)
 
typedef void(* LWRITER) (void *, void *)
 
typedef DB_LIST *(* LREADER) (void *)
 
typedef void(* VREADER) (void *, void *)
 

Functions

static int optimize_sets (SM_CLASS *class_, MOBJ volatile obj)
 
static OR_FIXUPtf_make_fixup (void)
 
static void tf_free_fixup (OR_FIXUP *fix)
 
static void fixup_callback (LC_OIDMAP *oidmap)
 
static int tf_do_fixup (OR_FIXUP *fix)
 
static int put_varinfo (OR_BUF *buf, char *obj, SM_CLASS *class_, int offset_size)
 
static int object_size (SM_CLASS *class_, MOBJ obj, int *offset_size_ptr)
 
static int put_attributes (OR_BUF *buf, char *obj, SM_CLASS *class_)
 
static char * get_current (OR_BUF *buf, SM_CLASS *class_, MOBJ *obj_ptr, int bound_bit_flag, int offset_size)
 
static SM_ATTRIBUTEfind_current_attribute (SM_CLASS *class_, int id)
 
static void clear_new_unbound (char *obj, SM_CLASS *class_, SM_REPRESENTATION *oldrep)
 
static char * get_old (OR_BUF *buf, SM_CLASS *class_, MOBJ *obj_ptr, int repid, int bound_bit_flag, int offset_size)
 
static char * unpack_allocator (int size)
 
static OR_VARINFOread_var_table (OR_BUF *buf, int nvars)
 
static OR_VARINFOread_var_table_internal (OR_BUF *buf, int nvars, int offset_size)
 
static void free_var_table (OR_VARINFO *vars)
 
static int string_disk_size (const char *string)
 
static char * get_string (OR_BUF *buf, int length)
 
static void put_string (OR_BUF *buf, const char *string)
 
static int object_set_size (DB_OBJLIST *list)
 
static int put_object_set (OR_BUF *buf, DB_OBJLIST *list)
 
static DB_OBJLISTget_object_set (OR_BUF *buf, int expected)
 
static int substructure_set_size (DB_LIST *list, LSIZER function)
 
static void put_substructure_set (OR_BUF *buf, DB_LIST *list, LWRITER writer, OID *class_, int repid)
 
static DB_LISTget_substructure_set (OR_BUF *buf, LREADER reader, int expected)
 
static void install_substructure_set (OR_BUF *buf, DB_LIST *list, VREADER reader, int expected)
 
static int property_list_size (DB_SEQ *properties)
 
static void put_property_list (OR_BUF *buf, DB_SEQ *properties)
 
static DB_SEQget_property_list (OR_BUF *buf, int expected_size)
 
static int domain_size (TP_DOMAIN *domain)
 
static void domain_to_disk (OR_BUF *buf, TP_DOMAIN *domain)
 
static TP_DOMAINdisk_to_domain2 (OR_BUF *buf)
 
static TP_DOMAINdisk_to_domain (OR_BUF *buf)
 
static void metharg_to_disk (OR_BUF *buf, SM_METHOD_ARGUMENT *arg)
 
static int metharg_size (SM_METHOD_ARGUMENT *arg)
 
static SM_METHOD_ARGUMENTdisk_to_metharg (OR_BUF *buf)
 
static int methsig_to_disk (OR_BUF *buf, SM_METHOD_SIGNATURE *sig)
 
static void methsig_to_disk_lwriter (void *buf, void *sig)
 
static int methsig_size (SM_METHOD_SIGNATURE *sig)
 
static SM_METHOD_SIGNATUREdisk_to_methsig (OR_BUF *buf)
 
static int method_to_disk (OR_BUF *buf, SM_METHOD *method)
 
static void method_to_disk_lwriter (void *buf, void *method)
 
static int method_size (SM_METHOD *method)
 
static void disk_to_method (OR_BUF *buf, SM_METHOD *method)
 
static int methfile_to_disk (OR_BUF *buf, SM_METHOD_FILE *file)
 
static void methfile_to_disk_lwriter (void *buf, void *file)
 
static int methfile_size (SM_METHOD_FILE *file)
 
static SM_METHOD_FILEdisk_to_methfile (OR_BUF *buf)
 
static int query_spec_to_disk (OR_BUF *buf, SM_QUERY_SPEC *query_spec)
 
static void query_spec_to_disk_lwriter (void *buf, void *query_spec)
 
static int query_spec_size (SM_QUERY_SPEC *statement)
 
static SM_QUERY_SPECdisk_to_query_spec (OR_BUF *buf)
 
static int attribute_to_disk (OR_BUF *buf, SM_ATTRIBUTE *att)
 
static void attribute_to_disk_lwriter (void *buf, void *att)
 
static int attribute_size (SM_ATTRIBUTE *att)
 
static void disk_to_attribute (OR_BUF *buf, SM_ATTRIBUTE *att)
 
static int resolution_to_disk (OR_BUF *buf, SM_RESOLUTION *res)
 
static void resolution_to_disk_lwriter (void *buf, void *res)
 
static int resolution_size (SM_RESOLUTION *res)
 
static SM_RESOLUTIONdisk_to_resolution (OR_BUF *buf)
 
static int repattribute_to_disk (OR_BUF *buf, SM_REPR_ATTRIBUTE *rat)
 
static void repattribute_to_disk_lwriter (void *buf, void *rat)
 
static int repattribute_size (SM_REPR_ATTRIBUTE *rat)
 
static SM_REPR_ATTRIBUTEdisk_to_repattribute (OR_BUF *buf)
 
static int representation_size (SM_REPRESENTATION *rep)
 
static int representation_to_disk (OR_BUF *buf, SM_REPRESENTATION *rep)
 
static void representation_to_disk_lwriter (void *buf, void *rep)
 
static SM_REPRESENTATIONdisk_to_representation (OR_BUF *buf)
 
static int check_class_structure (SM_CLASS *class_)
 
static int put_class_varinfo (OR_BUF *buf, SM_CLASS *class_)
 
static void put_class_attributes (OR_BUF *buf, SM_CLASS *class_)
 
static void class_to_disk (OR_BUF *buf, SM_CLASS *class_)
 
static void tag_component_namespace (SM_COMPONENT *components, SM_NAME_SPACE name_space)
 
static SM_CLASSdisk_to_class (OR_BUF *buf, SM_CLASS **class_ptr)
 
static void root_to_disk (OR_BUF *buf, ROOT_CLASS *root)
 
static int root_size (MOBJ rootobj)
 
static int tf_class_size (MOBJ classobj)
 
static ROOT_CLASSdisk_to_root (OR_BUF *buf)
 
static int enumeration_size (const DB_ENUMERATION *enumeration)
 
static void put_enumeration (OR_BUF *buf, const DB_ENUMERATION *e)
 
static int get_enumeration (OR_BUF *buf, DB_ENUMERATION *enumeration, int expected)
 
static int tf_attribute_default_expr_to_property (SM_ATTRIBUTE *attr_list)
 
static int partition_info_to_disk (OR_BUF *buf, SM_PARTITION *partition_info)
 
static void partition_info_to_disk_lwriter (void *buf, void *partition_info)
 
static SM_PARTITIONdisk_to_partition_info (OR_BUF *buf)
 
static int partition_info_size (SM_PARTITION *partition_info)
 
static void or_pack_mop (OR_BUF *buf, MOP mop)
 
static int tf_add_fixup (OR_FIXUP *fix, DB_OBJECT *obj, void *ref)
 
OIDtf_need_permanent_oid (or_buf *buf, DB_OBJECT *obj)
 
TF_STATUS tf_mem_to_disk (MOP classmop, MOBJ classobj, MOBJ volatile obj, RECDES *record, bool *index_flag)
 
MOBJ tf_disk_to_mem (MOBJ classobj, RECDES *record, int *convertp)
 
MOBJ tf_disk_to_class (OID *oid, RECDES *record)
 
TF_STATUS tf_class_to_disk (MOBJ classobj, RECDES *record)
 
int tf_object_size (MOBJ classobj, MOBJ obj)
 

Variables

int tf_Allow_fixups = 1
 

Macro Definition Documentation

#define TF_FIXUP_REFERENCE_QUANT   32

Definition at line 408 of file transform_cl.c.

Referenced by tf_add_fixup().

Typedef Documentation

typedef DB_LIST*(* LREADER) (void *)

Definition at line 122 of file transform_cl.c.

typedef int(* LSIZER) (void *)

Definition at line 120 of file transform_cl.c.

typedef void(* LWRITER) (void *, void *)

Definition at line 121 of file transform_cl.c.

typedef struct or_fixup OR_FIXUP
typedef struct or_tempoid OR_TEMPOID
typedef void(* VREADER) (void *, void *)

Definition at line 123 of file transform_cl.c.

Function Documentation

static void attribute_to_disk_lwriter ( void *  buf,
void *  att 
)
inlinestatic

Definition at line 2956 of file transform_cl.c.

References attribute_to_disk(), and STATIC_CAST.

Referenced by put_class_attributes().

Here is the caller graph for this function:

static int check_class_structure ( SM_CLASS class_)
static

Definition at line 3545 of file transform_cl.c.

Referenced by class_to_disk(), and tf_class_size().

Here is the caller graph for this function:

static void class_to_disk ( OR_BUF buf,
SM_CLASS class_ 
)
static
static void disk_to_attribute ( OR_BUF buf,
SM_ATTRIBUTE att 
)
static

Definition at line 3001 of file transform_cl.c.

References assert, sm_attribute::auto_increment, sm_attribute::class_mop, classobj_get_prop(), classobj_initialize_default_expr(), sm_attribute::comment, sm_attribute::constraints, pr_type::data_readval(), DB_DEFAULT_NONE, db_get_int(), db_get_object(), db_get_set(), db_get_string(), DB_TYPE_ENUMERATION, DB_TYPE_INTEGER, DB_TYPE_NULL, DB_TYPE_SEQUENCE, db_value_is_null(), db_value_put_null(), DB_VALUE_TYPE, db_value_type(), sm_default_value::default_expr, db_default_expr::default_expr_format, db_default_expr::default_expr_op, db_default_expr::default_expr_type, sm_attribute::default_value, disk_to_domain(), sm_attribute::domain, er_errid(), sm_attribute::flags, free_var_table(), get_object_set(), get_property_list(), get_string(), get_substructure_set(), sm_attribute::header, pr_type::id, sm_attribute::id, ID_NULL, or_varinfo::length, tf_meta_class::mc_n_variable, sm_component::name, sm_component::name_space, NO_ERROR, NULL, sm_attribute::offset, sm_attribute::on_update_default_expr, or_abort(), or_get_int(), or_get_value(), ORC_ATT_COMMENT_INDEX, ORC_ATT_CURRENT_VALUE_INDEX, ORC_ATT_DOMAIN_INDEX, ORC_ATT_NAME_INDEX, ORC_ATT_ORIGINAL_VALUE_INDEX, ORC_ATT_PROPERTIES_INDEX, ORC_ATT_TRIGGER_INDEX, sm_attribute::order, sm_attribute::order_link, sm_default_value::original_value, pr_clear_value(), pr_complete_enum_value(), pr_type_from_id(), sm_attribute::properties, rc, read_var_table(), set_get_element_nocopy(), set_size(), T_TO_CHAR, tf_Metaclass_attribute, TP_IS_CHAR_TYPE, tp_Object, TR_CACHE_ATTRIBUTE, tr_make_schema_cache(), sm_attribute::triggers, tp_domain::type, sm_attribute::type, sm_default_value::value, and ws_copy_string().

Referenced by disk_to_class().

Here is the caller graph for this function:

static SM_CLASS * disk_to_class ( OR_BUF buf,
SM_CLASS **  class_ptr 
)
static

Definition at line 3976 of file transform_cl.c.

References ARG_FILE_LINE, assert, ASSERT_ERROR, sm_class::att_ids, sm_attribute::auto_increment, AUTO_INCREMENT_SERIAL_NAME_MAX_LENGTH, sm_class_header::ch_heap, sm_class_header::ch_rep_dir, classobj_alloc_threaded_array(), classobj_fixup_loaded_class(), classobj_free_class(), classobj_initialize_attributes(), classobj_initialize_methods(), classobj_make_class(), CT_SERIAL_NAME, pr_type::data_readval(), db_get_object(), db_ws_free(), disk_to_attribute(), disk_to_methfile(), disk_to_method(), disk_to_partition_info(), disk_to_query_spec(), disk_to_representation(), disk_to_resolution(), do_get_serial_obj_id(), ER_ERROR_SEVERITY, ER_OBJ_INVALID_ATTRIBUTE, er_set(), vfid::fileid, sm_attribute::flags, free_var_table(), get_object_set(), get_property_list(), get_string(), get_substructure_set(), sm_attribute::header, sm_class::header, HFID_IS_NULL, hfid::hpgid, ID_ATTRIBUTE, ID_CLASS_ATTRIBUTE, ID_CLASS_METHOD, ID_METHOD, ID_SHARED_ATTRIBUTE, install_substructure_set(), or_varinfo::length, tf_meta_class::mc_n_variable, sm_class::method_ids, sm_component::name, sm_component::next, NO_ERROR, NULL, OID_ISNULL, on_error, or_abort(), or_get_int(), or_get_oid(), ORC_ATTRIBUTES_INDEX, ORC_CLASS_ATTRS_INDEX, ORC_CLASS_METHODS_INDEX, ORC_COMMENT_INDEX, ORC_LOADER_COMMANDS_INDEX, ORC_METHOD_FILES_INDEX, ORC_METHODS_INDEX, ORC_NAME_INDEX, ORC_PARTITION_INDEX, ORC_PROPERTIES_INDEX, ORC_QUERY_SPEC_INDEX, ORC_REPRESENTATIONS_INDEX, ORC_RESOLUTIONS_INDEX, ORC_SHARED_ATTRS_INDEX, ORC_SUBCLASSES_INDEX, ORC_SUPERCLASSES_INDEX, ORC_TRIGGERS_INDEX, rc, read_var_table(), SET_AUTO_INCREMENT_SERIAL_NAME, SM_ATTFLAG_AUTO_INCREMENT, sm_ch_heap(), sm_ch_name(), sm_ch_rep_dir(), sm_find_class(), tag_component_namespace(), tf_Metaclass_class, tp_Object, TR_CACHE_CLASS, tr_make_schema_cache(), hfid::vfid, and vfid::volid.

Referenced by tf_disk_to_class().

Here is the caller graph for this function:

static TP_DOMAIN * disk_to_domain ( OR_BUF buf)
static

Definition at line 2239 of file transform_cl.c.

References disk_to_domain2(), NULL, and tp_domain_cache().

Referenced by disk_to_attribute(), disk_to_metharg(), and disk_to_repattribute().

Here is the caller graph for this function:

static SM_QUERY_SPEC * disk_to_query_spec ( OR_BUF buf)
static
static int enumeration_size ( const DB_ENUMERATION enumeration)
static

Definition at line 4589 of file transform_cl.c.

References or_packed_enumeration_size().

Referenced by domain_size(), and domain_to_disk().

Here is the caller graph for this function:

static SM_ATTRIBUTE * find_current_attribute ( SM_CLASS class_,
int  id 
)
static

Definition at line 1023 of file transform_cl.c.

References sm_class::attributes, sm_attribute::header, sm_attribute::id, sm_component::next, and NULL.

Referenced by get_old().

Here is the caller graph for this function:

static void fixup_callback ( LC_OIDMAP oidmap)
static

Definition at line 572 of file transform_cl.c.

References lc_oidmap::client_data, i, if(), NULL, lc_oidmap::oid, OR_PUT_OID, or_tempoid::refcount, and or_tempoid::references.

Referenced by tf_do_fixup().

Here is the caller graph for this function:

static int get_enumeration ( OR_BUF buf,
DB_ENUMERATION enumeration,
int  expected 
)
static

Definition at line 4613 of file transform_cl.c.

References db_enumeration::count, db_enumeration::elements, NO_ERROR, NULL, and or_get_enumeration().

Referenced by disk_to_domain2().

Here is the caller graph for this function:

static DB_OBJLIST * get_object_set ( OR_BUF buf,
int  expected 
)
static

Definition at line 1713 of file transform_cl.c.

References cubregex::count(), pr_type::data_readval(), db_get_object(), i, ml_append(), NULL, or_abort(), or_skip_set_header(), and tp_Object.

Referenced by disk_to_attribute(), and disk_to_class().

Here is the caller graph for this function:

static DB_SEQ * get_property_list ( OR_BUF buf,
int  expected_size 
)
static

Definition at line 2000 of file transform_cl.c.

References pr_type::data_readval(), db_get_set(), max, NULL, or_abort(), set_free(), set_size(), and tp_Sequence.

Referenced by disk_to_attribute(), disk_to_class(), disk_to_methfile(), disk_to_method(), and disk_to_representation().

Here is the caller graph for this function:

static DB_LIST * get_substructure_set ( OR_BUF buf,
LREADER  reader,
int  expected 
)
static
static void install_substructure_set ( OR_BUF buf,
DB_LIST list,
VREADER  reader,
int  expected 
)
static

Definition at line 1917 of file transform_cl.c.

References cubregex::count(), i, db_list::next, NULL, or_skip_set_header(), and p.

Referenced by disk_to_class().

Here is the caller graph for this function:

static int metharg_size ( SM_METHOD_ARGUMENT arg)
static
static int methfile_size ( SM_METHOD_FILE file)
static
static void methfile_to_disk_lwriter ( void *  buf,
void *  file 
)
inlinestatic

Definition at line 2688 of file transform_cl.c.

References methfile_to_disk(), and STATIC_CAST.

Referenced by put_class_attributes().

Here is the caller graph for this function:

static void method_to_disk_lwriter ( void *  buf,
void *  method 
)
inlinestatic

Definition at line 2567 of file transform_cl.c.

References method_to_disk(), and STATIC_CAST.

Referenced by put_class_attributes().

Here is the caller graph for this function:

static void methsig_to_disk_lwriter ( void *  buf,
void *  sig 
)
inlinestatic

Definition at line 2417 of file transform_cl.c.

References methsig_to_disk(), and STATIC_CAST.

Referenced by method_to_disk().

Here is the caller graph for this function:

static int object_set_size ( DB_OBJLIST list)
static
static int optimize_sets ( SM_CLASS class_,
MOBJ volatile  obj 
)
static

Definition at line 310 of file transform_cl.c.

References sm_class::attributes, sm_attribute::domain, error(), sm_attribute::header, sm_component::next, NO_ERROR, NULL, sm_attribute::offset, setobj_sort(), TP_DOMAIN_TYPE, and TP_IS_SET_TYPE.

Referenced by tf_mem_to_disk().

Here is the caller graph for this function:

static void or_pack_mop ( OR_BUF buf,
MOP  mop 
)
static
static void partition_info_to_disk_lwriter ( void *  buf,
void *  partition_info 
)
inlinestatic

Definition at line 4919 of file transform_cl.c.

References partition_info_to_disk(), and STATIC_CAST.

Referenced by put_class_attributes().

Here is the caller graph for this function:

static int property_list_size ( DB_SEQ properties)
static
static void put_enumeration ( OR_BUF buf,
const DB_ENUMERATION e 
)
static

Definition at line 4600 of file transform_cl.c.

References or_put_enumeration().

Referenced by domain_to_disk().

Here is the caller graph for this function:

static int put_object_set ( OR_BUF buf,
DB_OBJLIST list 
)
static
static void put_property_list ( OR_BUF buf,
DB_SEQ properties 
)
static

Definition at line 1965 of file transform_cl.c.

References pr_type::data_writeval(), db_make_sequence(), max, NULL, set_size(), and tp_Sequence.

Referenced by attribute_to_disk(), methfile_to_disk(), method_to_disk(), put_class_attributes(), and representation_to_disk().

Here is the caller graph for this function:

static int put_varinfo ( OR_BUF buf,
char *  obj,
SM_CLASS class_,
int  offset_size 
)
static
static int query_spec_size ( SM_QUERY_SPEC statement)
static
static void query_spec_to_disk_lwriter ( void *  buf,
void *  query_spec 
)
inlinestatic

Definition at line 2797 of file transform_cl.c.

References query_spec_to_disk(), and STATIC_CAST.

Referenced by put_class_attributes().

Here is the caller graph for this function:

static OR_VARINFO * read_var_table_internal ( OR_BUF buf,
int  nvars,
int  offset_size 
)
static

Definition at line 1444 of file transform_cl.c.

References or_get_var_table_internal(), and unpack_allocator().

Referenced by read_var_table().

Here is the caller graph for this function:

static int repattribute_size ( SM_REPR_ATTRIBUTE rat)
static
static void repattribute_to_disk_lwriter ( void *  buf,
void *  rat 
)
inlinestatic

Definition at line 3343 of file transform_cl.c.

References repattribute_to_disk(), and STATIC_CAST.

Referenced by representation_to_disk().

Here is the caller graph for this function:

static int representation_size ( SM_REPRESENTATION rep)
static
static void representation_to_disk_lwriter ( void *  buf,
void *  rep 
)
inlinestatic

Definition at line 3472 of file transform_cl.c.

References representation_to_disk(), and STATIC_CAST.

Referenced by put_class_attributes().

Here is the caller graph for this function:

static int resolution_size ( SM_RESOLUTION res)
static
static void resolution_to_disk_lwriter ( void *  buf,
void *  res 
)
inlinestatic

Definition at line 3211 of file transform_cl.c.

References resolution_to_disk(), and STATIC_CAST.

Referenced by put_class_attributes().

Here is the caller graph for this function:

static int root_size ( MOBJ  rootobj)
static
static void tag_component_namespace ( SM_COMPONENT components,
SM_NAME_SPACE  name_space 
)
static

Definition at line 3956 of file transform_cl.c.

References sm_component::name_space, sm_component::next, and NULL.

Referenced by disk_to_class().

Here is the caller graph for this function:

static int tf_do_fixup ( OR_FIXUP fix)
static

Definition at line 595 of file transform_cl.c.

References error(), fixup_callback(), locator_assign_oidset(), NO_ERROR, NULL, and or_fixup::oidset.

Referenced by tf_mem_to_disk().

Here is the caller graph for this function:

static void tf_free_fixup ( OR_FIXUP fix)
static
static OR_FIXUP * tf_make_fixup ( void  )
static

Definition at line 345 of file transform_cl.c.

References NULL, and or_fixup::oidset.

Referenced by tf_mem_to_disk().

Here is the caller graph for this function:

int tf_object_size ( MOBJ  classobj,
MOBJ  obj 
)

Definition at line 4562 of file transform_cl.c.

References object_size(), root_size(), sm_Root_class, and tf_class_size().

Referenced by locator_add_oidset_object(), locator_assign_permanent_oid(), and sm_object_size_quick().

Here is the caller graph for this function:

static char * unpack_allocator ( int  size)
static

Definition at line 1417 of file transform_cl.c.

Referenced by read_var_table_internal().

Here is the caller graph for this function:

Variable Documentation

int tf_Allow_fixups = 1

Definition at line 70 of file transform_cl.c.

Referenced by tf_mem_to_disk(), and tf_need_permanent_oid().