summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/subselect.result15
-rw-r--r--mysql-test/r/type_datetime.result23
-rw-r--r--mysql-test/t/subselect.test4
-rw-r--r--mysql-test/t/type_datetime.test21
-rw-r--r--sql-common/my_time.c6
-rw-r--r--sql/slave.cc4
-rw-r--r--sql/sql_parse.cc12
-rw-r--r--sql/sql_select.cc6
-rw-r--r--sql/sql_union.cc6
9 files changed, 63 insertions, 34 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 25d9a39705d..863a250c670 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -2741,4 +2741,19 @@ WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N');
one two flag
5 6 N
7 8 N
+insert into t2 values (null,null,'N');
+SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1;
+one two test
+1 2 0
+2 3 0
+3 4 0
+5 6 1
+7 8 1
+SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1;
+one two test
+1 2 NULL
+2 3 NULL
+3 4 NULL
+5 6 1
+7 8 1
DROP TABLE t1,t2;
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result
index 8d28504d790..f313a6b934b 100644
--- a/mysql-test/r/type_datetime.result
+++ b/mysql-test/r/type_datetime.result
@@ -26,6 +26,8 @@ Table Op Msg_type Msg_text
test.t1 check status OK
delete from t1;
insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030100000000"),("20030000000000");
+insert into t1 values ("2003-003-03");
+insert into t1 values ("20030102T131415"),("2001-01-01T01:01:01"), ("2001-1-1T1:01:01");
select * from t1;
t
2000-01-01 00:00:00
@@ -43,6 +45,17 @@ t
9999-12-31 23:59:59
2003-01-00 00:00:00
2003-00-00 00:00:00
+2003-03-03 00:00:00
+2003-01-02 13:14:15
+2001-01-01 01:01:01
+2001-01-01 01:01:01
+truncate table t1;
+insert into t1 values("2003-0303 12:13:14");
+Warnings:
+Warning 1264 Data truncated; out of range for column 't' at row 1
+select * from t1;
+t
+0000-00-00 00:00:00
drop table t1;
CREATE TABLE t1 (a timestamp, b date, c time, d datetime);
insert into t1 (b,c,d) values(now(),curtime(),now());
@@ -153,13 +166,3 @@ dt
0000-00-00 00:00:00
0000-00-00 00:00:00
drop table t1;
-create table t1 (dt datetime);
-insert into t1 values ("20010101T010101");
-insert into t1 values ("2001-01-01T01:01:01");
-insert into t1 values ("2001-1-1T1:01:01");
-select * from t1;
-dt
-2001-01-01 01:01:01
-2001-01-01 01:01:01
-2001-01-01 01:01:01
-drop table t1;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 0b4791b0023..ecd553ee8f8 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -1768,6 +1768,10 @@ SELECT * FROM t1
SELECT * FROM t1
WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N');
+insert into t2 values (null,null,'N');
+SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1;
+SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1;
+
DROP TABLE t1,t2;
# End of 4.1 tests
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index ca70e35d3cd..4b6741b4242 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -14,6 +14,17 @@ optimize table t1;
check table t1;
delete from t1;
insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030100000000"),("20030000000000");
+
+# Strange dates
+insert into t1 values ("2003-003-03");
+
+# Bug #7308: ISO-8601 date format not handled correctly
+insert into t1 values ("20030102T131415"),("2001-01-01T01:01:01"), ("2001-1-1T1:01:01");
+select * from t1;
+
+# Test some wrong dates
+truncate table t1;
+insert into t1 values("2003-0303 12:13:14");
select * from t1;
drop table t1;
@@ -102,14 +113,4 @@ insert into t1 values ("00-00-00"), ("00-00-00 00:00:00");
select * from t1;
drop table t1;
-#
-# Bug #7308: ISO-8601 date format not handled correctly
-#
-create table t1 (dt datetime);
-insert into t1 values ("20010101T010101");
-insert into t1 values ("2001-01-01T01:01:01");
-insert into t1 values ("2001-1-1T1:01:01");
-select * from t1;
-drop table t1;
-
# End of 4.1 tests
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 1726a9a6e78..40d7799e274 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -137,7 +137,9 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
If length= 8 or >= 14 then year is of format YYYY.
(YYYY-MM-DD, YYYYMMDD, YYYYYMMDDHHMMSS)
*/
- for (pos=str; pos != end && my_isdigit(&my_charset_latin1,*pos) ; pos++)
+ for (pos=str;
+ pos != end && (my_isdigit(&my_charset_latin1,*pos) || *pos == 'T');
+ pos++)
;
digits= (uint) (pos-str);
@@ -203,7 +205,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time,
const char *start= str;
ulong tmp_value= (uint) (uchar) (*str++ - '0');
while (str != end && my_isdigit(&my_charset_latin1,str[0]) &&
- --field_length)
+ (!is_internal_format || --field_length))
{
tmp_value=tmp_value*10 + (ulong) (uchar) (*str - '0');
str++;
diff --git a/sql/slave.cc b/sql/slave.cc
index a0cc773d44f..9ff7a432b89 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -2186,8 +2186,8 @@ int show_master_info(THD* thd, MASTER_INFO* mi)
&my_charset_bin);
protocol->store((ulonglong) mi->rli.group_relay_log_pos);
protocol->store(mi->rli.group_master_log_name, &my_charset_bin);
- protocol->store(mi->slave_running == MYSQL_SLAVE_RUN_CONNECT
- ? "Yes":"No", &my_charset_bin);
+ protocol->store(mi->slave_running == MYSQL_SLAVE_RUN_CONNECT ?
+ "Yes" : "No", &my_charset_bin);
protocol->store(mi->rli.slave_running ? "Yes":"No", &my_charset_bin);
protocol->store(&replicate_do_db);
protocol->store(&replicate_ignore_db);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 135cef43e90..869e8e5063f 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4211,10 +4211,12 @@ void create_select_for_variable(const char *var_name)
We set the name of Item to @@session.var_name because that then is used
as the column name in the output.
*/
- var= get_system_var(thd, OPT_SESSION, tmp, null_lex_string);
- end= strxmov(buff, "@@session.", var_name, NullS);
- var->set_name(buff, end-buff, system_charset_info);
- add_item_to_list(thd, var);
+ if ((var= get_system_var(thd, OPT_SESSION, tmp, null_lex_string)))
+ {
+ end= strxmov(buff, "@@session.", var_name, NullS);
+ var->set_name(buff, end-buff, system_charset_info);
+ add_item_to_list(thd, var);
+ }
DBUG_VOID_RETURN;
}
@@ -5038,11 +5040,13 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
THR_LOCK_DATA **end_p= lock_p + thd->locked_tables->lock_count;
for (; lock_p < end_p; lock_p++)
+ {
if ((*lock_p)->type == TL_WRITE)
{
my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
return 1;
}
+ }
}
/*
Writing to the binlog could cause deadlocks, as we don't log
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 54afe5bb7a6..353ccf79ab8 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2260,11 +2260,9 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, Item_func *cond,
We use null_rejecting in add_not_null_conds() to add
'othertbl.field IS NOT NULL' to tab->select_cond.
*/
- (*key_fields)->null_rejecting= (cond->functype() == Item_func::EQ_FUNC) &&
+ (*key_fields)->null_rejecting= ((cond->functype() == Item_func::EQ_FUNC) &&
((*value)->type() == Item::FIELD_ITEM) &&
-
- (((Item_field*)*value)->field->maybe_null() ||
- ((Item_field *)*value)->field->table->maybe_null);
+ ((Item_field*)*value)->field->maybe_null());
(*key_fields)++;
}
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index c33444fd73e..8bb53f7b573 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -285,6 +285,8 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
List_iterator_fast<Item> tp(types);
Item_arena *arena= thd->current_arena;
Item *type;
+ ulong create_options;
+
while ((type= tp++))
{
if (type->result_type() == STRING_RESULT &&
@@ -295,8 +297,8 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
}
}
- ulong create_options= first_select_in_union()->options | thd_arg->options |
- TMP_TABLE_ALL_COLUMNS;
+ create_options= (first_select_in_union()->options | thd_arg->options |
+ TMP_TABLE_ALL_COLUMNS);
/*
Force the temporary table to be a MyISAM table if we're going to use
fullext functions (MATCH ... AGAINST .. IN BOOLEAN MODE) when reading