CUBRID Engine  latest
ddl_log.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/timeb.h>
#include <signal.h>
#include <assert.h>
#include "porting.h"
#include "cas_common.h"
#include "ddl_log.h"
#include "parse_tree.h"
#include "system_parameter.h"
#include "environment_variable.h"
#include "broker_config.h"
#include "util_func.h"
Include dependency graph for ddl_log.c:

Go to the source code of this file.

Classes

struct  t_ddl_audit_handle
 

Macros

#define DDL_LOG_MSG   (256)
 
#define DDL_LOG_PATH   "log/ddl_audit"
 
#define DDL_LOG_LOADDB_FILE_PATH   "log/ddl_audit/loaddb"
 
#define DDL_LOG_CSQL_FILE_PATH   "log/ddl_audit/csql"
 
#define FILE_BUFFER_SIZE   (1024)
 
#define TIME_STRING_SIZE   (16)
 
#define DDL_TIME_LEN   (32)
 
#define MAX_RETRY_COUNT   100
 

Typedefs

typedef struct t_ddl_audit_handle T_DDL_AUDIT_HANDLE
 

Functions

static int logddl_make_filename (char *filename_buf, size_t buf_size, T_APP_NAME app_name)
 
static int logddl_make_copy_filename (T_APP_NAME app_name, const char *file_full_path, char *copy_filename, size_t buf_size)
 
static int logddl_make_copy_dir (T_APP_NAME app_name, char *copy_filename, char *copy_fullpath, size_t buf_size)
 
static void logddl_backup (const char *path)
 
static int logddl_create_dir (const char *new_dir)
 
static int logddl_create_log_msg (char *msg)
 
static int logddl_get_current_date_time_string (char *buf, size_t size)
 
static int logddl_file_copy (char *src_file, char *dest_file)
 
static void logddl_remove_char (char *string, char ch)
 
static FILE * logddl_open (T_APP_NAME app_name)
 
static int logddl_get_time_string (char *buf, struct timeval *time_val)
 
static FILE * logddl_fopen_and_lock (const char *path, const char *mode)
 
static void logddl_set_elapsed_time (long sec, long msec)
 
static void logddl_timeval_diff (struct timeval *start, struct timeval *end, long *res_sec, long *res_msec)
 
static const char * logddl_get_app_name (T_APP_NAME app_name)
 
void logddl_init ()
 
void logddl_free (bool all_free)
 
void logddl_destroy ()
 
void logddl_set_app_name (T_APP_NAME app_name)
 
void logddl_set_db_name (const char *db_name)
 
void logddl_set_user_name (const char *user_name)
 
void logddl_set_ip (const char *ip_addr)
 
void logddl_set_pid (const int pid)
 
void logddl_set_br_name (const char *br_name)
 
void logddl_set_br_index (const int index)
 
void logddl_set_sql_text (char *sql_text, int len)
 
void logddl_set_stmt_type (int stmt_type)
 
void logddl_set_loaddb_file_type (T_LOADDB_FILE_TYPE file_type)
 
void logddl_set_csql_input_type (T_CSQL_INPUT_TYPE input_type)
 
void logddl_set_load_filename (const char *load_filename)
 
void logddl_set_file_line (int file_line)
 
void logddl_set_err_msg (char *msg)
 
void logddl_set_err_code (int err_code)
 
void logddl_set_start_time (struct timeval *time_val)
 
void logddl_set_msg (const char *fmt,...)
 
void logddl_set_execute_type (char exe_type)
 
void logddl_set_commit_count (int count)
 
void logddl_set_commit_mode (bool mode)
 
void logddl_set_jsp_mode (bool mode)
 
bool logddl_get_jsp_mode ()
 
void logddl_write_end ()
 
void logddl_write ()
 
void logddl_write_tran_str (const char *fmt,...)
 
void logddl_write_end_for_csql_fileinput (const char *fmt,...)
 
void logddl_set_logging_enabled (bool enable)
 
bool logddl_is_ddl_type (int node_type)
 

Variables

