CUBRID Engine
latest
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "system.h"
#include "error_code.h"
Go to the source code of this file.
Classes | |
struct | sp_cursor |
struct | sp_value |
struct | sp_parser_hint |
struct | sp_parser_hint_list |
struct | sp_parser_ctx |
Macros | |
#define | SP_VALUE_INIT_SIZE 50 |
Typedefs | |
typedef enum sp_hint_type | SP_HINT_TYPE |
typedef enum sp_bind_type | SP_BIND_TYPE |
typedef enum sp_value_type | SP_VALUE_TYPE |
typedef enum sp_token | SP_TOKEN |
typedef struct sp_cursor | SP_CURSOR |
typedef struct sp_value | SP_VALUE |
typedef struct sp_parser_hint | SP_PARSER_HINT |
typedef struct sp_parser_hint_list | SP_PARSER_HINT_LIST |
typedef struct sp_parser_ctx | SP_PARSER_CTX |
Enumerations | |
enum | sp_error_code { ER_SP_OUT_OF_MEMORY = -1, ER_SP_NOT_FOUND_HINT = -2, ER_SP_INVALID_HINT = -3, ER_SP_INVALID_SYNTAX = -4, ER_SP_DUPLICATED_HINT = -5 } |
enum | sp_hint_type { HT_INVAL = -1, HT_NONE, HT_KEY, HT_VAL, HT_ALL, HT_ID, HT_EOF } |
enum | sp_bind_type { BT_STATIC, BT_DYNAMIC } |
enum | sp_value_type { VT_INTEGER, VT_STRING } |
enum | sp_token { TT_NONE, TT_SINGLE_QUOTED, TT_DOUBLE_QUOTED, TT_CSQL_COMMENT, TT_CPP_COMMENT, TT_WHITESPACE, TT_NEWLINE, TT_C_COMMENT, TT_C_COMMENT_END, TT_HINT, TT_SHARD_HINT, TT_ASSIGN_OP, TT_IN_OP, TT_LEFT_BRAKET, TT_RIGHT_BRAKET, TT_BIND_CHAR } |
#define SP_VALUE_INIT_SIZE 50 |
Definition at line 37 of file shard_parser.h.
Referenced by sp_make_string_sp_value().
typedef enum sp_bind_type SP_BIND_TYPE |
Definition at line 66 of file shard_parser.h.
Definition at line 96 of file shard_parser.h.
typedef enum sp_hint_type SP_HINT_TYPE |
Definition at line 59 of file shard_parser.h.
typedef struct sp_parser_ctx SP_PARSER_CTX |
Definition at line 137 of file shard_parser.h.
typedef struct sp_parser_hint SP_PARSER_HINT |
Definition at line 117 of file shard_parser.h.
typedef struct sp_parser_hint_list SP_PARSER_HINT_LIST |
Definition at line 129 of file shard_parser.h.
Definition at line 94 of file shard_parser.h.
Definition at line 103 of file shard_parser.h.
typedef enum sp_value_type SP_VALUE_TYPE |
Definition at line 73 of file shard_parser.h.
enum sp_bind_type |
Enumerator | |
---|---|
BT_STATIC | |
BT_DYNAMIC |
Definition at line 61 of file shard_parser.h.
enum sp_error_code |
Enumerator | |
---|---|
ER_SP_OUT_OF_MEMORY | |
ER_SP_NOT_FOUND_HINT | |
ER_SP_INVALID_HINT | |
ER_SP_INVALID_SYNTAX | |
ER_SP_DUPLICATED_HINT |
Definition at line 40 of file shard_parser.h.
enum sp_hint_type |
Enumerator | |
---|---|
HT_INVAL | |
HT_NONE | |
HT_KEY | |
HT_VAL | |
HT_ALL | |
HT_ID | |
HT_EOF |
Definition at line 49 of file shard_parser.h.
enum sp_token |
Definition at line 75 of file shard_parser.h.
enum sp_value_type |
Enumerator | |
---|---|
VT_INTEGER | |
VT_STRING |
Definition at line 68 of file shard_parser.h.
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().
SP_PARSER_CTX* sp_create_parser | ( | const char * | sql_stmt | ) |
Definition at line 63 of file shard_parser.c.
References sp_parser_ctx::bind_count, BT_DYNAMIC, BT_STATIC, sp_parser_ctx::cursor, sp_parser_ctx::is_select, sp_parser_ctx::list_a, sp_parser_ctx::list_t, NULL, sp_parser_ctx::operator_, sp_cursor::pos, PROXY_LOG, PROXY_LOG_MODE_ERROR, sp_parser_ctx::prv_cursor, sp_init_praser_hint_list(), sp_parser_ctx::sql_stmt, strdup(), sp_cursor::token, and TT_NONE.
Referenced by shard_stmt_new_internal().
SP_PARSER_HINT* sp_create_parser_hint | ( | void | ) |
Definition at line 333 of file shard_parser.c.
References sp_parser_hint::arg, sp_parser_hint::bind_position, sp_parser_hint::bind_type, BT_DYNAMIC, BT_STATIC, error(), sp_parser_hint::hint_type, HT_NONE, sp_parser_hint::next_a, sp_parser_hint::next_t, NO_ERROR, NULL, PROXY_LOG, PROXY_LOG_MODE_ERROR, sp_free_parser_hint(), sp_init_sp_value(), and sp_parser_hint::value.
Referenced by shard_stmt_change_shard_val_to_id(), and sp_process_token().
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().
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().
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 | ) |
Definition at line 155 of file shard_parser.c.
References sp_parser_hint_list::head, and sp_parser_ctx::list_a.
Referenced by proxy_get_shard_id(), proxy_update_shard_stats(), shard_stmt_get_hint_type(), shard_stmt_set_hint_list(), and sp_free_parser_hint_from_ctx().
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 | ||
) |
Definition at line 610 of file shard_parser.c.
References sp_parser_hint::arg, ER_SP_INVALID_HINT, sp_parser_hint::hint_type, HT_ID, HT_VAL, left_trim(), NO_ERROR, p, sp_get_token_type(), sp_is_pair_token(), sp_make_sp_value(), and TT_LEFT_BRAKET.
Referenced by shard_stmt_change_shard_val_to_id(), and sp_process_token().
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().
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().
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().
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.
Definition at line 489 of file shard_parser.c.
References p, TT_ASSIGN_OP, TT_BIND_CHAR, TT_C_COMMENT, TT_C_COMMENT_END, TT_CPP_COMMENT, TT_CSQL_COMMENT, TT_DOUBLE_QUOTED, TT_HINT, TT_IN_OP, TT_LEFT_BRAKET, TT_NEWLINE, TT_NONE, TT_RIGHT_BRAKET, TT_SINGLE_QUOTED, and TT_WHITESPACE.
Referenced by shard_stmt_rewrite_sql(), sp_get_hint_arg(), sp_make_sp_value(), and sp_parse_sql_internal().
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.
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().
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().
Definition at line 203 of file shard_parser.c.
References left_trim(), TT_ASSIGN_OP, TT_BIND_CHAR, TT_C_COMMENT, TT_C_COMMENT_END, TT_CPP_COMMENT, TT_CSQL_COMMENT, TT_DOUBLE_QUOTED, TT_HINT, TT_IN_OP, TT_LEFT_BRAKET, TT_NEWLINE, TT_NONE, TT_RIGHT_BRAKET, TT_SHARD_HINT, TT_SINGLE_QUOTED, and TT_WHITESPACE.
Referenced by shard_stmt_rewrite_sql(), sp_get_hint_arg(), and sp_parse_sql_internal().
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().