mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fix of LP BUG#777809
There are 2 volatile condition constructions AND/OR constructions and fields(references) when first good supported to be top elements of conditions because it is normal practice (see copy_andor_structure for example) fields without any expression in the condition is really rare and mostly useless case however it could lead to problems when optimiser changes/moves them unaware of other variables referring to them. An easy solution of this problem is just to replace single field in a condition with equivalent expression well supported by the server (<field> -> <field> != 0). mysql-test/r/view.result: New test added. mysql-test/t/view.test: New test added. sql/sql_parse.cc: <field> -> <field> != 0 sql/sql_yacc.yy: <field> -> <field> != 0
This commit is contained in:
@ -6890,6 +6890,28 @@ push_new_name_resolution_context(THD *thd,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Fix condition which contains only field (f turns to f <> 0 )
|
||||
|
||||
@param cond The condition to fix
|
||||
|
||||
@return fixed condition
|
||||
*/
|
||||
|
||||
Item *normalize_cond(Item *cond)
|
||||
{
|
||||
if (cond)
|
||||
{
|
||||
Item::Type type= cond->type();
|
||||
if (type == Item::FIELD_ITEM || type == Item::REF_ITEM)
|
||||
{
|
||||
cond= new Item_func_ne(cond, new Item_int(0));
|
||||
}
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Add an ON condition to the second operand of a JOIN ... ON.
|
||||
|
||||
@ -6908,6 +6930,7 @@ void add_join_on(TABLE_LIST *b, Item *expr)
|
||||
{
|
||||
if (expr)
|
||||
{
|
||||
expr= normalize_cond(expr);
|
||||
if (!b->on_expr)
|
||||
b->on_expr= expr;
|
||||
else
|
||||
|
Reference in New Issue
Block a user