Commit 89625e60 authored by unknown's avatar unknown

fixed cleupup() for distinct aggregate functions (BUG#2663)


sql/item_sum.cc:
  fixed cleupup() for distinct aggregate functions
tests/client_test.c:
  fixed subqueries test
  test of distinct aggregate functions in PS
parent 541cb675
...@@ -1093,13 +1093,18 @@ void Item_sum_count_distinct::cleanup() ...@@ -1093,13 +1093,18 @@ void Item_sum_count_distinct::cleanup()
if (!original) if (!original)
{ {
if (table) if (table)
{
free_tmp_table(current_thd, table); free_tmp_table(current_thd, table);
table= 0;
}
delete tmp_table_param; delete tmp_table_param;
tmp_table_param= 0;
if (use_tree) if (use_tree)
{
delete_tree(tree); delete_tree(tree);
table= 0;
use_tree= 0; use_tree= 0;
} }
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1677,10 +1682,17 @@ void Item_func_group_concat::cleanup() ...@@ -1677,10 +1682,17 @@ void Item_func_group_concat::cleanup()
{ {
THD *thd= current_thd; THD *thd= current_thd;
if (table) if (table)
{
free_tmp_table(thd, table); free_tmp_table(thd, table);
table= 0;
}
delete tmp_table_param; delete tmp_table_param;
tmp_table_param= 0;
if (tree_mode) if (tree_mode)
{
delete_tree(tree); delete_tree(tree);
tree_mode= 0;
}
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -8117,6 +8117,7 @@ static void test_subqueries() ...@@ -8117,6 +8117,7 @@ static void test_subqueries()
myquery(rc); myquery(rc);
stmt= mysql_prepare(mysql, query, strlen(query)); stmt= mysql_prepare(mysql, query, strlen(query));
mystmt_init(stmt);
for (i= 0; i < 3; i++) for (i= 0; i < 3; i++)
{ {
rc= mysql_execute(stmt); rc= mysql_execute(stmt);
...@@ -8142,6 +8143,37 @@ static void test_bad_union() ...@@ -8142,6 +8143,37 @@ static void test_bad_union()
myerror(NULL); myerror(NULL);
} }
static void test_distinct()
{
MYSQL_STMT *stmt;
int rc, i;
const char *query= "SELECT count(distinct b), group_concat(a) FROM t1";
myheader("test_subquery");
rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1");
myquery(rc);
rc= mysql_query(mysql,"CREATE TABLE t1 (a int , b int);");
myquery(rc);
rc= mysql_query(mysql,
"insert into t1 values (1,1), (2, 2), (3,3), (4,4), (5,5);");
myquery(rc);
for (i= 0; i < 3; i++)
{
stmt= mysql_prepare(mysql, query, strlen(query));
mystmt_init(stmt);
rc= mysql_execute(stmt);
mystmt(stmt, rc);
assert(1 == my_process_stmt_result(stmt));
mysql_stmt_close(stmt);
}
rc= mysql_query(mysql, "DROP TABLE t1");
myquery(rc);
}
/* /*
Read and parse arguments and MySQL options from my.cnf Read and parse arguments and MySQL options from my.cnf
...@@ -8390,6 +8422,7 @@ int main(int argc, char **argv) ...@@ -8390,6 +8422,7 @@ int main(int argc, char **argv)
prepared queries */ prepared queries */
test_subqueries(); /* repeatable subqueries */ test_subqueries(); /* repeatable subqueries */
test_bad_union(); /* correct setup of UNION */ test_bad_union(); /* correct setup of UNION */
test_distinct(); /* distinct aggregate functions */
end_time= time((time_t *)0); end_time= time((time_t *)0);
......
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