diff options
author | unknown <bell@sanja.is.com.ua> | 2004-02-08 20:57:14 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-02-08 20:57:14 +0200 |
commit | 89625e60215faabdb6007d102e47e2d9bef74349 (patch) | |
tree | 75c08bf3f555da5ff27b244e7fc44623412cf38f | |
parent | 541cb675c87ae1efa1e1769abaed03e9535eaf27 (diff) | |
download | mariadb-git-89625e60215faabdb6007d102e47e2d9bef74349.tar.gz |
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
-rw-r--r-- | sql/item_sum.cc | 18 | ||||
-rw-r--r-- | tests/client_test.c | 33 |
2 files changed, 48 insertions, 3 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 87e8b124d4b..d9233d2157b 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1093,12 +1093,17 @@ void Item_sum_count_distinct::cleanup() if (!original) { if (table) + { free_tmp_table(current_thd, table); + table= 0; + } delete tmp_table_param; + tmp_table_param= 0; if (use_tree) + { delete_tree(tree); - table= 0; - use_tree= 0; + use_tree= 0; + } } DBUG_VOID_RETURN; } @@ -1677,10 +1682,17 @@ void Item_func_group_concat::cleanup() { THD *thd= current_thd; if (table) + { free_tmp_table(thd, table); + table= 0; + } delete tmp_table_param; + tmp_table_param= 0; if (tree_mode) - delete_tree(tree); + { + delete_tree(tree); + tree_mode= 0; + } } DBUG_VOID_RETURN; } diff --git a/tests/client_test.c b/tests/client_test.c index fbc9322b6b7..604514594dc 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -8117,6 +8117,7 @@ static void test_subqueries() myquery(rc); stmt= mysql_prepare(mysql, query, strlen(query)); + mystmt_init(stmt); for (i= 0; i < 3; i++) { rc= mysql_execute(stmt); @@ -8142,6 +8143,37 @@ static void test_bad_union() 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 @@ -8390,6 +8422,7 @@ int main(int argc, char **argv) prepared queries */ test_subqueries(); /* repeatable subqueries */ test_bad_union(); /* correct setup of UNION */ + test_distinct(); /* distinct aggregate functions */ end_time= time((time_t *)0); |