[MDEV-15112] Inconsistent evaluation of spvariable=0 in strict mode Created: 2018-01-29 Updated: 2018-01-29 Resolved: 2018-01-29 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Stored routines |
| Affects Version/s: | 10.2 |
| Fix Version/s: | 10.3.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
I create a table with a TIMESTAMP column and insert one record:
Now I create some very similar stored functions:
And finally run this script:
It returns the following output:
Notice:
f1 seems to be wrong. It should also fail with the same error. The difference happens because in f1 the condition is evaluated at the optimization phase in Item_cond::fix_fields() called from sp_prepare_func_item() from sp_eval_expr(), before this code block:
while in f2 and f3 it's evaluated in expr_item->save_in_field(), after the above code block. The sp_prepare_func_item() call should be moved after this code block, so both sp_prepare_func_item() and expr_item->save_in_field() are called with the same THD flags. |