CUBRID Engine  latest
object_representation_sr.c File Reference
#include "object_representation_sr.h"
#include "btree_load.h"
#include "config.h"
#include "dbtype.h"
#include "error_manager.h"
#include "object_primitive.h"
#include "object_representation.h"
#include "set_object.h"
#include <assert.h>
#include <new>
#include <stdio.h>
#include <string.h>
Include dependency graph for object_representation_sr.c:

Go to the source code of this file.

Classes

struct  or_btree_property
 

Macros

#define DATA_INIT(data, type)   memset(data, 0, sizeof(DB_DATA))
 
#define OR_ARRAY_EXTENT   10
 
#define OR_VAR_TABLE_ELEMENT_OFFSET(table, index)
 
#define OR_VAR_TABLE_ELEMENT_LENGTH(table, index)
 
#define HEAP_MOVE_INSIDE_RECORD(rec, dest_offset, src_offset)
 

Typedefs

typedef struct or_btree_property OR_BTREE_PROPERTY
 

Functions

static int or_get_hierarchy_helper (THREAD_ENTRY *thread_p, OID *source_class, OID *class_, BTID *btid, OID **class_oids, HFID **hfids, int *num_classes, int *max_classes, int *partition_local_index)
 
static TP_DOMAINor_get_domain_internal (char *ptr)
 
static TP_DOMAINor_get_domain_and_cache (char *ptr)
 
static void or_get_att_index (char *ptr, BTID *btid)
 
static int or_get_default_value (OR_ATTRIBUTE *attr, char *ptr, int length)
 
static int or_get_current_default_value (OR_ATTRIBUTE *attr, char *ptr, int length)
 
static int or_cl_get_prop_nocopy (DB_SEQ *properties, const char *name, DB_VALUE *pvalue)
 
static void or_install_btids_foreign_key (const char *fkname, DB_SEQ *fk_seq, OR_INDEX *index)
 
static void or_install_btids_foreign_key_ref (DB_SEQ *fk_container, OR_INDEX *index)
 
static void or_install_btids_prefix_length (DB_SEQ *prefix_seq, OR_INDEX *index, int num_attrs)
 
static int or_install_btids_filter_pred (DB_SEQ *pred_seq, OR_INDEX *index)
 
static void or_install_btids_class (OR_CLASSREP *rep, BTID *id, DB_SEQ *constraint_seq, int seq_size, BTREE_TYPE type, const char *cons_name)
 
static int or_install_btids_attribute (OR_CLASSREP *rep, int att_id, BTID *id)
 
static void or_install_btids_constraint (OR_CLASSREP *rep, DB_SEQ *constraint_seq, BTREE_TYPE type, const char *cons_name)
 
static void or_install_btids_function_info (DB_SEQ *fi_seq, OR_INDEX *index)
 
static void or_install_btids (OR_CLASSREP *rep, DB_SEQ *props)
 
static OR_CLASSREPor_get_current_representation (RECDES *record, int do_indexes)
 
static OR_CLASSREPor_get_old_representation (RECDES *record, int repid, int do_indexes)
 
static const char * or_find_diskattr (RECDES *record, int attr_id)
 
static int or_get_attr_string (RECDES *record, int attr_id, int attr_index, char **string, int *alloced_string)
 
static char or_mvcc_get_flag (RECDES *record)
 
static void or_mvcc_set_flag (RECDES *record, char flags)
 
static INLINE MVCCID or_mvcc_get_insid (OR_BUF *buf, int mvcc_flags, int *error) __attribute__((ALWAYS_INLINE))
 
static INLINE int or_mvcc_set_insid (OR_BUF *buf, MVCC_REC_HEADER *mvcc_rec_header) __attribute__((ALWAYS_INLINE))
 
static INLINE MVCCID or_mvcc_get_delid (OR_BUF *buf, int mvcc_flags, int *error) __attribute__((ALWAYS_INLINE))
 
static INLINE int or_mvcc_get_chn (OR_BUF *buf, int *error) __attribute__((ALWAYS_INLINE))
 
static INLINE int or_mvcc_set_delid (OR_BUF *buf, MVCC_REC_HEADER *mvcc_rec_header) __attribute__((ALWAYS_INLINE))
 
static INLINE int or_mvcc_set_chn (OR_BUF *buf, MVCC_REC_HEADER *mvcc_rec_header) __attribute__((ALWAYS_INLINE))
 
static INLINE int or_mvcc_set_prev_version_lsa (OR_BUF *buf, MVCC_REC_HEADER *mvcc_rec_header) __attribute__((ALWAYS_INLINE))
 
static INLINE int or_mvcc_get_prev_version_lsa (OR_BUF *buf, int mvcc_flags, LOG_LSA *prev_version_lsa) __attribute__((ALWAYS_INLINE))
 
DISK_REPRorc_diskrep_from_record (THREAD_ENTRY *thread_p, RECDES *record)
 
void orc_free_diskrep (DISK_REPR *rep)
 
CLS_INFOorc_class_info_from_record (RECDES *record)
 
void orc_free_class_info (CLS_INFO *info)
 
int orc_subclasses_from_record (RECDES *record, int *array_size, OID **array_ptr)
 
int orc_superclasses_from_record (RECDES *record, int *array_size, OID **array_ptr)
 
void or_class_rep_dir (RECDES *record, OID *rep_dir_p)
 
void or_class_hfid (RECDES *record, HFID *hfid)
 
void or_class_tde_algorithm (RECDES *record, TDE_ALGORITHM *tde_algo)
 
int or_get_unique_hierarchy (THREAD_ENTRY *thread_p, RECDES *record, int attrid, BTID *btid, OID **class_oids, HFID **hfids, int *num_classes, int *partition_local_index)
 
OR_CLASSREP ** or_get_all_representation (RECDES *record, bool do_indexes, int *count)
 
OR_CLASSREPor_get_classrep (RECDES *record, int repid)
 
OR_CLASSREPor_get_classrep_noindex (RECDES *record, int repid)
 
OR_CLASSREPor_classrep_load_indexes (OR_CLASSREP *rep, RECDES *record)
 
int or_class_get_partition_info (RECDES *record, OR_PARTITION *partition_info, REPR_ID *repr_id, int *has_partition_info)
 
const char * or_get_constraint_comment (RECDES *record, const char *constraint_name)
 
void or_free_classrep (OR_CLASSREP *rep)
 
int or_get_attrname (RECDES *record, int attrid, char **string, int *alloced_string)
 
int or_get_attrcomment (RECDES *record, int attrid, char **string, int *alloced_string)
 
int or_replace_rep_id (RECDES *record, int repid)
 
int or_mvcc_get_header (RECDES *record, MVCC_REC_HEADER *mvcc_header)
 
int or_mvcc_set_header (RECDES *record, MVCC_REC_HEADER *mvcc_rec_header)
 
int or_mvcc_add_header (RECDES *record, MVCC_REC_HEADER *mvcc_rec_header, int bound_bit, int variable_offset_size)
 
int or_mvcc_set_log_lsa_to_record (RECDES *record, LOG_LSA *lsa)
 

Macro Definition Documentation

#define DATA_INIT (   data,
  type 
)    memset(data, 0, sizeof(DB_DATA))

Definition at line 42 of file object_representation_sr.c.

#define HEAP_MOVE_INSIDE_RECORD (   rec,
  dest_offset,
  src_offset 
)
Value:
do \
{ \
assert ((rec) != NULL && (dest_offset) >= 0 && (src_offset) >= 0); \
assert (((rec)->length - (src_offset)) >= 0); \
assert (((rec)->area_size <= 0) || ((rec)->area_size >= (rec)->length)); \
assert (((rec)->area_size <= 0) \
|| (((rec)->length + ((dest_offset) - (src_offset))) \
<= (rec)->area_size)); \
if ((dest_offset) != (src_offset)) \
{ \
memmove ((rec)->data + (dest_offset), (rec)->data + (src_offset), \
(rec)->length - (src_offset)); \
(rec)->length = (rec)->length + ((dest_offset) - (src_offset)); \
} \
} \
while (0)
#define assert(x)
#define NULL
Definition: freelistheap.h:34
if(extra_options)
Definition: dynamic_load.c:958
while(1)
Definition: cnvlex.c:816

Definition at line 68 of file object_representation_sr.c.

Referenced by or_mvcc_set_header().

#define OR_ARRAY_EXTENT   10

Definition at line 43 of file object_representation_sr.c.

Referenced by or_get_hierarchy_helper().

#define OR_VAR_TABLE_ELEMENT_LENGTH (   table,
  index 
)
#define OR_VAR_TABLE_ELEMENT_OFFSET (   table,
  index 
)

Typedef Documentation

Definition at line 58 of file object_representation_sr.c.

Function Documentation

static int or_cl_get_prop_nocopy ( DB_SEQ properties,
const char *  name,
DB_VALUE pvalue 
)
static
OR_CLASSREP* or_classrep_load_indexes ( OR_CLASSREP rep,
RECDES record 
)
OR_CLASSREP** or_get_all_representation ( RECDES record,
bool  do_indexes,
int *  count 
)

Definition at line 3092 of file object_representation_sr.c.

References ARG_FILE_LINE, assert, or_classrep::attributes, BIG_VAR_OFFSET_SIZE, BTID_SET_NULL, or_attribute::btids, or_classrep::class_attrs, classobj_initialize_default_expr(), or_attribute::classoid, or_attribute::current_default_value, recdes::data, DB_ATT_ALIGN, db_set_free(), or_default_value::default_expr, or_attribute::default_value, or_attribute::domain, ER_ERROR_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), error(), or_classrep::fixed_length, free_and_init, or_classrep::has_partition_info, i, or_attribute::id, or_classrep::id, or_attribute::index, or_classrep::indexes, or_attribute::is_fixed, or_attribute::location, or_classrep::n_attributes, or_attribute::n_btids, or_classrep::n_class_attrs, or_classrep::n_indexes, or_classrep::n_shared_attrs, or_classrep::n_variable, or_classrep::needs_indexes, or_classrep::next, NULL, OID_SET_NULL, or_free_classrep(), or_get_current_representation(), or_get_domain_and_cache(), OR_GET_INT, OR_GET_OFFSET_SIZE, or_install_btids(), OR_SET_ELEMENT_COUNT, OR_SET_ELEMENT_OFFSET, or_unpack_setref(), OR_VAR_IS_NULL, OR_VAR_OFFSET, OR_VAR_TABLE_ELEMENT_LENGTH, OR_VAR_TABLE_ELEMENT_OFFSET, OR_VAR_TABLE_SIZE, ORC_PARTITION_INDEX, ORC_PROPERTIES_INDEX, ORC_REP_ATTRIBUTES_INDEX, ORC_REP_FIXED_COUNT_OFFSET, ORC_REP_ID_OFFSET, ORC_REP_VAR_ATT_COUNT, ORC_REP_VARIABLE_COUNT_OFFSET, ORC_REPATT_DOMAIN_INDEX, ORC_REPATT_ID_OFFSET, ORC_REPATT_TYPE_OFFSET, ORC_REPATT_VAR_ATT_COUNT, ORC_REPRESENTATIONS_INDEX, or_attribute::position, or_classrep::shared_attrs, tp_domain_disk_size(), tp_domain_resolve_default(), or_attribute::type, or_default_value::val_length, and or_default_value::value.

Referenced by heap_classrepr_dump_all().

Here is the caller graph for this function:

static void or_get_att_index ( char *  ptr,
BTID btid 
)
static

Definition at line 1326 of file object_representation_sr.c.

References vfid::fileid, OR_GET_INT, OR_INT_SIZE, btid::root_pageid, btid::vfid, and vfid::volid.

Referenced by or_get_current_representation().

Here is the caller graph for this function:

int or_get_attr_string ( RECDES record,
int  attr_id,
int  attr_index,
char **  string,
int *  alloced_string 
)
static
int or_get_attrcomment ( RECDES record,
int  attrid,
char **  string,
int *  alloced_string 
)

Definition at line 3993 of file object_representation_sr.c.

References or_get_attr_string(), and ORC_ATT_COMMENT_INDEX.

Referenced by qexec_execute_build_columns().

Here is the caller graph for this function:

