CUBRID Engine  latest
log_applier_sql_log.c File Reference
#include <stdio.h>
#include <assert.h>
#include <time.h>
#include <libgen.h>
#include <errno.h>
#include <unistd.h>
#include "log_applier_sql_log.h"
#include "system_parameter.h"
#include "object_primitive.h"
#include "object_template.h"
#include "object_print.h"
#include "error_manager.h"
#include "parser.h"
#include "work_space.h"
#include "class_object.h"
#include "environment_variable.h"
#include "set_object.h"
#include "cci_applier.h"
#include "schema_manager.h"
#include "dbtype.h"
#include "db_value_printer.hpp"
#include "mem_block.hpp"
#include "string_buffer.hpp"

Go to the source code of this file.

Classes

struct  sl_info
 

Macros

#define SL_LOG_FILE_MAX_SIZE   (prm_get_integer_value (PRM_ID_HA_SQL_LOG_MAX_SIZE_IN_MB) * 1024 * 1024)
 
#define FILE_ID_FORMAT   "%d"
 
#define SQL_ID_FORMAT   "%010u"
 
#define CATALOG_FORMAT   FILE_ID_FORMAT " | " SQL_ID_FORMAT
 

Typedefs

typedef struct sl_info SL_INFO
 

Functions

static int sl_write_sql (string_buffer &query, string_buffer *select)
 
static void sl_print_insert_att_names (string_buffer &strbuf, OBJ_TEMPASSIGN **assignments, int num_assignments)
 
static void sl_print_insert_att_values (string_buffer &strbuf, OBJ_TEMPASSIGN **assignments, int num_assignments)
 
static int sl_print_pk (string_buffer &strbuf, SM_CLASS *sm_class, DB_VALUE *key)
 
static void sl_print_midxkey (string_buffer &strbuf, SM_ATTRIBUTE **attributes, const DB_MIDXKEY *midxkey)
 
static void sl_print_update_att_set (string_buffer &strbuf, OBJ_TEMPASSIGN **assignments, int num_assignments)
 
static void sl_print_att_value (string_buffer &strbuf, const char *att_name, OBJ_TEMPASSIGN **assignments, int num_assignments)
 
static DB_VALUEsl_find_att_value (const char *att_name, OBJ_TEMPASSIGN **assignments, int num_assignments)
 
static FILE * sl_open_next_file (FILE *old_fp)
 
static FILE * sl_log_open (void)
 
static int sl_read_catalog (void)
 
static int sl_write_catalog (void)
 
static int create_dir (const char *new_dir)
 
static char * trim_single_quote (char *str, size_t len)
 
static int sl_print_select (string_buffer &strbuf, SM_CLASS *sm_class, DB_VALUE *key)
 
int sl_init (const char *db_name, const char *repl_log_path)
 
int sl_write_insert_sql (DB_OTMPL *inst_tp, DB_VALUE *key)
 
int sl_write_update_sql (DB_OTMPL *inst_tp, DB_VALUE *key)
 
int sl_write_delete_sql (char *class_name, MOBJ mclass, DB_VALUE *key)
 
int sl_write_statement_sql (char *class_name, char *db_user, int item_type, const char *stmt_text, char *ha_sys_prm)
 

Variables

SL_INFO sl_Info
 
static FILE * log_fp
 
static FILE * catalog_fp
 
static char sql_log_base_path [PATH_MAX]
 
static char sql_catalog_path [PATH_MAX]
 

Macro Definition Documentation

#define CATALOG_FORMAT   FILE_ID_FORMAT " | " SQL_ID_FORMAT

Definition at line 54 of file log_applier_sql_log.c.

Referenced by sl_read_catalog(), and sl_write_catalog().

#define FILE_ID_FORMAT   "%d"

Definition at line 52 of file log_applier_sql_log.c.

#define SL_LOG_FILE_MAX_SIZE   (prm_get_integer_value (PRM_ID_HA_SQL_LOG_MAX_SIZE_IN_MB) * 1024 * 1024)

Definition at line 50 of file log_applier_sql_log.c.

Referenced by sl_log_open(), and sl_write_sql().

#define SQL_ID_FORMAT   "%010u"

Definition at line 53 of file log_applier_sql_log.c.

Typedef Documentation

typedef struct sl_info SL_INFO

Definition at line 56 of file log_applier_sql_log.c.

Function Documentation

static int create_dir ( const char *  new_dir)
static

Definition at line 617 of file log_applier_sql_log.c.

References ER_FAILED, NO_ERROR, NULL, and p.

Referenced by sl_init().

Here is the caller graph for this function:

static DB_VALUE * sl_find_att_value ( const char *  att_name,
OBJ_TEMPASSIGN **  assignments,
int  num_assignments 
)
static

Definition at line 293 of file log_applier_sql_log.c.

References i, NULL, and obj_tempassign::variable.

Referenced by sl_print_att_value(), and sl_write_update_sql().

Here is the caller graph for this function:

