CUBRID Engine  latest
parse_tree.c File Reference
#include "config.h"
#include <stddef.h>
#include <assert.h>
#include <setjmp.h>
#include <time.h>
#include <sys/time.h>
#include "porting.h"
#include "dbi.h"
#include "parser.h"
#include "jansson.h"
#include "memory_alloc.h"
#include "dbtype.h"
Include dependency graph for parse_tree.c:

Go to the source code of this file.

Classes

struct  parser_node_block
 
struct  parser_node_free_list
 
struct  parser_string_block
 
union  parser_string_block::aligned
 

Macros

#define STRINGS_PER_BLOCK   (8192-(4*sizeof(long)+sizeof(char *)+40))
 
#define HASH_NUMBER   128
 
#define NODES_PER_BLOCK   256
 

Typedefs

typedef struct parser_node_block PARSER_NODE_BLOCK
 
typedef struct parser_node_free_list PARSER_NODE_FREE_LIST
 
typedef struct parser_string_block PARSER_STRING_BLOCK
 

Functions

static PT_NODEparser_create_node_block (const PARSER_CONTEXT *parser)
 
static void pt_free_node_blocks (const PARSER_CONTEXT *parser)
 
static PARSER_STRING_BLOCKparser_create_string_block (const PARSER_CONTEXT *parser, const int length)
 
static void pt_free_a_string_block (const PARSER_CONTEXT *parser, PARSER_STRING_BLOCK *string_to_free)
 
static PARSER_STRING_BLOCKpt_find_string_block (const PARSER_CONTEXT *parser, const char *old_string)
 
static char * pt_append_string_for (const PARSER_CONTEXT *parser, const char *old_string, const char *new_tail, const int wrap_with_single_quote)
 
static PARSER_VARCHARpt_append_bytes_for (const PARSER_CONTEXT *parser, PARSER_VARCHAR *old_string, const char *new_tail, const int new_tail_length)
 
static int pt_register_parser (const PARSER_CONTEXT *parser)
 
static void pt_unregister_parser (const PARSER_CONTEXT *parser)
 
static void pt_free_string_blocks (const PARSER_CONTEXT *parser)
 
PT_NODEparser_create_node (const PARSER_CONTEXT *parser)
 
void * parser_allocate_string_buffer (const PARSER_CONTEXT *parser, const int length, const int align)
 
void parser_free_node_resources (PT_NODE *node)
 
void parser_free_node (const PARSER_CONTEXT *parser, PT_NODE *node)
 
void * parser_alloc (const PARSER_CONTEXT *parser, const int length)
 
char * pt_append_string (const PARSER_CONTEXT *parser, const char *old_string, const char *new_tail)
 
PARSER_VARCHARpt_append_bytes (const PARSER_CONTEXT *parser, PARSER_VARCHAR *old_string, const char *new_tail, const int new_tail_length)
 
PARSER_VARCHARpt_append_varchar (const PARSER_CONTEXT *parser, PARSER_VARCHAR *old_string, const PARSER_VARCHAR *new_tail)
 
PARSER_VARCHARpt_append_nulstring (const PARSER_CONTEXT *parser, PARSER_VARCHAR *bstring, const char *nulstring)
 
const unsigned char * pt_get_varchar_bytes (const PARSER_VARCHAR *string)
 
int pt_get_varchar_length (const PARSER_VARCHAR *string)
 
PARSER_CONTEXTparser_create_parser (void)
 
void parser_free_parser (PARSER_CONTEXT *parser)
 
void parser_free_lcks_classes (PARSER_CONTEXT *parser)
 
void pt_init_assignments_helper (PARSER_CONTEXT *parser, PT_ASSIGNMENTS_HELPER *helper, PT_NODE *assignment)
 
PT_NODEpt_get_next_assignment (PT_ASSIGNMENTS_HELPER *ea)
 
int pt_count_assignments (PARSER_CONTEXT *parser, PT_NODE *assignments)
 
bool pt_is_json_value_type (PT_TYPE_ENUM type)
 
bool pt_is_json_doc_type (PT_TYPE_ENUM type)
 