static T_DDL_AUDIT_HANDLEddl_audit_handle = NULL
 
static bool ddl_logging_enabled = false
 
static bool is_executed_ddl_for_trans = false
 
static bool is_executed_ddl_for_csql = false
 

Macro Definition Documentation

#define DDL_LOG_CSQL_FILE_PATH   "log/ddl_audit/csql"

Definition at line 56 of file ddl_log.c.

Referenced by logddl_make_copy_dir().

#define DDL_LOG_LOADDB_FILE_PATH   "log/ddl_audit/loaddb"

Definition at line 55 of file ddl_log.c.

Referenced by logddl_make_copy_dir().

#define DDL_LOG_MSG   (256)
#define DDL_LOG_PATH   "log/ddl_audit"

Definition at line 54 of file ddl_log.c.

Referenced by logddl_make_filename().

#define DDL_TIME_LEN   (32)

Definition at line 59 of file ddl_log.c.

#define FILE_BUFFER_SIZE   (1024)

Definition at line 57 of file ddl_log.c.

Referenced by logddl_file_copy().

#define MAX_RETRY_COUNT   100

Referenced by cas_fopen(), and logddl_fopen_and_lock().

#define TIME_STRING_SIZE   (16)

Definition at line 58 of file ddl_log.c.

Referenced by logddl_make_copy_filename().

Typedef Documentation

Definition at line 62 of file ddl_log.c.

Function Documentation

static void logddl_backup ( const char *  path)
static

Definition at line 1123 of file ddl_log.c.

References NULL.

Referenced by logddl_write(), logddl_write_end_for_csql_fileinput(), and logddl_write_tran_str().

Here is the caller graph for this function:

static int logddl_create_dir ( const char *  new_dir)
static

Definition at line 1192 of file ddl_log.c.

References NULL, p, strlen, and trim().

Referenced by logddl_make_copy_dir(), and logddl_open().

Here is the caller graph for this function:

void logddl_destroy ( )

Definition at line 185 of file ddl_log.c.

References t_ddl_audit_handle::err_msg, FREE_MEM, NULL, and t_ddl_audit_handle::sql_text.

Referenced by cas_free(), csql(), and loaddb_internal().

Here is the caller graph for this function:

static int logddl_file_copy ( char *  src_file,
char *  dest_file 
)
static

Definition at line 460 of file ddl_log.c.

References FILE_BUFFER_SIZE, and NULL.

Referenced by logddl_write(), logddl_write_end_for_csql_fileinput(), and logddl_write_tran_str().

Here is the caller graph for this function:

static FILE * logddl_fopen_and_lock ( const char *  path,
const char *  mode 
)
static

Definition at line 1152 of file ddl_log.c.

References MAX_RETRY_COUNT, NULL, p, and SLEEP_MILISEC.

Referenced by logddl_open().

Here is the caller graph for this function:

static const char * logddl_get_app_name ( T_APP_NAME  app_name)
static

Definition at line 1386 of file ddl_log.c.

References APP_NAME_CAS, APP_NAME_CSQL, and APP_NAME_LOADDB.

Referenced by logddl_make_filename().

Here is the caller graph for this function:

static int logddl_get_current_date_time_string ( char *  buf,
size_t  size 
)
static

Definition at line 1246 of file ddl_log.c.

References NULL.

Referenced by logddl_make_copy_filename().

Here is the caller graph for this function:

bool logddl_get_jsp_mode ( )

Definition at line 440 of file ddl_log.c.

References t_ddl_audit_handle::jsp_mode.

Referenced by csql_execute_statements(), and process_request().

Here is the caller graph for this function:

static int logddl_get_time_string ( char *  buf,
struct timeval *  time_val 
)
static

Definition at line 1263 of file ddl_log.c.

References NULL, and util_get_second_and_ms_since_epoch().

Referenced by logddl_create_log_msg(), logddl_set_start_time(), logddl_write_end_for_csql_fileinput(), and logddl_write_tran_str().

Here is the caller graph for this function:

static int logddl_make_copy_dir ( T_APP_NAME  app_name,
char *  copy_filename,
char *  copy_fullpath,
size_t  buf_size 
)
static
static int logddl_make_copy_filename ( T_APP_NAME  app_name,
const char *  file_full_path,
char *  copy_filename,
size_t  buf_size 
)
static

Definition at line 531 of file ddl_log.c.

References assert, envvar_root(), logddl_get_current_date_time_string(), NULL, PATH_SEPARATOR, and TIME_STRING_SIZE.

Referenced by logddl_write(), logddl_write_end_for_csql_fileinput(), and logddl_write_tran_str().

Here is the caller graph for this function:

static int logddl_make_filename ( char *  filename_buf,
size_t  buf_size,
T_APP_NAME  app_name 
)
static
static FILE * logddl_open ( T_APP_NAME  app_name)
static

Definition at line 641 of file ddl_log.c.

References t_ddl_audit_handle::log_filepath, logddl_create_dir(), logddl_fopen_and_lock(), logddl_make_filename(), and NULL.

Referenced by logddl_write(), logddl_write_end_for_csql_fileinput(), and logddl_write_tran_str().

Here is the caller graph for this function:

static void logddl_remove_char ( char *  string,
char  ch 
)
static

Definition at line 1317 of file ddl_log.c.

Referenced by logddl_set_err_msg().

Here is the caller graph for this function:

void logddl_set_app_name ( T_APP_NAME  app_name)

Definition at line 196 of file ddl_log.c.

References t_ddl_audit_handle::app_name, and ddl_logging_enabled.

Referenced by cas_main(), csql(), and loaddb_internal().

Here is the caller graph for this function:

void logddl_set_br_index ( const int  index)

Definition at line 259 of file ddl_log.c.

References t_ddl_audit_handle::br_index, and ddl_logging_enabled.

Referenced by cas_main().

Here is the caller graph for this function:

void logddl_set_br_name ( const char *  br_name)

Definition at line 250 of file ddl_log.c.

References t_ddl_audit_handle::br_name, BROKER_NAME_LEN, ddl_logging_enabled, and NULL.

Referenced by cas_main().

Here is the caller graph for this function:

void logddl_set_commit_count ( int  count)

Definition at line 413 of file ddl_log.c.

References t_ddl_audit_handle::commit_count, cubregex::count(), and ddl_logging_enabled.

Referenced by ldr_exec_query_from_file().

Here is the caller graph for this function:

void logddl_set_commit_mode ( bool  mode)

Definition at line 422 of file ddl_log.c.

References t_ddl_audit_handle::auto_commit_mode, ddl_logging_enabled, and mode.

Referenced by csql_do_session_cmd(), csql_execute_statements(), fn_execute_batch(), fn_execute_internal(), fn_prepare_internal(), and start_csql().

Here is the caller graph for this function:

void logddl_set_csql_input_type ( T_CSQL_INPUT_TYPE  input_type)

Definition at line 317 of file ddl_log.c.

References t_ddl_audit_handle::csql_input_type, and ddl_logging_enabled.

Referenced by csql_execute_statements().

Here is the caller graph for this function:

void logddl_set_db_name ( const char *  db_name)

Definition at line 205 of file ddl_log.c.

References t_ddl_audit_handle::db_name, ddl_logging_enabled, and NULL.

Referenced by cas_main(), csql(), and loaddb_internal().

Here is the caller graph for this function:

static void logddl_set_elapsed_time ( long  sec,
long  msec 
)
static

Definition at line 451 of file ddl_log.c.

References ddl_logging_enabled, and t_ddl_audit_handle::elapsed_time.

Referenced by logddl_create_log_msg().

Here is the caller graph for this function:

void logddl_set_err_code ( int  err_code)
void logddl_set_err_msg ( char *  msg)

Definition at line 344 of file ddl_log.c.

References ALLOC_COPY, ddl_logging_enabled, t_ddl_audit_handle::err_msg, FREE_MEM, logddl_remove_char(), and NULL.

Referenced by nonscr_display_error().

Here is the caller graph for this function:

