From 7e5247aadeeaddc08f0d2c4405095e3c19e3a0a4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Aug 2004 20:37:31 +0500 Subject: fixed Bug #4358 Problem with HAVING clause that uses alias from the select list and TEXT field make setup_copy_fields to insert Item_copy_string for blobs in the beginning of the copy_funcs (push_back instead of push_front) the thing is that Item_copy_string::copy for function can call Item_copy_string::val_int for blob via Item_ref. But if Item_copy_string::copy for blob isn't called before, it's value will be wrong. So all the Item_copy_string::copy for blobs should be called before Item_copy_string::copy for functions. mysql-test/r/having.result: added test case for Bug #4358 Problem with HAVING clause that uses alias from the select list and TEXT field mysql-test/t/having.test: added test case for Bug #4358 Problem with HAVING clause that uses alias from the select list and TEXT field sql/sql_select.cc: make setup_copy_fields to insert Item_copy_string for blobs in the beginning of the copy_funcs (push_back instead of push_front) the thing is that Item_copy_string::copy for function can call Item_copy_string::val_int for blob via Item_ref. But if Item_copy_string::copy for blob isn't called before, it's value will be wrong. So all the Item_copy_string::copy for blobs should be called before Item_copy_string::copy for functions. fixed Bug #4358 Problem with HAVING clause that uses alias from the select list and TEXT field --- sql/sql_select.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 096b73c482f..8c30a1684b4 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7158,7 +7158,16 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, List &fields) if (!(pos=new Item_copy_string(pos))) goto err; VOID(li.replace(pos)); - if (param->copy_funcs.push_back(pos)) + /* + Item_copy_string::copy for function can call + Item_copy_string::val_int for blob via Item_ref. + But if Item_copy_string::copy for blob isn't called before, + it's value will be wrong + so let's insert Item_copy_string for blobs in the beginning of + copy_funcs + (to see full test case look at having.test, BUG #4358) + */ + if (param->copy_funcs.push_front(pos)) goto err; continue; } -- cgit v1.2.1