summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorgluh@gluh.mysql.r18.ru <>2005-02-04 15:31:36 +0300
committergluh@gluh.mysql.r18.ru <>2005-02-04 15:31:36 +0300
commit34915f7a91b7ba56f5bbb4ac6d6301f847a7d48b (patch)
treebbb0e40bc45b0aa18e65ab56858a6d4d78bd8c06 /mysql-test
parent7213ca46add8cd1674c196851ef1073046ce03d5 (diff)
downloadmariadb-git-34915f7a91b7ba56f5bbb4ac6d6301f847a7d48b.tar.gz
A fix: bug#6931: Date Type column problem when using UNION-Table
bug#7833: Wrong datatype of aggregate column is returned
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/func_group.result12
-rw-r--r--mysql-test/r/union.result36
-rw-r--r--mysql-test/t/func_group.test14
-rw-r--r--mysql-test/t/union.test35
4 files changed, 97 insertions, 0 deletions
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index 4bb79a1cb41..fa645700875 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -733,3 +733,15 @@ one 2
two 2
three 1
drop table t1;
+create table t1(f1 datetime);
+insert into t1 values (now());
+create table t2 select f2 from (select max(now()) f2 from t1) a;
+show columns from t2;
+Field Type Null Key Default Extra
+f2 datetime 0000-00-00 00:00:00
+drop table t2;
+create table t2 select f2 from (select now() f2 from t1) a;
+show columns from t2;
+Field Type Null Key Default Extra
+f2 datetime 0000-00-00 00:00:00
+drop table t2, t1;
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index f07bdad9021..115ef6a47f9 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1137,3 +1137,39 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
drop table t2;
+create table t1(a1 int, f1 char(10));
+create table t2
+select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
+union
+select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
+order by f2, a1;
+show columns from t2;
+Field Type Null Key Default Extra
+f2 date YES NULL
+a1 int(11) YES NULL
+drop table t1, t2;
+create table t1 (f1 int);
+create table t2 (f1 int, f2 int ,f3 date);
+create table t3 (f1 int, f2 char(10));
+create table t4
+(
+select t2.f3 as sdate
+from t1
+left outer join t2 on (t1.f1 = t2.f1)
+inner join t3 on (t2.f2 = t3.f1)
+order by t1.f1, t3.f1, t2.f3
+)
+union
+(
+select cast('2004-12-31' as date) as sdate
+from t1
+left outer join t2 on (t1.f1 = t2.f1)
+inner join t3 on (t2.f2 = t3.f1)
+group by t1.f1
+order by t1.f1, t3.f1, t2.f3
+)
+order by sdate;
+show columns from t4;
+Field Type Null Key Default Extra
+sdate date YES NULL
+drop table t1, t2, t3, t4;
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index 79d6112e6de..465611a5ebb 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -473,3 +473,17 @@ INSERT INTO t1 VALUES
select val, count(*) from t1 group by val;
drop table t1;
+
+
+#
+# Bug 7833: Wrong datatype of aggregate column is returned
+#
+
+create table t1(f1 datetime);
+insert into t1 values (now());
+create table t2 select f2 from (select max(now()) f2 from t1) a;
+show columns from t2;
+drop table t2;
+create table t2 select f2 from (select now() f2 from t1) a;
+show columns from t2;
+drop table t2, t1;
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index 8682808f3f3..90b2197603b 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -664,3 +664,38 @@ show create table t1;
drop table t1;
drop table t2;
+#
+# Bug 6931: Date Type column problem when using UNION-Table.
+#
+create table t1(a1 int, f1 char(10));
+create table t2
+select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
+union
+select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
+order by f2, a1;
+show columns from t2;
+drop table t1, t2;
+
+create table t1 (f1 int);
+create table t2 (f1 int, f2 int ,f3 date);
+create table t3 (f1 int, f2 char(10));
+create table t4
+(
+ select t2.f3 as sdate
+ from t1
+ left outer join t2 on (t1.f1 = t2.f1)
+ inner join t3 on (t2.f2 = t3.f1)
+ order by t1.f1, t3.f1, t2.f3
+)
+union
+(
+ select cast('2004-12-31' as date) as sdate
+ from t1
+ left outer join t2 on (t1.f1 = t2.f1)
+ inner join t3 on (t2.f2 = t3.f1)
+ group by t1.f1
+ order by t1.f1, t3.f1, t2.f3
+)
+order by sdate;
+show columns from t4;
+drop table t1, t2, t3, t4;