CUBRID Engine  latest
shard_parser.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "system.h"
#include "error_code.h"
Include dependency graph for shard_parser.h:
This graph shows which files directly or indirectly include this file:

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
}
 

Functions

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)
 
const char * sp_get_token_type (const char *sql, SP_TOKEN *token)
 
bool sp_is_pair_token (SP_TOKEN start_token, SP_TOKEN end_token)
 
bool sp_is_exist_pair_token (SP_TOKEN token)
 
SP_PARSER_HINTsp_create_parser_hint (void)
 
void sp_free_parser_hint (SP_PARSER_HINT *hint_p)
 
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)
 

Macro Definition Documentation

#define SP_VALUE_INIT_SIZE   50

Definition at line 37 of file shard_parser.h.

Referenced by sp_make_string_sp_value().

Typedef Documentation

typedef enum sp_bind_type SP_BIND_TYPE

Definition at line 66 of file shard_parser.h.

typedef struct sp_cursor SP_CURSOR

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.

Definition at line 117 of file shard_parser.h.

Definition at line 129 of file shard_parser.h.

typedef enum sp_token SP_TOKEN

Definition at line 94 of file shard_parser.h.

typedef struct sp_value SP_VALUE

Definition at line 103 of file shard_parser.h.

Definition at line 73 of file shard_parser.h.

Enumeration Type Documentation

Enumerator
BT_STATIC 
BT_DYNAMIC 

Definition at line 61 of file shard_parser.h.

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.

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
Enumerator
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 

Definition at line 75 of file shard_parser.h.

Enumerator
VT_INTEGER 
VT_STRING 

Definition at line 68 of file shard_parser.h.

Function Documentation

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:

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:

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:

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.

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.

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:

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: