Commit 97988099 authored by unknown's avatar unknown

Review of new pushed code

- Fixed some error condtion when handling dates with 'T'
- Added extra test for bug #11867 (Wrong result with "... WHERE ROW( a, b ) IN ( SELECT DISTINCT a, b WHERE ...)" to show it's not yet fixed
- Safety fixes and cleanups


mysql-test/r/subselect.result:
  Added extra test case to test case for bug #11867
  (Result shows that current code is not yet right and needs to be fixed)
mysql-test/r/type_datetime.result:
  More tests for dates of type CCYYMMDDTHHMMSS
mysql-test/t/subselect.test:
  Added extra test case to test case for bug #11867
mysql-test/t/type_datetime.test:
  More tests for dates of type CCYYMMDDTHHMMSS
sql-common/my_time.c:
  Fixed handling of dates of type CCYYMMDDTHHMMSS
  (Old code couldn't handle 2003-0304 or 2003-0003-02)
sql/slave.cc:
  Indentation cleanup
sql/sql_parse.cc:
  Added test of return value of get_system_var()
sql/sql_select.cc:
  Removed unnecessary call to field->table->maybe_null
sql/sql_union.cc:
  Indentation fixes
parent 22a73084
......@@ -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;
......@@ -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;
......@@ -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
......@@ -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
......@@ -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++;
......
......@@ -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);
......
......@@ -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
......
......@@ -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)++;
}
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment