Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1829 05/03/19 23:12:50 igor@stripped +3 -0
func_group.test, func_group.result:
Added a test case for bug #9210.
sql_select.cc:
Fixed bug #9210.
The function calc_group_buffer did not cover the case
when the GROUP BY expression was decimal.
Slightly optimized the other code.
mysql-test/r/func_group.result
1.42 05/03/19 23:09:20 igor@stripped +59 -0
mysql-test/t/func_group.test
1.40 05/03/19 23:08:50 igor@stripped +23 -0
Added a test case for bug #9210.
sql/sql_select.cc
1.301 05/03/19 23:03:35 igor@stripped +29 -19
Fixed bug #9210.
The function calc_group_buffer did not cover the case
when the GROUP by expression was decimal.
Slightly optimized the other code.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: igor
# Host: rurik.mysql.com
# Root: /home/igor/dev/mysql-5.0-0
--- 1.300/sql/sql_select.cc Thu Mar 17 21:46:14 2005
+++ 1.301/sql/sql_select.cc Sat Mar 19 23:03:35 2005
@@ -11891,7 +11891,8 @@
join->group= 1;
for (; group ; group=group->next)
{
- Field *field=(*group->item)->get_tmp_table_field();
+ Item *group_item= *group->item;
+ Field *field= group_item->get_tmp_table_field();
if (field)
{
if (field->type() == FIELD_TYPE_BLOB)
@@ -11901,27 +11902,36 @@
else
key_length+= field->pack_length();
}
- else if ((*group->item)->result_type() == REAL_RESULT)
- key_length+=sizeof(double);
- else if ((*group->item)->result_type() == INT_RESULT)
- key_length+=sizeof(longlong);
- else if ((*group->item)->result_type() == STRING_RESULT)
- {
- /*
- Group strings are taken as varstrings and require an length field.
- A field is not yet created by create_tmp_field()
- and the sizes should match up.
- */
- key_length+= (*group->item)->max_length + HA_KEY_BLOB_LENGTH;
- }
else
- {
- /* This case should never be choosen */
- DBUG_ASSERT(0);
- join->thd->fatal_error();
+ {
+ switch (group_item->result_type()) {
+ case REAL_RESULT:
+ key_length+= sizeof(double);
+ break;
+ case INT_RESULT:
+ key_length+= sizeof(longlong);
+ break;
+ case DECIMAL_RESULT:
+ key_length+= my_decimal_get_binary_size(group_item->max_length -
+ (group_item->decimals ? 1 : 0),
+ group_item->decimals);
+ break;
+ case STRING_RESULT:
+ /*
+ Group strings are taken as varstrings and require an length field.
+ A field is not yet created by create_tmp_field()
+ and the sizes should match up.
+ */
+ key_length+= group_item->max_length + HA_KEY_BLOB_LENGTH;
+ break;
+ default:
+ /* This case should never be choosen */
+ DBUG_ASSERT(0);
+ join->thd->fatal_error();
+ }
}
parts++;
- if ((*group->item)->maybe_null)
+ if (group_item->maybe_null)
null_parts++;
}
join->tmp_table_param.group_length=key_length+null_parts;
--- 1.41/mysql-test/r/func_group.result Mon Mar 14 16:46:13 2005
+++ 1.42/mysql-test/r/func_group.result Sat Mar 19 23:09:20 2005
@@ -888,3 +888,62 @@
COUNT(DISTINCT a)
2
DROP TABLE t1;
+CREATE TABLE t1 (a int, b int, c int);
+INSERT INTO t1 (a, b, c) VALUES
+(1,1,1), (1,1,2), (1,1,3),
+(1,2,1), (1,2,2), (1,2,3),
+(1,3,1), (1,3,2), (1,3,3),
+(2,1,1), (2,1,2), (2,1,3),
+(2,2,1), (2,2,2), (2,2,3),
+(2,3,1), (2,3,2), (2,3,3),
+(3,1,1), (3,1,2), (3,1,3),
+(3,2,1), (3,2,2), (3,2,3),
+(3,3,1), (3,3,2), (3,3,3);
+SELECT b/c as v, a FROM t1 ORDER BY v;
+v a
+0.33333 3
+0.33333 1
+0.33333 2
+0.50000 1
+0.50000 2
+0.50000 3
+0.66667 2
+0.66667 1
+0.66667 3
+1.00000 3
+1.00000 2
+1.00000 3
+1.00000 1
+1.00000 2
+1.00000 3
+1.00000 2
+1.00000 1
+1.00000 1
+1.50000 3
+1.50000 2
+1.50000 1
+2.00000 1
+2.00000 3
+2.00000 2
+3.00000 3
+3.00000 2
+3.00000 1
+SELECT b/c as v, SUM(a) FROM t1 GROUP BY v;
+v SUM(a)
+0.33333 6
+0.50000 6
+0.66667 6
+1.00000 18
+1.50000 6
+2.00000 6
+3.00000 6
+SELECT SUM(a) FROM t1 GROUP BY b/c;
+SUM(a)
+6
+6
+6
+18
+6
+6
+6
+DROP TABLE t1;
--- 1.39/mysql-test/t/func_group.test Mon Mar 14 16:46:13 2005
+++ 1.40/mysql-test/t/func_group.test Sat Mar 19 23:08:50 2005
@@ -601,3 +601,26 @@
("B"), ("b"), ("b "), ("b ");
SELECT COUNT(DISTINCT a) FROM t1;
DROP TABLE t1;
+
+#
+# Test for buf #9210: GROUP BY with expression if a decimal type
+#
+
+CREATE TABLE t1 (a int, b int, c int);
+INSERT INTO t1 (a, b, c) VALUES
+ (1,1,1), (1,1,2), (1,1,3),
+ (1,2,1), (1,2,2), (1,2,3),
+ (1,3,1), (1,3,2), (1,3,3),
+ (2,1,1), (2,1,2), (2,1,3),
+ (2,2,1), (2,2,2), (2,2,3),
+ (2,3,1), (2,3,2), (2,3,3),
+ (3,1,1), (3,1,2), (3,1,3),
+ (3,2,1), (3,2,2), (3,2,3),
+ (3,3,1), (3,3,2), (3,3,3);
+
+SELECT b/c as v, a FROM t1 ORDER BY v;
+SELECT b/c as v, SUM(a) FROM t1 GROUP BY v;
+SELECT SUM(a) FROM t1 GROUP BY b/c;
+
+DROP TABLE t1;
+
| Thread |
|---|
| • bk commit into 5.0 tree (igor:1.1829) BUG#9210 | igor | 20 Mar |