Variables

PT_RESERVED_NAME pt_Reserved_name_table []
 
static PARSER_NODE_BLOCKparser_Node_blocks [HASH_NUMBER]
 
static PARSER_NODE_FREE_LISTparser_Node_free_lists [HASH_NUMBER]
 
static PARSER_STRING_BLOCKparser_String_blocks [HASH_NUMBER]
 
static int parser_id = 1
 

Macro Definition Documentation

#define NODES_PER_BLOCK   256

Definition at line 58 of file parse_tree.c.

Referenced by parser_create_node_block().

#define STRINGS_PER_BLOCK   (8192-(4*sizeof(long)+sizeof(char *)+40))

Definition at line 56 of file parse_tree.c.

Referenced by parser_create_string_block().

Typedef Documentation

Definition at line 60 of file parse_tree.c.

Definition at line 68 of file parse_tree.c.

Definition at line 76 of file parse_tree.c.

Function Documentation

void parser_free_lcks_classes ( PARSER_CONTEXT parser)

Definition at line 1310 of file parse_tree.c.

References free_and_init, i, parser_context::lcks_classes, and parser_context::num_lcks_classes.

Referenced by parser_free_parser(), and pt_class_pre_fetch().

Here is the caller graph for this function:

void parser_free_node ( const PARSER_CONTEXT parser,
PT_NODE node 
)
static PARSER_VARCHAR * pt_append_bytes_for ( const PARSER_CONTEXT parser,
PARSER_VARCHAR old_string,
const char *  new_tail,
const int  new_tail_length 
)
static
PARSER_VARCHAR* pt_append_nulstring ( const PARSER_CONTEXT parser,
PARSER_VARCHAR bstring,
const char *  nulstring 
)

Definition at line 1072 of file parse_tree.c.

References NULL, pt_append_bytes(), and strlen.

Referenced by chksum_get_quote_escaped_lower_bound(), chksum_print_attribute_list(), chksum_print_checksum_query(), chksum_print_lower_bound_string(), chksum_print_pk_list(), chksum_print_select_last_chunk(), chksum_print_select_master_checksum(), chksum_print_update_master_checksum(), chksum_set_initial_chunk_id_and_lower_bound(), parser_print_tree(), pt_append_name(), pt_append_quoted_string(), pt_append_string_prefix(), pt_dbval_to_value(), pt_print_alter(), pt_print_alter_index(), pt_print_alter_one_clause(), pt_print_alter_serial(), pt_print_alter_stored_procedure(), pt_print_alter_trigger(), pt_print_alter_user(), pt_print_and_list(), pt_print_attach(), pt_print_attr_def(), pt_print_attr_ordering(), pt_print_auth_cmd(), pt_print_auto_increment(), pt_print_bytes_l(), pt_print_col_def_constraint(), pt_print_commit_work(), pt_print_constraint(), pt_print_create_entity(), pt_print_create_index(), pt_print_create_serial(), pt_print_create_stored_procedure(), pt_print_create_trigger(), pt_print_create_user(), pt_print_cte(), pt_print_data_default(), pt_print_datatype(), pt_print_db_value(), pt_print_delete(), pt_print_difference(), pt_print_do(), pt_print_dot(), pt_print_drop(), pt_print_drop_index(), pt_print_drop_serial(), pt_print_drop_session_variables(), pt_print_drop_stored_procedure(), pt_print_drop_trigger(), pt_print_drop_user(), pt_print_drop_variable(), pt_print_error_msg(), pt_print_evaluate(), pt_print_event_spec(), pt_print_event_target(), pt_print_execute_trigger(), pt_print_expr(), pt_print_function(), pt_print_get_opt_lvl(), pt_print_get_stats(), pt_print_get_trigger(), pt_print_get_xaction(), pt_print_grant(), pt_print_host_var(), pt_print_insert(), pt_print_intersection(), pt_print_isolation_lvl(), pt_print_json_table(), pt_print_json_table_column_error_or_empty_behavior(), pt_print_json_table_column_info(), pt_print_json_table_columns(), pt_print_json_table_node(), pt_print_merge(), pt_print_method_call(), pt_print_method_def(), pt_print_name(), pt_print_named_arg(), pt_print_partition(), pt_print_parts(), pt_print_prepare_to_commit(), pt_print_query_trace(), pt_print_remove_trigger(), pt_print_rename(), pt_print_rename_trigger(), pt_print_resolution(), pt_print_revoke(), pt_print_rollback_work(), pt_print_savepoint(), pt_print_scope(), pt_print_select(), pt_print_session_variables(), pt_print_set_names(), pt_print_set_opt_lvl(), pt_print_set_session_variables(), pt_print_set_sys_params(), pt_print_set_timezone(), pt_print_set_trigger(), pt_print_set_xaction(), pt_print_showstmt(), pt_print_sort_spec(), pt_print_sp_parameter(), pt_print_spec(), pt_print_table_option(), pt_print_timeout(), pt_print_trigger_action(), pt_print_truncate(), pt_print_union_stmt(), pt_print_update(), pt_print_update_stats(), pt_print_vacuum(), pt_print_value(), pt_print_with_clause(), and pt_to_regu_variable().

