diff options
author | Alexander Nozdrin <alik@sun.com> | 2009-11-05 12:20:41 +0300 |
---|---|---|
committer | Alexander Nozdrin <alik@sun.com> | 2009-11-05 12:20:41 +0300 |
commit | c063bd171e4eb4067e6684b77277e170b7a668bc (patch) | |
tree | 8b36c387d70977c948b7d1412fcd7d9b940852af /sql/sp_head.cc | |
parent | b40aed07bffb6fa37fc03ccd063b5a189e8ddb71 (diff) | |
parent | 754dee8e51950365956efb793af34a769cbd4792 (diff) | |
download | mariadb-git-c063bd171e4eb4067e6684b77277e170b7a668bc.tar.gz |
Manual merge from mysql-5.1.
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r-- | sql/sp_head.cc | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 7c7a846f53e..fe04ea93f60 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -335,16 +335,18 @@ bool sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr) { Item *expr_item; + enum_check_fields save_count_cuted_fields= thd->count_cuted_fields; + bool save_abort_on_warning= thd->abort_on_warning; + bool save_stmt_modified_non_trans_table= + thd->transaction.stmt.modified_non_trans_table; DBUG_ENTER("sp_eval_expr"); if (!*expr_item_ptr) - DBUG_RETURN(TRUE); + goto error; if (!(expr_item= sp_prepare_func_item(thd, expr_item_ptr))) - DBUG_RETURN(TRUE); - - bool err_status= FALSE; + goto error; /* Set THD flags to emit warnings/errors in case of overflow/type errors @@ -353,10 +355,6 @@ sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr) Save original values and restore them after save. */ - enum_check_fields save_count_cuted_fields= thd->count_cuted_fields; - bool save_abort_on_warning= thd->abort_on_warning; - bool save_stmt_modified_non_trans_table= thd->transaction.stmt.modified_non_trans_table; - thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; thd->abort_on_warning= thd->variables.sql_mode & @@ -371,13 +369,18 @@ sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr) thd->abort_on_warning= save_abort_on_warning; thd->transaction.stmt.modified_non_trans_table= save_stmt_modified_non_trans_table; - if (thd->is_error()) - { - /* Return error status if something went wrong. */ - err_status= TRUE; - } + if (!thd->is_error()) + DBUG_RETURN(FALSE); - DBUG_RETURN(err_status); +error: + /* + In case of error during evaluation, leave the result field set to NULL. + Sic: we can't do it in the beginning of the function because the + result field might be needed for its own re-evaluation, e.g. case of + set x = x + 1; + */ + result_field->set_null(); + DBUG_RETURN (TRUE); } |