summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <igor@rurik.mysql.com>2005-06-28 03:18:37 -0700
committerunknown <igor@rurik.mysql.com>2005-06-28 03:18:37 -0700
commit67abd491a1d5c631b0e72ea89941fafd9ac2fa34 (patch)
treec1899479c73a735ab5131308b58c7bcdff55f57e
parent3f499c32d44005906ad08c34011fbe96c598230a (diff)
downloadmariadb-git-67abd491a1d5c631b0e72ea89941fafd9ac2fa34.tar.gz
group_by.result, group_by.test:
Added a test case for bug #11414. sql_select.cc: Fixed bug #11414: crash on Windows with some simple GROUP BY queries. It happened to an allocation of an array containing 0 Copy_field elements in setup_copy_fields. The bug had been already fixed in 5.0. sql/sql_select.cc: Fixed bug #11414: crash on Windows with some simple GROUP BY queries. It happened to an allocation of an array containing 0 Copy_field elements in setup_copy_fields. The bug had been already fixed in 5.0. mysql-test/t/group_by.test: Added a test case for bug #11414. mysql-test/r/group_by.result: Added a test case for bug #11414.
-rw-r--r--mysql-test/r/group_by.result6
-rw-r--r--mysql-test/t/group_by.test12
-rw-r--r--sql/sql_select.cc5
3 files changed, 21 insertions, 2 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 7f78b8bda9b..295663fe1d3 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -751,3 +751,9 @@ COUNT(DISTINCT(t1.id)) err_comment
1 NULL
1 a problem
DROP TABLE t1, t2;
+CREATE TABLE t1 (n int);
+INSERT INTO t1 VALUES (1);
+SELECT n+1 AS n FROM t1 GROUP BY n;
+n
+2
+DROP TABLE t1;
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 694aa8d7411..23d51b0f297 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -580,3 +580,15 @@ SELECT COUNT(DISTINCT(t1.id)), LEFT(err_comment, 256) AS err_comment
FROM t1 LEFT JOIN t2 ON t1.id=t2.id GROUP BY err_comment;
DROP TABLE t1, t2;
+
+#
+# Test for bug #11414: crash on Windows for a simple GROUP BY query
+#
+
+CREATE TABLE t1 (n int);
+INSERT INTO t1 VALUES (1);
+
+SELECT n+1 AS n FROM t1 GROUP BY n;
+
+DROP TABLE t1;
+
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 2f165565ce1..f2db5adfdda 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8727,7 +8727,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
{
Item *pos;
List_iterator_fast<Item> li(all_fields);
- Copy_field *copy;
+ Copy_field *copy= NULL;
res_selected_fields.empty();
res_all_fields.empty();
List_iterator_fast<Item> itr(res_all_fields);
@@ -8735,7 +8735,8 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
uint i, border= all_fields.elements - elements;
DBUG_ENTER("setup_copy_fields");
- if (!(copy=param->copy_field= new Copy_field[param->field_count]))
+ if (param->field_count &&
+ !(copy=param->copy_field= new Copy_field[param->field_count]))
goto err2;
param->copy_funcs.empty();