static char * pt_append_string_for ( const PARSER_CONTEXT parser,
const char *  old_string,
const char *  new_tail,
const int  wrap_with_single_quote 
)
static
PARSER_VARCHAR* pt_append_varchar ( const PARSER_CONTEXT parser,
PARSER_VARCHAR old_string,
const PARSER_VARCHAR new_tail 
)

Definition at line 1052 of file parse_tree.c.

References parser_varchar::bytes, parser_varchar::length, NULL, and pt_append_bytes().

Referenced by chksum_print_checksum_query(), chksum_print_select_last_chunk(), pt_print_alter(), pt_print_alter_index(), pt_print_alter_one_clause(), pt_print_alter_serial(), pt_print_alter_stored_procedure(), pt_print_alter_trigger(), pt_print_alter_user(), pt_print_and_list(), pt_print_attr_def(), pt_print_attr_ordering(), pt_print_auth_cmd(), pt_print_auto_increment(), pt_print_bytes_spec_list(), pt_print_col_def_constraint(), pt_print_constraint(), pt_print_create_entity(), pt_print_create_index(), pt_print_create_serial(), pt_print_create_stored_procedure(), pt_print_create_trigger(), pt_print_create_user(), pt_print_cte(), pt_print_data_default(), pt_print_datatype(), pt_print_delete(), pt_print_difference(), pt_print_do(), pt_print_dot(), pt_print_drop(), pt_print_drop_index(), pt_print_drop_serial(), pt_print_drop_session_variables(), pt_print_drop_stored_procedure(), pt_print_drop_trigger(), pt_print_drop_user(), pt_print_drop_variable(), pt_print_evaluate(), pt_print_event_spec(), pt_print_event_target(), pt_print_execute_trigger(), pt_print_expr(), pt_print_file_path(), pt_print_function(), pt_print_get_opt_lvl(), pt_print_get_stats(), pt_print_get_trigger(), pt_print_get_xaction(), pt_print_grant(), pt_print_host_var(), pt_print_index_columns(), pt_print_insert(), pt_print_intersection(), pt_print_isolation_lvl(), pt_print_json_table(), pt_print_json_table_column_error_or_empty_behavior(), pt_print_json_table_column_info(), pt_print_json_table_node(), pt_print_merge(), pt_print_method_call(), pt_print_method_def(), pt_print_name(), pt_print_named_arg(), pt_print_partition(), pt_print_parts(), pt_print_remove_trigger(), pt_print_rename(), pt_print_rename_trigger(), pt_print_resolution(), pt_print_revoke(), pt_print_rollback_work(), pt_print_savepoint(), pt_print_scope(), pt_print_select(), pt_print_session_variables(), pt_print_set_names(), pt_print_set_opt_lvl(), pt_print_set_session_variables(), pt_print_set_sys_params(), pt_print_set_timezone(), pt_print_set_trigger(), pt_print_set_xaction(), pt_print_showstmt(), pt_print_sort_spec(), pt_print_sp_parameter(), pt_print_spec(), pt_print_table_option(), pt_print_timeout(), pt_print_trigger_action(), pt_print_trigger_spec_list(), pt_print_truncate(), pt_print_union_stmt(), pt_print_update(), pt_print_update_stats(), pt_print_value(), and pt_print_with_clause().

