summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Bruehe <joerg@mysql.com>2009-07-16 13:00:31 +0200
committerJoerg Bruehe <joerg@mysql.com>2009-07-16 13:00:31 +0200
commit692fb3702b9866ce3f95ccbf219d37c40288e8b4 (patch)
tree1395da41935e582f3295cb2438e091b5aeb27667
parent9313d74e913cf7a3ce4f019d323c4689842af074 (diff)
parente2099d3dad679b805c0ea85e09ab562c19827d90 (diff)
downloadmariadb-git-692fb3702b9866ce3f95ccbf219d37c40288e8b4.tar.gz
Merge main 5.0 into 5.0-build
-rwxr-xr-xBUILD/check-cpu9
-rw-r--r--mysql-test/r/bug46080.result14
-rw-r--r--mysql-test/t/bug46080-master.opt1
-rw-r--r--mysql-test/t/bug46080.test22
-rw-r--r--sql/item_sum.cc5
5 files changed, 49 insertions, 2 deletions
diff --git a/BUILD/check-cpu b/BUILD/check-cpu
index 4974d3f4ecc..e7cae1c1da8 100755
--- a/BUILD/check-cpu
+++ b/BUILD/check-cpu
@@ -44,8 +44,13 @@ check_cpu () {
model_name=`sysctl -n hw.model`
;;
Darwin)
- cpu_family=`uname -p`
- model_name=`machine`
+ cpu_family=`sysctl -n machdep.cpu.vendor`
+ model_name=`sysctl -n machdep.cpu.brand_string`
+ if [ -z "$cpu_family" -o -z "$model_name" ]
+ then
+ cpu_family=`uname -p`
+ model_name=`machine`
+ fi
;;
*)
cpu_family=`uname -m`;
diff --git a/mysql-test/r/bug46080.result b/mysql-test/r/bug46080.result
new file mode 100644
index 00000000000..18c7c22829a
--- /dev/null
+++ b/mysql-test/r/bug46080.result
@@ -0,0 +1,14 @@
+#
+# Bug #46080: group_concat(... order by) crashes server when
+# sort_buffer_size cannot allocate
+#
+CREATE TABLE t1(a CHAR(255));
+INSERT INTO t1 VALUES ('a');
+SET @@SESSION.sort_buffer_size=5*16*1000000;
+SET @@SESSION.max_heap_table_size=5*1000000;
+# Must not crash.
+SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a;
+DROP TABLE t1;
+SET @@SESSION.sort_buffer_size=default;
+SET @@SESSION.max_heap_table_size=default;
+End of 5.0 tests
diff --git a/mysql-test/t/bug46080-master.opt b/mysql-test/t/bug46080-master.opt
new file mode 100644
index 00000000000..f59740afe60
--- /dev/null
+++ b/mysql-test/t/bug46080-master.opt
@@ -0,0 +1 @@
+--skip-grant-tables --skip-name-resolve --safemalloc-mem-limit=4000000
diff --git a/mysql-test/t/bug46080.test b/mysql-test/t/bug46080.test
new file mode 100644
index 00000000000..7e56e3ce421
--- /dev/null
+++ b/mysql-test/t/bug46080.test
@@ -0,0 +1,22 @@
+--echo #
+--echo # Bug #46080: group_concat(... order by) crashes server when
+--echo # sort_buffer_size cannot allocate
+--echo #
+
+CREATE TABLE t1(a CHAR(255));
+INSERT INTO t1 VALUES ('a');
+
+SET @@SESSION.sort_buffer_size=5*16*1000000;
+SET @@SESSION.max_heap_table_size=5*1000000;
+
+--echo # Must not crash.
+--disable_result_log
+--error 0,5
+SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a;
+--enable_result_log
+
+DROP TABLE t1;
+SET @@SESSION.sort_buffer_size=default;
+SET @@SESSION.max_heap_table_size=default;
+
+--echo End of 5.0 tests
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index a381361e8a2..dde8fe29e5a 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -3291,8 +3291,13 @@ bool Item_func_group_concat::add()
TREE_ELEMENT *el= 0; // Only for safety
if (row_eligible && tree)
+ {
el= tree_insert(tree, table->record[0] + table->s->null_bytes, 0,
tree->custom_arg);
+ /* check if there was enough memory to insert the row */
+ if (!el)
+ return 1;
+ }
/*
If the row is not a duplicate (el->count == 1)
we can dump the row here in case of GROUP_CONCAT(DISTINCT...)