int sl_init ( const char *  db_name,
const char *  repl_log_path 
)
static FILE * sl_log_open ( void  )
static

Definition at line 556 of file log_applier_sql_log.c.

References ARG_FILE_LINE, assert, sl_info::curr_file_id, er_log_debug, NULL, SL_LOG_FILE_MAX_SIZE, sl_open_next_file(), and sql_log_base_path.

Referenced by sl_write_sql().

Here is the caller graph for this function:

static FILE * sl_open_next_file ( FILE *  old_fp)
static

Definition at line 590 of file log_applier_sql_log.c.

References assert, sl_info::curr_file_id, sl_info::last_inserted_sql_id, NO_ERROR, NULL, sl_write_catalog(), and sql_log_base_path.

Referenced by sl_log_open(), and sl_write_sql().

Here is the caller graph for this function:

static void sl_print_att_value ( string_buffer strbuf,
const char *  att_name,
OBJ_TEMPASSIGN **  assignments,
int  num_assignments 
)
static

Definition at line 307 of file log_applier_sql_log.c.

References db_value_printer::describe_value(), NULL, and sl_find_att_value().

Referenced by sl_write_update_sql().

Here is the caller graph for this function:

static void sl_print_insert_att_names ( string_buffer strbuf,
OBJ_TEMPASSIGN **  assignments,
int  num_assignments 
)
static

Definition at line 237 of file log_applier_sql_log.c.

References i.

Referenced by sl_write_insert_sql().

Here is the caller graph for this function:

static void sl_print_insert_att_values ( string_buffer strbuf,
OBJ_TEMPASSIGN **  assignments,
int  num_assignments 
)
static

Definition at line 250 of file log_applier_sql_log.c.

References db_value_printer::describe_value(), and i.

Referenced by sl_write_insert_sql().

Here is the caller graph for this function:

static void sl_print_midxkey ( string_buffer strbuf,
SM_ATTRIBUTE **  attributes,
const DB_MIDXKEY midxkey 
)
static

Definition at line 271 of file log_applier_sql_log.c.

References db_value_printer::describe_value(), i, db_midxkey::ncolumns, NULL, and pr_midxkey_get_element_nocopy().

Referenced by sl_print_pk().

Here is the caller graph for this function:

static int sl_print_select ( string_buffer strbuf,
SM_CLASS sm_class,
DB_VALUE key 
)
static

Definition at line 98 of file log_applier_sql_log.c.

References ER_FAILED, NO_ERROR, sl_print_pk(), and sm_ch_name().

Referenced by sl_write_delete_sql(), sl_write_insert_sql(), and sl_write_update_sql().

Here is the caller graph for this function:

static void sl_print_update_att_set ( string_buffer strbuf,
OBJ_TEMPASSIGN **  assignments,
int  num_assignments 
)
static

Definition at line 319 of file log_applier_sql_log.c.

References db_value_printer::describe_value(), and i.

Referenced by sl_write_update_sql().

Here is the caller graph for this function:

static int sl_read_catalog ( void  )
static

Definition at line 139 of file log_applier_sql_log.c.

References CATALOG_FORMAT, sl_info::curr_file_id, ER_FAILED, sl_info::last_inserted_sql_id, NO_ERROR, NULL, sl_write_catalog(), and sql_catalog_path.

Referenced by sl_init().

Here is the caller graph for this function:

static int sl_write_catalog ( void  )
static
int sl_write_delete_sql ( char *  class_name,
MOBJ  mclass,
DB_VALUE key 
)

Definition at line 423 of file log_applier_sql_log.c.

References ER_FAILED, NO_ERROR, sl_print_pk(), sl_print_select(), and sl_write_sql().

Referenced by la_apply_delete_log().

Here is the caller graph for this function:

int sl_write_insert_sql ( DB_OTMPL inst_tp,
DB_VALUE key 
)
int sl_write_statement_sql ( char *  class_name,
char *  db_user,
int  item_type,
const char *  stmt_text,
char *  ha_sys_prm 
)
static char* trim_single_quote ( char *  str,
size_t  len 
)
static

Definition at line 87 of file log_applier_sql_log.c.

Referenced by sl_write_update_sql().

Here is the caller graph for this function:

Variable Documentation

FILE* catalog_fp
static

Definition at line 66 of file log_applier_sql_log.c.

Referenced by sl_init(), and sl_write_catalog().

FILE* log_fp
static

Definition at line 65 of file log_applier_sql_log.c.

Referenced by sl_init(), and sl_write_sql().

SL_INFO sl_Info

Definition at line 63 of file log_applier_sql_log.c.

char sql_catalog_path[PATH_MAX]
static

Definition at line 68 of file log_applier_sql_log.c.

Referenced by sl_init(), sl_read_catalog(), and sl_write_catalog().

char sql_log_base_path[PATH_MAX]
static

Definition at line 67 of file log_applier_sql_log.c.

Referenced by sl_init(), sl_log_open(), and sl_open_next_file().