summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
diff options
context:
space:
mode:
authorunknown <kroki/tomash@moonlight.intranet>2006-11-22 13:58:00 +0300
committerunknown <kroki/tomash@moonlight.intranet>2006-11-22 13:58:00 +0300
commit18770d2fe4956e9be33a73cfc790129c19c6305a (patch)
tree39c6df66fba0d7fb2e327bab5949bc349cb8e3a1 /sql/item_sum.cc
parent2886e07d3fa72d8aac8091c581adccb7a666a411 (diff)
downloadmariadb-git-18770d2fe4956e9be33a73cfc790129c19c6305a.tar.gz
BUG#21635: MYSQL_FIELD struct's member strings seem to misbehave for
expression cols. The problem was that MYSQL_FIELD::org_name was set for MIN() and MAX() functions (COUNT() is also mentioned in the bug report but was already fixed). After this patch for expressions MYSQL_FIELD::name is set to either expression itself or its alias, and other data origin fields of MYSQL_FILED (db, org_table, table, org_name) are empty strings. sql/item_sum.cc: For expressions only col_name should be non-empty string. tests/mysql_client_test.c: Add test case for bug#21635: MYSQL_FIELD struct's member strings seem to misbehave for expression cols.
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r--sql/item_sum.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 5fd65fecbfc..87c768e9383 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -71,9 +71,13 @@ void Item_sum::make_field(Send_field *tmp_field)
if (args[0]->type() == Item::FIELD_ITEM && keep_field_type())
{
((Item_field*) args[0])->field->make_field(tmp_field);
- tmp_field->db_name=(char*)"";
- tmp_field->org_table_name=tmp_field->table_name=(char*)"";
- tmp_field->org_col_name=tmp_field->col_name=name;
+ /* For expressions only col_name should be non-empty string. */
+ char *empty_string= (char*)"";
+ tmp_field->db_name= empty_string;
+ tmp_field->org_table_name= empty_string;
+ tmp_field->table_name= empty_string;
+ tmp_field->org_col_name= empty_string;
+ tmp_field->col_name= name;
if (maybe_null)
tmp_field->flags&= ~NOT_NULL_FLAG;
}