CUBRID Engine  latest
shard_parser.c File Reference
#include "shard_parser.h"
#include "shard_proxy_log.h"
Include dependency graph for shard_parser.c:

Go to the source code of this file.

Functions

static const char * left_trim (const char *str)
 
static int sp_init_sp_value (SP_VALUE *value_p)
 
static void sp_free_sp_value (SP_VALUE *value_p)
 
static int sp_make_sp_value (SP_VALUE *value_p, const char *pos, int length)
 
static int sp_make_string_sp_value (SP_VALUE *value_p, const char *pos, int length)
 
static int sp_make_int_sp_value_from_string (SP_VALUE *value_p, char *pos, int length)
 
static void sp_init_praser_hint_list (SP_PARSER_HINT_LIST *list)
 
static void sp_append_parser_hint_to_ctx (SP_PARSER_CTX *parser_p, SP_PARSER_HINT *hint_p)
 
static int sp_parse_sql_internal (SP_PARSER_CTX *parser_p)
 
static void sp_free_parser_hint_from_ctx (SP_PARSER_CTX *parser_p)
 
static int sp_process_token (SP_PARSER_CTX *parser_p, SP_TOKEN token_type)
 
static int sp_get_bind_type_and_value (SP_PARSER_CTX *parser_p, SP_PARSER_HINT *hint_p)
 
static void sp_copy_cursor_to_prv (SP_PARSER_CTX *parser_p)
 
static int sp_get_string_bind_value (SP_PARSER_CTX *parser_p, SP_PARSER_HINT *hint_p)
 
static int sp_get_int_bind_value (SP_PARSER_CTX *parser_p, SP_PARSER_HINT *hint_p)
 
static int sp_is_valid_hint (SP_PARSER_CTX *parser_p, SP_PARSER_HINT *hint_p)
 
static bool sp_is_start_token (SP_TOKEN token)
 
SP_PARSER_CTXsp_create_parser (const char *sql_stmt)
 
int sp_parse_sql (SP_PARSER_CTX *parser_p)
 
void sp_destroy_parser (SP_PARSER_CTX *parser_p)
 
bool sp_is_hint_static (SP_PARSER_CTX *parser_p)
 
int sp_get_total_hint_count (SP_PARSER_CTX *parser_p)
 
int sp_get_static_hint_count (SP_PARSER_CTX *parser_p)
 
int sp_get_dynamic_hint_count (SP_PARSER_CTX *parser_p)
 
SP_PARSER_HINTsp_get_first_hint (SP_PARSER_CTX *parser_p)
 
SP_PARSER_HINTsp_get_next_hint (SP_PARSER_HINT *hint_p)
 
SP_PARSER_HINTsp_get_first_static_hint (SP_PARSER_CTX *parser_p)
 
SP_PARSER_HINTsp_get_next_static_hint (SP_PARSER_HINT *hint_p)
 
SP_PARSER_HINTsp_get_first_dynamic_hint (SP_PARSER_CTX *parser_p)
 
SP_PARSER_HINTsp_get_next_dynamic_hint (SP_PARSER_HINT *hint_p)
 
char * sp_get_hint_key (SP_PARSER_HINT *hint_p)
 
const char * sp_get_sql_stmt (SP_PARSER_CTX *parser_p)
 
bool sp_is_pair_token (SP_TOKEN start_token, SP_TOKEN end_token)
 
SP_PARSER_HINTsp_create_parser_hint (void)
 
void sp_free_parser_hint (SP_PARSER_HINT *hint_p)
 
const char * sp_get_token_type (const char *sql, SP_TOKEN *token)
 
const char * sp_get_hint_type (const char *sql, SP_HINT_TYPE *hint_type)
 
const char * sp_get_hint_arg (const char *sql, SP_PARSER_HINT *hint_p, int *error)
 
const char * sp_check_end_of_hint (const char *sql, int *error)
 
bool sp_is_exist_pair_token (SP_TOKEN token)
 

Function Documentation

static const char * left_trim ( const char *  str)
inlinestatic

Definition at line 236 of file shard_parser.c.

References p.

Referenced by sp_check_end_of_hint(), sp_get_bind_type_and_value(), sp_get_hint_arg(), sp_get_hint_type(), sp_is_pair_token(), and sp_make_sp_value().

Here is the caller graph for this function:

static void sp_append_parser_hint_to_ctx ( SP_PARSER_CTX parser_p,
SP_PARSER_HINT hint_p 
)
static
const char* sp_check_end_of_hint ( const char *  sql,
int *  error 
)

Definition at line 649 of file shard_parser.c.

References ER_SP_INVALID_HINT, left_trim(), and NO_ERROR.

Referenced by shard_stmt_change_shard_val_to_id(), and sp_process_token().

Here is the caller graph for this function:

static void sp_copy_cursor_to_prv ( SP_PARSER_CTX parser_p)
inlinestatic