int pt_count_assignments ( PARSER_CONTEXT parser,
PT_NODE assignments 
)

Definition at line 1413 of file parse_tree.c.

References pt_get_next_assignment(), and pt_init_assignments_helper().

Referenced by check_trigger().

Here is the caller graph for this function:

static void pt_free_a_string_block ( const PARSER_CONTEXT parser,
PARSER_STRING_BLOCK string_to_free 
)
static

Definition at line 509 of file parse_tree.c.

References free_and_init, HASH_NUMBER, parser_context::id, parser_string_block::next, pthread_mutex_lock, pthread_mutex_unlock, and rv.

Referenced by pt_append_bytes_for(), and pt_append_string_for().

Here is the caller graph for this function:

static void pt_free_node_blocks ( const PARSER_CONTEXT parser)
static

Definition at line 328 of file parse_tree.c.

References free_and_init, HASH_NUMBER, parser_context::id, parser_node_block::next, NULL, parser_node_block::parser_id, pthread_mutex_lock, pthread_mutex_unlock, and rv.

Referenced by parser_free_parser().

Here is the caller graph for this function:

static void pt_free_string_blocks ( const PARSER_CONTEXT parser)
static

Definition at line 1123 of file parse_tree.c.

References free_and_init, HASH_NUMBER, parser_context::id, parser_string_block::next, NULL, parser_string_block::parser_id, pthread_mutex_lock, pthread_mutex_unlock, and rv.

Referenced by parser_free_parser().

Here is the caller graph for this function:

int pt_get_varchar_length ( const PARSER_VARCHAR string)

Definition at line 1106 of file parse_tree.c.

References NULL.

Referenced by pt_get_enumeration_from_data_type(), and pt_is_same_enum_data_type().

Here is the caller graph for this function:

bool pt_is_json_doc_type ( PT_TYPE_ENUM  type)

Definition at line 1442 of file parse_tree.c.

References db_is_json_doc_type(), pt_type_enum_to_db(), PT_TYPE_MAYBE, and PT_TYPE_NULL.

Referenced by pt_are_equivalent_types(), pt_get_equivalent_type(), and pt_semantic_check_local().

Here is the caller graph for this function:

bool pt_is_json_value_type ( PT_TYPE_ENUM  type)

Definition at line 1429 of file parse_tree.c.

References db_is_json_value_type(), pt_type_enum_to_db(), PT_TYPE_MAYBE, and PT_TYPE_NULL.

Referenced by pt_are_equivalent_types(), and pt_get_equivalent_type().

Here is the caller graph for this function:

static int pt_register_parser ( const PARSER_CONTEXT parser)
static
static void pt_unregister_parser ( const PARSER_CONTEXT parser)
static

Definition at line 801 of file parse_tree.c.

References free_and_init, HASH_NUMBER, parser_context::id, parser_node_free_list::next, NULL, parser_node_free_list::parser_id, pthread_mutex_lock, pthread_mutex_unlock, and rv.

Referenced by parser_free_parser().

Here is the caller graph for this function:

Variable Documentation

int parser_id = 1
static

Definition at line 192 of file parse_tree.c.

Referenced by parser_init_node(), and parser_reinit_node().

PARSER_NODE_BLOCK* parser_Node_blocks[HASH_NUMBER]
static

Definition at line 188 of file parse_tree.c.

PARSER_NODE_FREE_LIST* parser_Node_free_lists[HASH_NUMBER]
static

Definition at line 189 of file parse_tree.c.

PARSER_STRING_BLOCK* parser_String_blocks[HASH_NUMBER]
static

Definition at line 190 of file parse_tree.c.

PT_RESERVED_NAME pt_Reserved_name_table[]