diff options
author | Evgeny Potemkin <epotemkin@mysql.com> | 2008-10-27 12:26:32 +0300 |
---|---|---|
committer | Evgeny Potemkin <epotemkin@mysql.com> | 2008-10-27 12:26:32 +0300 |
commit | e27e56078388c2005b46073b5b295edcba79f359 (patch) | |
tree | 82b205973c13550077fd57e3d36300829b9a4d9c /sql/item_cmpfunc.cc | |
parent | 9846ab0a70241945f59e1f474137546dcbd66ed8 (diff) | |
download | mariadb-git-e27e56078388c2005b46073b5b295edcba79f359.tar.gz |
Bug#37870: Usage of uninitialized value caused failed assertion.
The convert_constant_item function converts a constant to integer using
field for condition like 'field = a_constant'. When the convert_constant_item
is called for a subquery the outer select is already being executed, so
convert_constant_item saves field's value to prevent its corruption.
For EXPLAIN field's value isn't initialized thus when convert_constant_item
tries to restore saved value it fails assertion.
Now the convert_constant_item doesn't save/restore field's value
for EXPLAIN.
mysql-test/r/explain.result:
Added a test case for the bug#37870.
mysql-test/t/explain.test:
Added a test case for the bug#37870.
sql/item_cmpfunc.cc:
Bug#37870: Usage of uninitialized value caused failed assertion.
Now the convert_constant_item doesn't save/restore field's value
for EXPLAIN.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index bd6065c9403..0c95336251b 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -415,8 +415,9 @@ static bool convert_constant_item(THD *thd, Item_field *field_item, /* Store the value of the field if it references an outer field because the call to save_in_field below overrides that value. + Don't store it for EXPLAIN since it's not initialized. */ - if (field_item->depended_from) + if (field_item->depended_from && !thd->lex->describe) orig_field_val= field->val_int(); if (!(*item)->is_null() && !(*item)->save_in_field(field, 1)) { @@ -427,7 +428,7 @@ static bool convert_constant_item(THD *thd, Item_field *field_item, result= 1; // Item was replaced } /* Restore the original field value. */ - if (field_item->depended_from) + if (field_item->depended_from && !thd->lex->describe) { result= field->store(orig_field_val, TRUE); /* orig_field_val must be a valid value that can be restored back. */ |