summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorSergey Glukhov <Sergey.Glukhov@sun.com>2010-02-26 17:40:01 +0400
committerSergey Glukhov <Sergey.Glukhov@sun.com>2010-02-26 17:40:01 +0400
commitca6691533a7e2a454bbb614583a0058bf7acd2d2 (patch)
treef0ae736e5674de5566766cbec76784fcfad888f9 /sql/item.cc
parentfe229e33f7fdde3c5afe1c78522626562fcb4941 (diff)
downloadmariadb-git-ca6691533a7e2a454bbb614583a0058bf7acd2d2.tar.gz
Bug#47669 Query showed by EXPLAIN EXTENDED gives different result from original query
Item_field::print method does not take into account fields whose values may be null. The fix is to print 'NULL' if field value is null. mysql-test/r/explain.result: test case mysql-test/r/func_str.result: result fix mysql-test/r/having.result: result fix mysql-test/r/select.result: result fix mysql-test/r/subselect.result: result fix mysql-test/r/union.result: result fix mysql-test/t/explain.test: test case sql/item.cc: print 'NULL' if field value is null.
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 934e897f923..04496338b8f 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -5690,9 +5690,14 @@ void Item_field::print(String *str, enum_query_type query_type)
char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff),str->charset());
field->val_str(&tmp);
- str->append('\'');
- str->append(tmp);
- str->append('\'');
+ if (field->is_null())
+ str->append("NULL");
+ else
+ {
+ str->append('\'');
+ str->append(tmp);
+ str->append('\'');
+ }
return;
}
Item_ident::print(str, query_type);