Definition at line 786 of file shard_parser.c.

References sp_parser_ctx::cursor, sp_parser_ctx::prv_cursor, sp_cursor::token, and TT_NONE.

Referenced by sp_get_bind_type_and_value(), and sp_parse_sql_internal().

Here is the caller graph for this function:

void sp_destroy_parser ( SP_PARSER_CTX parser_p)

Definition at line 116 of file shard_parser.c.

References NULL, sp_free_parser_hint_from_ctx(), and sp_parser_ctx::sql_stmt.

Referenced by shard_stmt_destroy(), and shard_stmt_free().

Here is the caller graph for this function:

void sp_free_parser_hint ( SP_PARSER_HINT hint_p)

Definition at line 416 of file shard_parser.c.

References sp_parser_hint::arg, NULL, sp_free_sp_value(), and sp_parser_hint::value.

Referenced by shard_stmt_change_shard_val_to_id(), sp_create_parser_hint(), sp_free_parser_hint_from_ctx(), and sp_process_token().

Here is the caller graph for this function:

static void sp_free_parser_hint_from_ctx ( SP_PARSER_CTX parser_p)
static

Definition at line 474 of file shard_parser.c.

References NULL, sp_free_parser_hint(), sp_get_first_hint(), and sp_get_next_hint().

Referenced by sp_destroy_parser().

Here is the caller graph for this function:

static void sp_free_sp_value ( SP_VALUE value_p)
static

Definition at line 262 of file shard_parser.c.

References NULL, sp_value::string, and sp_value::value_ex.

Referenced by sp_free_parser_hint().

Here is the caller graph for this function:

static int sp_get_bind_type_and_value ( SP_PARSER_CTX parser_p,
SP_PARSER_HINT hint_p 
)
static
int sp_get_dynamic_hint_count ( SP_PARSER_CTX parser_p)

Definition at line 149 of file shard_parser.c.

References BT_DYNAMIC, sp_parser_ctx::list_t, and sp_parser_hint_list::size.

SP_PARSER_HINT* sp_get_first_dynamic_hint ( SP_PARSER_CTX parser_p)

Definition at line 179 of file shard_parser.c.

References BT_DYNAMIC, sp_parser_hint_list::head, and sp_parser_ctx::list_t.

SP_PARSER_HINT* sp_get_first_hint ( SP_PARSER_CTX parser_p)
SP_PARSER_HINT* sp_get_first_static_hint ( SP_PARSER_CTX parser_p)

Definition at line 167 of file shard_parser.c.

References BT_STATIC, sp_parser_hint_list::head, and sp_parser_ctx::list_t.

const char* sp_get_hint_arg ( const char *  sql,
SP_PARSER_HINT hint_p,
int *  error 
)
char* sp_get_hint_key ( SP_PARSER_HINT hint_p)

Definition at line 191 of file shard_parser.c.

References sp_parser_hint::arg, sp_value::string, and sp_value::value.

const char* sp_get_hint_type ( const char *  sql,
SP_HINT_TYPE hint_type 
)

Definition at line 575 of file shard_parser.c.

References HT_ALL, HT_ID, HT_KEY, HT_NONE, HT_VAL, and left_trim().

Referenced by shard_stmt_rewrite_sql(), and sp_process_token().

Here is the caller graph for this function:

static int sp_get_int_bind_value ( SP_PARSER_CTX parser_p,
SP_PARSER_HINT hint_p 
)
static

Definition at line 813 of file shard_parser.c.

References sp_parser_ctx::cursor, p, sp_cursor::pos, sp_make_int_sp_value_from_string(), sp_parser_hint::value, and while().

Referenced by sp_get_bind_type_and_value().

Here is the caller graph for this function:

SP_PARSER_HINT* sp_get_next_dynamic_hint ( SP_PARSER_HINT hint_p)

Definition at line 185 of file shard_parser.c.

References BT_DYNAMIC, and sp_parser_hint::next_t.

SP_PARSER_HINT* sp_get_next_hint ( SP_PARSER_HINT hint_p)

Definition at line 161 of file shard_parser.c.

References sp_parser_hint::next_a.

Referenced by proxy_get_shard_id(), shard_stmt_set_hint_list(), and sp_free_parser_hint_from_ctx().

Here is the caller graph for this function:

SP_PARSER_HINT* sp_get_next_static_hint ( SP_PARSER_HINT hint_p)

Definition at line 173 of file shard_parser.c.

References BT_STATIC, and sp_parser_hint::next_t.

const char* sp_get_sql_stmt ( SP_PARSER_CTX parser_p)

Definition at line 197 of file shard_parser.c.

References sp_parser_ctx::sql_stmt.

Referenced by shard_stmt_del_statement_from_map(), shard_stmt_find_by_sql(), and shard_stmt_put_statement_to_map().