static int or_get_current_default_value ( OR_ATTRIBUTE attr,
char *  ptr,
int  length 
)
static
static OR_CLASSREP * or_get_current_representation ( RECDES record,
int  do_indexes 
)
static

Definition at line 2357 of file object_representation_sr.c.

References ARG_FILE_LINE, assert, or_classrep::attributes, or_attribute::auto_increment, BIG_VAR_OFFSET_SIZE, or_attribute::btids, or_classrep::class_attrs, classobj_get_prop(), classobj_initialize_default_expr(), or_attribute::classoid, or_attribute::current_default_value, recdes::data, DB_DEFAULT_NONE, db_get_int(), db_get_set(), db_get_string(), db_make_null(), db_set_free(), DB_TYPE_INTEGER, DB_TYPE_NULL, DB_TYPE_SEQUENCE, db_value_is_null(), DB_VALUE_TYPE, db_value_type(), or_attribute::def_order, or_default_value::default_expr, db_default_expr::default_expr_format, db_default_expr::default_expr_op, db_default_expr::default_expr_type, or_attribute::default_value, or_attribute::domain, ER_ERROR_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), or_classrep::fixed_length, free_and_init, or_classrep::has_partition_info, i, or_attribute::id, or_classrep::id, or_attribute::index, or_classrep::indexes, or_attribute::is_autoincrement, or_attribute::is_fixed, or_attribute::is_notnull, or_attribute::location, or_classrep::n_attributes, or_attribute::n_btids, or_classrep::n_class_attrs, or_classrep::n_indexes, or_classrep::n_shared_attrs, or_classrep::n_variable, or_classrep::needs_indexes, NO_ERROR, NULL, oid_Null_oid, or_attribute::on_update_expr, OR_FIXED_ATTRIBUTES_OFFSET, or_get_att_index(), or_get_current_default_value(), or_get_default_value(), or_get_domain_and_cache(), OR_GET_INT, OR_GET_OFFSET_SIZE, OR_GET_OID, or_get_value(), or_init(), or_install_btids(), or_rep_id(), OR_SET_ELEMENT_OFFSET, or_unpack_setref(), OR_VAR_IS_NULL, OR_VAR_OFFSET, OR_VAR_TABLE_ELEMENT_LENGTH, OR_VAR_TABLE_ELEMENT_OFFSET, OR_VAR_TABLE_SIZE, ORC_ATT_CLASS_OFFSET, ORC_ATT_CURRENT_VALUE_INDEX, ORC_ATT_DEF_ORDER_OFFSET, ORC_ATT_DOMAIN_INDEX, ORC_ATT_FLAG_OFFSET, ORC_ATT_ID_OFFSET, ORC_ATT_INDEX_OFFSET, ORC_ATT_ORIGINAL_VALUE_INDEX, ORC_ATT_PROPERTIES_INDEX, ORC_ATT_TYPE_OFFSET, ORC_ATT_VAR_ATT_COUNT, ORC_ATTRIBUTES_INDEX, ORC_CLASS_ATTR_COUNT_OFFSET, ORC_CLASS_ATTRS_INDEX, ORC_CLASS_VAR_ATT_COUNT, ORC_FIXED_COUNT_OFFSET, ORC_FIXED_LENGTH_OFFSET, ORC_PARTITION_INDEX, ORC_PROPERTIES_INDEX, ORC_SHARED_ATTRS_INDEX, ORC_SHARED_COUNT_OFFSET, ORC_VARIABLE_COUNT_OFFSET, or_attribute::position, pr_clear_value(), or_auto_increment::serial_obj, set_get_element_nocopy(), set_size(), or_classrep::shared_attrs, SM_ATTFLAG_AUTO_INCREMENT, SM_ATTFLAG_NON_NULL, strdup(), T_TO_CHAR, tp_domain_disk_size(), tp_domain_resolve_default(), TP_IS_CHAR_TYPE, or_attribute::type, or_default_value::val_length, and or_default_value::value.

Referenced by or_get_all_representation(), or_get_classrep(), or_get_classrep_noindex(), and or_get_old_representation().

Here is the caller graph for this function:

static int or_get_default_value ( OR_ATTRIBUTE attr,
char *  ptr,
int  length 
)
static
static TP_DOMAIN * or_get_domain_and_cache ( char *  ptr)
static

Definition at line 1305 of file object_representation_sr.c.

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

Referenced by or_get_all_representation(), or_get_current_representation(), and or_get_old_representation().

Here is the caller graph for this function:

static OR_CLASSREP * or_get_old_representation ( RECDES record,
int  repid,
int  do_indexes 
)
static

Definition at line 2888 of file object_representation_sr.c.

References ARG_FILE_LINE, assert, or_classrep::attributes, BIG_VAR_OFFSET_SIZE, BTID_SET_NULL, or_attribute::btids, or_classrep::class_attrs, classobj_initialize_default_expr(), or_attribute::classoid, or_attribute::current_default_value, recdes::data, DB_ATT_ALIGN, db_set_free(), or_default_value::default_expr, or_attribute::default_value, or_attribute::domain, ER_CT_UNKNOWN_REPRID, ER_ERROR_SEVERITY, er_set(), or_classrep::fixed_length, free_and_init, or_classrep::has_partition_info, i, or_attribute::id, or_classrep::id, or_attribute::index, or_classrep::indexes, or_attribute::is_fixed, or_attribute::location, or_classrep::n_attributes, or_attribute::n_btids, or_classrep::n_indexes, or_classrep::n_variable, or_classrep::needs_indexes, NULL, NULL_REPRID, OID_SET_NULL, or_get_current_representation(), or_get_domain_and_cache(), OR_GET_INT, OR_GET_OFFSET_SIZE, or_install_btids(), OR_SET_ELEMENT_COUNT, OR_SET_ELEMENT_OFFSET, or_unpack_setref(), OR_VAR_IS_NULL, OR_VAR_OFFSET, OR_VAR_TABLE_ELEMENT_LENGTH, OR_VAR_TABLE_ELEMENT_OFFSET, OR_VAR_TABLE_SIZE, ORC_PARTITION_INDEX, ORC_PROPERTIES_INDEX, ORC_REP_ATTRIBUTES_INDEX, ORC_REP_FIXED_COUNT_OFFSET, ORC_REP_ID_OFFSET, ORC_REP_VAR_ATT_COUNT, ORC_REP_VARIABLE_COUNT_OFFSET, ORC_REPATT_DOMAIN_INDEX, ORC_REPATT_ID_OFFSET, ORC_REPATT_TYPE_OFFSET, ORC_REPATT_VAR_ATT_COUNT, ORC_REPRESENTATIONS_INDEX, or_attribute::position, or_classrep::shared_attrs, tp_domain_disk_size(), tp_domain_resolve_default(), or_attribute::type, or_default_value::val_length, and or_default_value::value.

Referenced by or_get_classrep(), and or_get_classrep_noindex().

Here is the caller graph for this function:

static int or_install_btids_attribute ( OR_CLASSREP rep,
int  att_id,
BTID id 
)
static
static void or_install_btids_constraint ( OR_CLASSREP rep,
DB_SEQ constraint_seq,
BTREE_TYPE  type,
const char *  cons_name 
)
static
static void or_install_btids_prefix_length ( DB_SEQ prefix_seq,
OR_INDEX index,
int  num_attrs 
)
static
STATIC_INLINE int or_mvcc_get_chn ( OR_BUF buf,
int *  error 
)
static

Definition at line 4557 of file object_representation_sr.c.

References assert, ASSERT_ALIGN, or_buf::endptr, INT_ALIGNMENT, NO_ERROR, NULL, NULL_CHN, OR_GET_INT, OR_INT_SIZE, or_underflow(), or_buf::ptr, and STATIC_INLINE.

Referenced by or_mvcc_get_header().

Here is the caller graph for this function:

STATIC_INLINE MVCCID or_mvcc_get_delid ( OR_BUF buf,
int  mvcc_flags,
int *  error 
)
static
static char or_mvcc_get_flag ( RECDES record)
static

Definition at line 4427 of file object_representation_sr.c.

References assert, recdes::data, recdes::length, NULL, OR_GET_MVCC_FLAG, and OR_HEADER_SIZE.