void logddl_set_execute_type ( char  exe_type)

Definition at line 404 of file ddl_log.c.

References ddl_logging_enabled, and t_ddl_audit_handle::execute_type.

Referenced by ux_execute_batch().

Here is the caller graph for this function:

void logddl_set_file_line ( int  file_line)

Definition at line 335 of file ddl_log.c.

References ddl_logging_enabled, and t_ddl_audit_handle::file_line_number.

Referenced by csql_execute_statements(), and ldr_exec_query_from_file().

Here is the caller graph for this function:

void logddl_set_ip ( const char *  ip_addr)

Definition at line 232 of file ddl_log.c.

References ddl_logging_enabled, t_ddl_audit_handle::ip_addr, and NULL.

Referenced by cas_main(), and csql().

Here is the caller graph for this function:

void logddl_set_jsp_mode ( bool  mode)

Definition at line 431 of file ddl_log.c.

References ddl_logging_enabled, t_ddl_audit_handle::jsp_mode, and mode.

Referenced by cas_main().

Here is the caller graph for this function:

void logddl_set_load_filename ( const char *  load_filename)

Definition at line 326 of file ddl_log.c.

References ddl_logging_enabled, and t_ddl_audit_handle::load_filename.

Referenced by csql_execute_statements(), and loaddb_internal().

Here is the caller graph for this function:

void logddl_set_loaddb_file_type ( T_LOADDB_FILE_TYPE  file_type)

Definition at line 308 of file ddl_log.c.

References ddl_logging_enabled, and t_ddl_audit_handle::loaddb_file_type.

Referenced by loaddb_internal().

Here is the caller graph for this function:

void logddl_set_logging_enabled ( bool  enable)

Definition at line 995 of file ddl_log.c.

References ddl_logging_enabled.

Referenced by cas_main(), csql(), csql_execute_statements(), and loaddb_internal().

Here is the caller graph for this function:

void logddl_set_msg ( const char *  fmt,
  ... 
)

Definition at line 392 of file ddl_log.c.

References DDL_LOG_MSG, ddl_logging_enabled, and t_ddl_audit_handle::msg.

Referenced by csql_execute_statements(), ldr_exec_query_from_file(), ux_auto_commit(), and ux_execute_batch().

Here is the caller graph for this function:

void logddl_set_pid ( const int  pid)

Definition at line 241 of file ddl_log.c.

References ddl_logging_enabled, and t_ddl_audit_handle::pid.

Referenced by cas_main(), csql(), and loaddb_internal().

Here is the caller graph for this function:

void logddl_set_sql_text ( char *  sql_text,
int  len 
)

Definition at line 268 of file ddl_log.c.

References ddl_logging_enabled, FREE_MEM, MALLOC, NULL, and t_ddl_audit_handle::sql_text.

Referenced by csql_execute_statements(), fn_execute_array(), fn_execute_internal(), fn_prepare_internal(), and ux_execute_batch().

Here is the caller graph for this function:

void logddl_set_start_time ( struct timeval *  time_val)
void logddl_set_stmt_type ( int  stmt_type)
void logddl_set_user_name ( const char *  user_name)

Definition at line 223 of file ddl_log.c.

References ddl_logging_enabled, NULL, and t_ddl_audit_handle::user_name.

Referenced by cas_main(), csql(), and loaddb_internal().

Here is the caller graph for this function:

static void logddl_timeval_diff ( struct timeval *  start,
struct timeval *  end,
long *  res_sec,
long *  res_msec 
)
static

Definition at line 1368 of file ddl_log.c.

References assert, and NULL.

Referenced by logddl_create_log_msg().

Here is the caller graph for this function:

Variable Documentation

T_DDL_AUDIT_HANDLE* ddl_audit_handle = NULL
static

Definition at line 92 of file ddl_log.c.

bool is_executed_ddl_for_csql = false
static
bool is_executed_ddl_for_trans = false
static

Definition at line 115 of file ddl_log.c.

Referenced by logddl_free(), logddl_set_stmt_type(), and logddl_write_tran_str().