diff options
-rw-r--r-- | mysql-test/r/innodb_mysql.result | 1 | ||||
-rw-r--r-- | mysql-test/r/join.result | 15 | ||||
-rw-r--r-- | mysql-test/r/subselect.result | 23 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 5 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 25 | ||||
-rw-r--r-- | sql/time.cc | 4 |
6 files changed, 54 insertions, 19 deletions
diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 895cb88a018..d17820e37bc 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -459,6 +459,7 @@ id c counter 3 b 2 4 a 2 drop table t1; +End of 5.0 tests CREATE TABLE t1 (a int, b int); insert into t1 values (1,1),(1,2); CREATE TABLE t2 (primary key (a)) select * from t1; diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index 840a92dcce2..b132c8b2e4c 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -847,19 +847,4 @@ select '^^: The above should be ~= 20 + cost(select * from t1). Value less than Z ^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error drop table t1, t2; -CREATE TABLE t1 (ID INTEGER, Name VARCHAR(50)); -CREATE TABLE t2 (Test_ID INTEGER); -CREATE VIEW v1 (Test_ID, Description) AS SELECT ID, Name FROM t1; -CREATE TABLE tv1 SELECT Description AS Name FROM v1 JOIN t2 -USING (Test_ID); -DESCRIBE tv1; -Field Type Null Key Default Extra -Name varchar(50) YES NULL -CREATE TABLE tv2 SELECT Description AS Name FROM v1 JOIN t2 -ON v1.Test_ID = t2.Test_ID; -DESCRIBE tv2; -Field Type Null Key Default Extra -Name varchar(50) YES NULL -DROP VIEW v1; -DROP TABLE t1,t2,tv1,tv2; End of 5.0 tests. diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 1fff29cd72c..0143b0c7fd3 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -4035,6 +4035,29 @@ FROM t1; ERROR HY000: Invalid use of group function DROP TABLE t1,t2; End of 5.0 tests. +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (2,22),(1,11),(2,22); +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a; +a +1 +2 +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a; +a +SELECT a FROM t1 t0 +WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a; +a +1 +2 +SET @@sql_mode='ansi'; +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a; +ERROR HY000: Invalid use of group function +SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a; +ERROR HY000: Invalid use of group function +SELECT a FROM t1 t0 +WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a; +ERROR HY000: Invalid use of group function +SET @@sql_mode=default; +DROP TABLE t1; CREATE TABLE t1 (s1 char(1)); INSERT INTO t1 VALUES ('a'); SELECT * FROM t1 WHERE _utf8'a' = ANY (SELECT s1 FROM t1); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 982179a3bb2..ad7b877cd0b 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -619,8 +619,9 @@ get_date_from_str(THD *thd, String *str, timestamp_type warn_type, if (error || *error_arg) { - make_truncated_value_warning(thd, str->ptr(), str->length(), warn_type, - warn_name); + make_truncated_value_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + str->ptr(), str->length(), + warn_type, warn_name); *error_arg= TRUE; } return value; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 4d6ca2a9b3e..0fd57264784 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2056,7 +2056,30 @@ bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, uint fuzzy_date) if (date_sub_interval) interval.neg = !interval.neg; - return (null_value= date_add_interval(ltime, int_type, interval)); + if ((null_value= date_add_interval(ltime, int_type, interval))) + return 1; + + /* Adjust cached_field_type according to the detected type. */ + if (cached_field_type == MYSQL_TYPE_STRING) + { + switch (ltime->time_type) + { + case MYSQL_TIMESTAMP_DATE: + cached_field_type= MYSQL_TYPE_DATE; + break; + case MYSQL_TIMESTAMP_DATETIME: + cached_field_type= MYSQL_TYPE_DATETIME; + break; + case MYSQL_TIMESTAMP_TIME: + cached_field_type= MYSQL_TYPE_TIME; + break; + default: + /* Shouldn't get here. */ + DBUG_ASSERT(0); + break; + } + } + return 0; } diff --git a/sql/time.cc b/sql/time.cc index 249de3b879b..c552d085f5e 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -860,8 +860,9 @@ bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL inter } break; default: - return 1; + goto null_date; } + return 0; // Ok invalid_date: @@ -869,6 +870,7 @@ invalid_date: ER_DATETIME_FUNCTION_OVERFLOW, ER(ER_DATETIME_FUNCTION_OVERFLOW), "datetime"); +null_date: return 1; } |