diff options
author | Alexey Botchkov <holyfoot@mysql.com> | 2009-04-29 07:59:10 +0500 |
---|---|---|
committer | Alexey Botchkov <holyfoot@mysql.com> | 2009-04-29 07:59:10 +0500 |
commit | 0e88c80580b244a960afd39408f4a459c555fb56 (patch) | |
tree | 4f09cda898568a4480e2d228438c4b9befbdd3b8 /sql/sql_yacc.yy | |
parent | 755d312e8456da751f432fd0e9c211dc4aeba131 (diff) | |
parent | ddc9a195508c35fc3f83ce58327b5fe7f09f4277 (diff) | |
download | mariadb-git-0e88c80580b244a960afd39408f4a459c555fb56.tar.gz |
merging
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r-- | sql/sql_yacc.yy | 169 |
1 files changed, 87 insertions, 82 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7752ccce73d..0b158ff7574 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -280,9 +280,7 @@ int case_stmt_action_expr(LEX *lex, Item* expr) parsing_ctx, case_expr_id, expr, lex); sp->add_cont_backpatch(i); - sp->add_instr(i); - - return 0; + return sp->add_instr(i); } /** @@ -293,7 +291,7 @@ int case_stmt_action_expr(LEX *lex, Item* expr) @param simple true for simple cases, false for searched cases */ -void case_stmt_action_when(LEX *lex, Item *when, bool simple) +int case_stmt_action_when(LEX *lex, Item *when, bool simple) { sp_head *sp= lex->sphead; sp_pcontext *ctx= lex->spcont; @@ -325,9 +323,10 @@ void case_stmt_action_when(LEX *lex, Item *when, bool simple) (jump_if_not from instruction 2 to 5, 5 to 8 ... in the example) */ - sp->push_backpatch(i, ctx->push_label((char *)"", 0)); - sp->add_cont_backpatch(i); - sp->add_instr(i); + return !test(i) || + sp->push_backpatch(i, ctx->push_label((char *)"", 0)) || + sp->add_cont_backpatch(i) || + sp->add_instr(i); } /** @@ -336,13 +335,14 @@ void case_stmt_action_when(LEX *lex, Item *when, bool simple) @param lex the parser lex context */ -void case_stmt_action_then(LEX *lex) +int case_stmt_action_then(LEX *lex) { sp_head *sp= lex->sphead; sp_pcontext *ctx= lex->spcont; uint ip= sp->instructions(); sp_instr_jump *i = new sp_instr_jump(ip, ctx); - sp->add_instr(i); + if (!test(i) || sp->add_instr(i)) + return 1; /* BACKPATCH: Resolving forward jump from @@ -358,7 +358,7 @@ void case_stmt_action_then(LEX *lex) (jump from instruction 4 to 12, 7 to 12 ... in the example) */ - sp->push_backpatch(i, ctx->last_label()); + return sp->push_backpatch(i, ctx->last_label()); } /** @@ -2322,10 +2322,9 @@ sp_decl: var_type, lex, (i == num_vars - 1)); - if (is == NULL) + if (is == NULL || + lex->sphead->add_instr(is)) MYSQL_YYABORT; - - lex->sphead->add_instr(is); } pctx->declare_var_boundary(0); @@ -2339,12 +2338,13 @@ sp_decl: LEX *lex= Lex; sp_pcontext *spc= lex->spcont; - if (spc->find_cond(&$2, TRUE)) - { - my_error(ER_SP_DUP_COND, MYF(0), $2.str); + if (spc->find_cond(&$2, TRUE)) + { + my_error(ER_SP_DUP_COND, MYF(0), $2.str); + MYSQL_YYABORT; + } + if(YYTHD->lex->spcont->push_cond(&$2, $5)) MYSQL_YYABORT; - } - YYTHD->lex->spcont->push_cond(&$2, $5); $$.vars= $$.hndlrs= $$.curs= 0; $$.conds= 1; } @@ -2358,11 +2358,11 @@ sp_decl: sp_pcontext *ctx= lex->spcont; sp_instr_hpush_jump *i= new sp_instr_hpush_jump(sp->instructions(), ctx, $2, - ctx->current_var_count()); - if (i == NULL) + ctx->current_var_count()); + if (i == NULL || + sp->add_instr(i) || + sp->push_backpatch(i, ctx->push_label((char *)"", 0))) MYSQL_YYABORT; - sp->add_instr(i); - sp->push_backpatch(i, ctx->push_label((char *)"", 0)); } sp_hcond_list sp_proc_stmt { @@ -2376,17 +2376,17 @@ sp_decl: { i= new sp_instr_hreturn(sp->instructions(), ctx, ctx->current_var_count()); - if (i == NULL) + if (i == NULL || + sp->add_instr(i)) MYSQL_YYABORT; - sp->add_instr(i); } else { /* EXIT or UNDO handler, just jump to the end of the block */ i= new sp_instr_hreturn(sp->instructions(), ctx, 0); - if (i == NULL) + if (i == NULL || + sp->add_instr(i) || + sp->push_backpatch(i, lex->spcont->last_label())) /* Block end */ MYSQL_YYABORT; - sp->add_instr(i); - sp->push_backpatch(i, lex->spcont->last_label()); /* Block end */ } lex->sphead->backpatch(hlab); @@ -2412,10 +2412,10 @@ sp_decl: } i= new sp_instr_cpush(sp->instructions(), ctx, $5, ctx->current_cursor_count()); - if (i == NULL) + if (i == NULL || + sp->add_instr(i) || + ctx->push_cursor(&$2)) MYSQL_YYABORT; - sp->add_instr(i); - ctx->push_cursor(&$2); $$.vars= $$.conds= $$.hndlrs= 0; $$.curs= 1; } @@ -2652,10 +2652,11 @@ sp_proc_stmt_statement: i->m_query.length= lip->get_ptr() - sp->m_tmp_query; else i->m_query.length= lip->get_tok_end() - sp->m_tmp_query; - i->m_query.str= strmake_root(thd->mem_root, - sp->m_tmp_query, - i->m_query.length); - sp->add_instr(i); + if (!(i->m_query.str= strmake_root(thd->mem_root, + sp->m_tmp_query, + i->m_query.length)) || + sp->add_instr(i)) + MYSQL_YYABORT; } sp->restore_lex(thd); } @@ -2680,9 +2681,9 @@ sp_proc_stmt_return: i= new sp_instr_freturn(sp->instructions(), lex->spcont, $3, sp->m_return_field_def.sql_type, lex); - if (i == NULL) + if (i == NULL || + sp->add_instr(i)) MYSQL_YYABORT; - sp->add_instr(i); sp->m_flags|= sp_head::HAS_RETURN; } sp->restore_lex(YYTHD); @@ -2779,22 +2780,22 @@ sp_proc_stmt_iterate: if (n) { sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n); - if (hpop == NULL) + if (hpop == NULL || + sp->add_instr(hpop)) MYSQL_YYABORT; - sp->add_instr(hpop); } n= ctx->diff_cursors(lab->ctx, FALSE); /* Inclusive the dest. */ if (n) { sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n); - if (cpop == NULL) + if (cpop == NULL || + sp->add_instr(cpop)) MYSQL_YYABORT; - sp->add_instr(cpop); } i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */ - if (i == NULL) + if (i == NULL || + sp->add_instr(i)) MYSQL_YYABORT; - sp->add_instr(i); } } ; @@ -2813,9 +2814,9 @@ sp_proc_stmt_open: MYSQL_YYABORT; } i= new sp_instr_copen(sp->instructions(), lex->spcont, offset); - if (i == NULL) + if (i == NULL || + sp->add_instr(i)) MYSQL_YYABORT; - sp->add_instr(i); } ; @@ -2833,9 +2834,9 @@ sp_proc_stmt_fetch: MYSQL_YYABORT; } i= new sp_instr_cfetch(sp->instructions(), lex->spcont, offset); - if (i == NULL) + if (i == NULL || + sp->add_instr(i)) MYSQL_YYABORT; - sp->add_instr(i); } sp_fetch_list {} @@ -2855,9 +2856,9 @@ sp_proc_stmt_close: MYSQL_YYABORT; } i= new sp_instr_cclose(sp->instructions(), lex->spcont, offset); - if (i == NULL) + if (i == NULL || + sp->add_instr(i)) MYSQL_YYABORT; - sp->add_instr(i); } ; @@ -2920,12 +2921,11 @@ sp_if: uint ip= sp->instructions(); sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, ctx, $2, lex); - if (i == NULL) + if (i == NULL || + sp->push_backpatch(i, ctx->push_label((char *)"", 0)) || + sp->add_cont_backpatch(i) || + sp->add_instr(i)) MYSQL_YYABORT; - - sp->push_backpatch(i, ctx->push_label((char *)"", 0)); - sp->add_cont_backpatch(i); - sp->add_instr(i); sp->restore_lex(YYTHD); } sp_proc_stmts1 @@ -2934,10 +2934,9 @@ sp_if: sp_pcontext *ctx= Lex->spcont; uint ip= sp->instructions(); sp_instr_jump *i = new sp_instr_jump(ip, ctx); - if (i == NULL) + if (i == NULL || + sp->add_instr(i)) MYSQL_YYABORT; - - sp->add_instr(i); sp->backpatch(ctx->pop_label()); sp->push_backpatch(i, ctx->push_label((char *)"", 0)); } @@ -3021,14 +3020,16 @@ simple_when_clause: /* Simple case: <caseval> = <whenval> */ LEX *lex= Lex; - case_stmt_action_when(lex, $3, true); + if (case_stmt_action_when(lex, $3, true)) + MYSQL_YYABORT; lex->sphead->restore_lex(YYTHD); /* For expr $3 */ } THEN_SYM sp_proc_stmts1 { LEX *lex= Lex; - case_stmt_action_then(lex); + if (case_stmt_action_then(lex)) + MYSQL_YYABORT; } ; @@ -3040,14 +3041,16 @@ searched_when_clause: expr { LEX *lex= Lex; - case_stmt_action_when(lex, $3, false); + if (case_stmt_action_when(lex, $3, false)) + MYSQL_YYABORT; lex->sphead->restore_lex(YYTHD); /* For expr $3 */ } THEN_SYM sp_proc_stmts1 { LEX *lex= Lex; - case_stmt_action_then(lex); + if (case_stmt_action_then(lex)) + MYSQL_YYABORT; } ; @@ -3059,9 +3062,9 @@ else_clause_opt: uint ip= sp->instructions(); sp_instr_error *i= new sp_instr_error(ip, lex->spcont, ER_SP_CASE_NOT_FOUND); - if (i == NULL) + if (i == NULL || + sp->add_instr(i)) MYSQL_YYABORT; - sp->add_instr(i); } | ELSE sp_proc_stmts1 ; @@ -3175,16 +3178,16 @@ sp_block_content: if ($3.hndlrs) { i= new sp_instr_hpop(sp->instructions(), ctx, $3.hndlrs); - if (i == NULL) + if (i == NULL || + sp->add_instr(i)) MYSQL_YYABORT; - sp->add_instr(i); } if ($3.curs) { i= new sp_instr_cpop(sp->instructions(), ctx, $3.curs); - if (i == NULL) + if (i == NULL || + sp->add_instr(i)) MYSQL_YYABORT; - sp->add_instr(i); } lex->spcont= ctx->pop_context(); } @@ -3198,10 +3201,10 @@ sp_unlabeled_control: uint ip= lex->sphead->instructions(); sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */ sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip); - if (i == NULL) + if (i == NULL || + lex->sphead->add_instr(i)) MYSQL_YYABORT; - lex->sphead->add_instr(i); - } + } | WHILE_SYM { Lex->sphead->reset_lex(YYTHD); } expr DO_SYM @@ -3211,12 +3214,12 @@ sp_unlabeled_control: uint ip= sp->instructions(); sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont, $3, lex); - if (i == NULL) + if (i == NULL || + /* Jumping forward */ + sp->push_backpatch(i, lex->spcont->last_label()) || + sp->new_cont_backpatch(i) || + sp->add_instr(i)) MYSQL_YYABORT; - /* Jumping forward */ - sp->push_backpatch(i, lex->spcont->last_label()); - sp->new_cont_backpatch(i); - sp->add_instr(i); sp->restore_lex(YYTHD); } sp_proc_stmts1 END WHILE_SYM @@ -3225,9 +3228,9 @@ sp_unlabeled_control: uint ip= lex->sphead->instructions(); sp_label_t *lab= lex->spcont->last_label(); /* Jumping back */ sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip); - if (i == NULL) + if (i == NULL || + lex->sphead->add_instr(i)) MYSQL_YYABORT; - lex->sphead->add_instr(i); lex->sphead->do_cont_backpatch(); } | REPEAT_SYM sp_proc_stmts1 UNTIL_SYM @@ -3240,9 +3243,9 @@ sp_unlabeled_control: sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont, $5, lab->ip, lex); - if (i == NULL) + if (i == NULL || + lex->sphead->add_instr(i)) MYSQL_YYABORT; - lex->sphead->add_instr(i); lex->sphead->restore_lex(YYTHD); /* We can shortcut the cont_backpatch here */ i->m_cont_dest= ip+1; @@ -11751,7 +11754,8 @@ option_type_value: qbuff.length); qbuff.length+= 4; i->m_query= qbuff; - sp->add_instr(i); + if (sp->add_instr(i)) + MYSQL_YYABORT; } lex->sphead->restore_lex(thd); } @@ -11843,7 +11847,8 @@ sys_option_value: (uchar **) &trg_fld-> next_trg_field); - lex->sphead->add_instr(sp_fld); + if (lex->sphead->add_instr(sp_fld)) + MYSQL_YYABORT; } else if ($2.var) { /* System variable */ @@ -11882,9 +11887,9 @@ sys_option_value: } sp_set= new sp_instr_set(lex->sphead->instructions(), ctx, spv->offset, it, spv->type, lex, TRUE); - if (sp_set == NULL) + if (sp_set == NULL || + lex->sphead->add_instr(sp_set)) MYSQL_YYABORT; - lex->sphead->add_instr(sp_set); } } | option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types |