CUBRID Engine
latest
|
#include "config.h"
#include <stdio.h>
#include <stdarg.h>
#include <signal.h>
#include <setjmp.h>
#include <assert.h>
#include <pwd.h>
#include "porting.h"
#include "csql.h"
#include "filesys.hpp"
#include "filesys_temp.hpp"
#include "memory_alloc.h"
#include "system_parameter.h"
#include "ddl_log.h"
Go to the source code of this file.
Classes | |
struct | CSQL_EDIT_CONTENTS |
struct | CSQL_ERR_MSG_MAP |
Macros | |
#define | TAB_STOP 8 |
#define | MORE_LINE_EXPANSION_UNIT 40 |
#define | DEFAULT_DB_ERROR_MSG_LEVEL 3 /* current max */ |
Typedefs | |
typedef enum csql_statement_state | CSQL_STATEMENT_STATE |
Functions | |
static void | iq_pipe_handler (int sig_no) |
static void | iq_format_err (char *string, int buf_size, int line_no, int col_no) |
static bool | iq_input_device_is_a_tty (void) |
static bool | iq_output_device_is_a_tty (void) |
static int | csql_get_user_home (char *homebuf, int bufsize) |
char * | csql_get_real_path (const char *pathname) |
void | csql_invoke_system (const char *command) |
int | csql_invoke_system_editor (void) |
void | csql_fputs (const char *str, FILE *fp) |
void | csql_fputs_console_conv (const char *str, FILE *fp) |
FILE * | csql_popen (const char *cmd, FILE *fd) |
void | csql_pclose (FILE *pf, FILE *fd) |
void | csql_display_csql_err (int line_no, int col_no) |
void | csql_display_session_err (DB_SESSION *session, int line_no) |
int | csql_append_more_line (int indent, const char *line) |
void | csql_display_more_lines (const char *title) |
void | csql_free_more_lines (void) |
void | csql_check_server_down (void) |
char * | csql_get_tmp_buf (size_t size) |
void | nonscr_display_error (char *buffer, int buf_length) |
char * | csql_edit_contents_get () |
static int | csql_edit_contents_expand (int required_size) |
int | csql_edit_contents_append (const char *str, bool flag_append_new_line) |
void | csql_walk_statement (const char *str) |
bool | csql_is_statement_complete (void) |
bool | csql_is_statement_in_block (void) |
void | csql_edit_contents_clear () |
void | csql_edit_contents_finalize () |
int | csql_edit_read_file (FILE *fp) |
int | csql_edit_write_file (FILE *fp) |
const char * | csql_errmsg (int code) |
Variables | |
static char ** | iq_More_lines |
static int | iq_Num_more_lines = 0 |
static jmp_buf | iq_Jmp_buf |
static CSQL_EDIT_CONTENTS | csql_Edit_contents = { NULL, 0, 0, CSQL_STATE_GENERAL } |
static CSQL_ERR_MSG_MAP | csql_Err_msg_map [] |
#define DEFAULT_DB_ERROR_MSG_LEVEL 3 /* current max */ |
Definition at line 60 of file csql_support.c.
Referenced by csql_errmsg().
#define MORE_LINE_EXPANSION_UNIT 40 |
Definition at line 53 of file csql_support.c.
Referenced by csql_append_more_line().
#define TAB_STOP 8 |
Definition at line 50 of file csql_support.c.
Referenced by csql_append_more_line().
typedef enum csql_statement_state CSQL_STATEMENT_STATE |
enum csql_statement_state |
Definition at line 62 of file csql_support.c.
int csql_append_more_line | ( | int | indent, |
const char * | line | ||
) |
Definition at line 550 of file csql_support.c.
References assert, CSQL_ERR_NO_MORE_MEMORY, csql_Error_code, CSQL_FAILURE, CSQL_SUCCESS, csql_text_utf8_to_console, free_and_init, i, iq_More_lines, iq_Num_more_lines, MORE_LINE_EXPANSION_UNIT, NO_ERROR, NULL, p, strlen, and TAB_STOP.
Referenced by csql_get_sys_param(), csql_help_menu(), csql_set_plan_dump(), csql_set_sys_param(), and csql_set_trace().
void csql_check_server_down | ( | void | ) |
Definition at line 753 of file csql_support.c.
References csql_Error_fp, csql_exit(), csql_Scratch_text, db_error_code(), ER_TM_SERVER_DOWN_UNILATERALLY_ABORTED, nonscr_display_error(), and SCRATCH_TEXT_LEN.
Referenced by csql_do_session_cmd(), csql_help_info(), csql_results(), and display_error().
void csql_display_csql_err | ( | int | line_no, |
int | col_no | ||
) |
Definition at line 490 of file csql_support.c.
References CSQL_ERR_SQL_ERROR, csql_Error_code, csql_Error_fp, csql_fputs(), csql_fputs_console_conv(), csql_Scratch_text, iq_format_err(), nonscr_display_error(), and SCRATCH_TEXT_LEN.
Referenced by csql_do_session_cmd(), csql_help_info(), csql_help_schema(), csql_help_trigger(), and csql_results().
void csql_display_more_lines | ( | const char * | title | ) |
Definition at line 675 of file csql_support.c.
References csql_fputs(), csql_Output_fp, csql_Pager_cmd, csql_pclose(), csql_popen(), csql_Scratch_text, i, iq_Jmp_buf, iq_More_lines, iq_Num_more_lines, iq_pipe_handler(), and NULL.
Referenced by csql_get_sys_param(), csql_help_menu(), csql_help_schema(), csql_help_trigger(), csql_set_plan_dump(), csql_set_sys_param(), and csql_set_trace().
void csql_display_session_err | ( | DB_SESSION * | session, |
int | line_no | ||
) |
Definition at line 512 of file csql_support.c.
References CSQL_ERR_SQL_ERROR, csql_Error_code, csql_Error_fp, csql_fputs(), csql_fputs_console_conv(), csql_Scratch_text, db_get_errors(), db_get_next_error(), err, iq_format_err(), nonscr_display_error(), and SCRATCH_TEXT_LEN.
Referenced by display_error().
Definition at line 938 of file csql_support.c.
References CSQL_EDIT_CONTENTS::contents, csql_edit_contents_expand(), CSQL_FAILURE, CSQL_SUCCESS, CSQL_EDIT_CONTENTS::data_size, NULL, and strlen.
Referenced by csql_do_session_cmd(), csql_edit_read_file(), and start_csql().
void csql_edit_contents_clear | ( | void | ) |
Definition at line 1214 of file csql_support.c.
References CSQL_STATE_GENERAL, CSQL_EDIT_CONTENTS::data_size, and CSQL_EDIT_CONTENTS::state.
Referenced by csql_do_session_cmd(), csql_edit_contents_finalize(), csql_invoke_system_editor(), and start_csql().
|
static |
Definition at line 906 of file csql_support.c.
References CSQL_EDIT_CONTENTS::alloc_size, CSQL_EDIT_CONTENTS::contents, CSQL_ERR_NO_MORE_MEMORY, csql_Error_code, CSQL_FAILURE, CSQL_SUCCESS, and NULL.
Referenced by csql_edit_contents_append().
void csql_edit_contents_finalize | ( | void | ) |
Definition at line 1221 of file csql_support.c.
References CSQL_EDIT_CONTENTS::alloc_size, CSQL_EDIT_CONTENTS::contents, csql_edit_contents_clear(), and free_and_init.
Referenced by start_csql().
char* csql_edit_contents_get | ( | void | ) |
Definition at line 896 of file csql_support.c.
References CSQL_EDIT_CONTENTS::contents, and CSQL_EDIT_CONTENTS::data_size.
Referenced by csql_execute_statements(), and display_buffer().
int csql_edit_read_file | ( | FILE * | fp | ) |
Definition at line 1235 of file csql_support.c.
References csql_edit_contents_append(), CSQL_FAILURE, CSQL_SUCCESS, intl_is_bom_magic(), NULL, and strlen.
Referenced by csql_invoke_system_editor(), and csql_read_file().
int csql_edit_write_file | ( | FILE * | fp | ) |
Definition at line 1263 of file csql_support.c.
References CSQL_EDIT_CONTENTS::contents, CSQL_ERR_OS_ERROR, csql_Error_code, CSQL_FAILURE, CSQL_SUCCESS, CSQL_EDIT_CONTENTS::data_size, and p.
Referenced by csql_invoke_system_editor(), csql_print_buffer(), and csql_write_file().
const char* csql_errmsg | ( | int | code | ) |
Definition at line 1310 of file csql_support.c.
References CSQL_E_UNKNOWN_TEXT, CSQL_ERR_OS_ERROR, CSQL_ERR_SQL_ERROR, csql_get_message(), db_error_string(), DEFAULT_DB_ERROR_MSG_LEVEL, i, and NULL.
Referenced by nonscr_display_error().
void csql_fputs | ( | const char * | str, |
FILE * | fp | ||
) |
Definition at line 322 of file csql_support.c.
Referenced by csql_display_csql_err(), csql_display_more_lines(), csql_display_msg(), csql_display_session_err(), csql_do_session_cmd(), csql_fputs_console_conv(), display_empty_result(), nonscr_display_error(), and write_results_to_stream().
void csql_fputs_console_conv | ( | const char * | str, |
FILE * | fp | ||
) |
Definition at line 357 of file csql_support.c.
References csql_fputs(), csql_text_utf8_to_console, NO_ERROR, NULL, and strlen.
Referenced by csql_change_working_directory(), csql_display_csql_err(), csql_display_msg(), csql_display_session_err(), display_empty_result(), and start_csql().
void csql_free_more_lines | ( | void | ) |
Definition at line 714 of file csql_support.c.
References free_and_init, i, iq_More_lines, iq_Num_more_lines, and NULL.
Referenced by csql_get_sys_param(), csql_help_menu(), csql_help_schema(), csql_help_trigger(), csql_set_plan_dump(), csql_set_sys_param(), and csql_set_trace().
char* csql_get_real_path | ( | const char * | pathname | ) |
Definition at line 160 of file csql_support.c.
References csql_get_user_home(), NO_ERROR, and NULL.
Referenced by csql_change_working_directory(), csql_read_file(), and csql_write_file().
char* csql_get_tmp_buf | ( | size_t | size | ) |
Definition at line 779 of file csql_support.c.
References CSQL_ERR_NO_MORE_MEMORY, csql_Error_code, free_and_init, and NULL.
Referenced by csql_invoke_system_editor(), and csql_print_buffer().
|
static |
Definition at line 126 of file csql_support.c.
References ER_FAILED, NO_ERROR, and NULL.
Referenced by csql_get_real_path().
void csql_invoke_system | ( | const char * | command | ) |
Definition at line 226 of file csql_support.c.
References CSQL_ERR_OS_ERROR, csql_Error_code, csql_Scratch_text, nonscr_display_error(), and SCRATCH_TEXT_LEN.
Referenced by csql_do_session_cmd(), csql_invoke_system_editor(), and csql_print_buffer().
int csql_invoke_system_editor | ( | void | ) |
Definition at line 252 of file csql_support.c.
References csql_edit_contents_clear(), csql_edit_read_file(), csql_edit_write_file(), csql_Editor_cmd, CSQL_ERR_CANT_EDIT, CSQL_ERR_OS_ERROR, csql_Error_code, CSQL_FAILURE, csql_get_tmp_buf(), csql_invoke_system(), csql_Scratch_text, CSQL_SUCCESS, iq_output_device_is_a_tty(), nonscr_display_error(), NULL, filesys::open_temp_file(), SCRATCH_TEXT_LEN, and strlen.
Referenced by csql_do_session_cmd().
bool csql_is_statement_complete | ( | void | ) |
Definition at line 1175 of file csql_support.c.
References CSQL_STATE_STATEMENT_END, and CSQL_EDIT_CONTENTS::state.
Referenced by start_csql().
bool csql_is_statement_in_block | ( | void | ) |
Definition at line 1193 of file csql_support.c.
References CSQL_STATE_BACKTICK_IDENTIFIER, CSQL_STATE_BRACKET_IDENTIFIER, CSQL_STATE_C_COMMENT, CSQL_STATE_DOUBLE_QUOTE_IDENTIFIER, CSQL_STATE_MYSQL_QUOTE, CSQL_STATE_SINGLE_QUOTE, and CSQL_EDIT_CONTENTS::state.
Referenced by start_csql().
void csql_pclose | ( | FILE * | pf, |
FILE * | fd | ||
) |
Definition at line 444 of file csql_support.c.
Referenced by csql_display_more_lines(), csql_display_trace(), csql_dump_alltran(), csql_help_info(), display_buffer(), display_empty_result(), and write_results_to_stream().
FILE* csql_popen | ( | const char * | cmd, |
FILE * | fd | ||
) |
Definition at line 396 of file csql_support.c.
References CSQL_ERR_CANT_EXEC_PAGER, csql_Error_code, csql_Scratch_text, iq_input_device_is_a_tty(), iq_output_device_is_a_tty(), nonscr_display_error(), NULL, and SCRATCH_TEXT_LEN.
Referenced by csql_display_more_lines(), csql_display_trace(), csql_dump_alltran(), csql_help_info(), display_buffer(), display_empty_result(), and write_results_to_stream().
void csql_walk_statement | ( | const char * | str | ) |
Definition at line 967 of file csql_support.c.
References CSQL_STATE_BACKTICK_IDENTIFIER, CSQL_STATE_BRACKET_IDENTIFIER, CSQL_STATE_C_COMMENT, CSQL_STATE_CPP_COMMENT, CSQL_STATE_DOUBLE_QUOTE_IDENTIFIER, CSQL_STATE_GENERAL, CSQL_STATE_MYSQL_QUOTE, CSQL_STATE_SINGLE_QUOTE, CSQL_STATE_SQL_COMMENT, CSQL_STATE_STATEMENT_END, NULL, p, prm_get_bool_value(), PRM_ID_ANSI_QUOTES, PRM_ID_NO_BACKSLASH_ESCAPES, CSQL_EDIT_CONTENTS::state, and strlen.
Referenced by start_csql().
|
static |
Definition at line 462 of file csql_support.c.
References CSQL_EXACT_POSITION_ERR_FORMAT, CSQL_START_POSITION_ERR_FORMAT, MSGCAT_CATALOG_CSQL, MSGCAT_CSQL_SET_CSQL, and msgcat_message().
Referenced by csql_display_csql_err(), and csql_display_session_err().
|
static |
Definition at line 113 of file csql_support.c.
References csql_Input_fp.
Referenced by csql_popen().
|
static |
Definition at line 102 of file csql_support.c.
References csql_Output_fp.
Referenced by csql_invoke_system_editor(), and csql_popen().
|
static |
Definition at line 741 of file csql_support.c.
References iq_Jmp_buf.
Referenced by csql_display_more_lines().
void nonscr_display_error | ( | char * | buffer, |
int | buf_length | ||
) |
Definition at line 830 of file csql_support.c.
References csql_errmsg(), csql_Error_code, csql_Error_fp, CSQL_ERROR_PREFIX, csql_fputs(), csql_text_utf8_to_console, free_and_init, logddl_set_err_msg(), MSGCAT_CATALOG_CSQL, MSGCAT_CSQL_SET_CSQL, msgcat_message(), NO_ERROR, NULL, and strlen.
Referenced by csql(), csql_change_working_directory(), csql_check_server_down(), csql_display_csql_err(), csql_display_session_err(), csql_do_session_cmd(), csql_exit_session(), csql_help_info(), csql_help_menu(), csql_help_schema(), csql_help_trigger(), csql_invoke_system(), csql_invoke_system_editor(), csql_killtran(), csql_popen(), csql_print_buffer(), csql_read_file(), csql_results(), csql_write_file(), display_error(), and start_csql().
|
static |
Definition at line 85 of file csql_support.c.
|
static |
Definition at line 1287 of file csql_support.c.
|
static |
Definition at line 58 of file csql_support.c.
Referenced by csql_display_more_lines(), and iq_pipe_handler().
|
static |
Definition at line 56 of file csql_support.c.
Referenced by csql_append_more_line(), csql_display_more_lines(), and csql_free_more_lines().
|
static |
Definition at line 57 of file csql_support.c.
Referenced by csql_append_more_line(), csql_display_more_lines(), and csql_free_more_lines().