Here is the caller graph for this function:

int sp_get_static_hint_count ( SP_PARSER_CTX parser_p)

Definition at line 143 of file shard_parser.c.

References BT_STATIC, sp_parser_ctx::list_t, and sp_parser_hint_list::size.

static int sp_get_string_bind_value ( SP_PARSER_CTX parser_p,
SP_PARSER_HINT hint_p 
)
static

Definition at line 794 of file shard_parser.c.

References sp_parser_ctx::cursor, ER_SP_INVALID_SYNTAX, NULL, p, sp_cursor::pos, sp_make_string_sp_value(), sp_parser_hint::value, and while().

Referenced by sp_get_bind_type_and_value().

Here is the caller graph for this function:

const char* sp_get_token_type ( const char *  sql,
SP_TOKEN token 
)
int sp_get_total_hint_count ( SP_PARSER_CTX parser_p)

Definition at line 137 of file shard_parser.c.

References sp_parser_ctx::list_a, and sp_parser_hint_list::size.

static void sp_init_praser_hint_list ( SP_PARSER_HINT_LIST list)
static

Definition at line 379 of file shard_parser.c.

References sp_parser_hint_list::head, NULL, sp_parser_hint_list::size, and sp_parser_hint_list::tail.

Referenced by sp_create_parser().

Here is the caller graph for this function:

static int sp_init_sp_value ( SP_VALUE value_p)
static

Definition at line 250 of file shard_parser.c.

References sp_value::integer, sp_value::length, NO_ERROR, NULL, sp_value::string, sp_value::type, sp_value::value, sp_value::value_arr, sp_value::value_ex, and VT_INTEGER.

Referenced by sp_create_parser_hint().

Here is the caller graph for this function:

bool sp_is_exist_pair_token ( SP_TOKEN  token)

Definition at line 852 of file shard_parser.c.

References TT_ASSIGN_OP, TT_BIND_CHAR, TT_C_COMMENT_END, TT_IN_OP, TT_LEFT_BRAKET, TT_NEWLINE, TT_NONE, TT_RIGHT_BRAKET, TT_SHARD_HINT, and TT_WHITESPACE.

Referenced by shard_stmt_rewrite_sql(), and sp_parse_sql_internal().

Here is the caller graph for this function:

bool sp_is_hint_static ( SP_PARSER_CTX parser_p)

Definition at line 131 of file shard_parser.c.

References BT_STATIC, sp_parser_ctx::list_a, sp_parser_ctx::list_t, and sp_parser_hint_list::size.

Referenced by fn_proxy_client_prepare().

Here is the caller graph for this function:

static bool sp_is_start_token ( SP_TOKEN  token)
static

Definition at line 840 of file shard_parser.c.

References TT_C_COMMENT_END.

Referenced by sp_parse_sql_internal().

Here is the caller graph for this function:

static int sp_is_valid_hint ( SP_PARSER_CTX parser_p,
SP_PARSER_HINT hint_p 
)
static

Definition at line 827 of file shard_parser.c.

References ER_SP_INVALID_SYNTAX, sp_parser_hint::hint_type, HT_KEY, sp_parser_ctx::is_select, NO_ERROR, sp_parser_ctx::operator_, TT_ASSIGN_OP, and TT_IN_OP.

Referenced by sp_process_token().

Here is the caller graph for this function:

static int sp_make_int_sp_value_from_string ( SP_VALUE value_p,
char *  pos,
int  length 
)
static

Definition at line 316 of file shard_parser.c.

References ER_SP_INVALID_HINT, sp_value::integer, NO_ERROR, parse_bigint(), sp_value::type, and VT_INTEGER.

Referenced by sp_get_int_bind_value(), and sp_make_sp_value().

Here is the caller graph for this function:

static int sp_make_sp_value ( SP_VALUE value_p,
const char *  pos,
int  length 
)
static

Definition at line 271 of file shard_parser.c.

References left_trim(), p, sp_get_token_type(), sp_make_int_sp_value_from_string(), sp_make_string_sp_value(), TT_DOUBLE_QUOTED, and TT_SINGLE_QUOTED.

Referenced by sp_get_hint_arg().

Here is the caller graph for this function:

static int sp_make_string_sp_value ( SP_VALUE value_p,
const char *  pos,
int  length 
)
static
int sp_parse_sql ( SP_PARSER_CTX parser_p)

Definition at line 96 of file shard_parser.c.

References sp_parser_ctx::cursor, ER_SP_INVALID_SYNTAX, error(), NO_ERROR, PROXY_LOG, PROXY_LOG_MODE_ERROR, sp_parse_sql_internal(), sp_cursor::token, and TT_NONE.

Referenced by shard_stmt_set_hint_list().

Here is the caller graph for this function:

static int sp_parse_sql_internal ( SP_PARSER_CTX parser_p)
static