| 8974 | */ |
| 8975 | |
| 8976 | Item *normalize_cond(THD *thd, Item *cond) |
| 8977 | { |
| 8978 | if (cond) |
| 8979 | { |
| 8980 | Item::Type type= cond->type(); |
| 8981 | if (type == Item::FIELD_ITEM || type == Item::REF_ITEM) |
| 8982 | { |
| 8983 | item_base_t is_cond_flag= cond->base_flags & |
| 8984 | (item_base_t::IS_COND | item_base_t::AT_TOP_LEVEL); |
| 8985 | cond->base_flags&= ~item_base_t::IS_COND; |
| 8986 | cond= new (thd->mem_root) Item_func_istrue(thd, cond); |
| 8987 | if (cond) |
| 8988 | cond->base_flags|= is_cond_flag; |
| 8989 | } |
| 8990 | else |
| 8991 | { |
| 8992 | if (type == Item::FUNC_ITEM) |
| 8993 | { |
| 8994 | Item_func *func_item= (Item_func *)cond; |
| 8995 | if (func_item->functype() == Item_func::NOT_FUNC) |
| 8996 | { |
| 8997 | Item *arg= func_item->arguments()[0]; |
| 8998 | if (arg->type() == Item::FIELD_ITEM || |
| 8999 | arg->type() == Item::REF_ITEM) |
| 9000 | cond= new (thd->mem_root) Item_func_isfalse(thd, arg); |
| 9001 | } |
| 9002 | } |
| 9003 | } |
| 9004 | } |
| 9005 | return cond; |
| 9006 | } |
| 9007 | |
| 9008 | |
| 9009 | /** |
no test coverage detected