Commit f694df6a authored by Oleksandr Byelkin's avatar Oleksandr Byelkin Committed by Sergei Golubchik

Fix of NULLIF print statement.

parent 29031fe3
......@@ -2826,7 +2826,9 @@ void Item_func_nullif::print(String *str, enum_query_type query_type)
Therefore, after equal field propagation args[0] and args[2] can point
to different items.
*/
if ((query_type & QT_ITEM_ORIGINAL_FUNC_NULLIF) || args[0] == args[2])
if ((query_type & QT_ITEM_ORIGINAL_FUNC_NULLIF) ||
(arg_count == 2) ||
(args[0] == args[2]))
{
/*
If QT_ITEM_ORIGINAL_FUNC_NULLIF is requested,
......@@ -2844,10 +2846,14 @@ void Item_func_nullif::print(String *str, enum_query_type query_type)
- one "a" for comparison
- another "a" for the returned value!
*/
DBUG_ASSERT(args[0] == args[2] || current_thd->lex->context_analysis_only);
DBUG_ASSERT(arg_count == 2 ||
args[0] == args[2] || current_thd->lex->context_analysis_only);
str->append(func_name());
str->append('(');
args[2]->print(str, query_type);
if (arg_count == 2)
args[0]->print(str, query_type);
else
args[2]->print(str, query_type);
str->append(',');
args[1]->print(str, query_type);
str->append(')');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment