MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / negate_expression

Function negate_expression

sql/sql_parse.cc:2170–2191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2168*/
2169
2170Item *negate_expression(THD *thd, Item *expr)
2171{
2172 Item *negated;
2173 if (expr->type() == Item::FUNC_ITEM &&
2174 ((Item_func *) expr)->functype() == Item_func::NOT_FUNC)
2175 {
2176 /* it is NOT(NOT( ... )) */
2177 Item *arg= ((Item_func *) expr)->arguments()[0];
2178 enum_parsing_place place= thd->lex->current_select->parsing_place;
2179 if (arg->is_bool_func() || place == IN_WHERE || place == IN_HAVING)
2180 return arg;
2181 /*
2182 if it is not boolean function then we have to emulate value of
2183 not(not(a)), it will be a != 0
2184 */
2185 return new Item_func_ne(arg, new Item_int_0());
2186 }
2187
2188 if ((negated= expr->neg_transformer(thd)) != 0)
2189 return negated;
2190 return new Item_func_not(expr);
2191}
2192
2193/**
2194 Set the specified definer to the default value, which is the

Callers

nothing calls this directly

Calls 5

argumentsMethod · 0.80
typeMethod · 0.45
functypeMethod · 0.45
is_bool_funcMethod · 0.45
neg_transformerMethod · 0.45

Tested by

no test coverage detected