Referenced by or_mvcc_set_log_lsa_to_record(), and or_replace_rep_id().

Here is the caller graph for this function:

STATIC_INLINE MVCCID or_mvcc_get_insid ( OR_BUF buf,
int  mvcc_flags,
int *  error 
)
static
STATIC_INLINE int or_mvcc_get_prev_version_lsa ( OR_BUF buf,
int  mvcc_flags,
LOG_LSA prev_version_lsa 
)
static
STATIC_INLINE int or_mvcc_set_chn ( OR_BUF buf,
MVCC_REC_HEADER mvcc_rec_header 
)
static

Definition at line 4609 of file object_representation_sr.c.

References assert, ASSERT_ALIGN, mvcc_rec_header::chn, INT_ALIGNMENT, NULL, or_put_int(), or_buf::ptr, and STATIC_INLINE.

Referenced by or_mvcc_add_header(), and or_mvcc_set_header().

Here is the caller graph for this function:

STATIC_INLINE int or_mvcc_set_delid ( OR_BUF buf,
MVCC_REC_HEADER mvcc_rec_header 
)
static
STATIC_INLINE int or_mvcc_set_insid ( OR_BUF buf,
MVCC_REC_HEADER mvcc_rec_header 
)
static
STATIC_INLINE int or_mvcc_set_prev_version_lsa ( OR_BUF buf,
MVCC_REC_HEADER mvcc_rec_header 
)
static
DISK_REPR* orc_diskrep_from_record ( THREAD_ENTRY thread_p,
RECDES record 
)

Definition at line 173 of file object_representation_sr.c.

References ARG_FILE_LINE, assert, or_classrep::attributes, disk_attribute::bt_stats, btree_stats::btid, or_index::btid, BTID_IS_EQUAL, or_attribute::btids, btree_get_root_header(), btree_glean_root_header_info(), BTREE_STATS_PKEYS_NUM, BTREE_STATS_RESERVED_NUM, disk_attribute::classoid, or_attribute::classoid, or_function_index::col_id, DB_TYPE_MIDXKEY, or_attribute::default_value, ER_ERROR_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), error(), disk_representation::fixed, disk_representation::fixed_length, or_classrep::fixed_length, or_index::func_index_info, btree_stats::has_function, btree_stats::height, i, disk_representation::id, disk_attribute::id, or_attribute::id, or_classrep::id, or_classrep::indexes, or_attribute::is_fixed, btree_stats::key_type, btid_int::key_type, btree_stats::keys, btree_stats::leafs, disk_attribute::location, or_attribute::location, or_classrep::n_attributes, or_attribute::n_btids, disk_attribute::n_btstats, disk_representation::n_fixed, or_classrep::n_indexes, disk_representation::n_variable, NO_ERROR, NULL, NULL_REPRID, OLD_PAGE, or_free_classrep(), or_get_classrep(), orc_free_diskrep(), PAGE_BTREE, vpid::pageid, btree_stats::pages, pgbuf_check_page_ptype(), pgbuf_fix, PGBUF_LATCH_READ, PGBUF_UNCONDITIONAL_LATCH, pgbuf_unfix_and_init, btree_stats::pkeys, btree_stats::pkeys_size, disk_attribute::position, or_attribute::position, btid::root_pageid, tp_domain::setdomain, btid_int::sys_btid, tp_domain_size(), TP_DOMAIN_TYPE, disk_attribute::type, or_attribute::type, or_default_value::val_length, disk_attribute::val_length, or_default_value::value, disk_attribute::value, disk_representation::variable, btid::vfid, vpid::volid, vfid::volid, and VPID_ISNULL.

Referenced by catalog_insert(), catalog_update(), and xcatalog_check_rep_dir().

Here is the caller graph for this function:

void orc_free_class_info ( CLS_INFO info)

Definition at line 523 of file object_representation_sr.c.

References free_and_init.

Referenced by catalog_insert().

Here is the caller graph for this function:

int orc_subclasses_from_record ( RECDES record,
int *  array_size,
OID **  array_ptr 
)
int orc_superclasses_from_record ( RECDES record,
int *  array_size,
OID **  array_ptr 
)