summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <ramil@mysql.com>2005-02-28 18:11:18 +0400
committerunknown <ramil@mysql.com>2005-02-28 18:11:18 +0400
commit7865746c27c2ec164fa97c914fef5d80239bce81 (patch)
tree5f944a93b81ec4584682abfae38393fa2839e673
parentc8b3d65ca26ff2be783115da2fb7c790dd4338e4 (diff)
parent556950da46e61a1a04f0531f6d96ec60c7ede79c (diff)
downloadmariadb-git-7865746c27c2ec164fa97c914fef5d80239bce81.tar.gz
merging
mysql-test/r/show_check.result: Auto merged sql/sql_select.cc: Auto merged
-rw-r--r--mysql-test/r/func_group.result9
-rw-r--r--mysql-test/r/show_check.result4
-rw-r--r--mysql-test/t/func_group.test9
-rw-r--r--sql/sql_select.cc9
4 files changed, 30 insertions, 1 deletions
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index fa645700875..304afda7b72 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -733,6 +733,15 @@ one 2
two 2
three 1
drop table t1;
+create table t1(a int, b datetime);
+insert into t1 values (1, NOW()), (2, NOW());
+create table t2 select MAX(b) from t1 group by a;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `MAX(b)` datetime default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2;
create table t1(f1 datetime);
insert into t1 values (now());
create table t2 select f2 from (select max(now()) f2 from t1) a;
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 37531f05f43..0d580ae2505 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -250,9 +250,11 @@ type_bool type_tiny type_short type_mediumint type_bigint type_decimal type_nume
drop table t1;
create table t1 (a int not null);
create table t2 select max(a) from t1;
+Warnings:
+Warning 1263 Data truncated; NULL supplied to NOT NULL column 'max(a)' at row 1
show columns from t2;
Field Type Null Key Default Extra
-max(a) bigint(20) YES NULL
+max(a) int(11) 0
drop table t1,t2;
create table t1 (c decimal, d double, f float, r real);
show columns from t1;
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index 465611a5ebb..1ee812e5c2f 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -474,6 +474,15 @@ INSERT INTO t1 VALUES
select val, count(*) from t1 group by val;
drop table t1;
+#
+# Bug #5615: type of aggregate function column wrong when using group by
+#
+
+create table t1(a int, b datetime);
+insert into t1 values (1, NOW()), (2, NOW());
+create table t2 select MAX(b) from t1 group by a;
+show create table t2;
+drop table t1, t2;
#
# Bug 7833: Wrong datatype of aggregate column is returned
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a210fbbbe02..3e7e4a7734e 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4771,6 +4771,15 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
item->name,table,item_sum->decimals);
case Item_sum::UNIQUE_USERS_FUNC:
return new Field_long(9,maybe_null,item->name,table,1);
+ case Item_sum::MIN_FUNC:
+ case Item_sum::MAX_FUNC:
+ if (item_sum->args[0]->type() == Item::FIELD_ITEM)
+ {
+ *from_field= ((Item_field*) item_sum->args[0])->field;
+ return create_tmp_field_from_field(thd, *from_field, item, table,
+ modify_item, convert_blob_length);
+ }
+ /* fall through */
default:
switch (item_sum->result_type()) {
case REAL_RESULT: