diff options
Diffstat (limited to 'sql/sql_lex.h')
-rw-r--r-- | sql/sql_lex.h | 98 |
1 files changed, 70 insertions, 28 deletions
diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 1bb63833c41..58f8c5c6b04 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -3260,7 +3260,8 @@ private: class sp_label **splabel); bool sp_change_context(THD *thd, const sp_pcontext *ctx, bool exclusive); bool sp_exit_block(THD *thd, sp_label *lab); - bool sp_exit_block(THD *thd, sp_label *lab, Item *when); + bool sp_exit_block(THD *thd, sp_label *lab, Item *when, + LEX_CSTRING expr_str); bool sp_continue_loop(THD *thd, sp_label *lab); @@ -3275,7 +3276,8 @@ private: bool check_expr_allows_fields_or_error(THD *thd, const char *name) const; protected: - bool sp_continue_loop(THD *thd, sp_label *lab, Item *when); + bool sp_continue_loop(THD *thd, sp_label *lab, Item *when, + LEX_CSTRING expr_str); public: void parse_error(uint err_number= ER_SYNTAX_ERROR); @@ -3808,9 +3810,10 @@ public: int case_stmt_action_then(); bool setup_select_in_parentheses(); - bool set_trigger_new_row(const LEX_CSTRING *name, Item *val); + bool set_trigger_new_row(const LEX_CSTRING *name, Item *val, + LEX_CSTRING expr_str); bool set_trigger_field(const LEX_CSTRING *name1, const LEX_CSTRING *name2, - Item *val); + Item *val, LEX_CSTRING expr_str); bool set_system_variable(enum_var_type var_type, sys_var *var, const Lex_ident_sys_st *base_name, Item *val); bool set_system_variable(enum_var_type var_type, @@ -3862,40 +3865,50 @@ public: sp_pcontext *not_used_ctx; return find_variable(name, ¬_used_ctx, rh); } - bool set_variable(const Lex_ident_sys_st *name, Item *item); + bool set_variable(const Lex_ident_sys_st *name, Item *item, + LEX_CSTRING expr_str); bool set_variable(const Lex_ident_sys_st *name1, - const Lex_ident_sys_st *name2, Item *item); + const Lex_ident_sys_st *name2, Item *item, + LEX_CSTRING expr_str); void sp_variable_declarations_init(THD *thd, int nvars); bool sp_variable_declarations_finalize(THD *thd, int nvars, const Column_definition *cdef, - Item *def); - bool sp_variable_declarations_set_default(THD *thd, int nvars, Item *def); + Item *def, LEX_CSTRING expr_str); + bool sp_variable_declarations_set_default(THD *thd, int nvars, Item *def, + LEX_CSTRING expr_str); bool sp_variable_declarations_row_finalize(THD *thd, int nvars, Row_definition_list *row, - Item *def); + Item *def, LEX_CSTRING expr_str); bool sp_variable_declarations_with_ref_finalize(THD *thd, int nvars, Qualified_column_ident *col, - Item *def); + Item *def, + LEX_CSTRING expr_str); bool sp_variable_declarations_rowtype_finalize(THD *thd, int nvars, Qualified_column_ident *, - Item *def); + Item *def, + LEX_CSTRING expr_str); bool sp_variable_declarations_cursor_rowtype_finalize(THD *thd, int nvars, uint offset, - Item *def); + Item *def, + LEX_CSTRING expr_str); bool sp_variable_declarations_table_rowtype_finalize(THD *thd, int nvars, const LEX_CSTRING &db, const LEX_CSTRING &table, - Item *def); + Item *def, + LEX_CSTRING expr_str); bool sp_variable_declarations_column_type_finalize(THD *thd, int nvars, Qualified_column_ident *ref, - Item *def); + Item *def, + LEX_CSTRING expr_str); bool sp_variable_declarations_vartype_finalize(THD *thd, int nvars, const LEX_CSTRING &name, - Item *def); + Item *def, + LEX_CSTRING expr_str); bool sp_variable_declarations_copy_type_finalize(THD *thd, int nvars, const Column_definition &ref, Row_definition_list *fields, - Item *def); + Item *def, + LEX_CSTRING expr_str); LEX_USER *current_user_for_set_password(THD *thd); bool sp_create_set_password_instr(THD *thd, @@ -3916,7 +3929,8 @@ public: bool sp_declare_cursor(THD *thd, const LEX_CSTRING *name, class sp_lex_cursor *cursor_stmt, - sp_pcontext *param_ctx, bool add_cpush_instr); + sp_pcontext *param_ctx, bool add_cpush_instr, + LEX_CSTRING cursor_query); bool sp_open_cursor(THD *thd, const LEX_CSTRING *name, List<sp_assignment_lex> *parameters); @@ -4181,8 +4195,9 @@ public: uint executable_section_ip, uint exception_count); bool sp_block_with_exceptions_add_empty(THD *thd); - bool sp_exit_statement(THD *thd, Item *when); - bool sp_exit_statement(THD *thd, const LEX_CSTRING *label_name, Item *item); + bool sp_exit_statement(THD *thd, Item *when, LEX_CSTRING expr_str); + bool sp_exit_statement(THD *thd, const LEX_CSTRING *label_name, Item *item, + LEX_CSTRING expr_str); bool sp_leave_statement(THD *thd, const LEX_CSTRING *label_name); bool sp_goto_statement(THD *thd, const LEX_CSTRING *label_name); @@ -4195,7 +4210,7 @@ public: bool sp_push_loop_empty_label(THD *thd); bool sp_pop_loop_label(THD *thd, const LEX_CSTRING *label_name); void sp_pop_loop_empty_label(THD *thd); - bool sp_while_loop_expression(THD *thd, Item *expr); + bool sp_while_loop_expression(THD *thd, Item *expr, LEX_CSTRING expr_str); bool sp_while_loop_finalize(THD *thd); bool sp_if_after_statements(THD *thd); bool sp_push_goto_label(THD *thd, const LEX_CSTRING *label_name); @@ -4205,11 +4220,12 @@ public: /* Integer range FOR LOOP methods */ sp_variable *sp_add_for_loop_variable(THD *thd, const LEX_CSTRING *name, - Item *value); - sp_variable *sp_add_for_loop_target_bound(THD *thd, Item *value) + Item *value, LEX_CSTRING expr_str); + sp_variable *sp_add_for_loop_target_bound(THD *thd, Item *value, + LEX_CSTRING expr_str) { LEX_CSTRING name= { STRING_WITH_LEN("[target_bound]") }; - return sp_add_for_loop_variable(thd, &name, value); + return sp_add_for_loop_variable(thd, &name, value, expr_str); } bool sp_for_loop_intrange_declarations(THD *thd, Lex_for_loop_st *loop, const LEX_CSTRING *index, @@ -4229,7 +4245,8 @@ public: Item_args *parameters); bool sp_for_loop_implicit_cursor_statement(THD *thd, Lex_for_loop_bounds_st *bounds, - sp_lex_cursor *cur); + sp_lex_cursor *cur, + LEX_CSTRING cursor_query); bool sp_for_loop_cursor_condition_test(THD *thd, const Lex_for_loop_st &loop); bool sp_for_loop_cursor_finalize(THD *thd, const Lex_for_loop_st &); @@ -4759,6 +4776,15 @@ public: builtin_select.options |= SELECT_DESCRIBE; } + + /** + Check if the current statement uses meta-data (uses a table or a stored + routine). + */ + bool is_metadata_used() const + { + return query_tables != nullptr || sroutines.records > 0; + } }; @@ -4985,14 +5011,16 @@ public: class sp_expr_lex: public sp_lex_local { Item *m_item; // The expression + LEX_CSTRING m_expr_str; public: sp_expr_lex(THD *thd, LEX *oldlex) :sp_lex_local(thd, oldlex), - m_item(NULL) + m_item(NULL), m_expr_str(empty_clex_str) { } - void set_item(Item *item) + void set_item(Item *item, LEX_CSTRING expr_str) { m_item= item; + m_expr_str= expr_str; } Item *get_item() const { @@ -5004,10 +5032,14 @@ public: int case_stmt_action_when(bool simple); bool sp_while_loop_expression(THD *thd) { - return LEX::sp_while_loop_expression(thd, get_item()); + return LEX::sp_while_loop_expression(thd, get_item(), m_expr_str); } bool sp_repeat_loop_finalize(THD *thd); bool sp_if_expr(THD *thd); + LEX_CSTRING get_expr_str() const + { + return m_expr_str; + } }; @@ -5038,11 +5070,13 @@ class sp_assignment_lex: public sp_lex_local { Item *m_item; // The expression Item *m_free_list; // The associated free_list (sub-expressions) + LEX_CSTRING m_expr_str; public: sp_assignment_lex(THD *thd, LEX *oldlex) :sp_lex_local(thd, oldlex), m_item(NULL), - m_free_list(NULL) + m_free_list(NULL), + m_expr_str(empty_clex_str) { } void set_item_and_free_list(Item *item, Item *free_list) { @@ -5057,6 +5091,14 @@ public: { return m_free_list; } + void set_expr_str(LEX_CSTRING expr_str) + { + m_expr_str= expr_str; + } + LEX_CSTRING get_expr_str() const + { + return m_expr_str; + } }; |