diff options
Diffstat (limited to 'sql/sp_head.h')
-rw-r--r-- | sql/sp_head.h | 111 |
1 files changed, 52 insertions, 59 deletions
diff --git a/sql/sp_head.h b/sql/sp_head.h index 9c29297180d..c0881661ad1 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -86,6 +86,7 @@ public: my_bool m_has_return; // For FUNCTIONs only my_bool m_simple_case; // TRUE if parsing simple case, FALSE otherwise my_bool m_multi_results; // TRUE if a procedure with SELECT(s) + my_bool m_in_handler; // TRUE if parser in a handler body uint m_old_cmq; // Old CLIENT_MULTI_QUERIES value st_sp_chistics *m_chistics; ulong m_sql_mode; // For SHOW CREATE @@ -262,10 +263,11 @@ public: uint marked; Item *free_list; // My Items uint m_ip; // My index + sp_pcontext *m_ctx; // My parse context // Should give each a name or type code for debugging purposes? - sp_instr(uint ip) - :Sql_alloc(), marked(0), free_list(0), m_ip(ip) + sp_instr(uint ip, sp_pcontext *ctx) + :Sql_alloc(), marked(0), free_list(0), m_ip(ip), m_ctx(ctx) {} virtual ~sp_instr() @@ -279,7 +281,7 @@ public: virtual void print(String *str) = 0; - virtual void backpatch(uint dest, uint hpop, uint cpop) + virtual void backpatch(uint dest, sp_pcontext *dst_ctx) {} virtual uint opt_mark(sp_head *sp) @@ -288,7 +290,7 @@ public: return m_ip+1; } - virtual uint opt_shortcut_jump(sp_head *sp) + virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start) { return m_ip; } @@ -311,8 +313,8 @@ class sp_instr_stmt : public sp_instr public: - sp_instr_stmt(uint ip) - : sp_instr(ip), m_lex(NULL) + sp_instr_stmt(uint ip, sp_pcontext *ctx) + : sp_instr(ip, ctx), m_lex(NULL) {} virtual ~sp_instr_stmt(); @@ -353,8 +355,10 @@ public: TABLE_LIST *tables; - sp_instr_set(uint ip, uint offset, Item *val, enum enum_field_types type) - : sp_instr(ip), tables(NULL), m_offset(offset), m_value(val), m_type(type) + sp_instr_set(uint ip, sp_pcontext *ctx, + uint offset, Item *val, enum enum_field_types type) + : sp_instr(ip, ctx), + tables(NULL), m_offset(offset), m_value(val), m_type(type) {} virtual ~sp_instr_set() @@ -382,12 +386,12 @@ public: uint m_dest; // Where we will go - sp_instr_jump(uint ip) - : sp_instr(ip), m_dest(0), m_optdest(0) + sp_instr_jump(uint ip, sp_pcontext *ctx) + : sp_instr(ip, ctx), m_dest(0), m_optdest(0) {} - sp_instr_jump(uint ip, uint dest) - : sp_instr(ip), m_dest(dest), m_optdest(0) + sp_instr_jump(uint ip, sp_pcontext *ctx, uint dest) + : sp_instr(ip, ctx), m_dest(dest), m_optdest(0) {} virtual ~sp_instr_jump() @@ -399,11 +403,11 @@ public: virtual uint opt_mark(sp_head *sp); - virtual uint opt_shortcut_jump(sp_head *sp); + virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start); virtual void opt_move(uint dst, List<sp_instr> *ibp); - virtual void backpatch(uint dest, uint hpop, uint cpop) + virtual void backpatch(uint dest, sp_pcontext *dst_ctx) { if (m_dest == 0) // Don't reset m_dest= dest; @@ -425,12 +429,12 @@ public: TABLE_LIST *tables; - sp_instr_jump_if(uint ip, Item *i) - : sp_instr_jump(ip), tables(NULL), m_expr(i) + sp_instr_jump_if(uint ip, sp_pcontext *ctx, Item *i) + : sp_instr_jump(ip, ctx), tables(NULL), m_expr(i) {} - sp_instr_jump_if(uint ip, Item *i, uint dest) - : sp_instr_jump(ip, dest), tables(NULL), m_expr(i) + sp_instr_jump_if(uint ip, sp_pcontext *ctx, Item *i, uint dest) + : sp_instr_jump(ip, ctx, dest), tables(NULL), m_expr(i) {} virtual ~sp_instr_jump_if() @@ -442,7 +446,7 @@ public: virtual uint opt_mark(sp_head *sp); - virtual uint opt_shortcut_jump(sp_head *sp) + virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start) { return m_ip; } @@ -463,12 +467,12 @@ public: TABLE_LIST *tables; - sp_instr_jump_if_not(uint ip, Item *i) - : sp_instr_jump(ip), tables(NULL), m_expr(i) + sp_instr_jump_if_not(uint ip, sp_pcontext *ctx, Item *i) + : sp_instr_jump(ip, ctx), tables(NULL), m_expr(i) {} - sp_instr_jump_if_not(uint ip, Item *i, uint dest) - : sp_instr_jump(ip, dest), tables(NULL), m_expr(i) + sp_instr_jump_if_not(uint ip, sp_pcontext *ctx, Item *i, uint dest) + : sp_instr_jump(ip, ctx, dest), tables(NULL), m_expr(i) {} virtual ~sp_instr_jump_if_not() @@ -480,7 +484,7 @@ public: virtual uint opt_mark(sp_head *sp); - virtual uint opt_shortcut_jump(sp_head *sp) + virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start) { return m_ip; } @@ -501,8 +505,9 @@ public: TABLE_LIST *tables; - sp_instr_freturn(uint ip, Item *val, enum enum_field_types type) - : sp_instr(ip), tables(NULL), m_value(val), m_type(type) + sp_instr_freturn(uint ip, sp_pcontext *ctx, + Item *val, enum enum_field_types type) + : sp_instr(ip, ctx), tables(NULL), m_value(val), m_type(type) {} virtual ~sp_instr_freturn() @@ -533,8 +538,8 @@ class sp_instr_hpush_jump : public sp_instr_jump public: - sp_instr_hpush_jump(uint ip, int htype, uint fp) - : sp_instr_jump(ip), m_type(htype), m_frame(fp) + sp_instr_hpush_jump(uint ip, sp_pcontext *ctx, int htype, uint fp) + : sp_instr_jump(ip, ctx), m_type(htype), m_frame(fp) { m_handler= ip+1; m_cond.empty(); @@ -551,7 +556,7 @@ public: virtual uint opt_mark(sp_head *sp); - virtual uint opt_shortcut_jump(sp_head *sp) + virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start) { return m_ip; } @@ -578,8 +583,8 @@ class sp_instr_hpop : public sp_instr public: - sp_instr_hpop(uint ip, uint count) - : sp_instr(ip), m_count(count) + sp_instr_hpop(uint ip, sp_pcontext *ctx, uint count) + : sp_instr(ip, ctx), m_count(count) {} virtual ~sp_instr_hpop() @@ -589,13 +594,7 @@ public: virtual void print(String *str); - virtual void backpatch(uint dest, uint hpop, uint cpop) - { - if (hpop > m_count) - m_count= 0; - else - m_count-= hpop; - } + virtual void backpatch(uint dest, sp_pcontext *dst_ctx); virtual uint opt_mark(sp_head *sp) { @@ -618,8 +617,8 @@ class sp_instr_hreturn : public sp_instr public: - sp_instr_hreturn(uint ip, uint fp) - : sp_instr(ip), m_frame(fp) + sp_instr_hreturn(uint ip, sp_pcontext *ctx, uint fp) + : sp_instr(ip, ctx), m_frame(fp) {} virtual ~sp_instr_hreturn() @@ -649,8 +648,8 @@ class sp_instr_cpush : public sp_instr public: - sp_instr_cpush(uint ip, LEX *lex) - : sp_instr(ip), m_lex(lex) + sp_instr_cpush(uint ip, sp_pcontext *ctx, LEX *lex) + : sp_instr(ip, ctx), m_lex(lex) {} virtual ~sp_instr_cpush(); @@ -673,8 +672,8 @@ class sp_instr_cpop : public sp_instr public: - sp_instr_cpop(uint ip, uint count) - : sp_instr(ip), m_count(count) + sp_instr_cpop(uint ip, sp_pcontext *ctx, uint count) + : sp_instr(ip, ctx), m_count(count) {} virtual ~sp_instr_cpop() @@ -684,13 +683,7 @@ public: virtual void print(String *str); - virtual void backpatch(uint dest, uint hpop, uint cpop) - { - if (cpop > m_count) - m_count= 0; - else - m_count-= cpop; - } + virtual void backpatch(uint dest, sp_pcontext *dst_ctx); virtual uint opt_mark(sp_head *sp) { @@ -713,8 +706,8 @@ class sp_instr_copen : public sp_instr_stmt public: - sp_instr_copen(uint ip, uint c) - : sp_instr_stmt(ip), m_cursor(c) + sp_instr_copen(uint ip, sp_pcontext *ctx, uint c) + : sp_instr_stmt(ip, ctx), m_cursor(c) {} virtual ~sp_instr_copen() @@ -738,8 +731,8 @@ class sp_instr_cclose : public sp_instr public: - sp_instr_cclose(uint ip, uint c) - : sp_instr(ip), m_cursor(c) + sp_instr_cclose(uint ip, sp_pcontext *ctx, uint c) + : sp_instr(ip, ctx), m_cursor(c) {} virtual ~sp_instr_cclose() @@ -763,8 +756,8 @@ class sp_instr_cfetch : public sp_instr public: - sp_instr_cfetch(uint ip, uint c) - : sp_instr(ip), m_cursor(c) + sp_instr_cfetch(uint ip, sp_pcontext *ctx, uint c) + : sp_instr(ip, ctx), m_cursor(c) { m_varlist.empty(); } @@ -796,8 +789,8 @@ class sp_instr_error : public sp_instr public: - sp_instr_error(uint ip, int errcode) - : sp_instr(ip), m_errcode(errcode) + sp_instr_error(uint ip, sp_pcontext *ctx, int errcode) + : sp_instr(ip, ctx), m_errcode(errcode) {} virtual ~sp_instr_error() |