CUBRID Engine
latest
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include "cubrid_getopt.h"
#include "cas_common.h"
#include "cas_cci.h"
#include "broker_log_util.h"
#include "porting.h"
#include "error_code.h"
Go to the source code of this file.
Classes | |
struct | t_sql_info |
struct | t_summary_info |
struct | t_sql_result |
Macros | |
#define | STAT_MAX_DIFF_TIME (60000) /* 60 * 1000 : 10 min */ |
#define | SORT_BUF_MAX (4096) |
#define | BIND_STR_BUF_SIZE (4096) |
#define | SQL_INFO_TITLE_LEN (128) |
#define | CCI_ERR_FILE_NAME "replay.err" |
#define | PASS_SQL_FILE_NAME "skip.sql" |
#define | DEFAULT_DIFF_TIME_LOWER (0.01) /* 10 millisecond */ |
#define | DEFAULT_BREAK_TIME (0.01) /* 10 millisecond */ |
#define | INVALID_PORT_NUM (-1) |
#define | free_and_init(ptr) |
Typedefs | |
typedef enum temp_read_result | READ_RESULT |
typedef struct t_sql_info | T_SQL_INFO |
typedef struct t_summary_info | T_SUMMARY_INFO |
typedef struct t_sql_result | T_SQL_RESULT |
Enumerations | |
enum | temp_read_result { READ_STOP = -1, READ_CONTINUE = 0, READ_SUCCESS = 1 } |
Functions | |
static int | log_replay (char *infilename, char *outfilename) |
static char * | get_next_log_line (FILE *infp, T_STRING *linebuf_tstr, const off_t last_offset, int *lineno) |
static char * | get_query_stmt_from_plan (int req) |
static int | log_prepare (FILE *cci_err, FILE *pass_sql, int con, char *sql_log, T_SQL_INFO *sql_info, T_SUMMARY_INFO *summary) |
static int | get_cci_type (char *p) |
static int | log_bind_value (int req, T_STRING *linebuf, char *sql_log, char *output_result, int remain_bind_buf) |
static int | log_execute (int con_h, int req, char *sql_log, double *execute_time) |
static void | get_sql_time_info (char *sql_log, T_SQL_INFO *info) |
static void | update_diff_time_statistics (double diff_time) |
static int | print_temp_result (char *sql_log, T_SQL_INFO *info) |
static void | update_summary_info (T_SUMMARY_INFO *summary, T_SQL_INFO *sql_info) |
static void | print_summary_info (T_SUMMARY_INFO *summary) |
static void | print_result (FILE *outfp, double max_diff_time, double min_diff_time, int tmp_line_len_max) |
static char * | make_sql_info (char *info_buf, char *start_p, int diff_time, int buf_size) |
static int | result_sort_func (const void *arg1, const void *arg2) |
static READ_RESULT | get_temp_file_line (char *read_buf, unsigned int read_buf_size, int *diff_time, char **endp) |
static int | print_result_without_sort (FILE *outfp, int print_diff_time_lower, int read_buf_max) |
static int | print_result_with_sort (FILE *outfp, int print_diff_time_lower, int num_query, int read_buf_max) |
static int | get_args (int argc, char *argv[]) |
static int | open_file (char *infilename, char *outfilename, FILE **infp, FILE **outfp, FILE **cci_errfp, FILE **skip_sqlfp) |
static void | close_file (FILE *infp, FILE *outfp, FILE *cci_errfp, FILE *skip_sqlfp) |
int | main (int argc, char *argv[]) |
Variables | |
static char * | host = NULL |
static int | broker_port = INVALID_PORT_NUM |
static char * | dbname = NULL |
static char * | dbuser = NULL |
static char * | dbpasswd = NULL |
static char | from_date [128] = "" |
static char | to_date [128] = "" |
static char | check_date_flag = 0 |
static char | rewrite_query_flag = 0 |
static int | break_time = 0 |
static double | print_result_diff_time_lower = 0 |
static FILE * | br_tmpfp = NULL |
static unsigned int | num_slower_queries [STAT_MAX_DIFF_TIME] = { 0 } |
static unsigned int | num_faster_queries [STAT_MAX_DIFF_TIME] = { 0 } |
#define BIND_STR_BUF_SIZE (4096) |
Definition at line 45 of file broker_log_replay.c.
Referenced by log_replay().
#define CCI_ERR_FILE_NAME "replay.err" |
Definition at line 48 of file broker_log_replay.c.
Referenced by open_file().
#define DEFAULT_BREAK_TIME (0.01) /* 10 millisecond */ |
Definition at line 52 of file broker_log_replay.c.
Referenced by get_args().
#define DEFAULT_DIFF_TIME_LOWER (0.01) /* 10 millisecond */ |
Definition at line 51 of file broker_log_replay.c.
Referenced by get_args().
#define free_and_init | ( | ptr | ) |
Definition at line 56 of file broker_log_replay.c.
Referenced by get_query_stmt_from_plan(), log_prepare(), log_replay(), print_result_with_sort(), and print_result_without_sort().
#define INVALID_PORT_NUM (-1) |
Definition at line 54 of file broker_log_replay.c.
Referenced by get_args().
#define PASS_SQL_FILE_NAME "skip.sql" |
Definition at line 49 of file broker_log_replay.c.
Referenced by open_file().
#define SORT_BUF_MAX (4096) |
Definition at line 44 of file broker_log_replay.c.
Referenced by print_result().
#define SQL_INFO_TITLE_LEN (128) |
Definition at line 46 of file broker_log_replay.c.
Referenced by print_result_with_sort(), and print_result_without_sort().
#define STAT_MAX_DIFF_TIME (60000) /* 60 * 1000 : 10 min */ |
Definition at line 43 of file broker_log_replay.c.
Referenced by print_result(), and update_diff_time_statistics().
typedef enum temp_read_result READ_RESULT |
Definition at line 70 of file broker_log_replay.c.
typedef struct t_sql_info T_SQL_INFO |
Definition at line 72 of file broker_log_replay.c.
typedef struct t_sql_result T_SQL_RESULT |
Definition at line 96 of file broker_log_replay.c.
typedef struct t_summary_info T_SUMMARY_INFO |
Definition at line 83 of file broker_log_replay.c.
enum temp_read_result |
Enumerator | |
---|---|
READ_STOP | |
READ_CONTINUE | |
READ_SUCCESS |
Definition at line 64 of file broker_log_replay.c.
|
static |
Definition at line 1619 of file broker_log_replay.c.
References br_tmpfp, and NULL.
Referenced by log_replay(), and open_file().
|
static |
Definition at line 1459 of file broker_log_replay.c.
References break_time, broker_port, check_date_flag, dbname, dbpasswd, dbuser, DEFAULT_BREAK_TIME, DEFAULT_DIFF_TIME_LOWER, ER_FAILED, from_date, getopt(), host, INVALID_PORT_NUM, NULL, optarg, optind, parse_int(), print_result_diff_time_lower, rewrite_query_flag, str_to_log_date_format(), strdup(), strlen, to_date, and usage().
Referenced by main().
|
static |
Definition at line 621 of file broker_log_replay.c.
Referenced by log_bind_value().
|
static |
Definition at line 391 of file broker_log_replay.c.
References assert, NULL, strlen, t_string_len(), t_string_str(), and ut_get_line().
Referenced by log_replay().
|
static |
Definition at line 431 of file broker_log_replay.c.
References error(), free_and_init, NULL, p, strlen, and trim().
Referenced by log_prepare().
|
static |
Definition at line 921 of file broker_log_replay.c.
References assert, t_sql_info::diff_time, t_sql_info::exec_time, NULL, and t_sql_info::sql_log_time.
Referenced by log_replay().
|
static |
Definition at line 1156 of file broker_log_replay.c.
References br_tmpfp, p, READ_CONTINUE, READ_STOP, READ_SUCCESS, and str_to_int32().
Referenced by print_result_with_sort(), and print_result_without_sort().
|
static |
Definition at line 747 of file broker_log_replay.c.
References assert, ER_FAILED, get_cci_type(), NO_ERROR, NULL, p, str_to_int32(), and t_string_bind_len().
Referenced by log_replay().
|
static |
Definition at line 858 of file broker_log_replay.c.
References assert, break_time, ER_FAILED, mode, NULL, SLEEP_MILISEC, ut_diff_time(), and ut_get_execute_type().
Referenced by log_replay().
|
static |
Definition at line 530 of file broker_log_replay.c.
References CUBRID_STMT_DELETE, CUBRID_STMT_NONE, CUBRID_STMT_SELECT, CUBRID_STMT_UPDATE, ER_FAILED, free_and_init, get_query_stmt_from_plan(), NULL, t_summary_info::num_err_query, t_summary_info::num_skip_query, t_summary_info::num_total_query, rewrite_query_flag, t_sql_info::rewrite_sql, t_sql_info::sql, str_to_int32(), strdup(), and ut_get_execute_type().
Referenced by log_replay().
|
static |
Definition at line 161 of file broker_log_replay.c.
References assert, t_sql_info::bind_str, BIND_STR_BUF_SIZE, br_tmpfp, broker_port, check_date_flag, close_file(), t_string::data, DATE_STR_LEN, dbname, dbpasswd, dbuser, t_sql_info::diff_time, ER_FAILED, t_sql_info::exec_time, free_and_init, from_date, GET_CUR_DATE_STR, get_msg_start_ptr(), get_next_log_line(), get_sql_time_info(), host, is_cas_log(), log_bind_value(), log_execute(), log_prepare(), t_summary_info::max_diff_time, t_summary_info::min_diff_time, NULL, t_summary_info::num_err_query, t_summary_info::num_exec_query, open_file(), print_result(), print_result_diff_time_lower, print_summary_info(), print_temp_result(), t_sql_info::rewrite_sql, t_sql_info::sql, t_string_make(), to_date, update_diff_time_statistics(), update_summary_info(), ut_check_log_valid_time(), and ut_diff_time().
Referenced by main().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 1650 of file broker_log_replay.c.
References assert, dbpasswd, ER_FAILED, get_args(), infilename, log_replay(), and NULL.
|
static |
Definition at line 1065 of file broker_log_replay.c.
References t_sql_info::bind_str, t_sql_info::exec_time, NULL, p, t_sql_info::rewrite_sql, t_sql_info::sql, t_sql_info::sql_log_time, and str_to_int32().
Referenced by print_result_with_sort(), and print_result_without_sort().
|
static |
Definition at line 1566 of file broker_log_replay.c.
References br_tmpfp, CCI_ERR_FILE_NAME, close_file(), ER_FAILED, error(), NO_ERROR, NULL, and PASS_SQL_FILE_NAME.
Referenced by log_replay().
|
static |
Definition at line 1394 of file broker_log_replay.c.
References i, num_faster_queries, num_slower_queries, print_result_with_sort(), print_result_without_sort(), SORT_BUF_MAX, and STAT_MAX_DIFF_TIME.
Referenced by log_replay().
|
static |
Definition at line 1273 of file broker_log_replay.c.
References br_tmpfp, t_sql_info::diff_time, t_sql_result::diff_time, ER_FAILED, error(), free_and_init, get_temp_file_line(), i, make_sql_info(), NO_ERROR, NULL, READ_CONTINUE, READ_STOP, result_sort_func(), t_sql_result::sql_info, and SQL_INFO_TITLE_LEN.
Referenced by print_result().
|
static |
Definition at line 1195 of file broker_log_replay.c.
References br_tmpfp, t_sql_info::diff_time, ER_FAILED, free_and_init, get_temp_file_line(), make_sql_info(), NO_ERROR, NULL, READ_CONTINUE, READ_STOP, t_sql_result::sql_info, and SQL_INFO_TITLE_LEN.
Referenced by print_result().
|
static |
Definition at line 1034 of file broker_log_replay.c.
References t_summary_info::max_diff_time, t_summary_info::num_diff_time_query, t_summary_info::num_err_query, t_summary_info::num_exec_query, t_summary_info::num_skip_query, t_summary_info::num_total_query, print_result_diff_time_lower, and t_summary_info::sum_diff_time.
Referenced by log_replay().
|
static |
Definition at line 976 of file broker_log_replay.c.
References t_sql_info::bind_str, br_tmpfp, t_sql_info::diff_time, t_sql_info::exec_time, NULL, t_sql_info::rewrite_sql, t_sql_info::sql, t_sql_info::sql_log_time, and strlen.
Referenced by log_replay().
Definition at line 1136 of file broker_log_replay.c.
Referenced by print_result_with_sort().
|
static |
Definition at line 938 of file broker_log_replay.c.
References assert, num_faster_queries, num_slower_queries, and STAT_MAX_DIFF_TIME.
Referenced by log_replay().
|
static |
Definition at line 1012 of file broker_log_replay.c.
References t_sql_info::diff_time, t_summary_info::max_diff_time, t_summary_info::min_diff_time, t_summary_info::num_diff_time_query, print_result_diff_time_lower, and t_summary_info::sum_diff_time.
Referenced by log_replay().
|
static |
Definition at line 148 of file broker_log_replay.c.
Referenced by close_file(), get_temp_file_line(), log_replay(), open_file(), print_result_with_sort(), print_result_without_sort(), and print_temp_result().
|
static |
Definition at line 145 of file broker_log_replay.c.
Referenced by get_args(), and log_execute().
|
static |
Definition at line 134 of file broker_log_replay.c.
Referenced by get_args(), log_replay(), net_connect_proxy(), proxy_io_cas_lsnr(), and proxy_io_initialize().
|
static |
Definition at line 141 of file broker_log_replay.c.
Referenced by get_args(), and log_replay().
|
static |
Definition at line 135 of file broker_log_replay.c.
Referenced by access_control_read_config_file(), catcls_vclass_install(), css_register_server_timeout_fn(), db_init(), get_args(), log_replay(), logpb_verify_length(), pt_to_regu_variable(), and ux_check_connection().
|
static |
Definition at line 137 of file broker_log_replay.c.
Referenced by get_args(), log_replay(), main(), and ux_check_connection().
|
static |
Definition at line 136 of file broker_log_replay.c.
Referenced by access_control_read_config_file(), au_perform_login(), get_args(), log_replay(), and ux_check_connection().
|
static |
Definition at line 139 of file broker_log_replay.c.
Referenced by get_args(), and log_replay().
|
static |
Definition at line 133 of file broker_log_replay.c.
Referenced by cfg_add_db(), cfg_copy_hosts(), cfg_pop_host(), css_client_init(), css_send_req_to_server(), event_log_print_client_info(), fileio_check_lockby_file(), fileio_lock(), fileio_lock_la_log_path(), get_args(), hb_cluster_remove_all_ping_hosts(), log_replay(), ssession_find_or_create_session(), and tran_unilaterally_abort().
|
static |
Definition at line 151 of file broker_log_replay.c.
Referenced by print_result(), and update_diff_time_statistics().
|
static |
Definition at line 150 of file broker_log_replay.c.
Referenced by print_result(), and update_diff_time_statistics().
|
static |
Definition at line 146 of file broker_log_replay.c.
Referenced by get_args(), log_replay(), print_summary_info(), and update_summary_info().
|
static |
Definition at line 143 of file broker_log_replay.c.
Referenced by get_args(), and log_prepare().
|
static |
Definition at line 140 of file broker_log_replay.c.
Referenced by get_args(), and log_replay().