2000-12-28 02:56:38 +01:00
#
# time functions
#
2003-01-06 00:48:59 +01:00
--disable_warnings
2002-11-05 21:45:42 +01:00
drop table if exists t1,t2,t3;
2003-01-06 00:48:59 +01:00
--enable_warnings
2001-01-31 03:47:25 +01:00
2006-06-22 20:23:22 +02:00
# Set timezone to GMT-3, to make it possible to use "interval 3 hour"
set time_zone="+03:00";
2000-12-28 02:56:38 +01:00
select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29");
select period_add("9602",-12),period_diff(199505,"9404") ;
2003-10-30 11:57:26 +01:00
2000-12-28 02:56:38 +01:00
select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_timestamp(now());
select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
2001-08-16 20:01:35 +02:00
select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
sec_to_time(time_to_sec("0:30:47")/6.21);
2011-05-19 19:01:46 +02:00
select sec_to_time(9001.1), time_to_sec('15:12:22.123456'), time_to_sec(15.5566778899);
2001-11-03 14:18:09 +01:00
select sec_to_time(time_to_sec('-838:59:59'));
2011-06-06 20:28:15 +02:00
select sec_to_time('9001.1'), sec_to_time('1234567890123.123');
2011-09-01 12:23:03 +02:00
select sec_to_time(-9001.1), sec_to_time(-9001.1) / 1,
sec_to_time(-9001.1) / 1e0, sec_to_time(-9001) div 1;
2011-06-10 21:15:13 +02:00
--replace_result e+042 e+42
2011-06-06 20:28:15 +02:00
select sec_to_time(90011e-1), sec_to_time(1234567890123e30);
select sec_to_time(1234567890123), sec_to_time('99999999999999999999999999999');
2000-12-28 02:56:38 +01:00
select now()-curdate()*1000000-curtime();
select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
2002-11-24 14:47:19 +01:00
select strcmp(localtime(),concat(current_date()," ",current_time()));
select strcmp(localtimestamp(),concat(current_date()," ",current_time()));
2000-12-28 02:56:38 +01:00
select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
select date_format("1997-01-02", concat("%M %W %D ","%Y %y %m %d %h %i %s %w"));
select dayofmonth("1997-01-02"),dayofmonth(19970323);
select month("1997-01-02"),year("98-02-03"),dayofyear("1997-12-31");
2001-05-23 01:40:24 +02:00
select month("2001-02-00"),year("2001-00-00");
2000-12-28 02:56:38 +01:00
select DAYOFYEAR("1997-03-03"), WEEK("1998-03-03"), QUARTER(980303);
select HOUR("1997-03-03 23:03:22"), MINUTE("23:03:22"), SECOND(230322);
2011-05-28 04:11:32 +02:00
select TIME(230322), TIME(230322.33), TIME("230322.33");
2001-08-21 12:44:01 +02:00
# Test of week and yearweek
2000-12-28 02:56:38 +01:00
select week(19980101),week(19970101),week(19980101,1),week(19970101,1);
select week(19981231),week(19971231),week(19981231,1),week(19971231,1);
select week(19950101),week(19950101,1);
select yearweek('1981-12-31',1),yearweek('1982-01-01',1),yearweek('1982-12-31',1),yearweek('1983-01-01',1);
2001-08-21 12:44:01 +02:00
select yearweek('1987-01-01',1),yearweek('1987-01-01');
select week("2000-01-01",0) as '2000', week("2001-01-01",0) as '2001', week("2002-01-01",0) as '2002',week("2003-01-01",0) as '2003', week("2004-01-01",0) as '2004', week("2005-01-01",0) as '2005', week("2006-01-01",0) as '2006';
select week("2000-01-06",0) as '2000', week("2001-01-06",0) as '2001', week("2002-01-06",0) as '2002',week("2003-01-06",0) as '2003', week("2004-01-06",0) as '2004', week("2005-01-06",0) as '2005', week("2006-01-06",0) as '2006';
select week("2000-01-01",1) as '2000', week("2001-01-01",1) as '2001', week("2002-01-01",1) as '2002',week("2003-01-01",1) as '2003', week("2004-01-01",1) as '2004', week("2005-01-01",1) as '2005', week("2006-01-01",1) as '2006';
select week("2000-01-06",1) as '2000', week("2001-01-06",1) as '2001', week("2002-01-06",1) as '2002',week("2003-01-06",1) as '2003', week("2004-01-06",1) as '2004', week("2005-01-06",1) as '2005', week("2006-01-06",1) as '2006';
select yearweek("2000-01-01",0) as '2000', yearweek("2001-01-01",0) as '2001', yearweek("2002-01-01",0) as '2002',yearweek("2003-01-01",0) as '2003', yearweek("2004-01-01",0) as '2004', yearweek("2005-01-01",0) as '2005', yearweek("2006-01-01",0) as '2006';
select yearweek("2000-01-06",0) as '2000', yearweek("2001-01-06",0) as '2001', yearweek("2002-01-06",0) as '2002',yearweek("2003-01-06",0) as '2003', yearweek("2004-01-06",0) as '2004', yearweek("2005-01-06",0) as '2005', yearweek("2006-01-06",0) as '2006';
select yearweek("2000-01-01",1) as '2000', yearweek("2001-01-01",1) as '2001', yearweek("2002-01-01",1) as '2002',yearweek("2003-01-01",1) as '2003', yearweek("2004-01-01",1) as '2004', yearweek("2005-01-01",1) as '2005', yearweek("2006-01-01",1) as '2006';
select yearweek("2000-01-06",1) as '2000', yearweek("2001-01-06",1) as '2001', yearweek("2002-01-06",1) as '2002',yearweek("2003-01-06",1) as '2003', yearweek("2004-01-06",1) as '2004', yearweek("2005-01-06",1) as '2005', yearweek("2006-01-06",1) as '2006';
2002-11-12 11:42:42 +01:00
select week(19981231,2), week(19981231,3), week(20000101,2), week(20000101,3);
select week(20001231,2),week(20001231,3);
2003-12-07 12:10:21 +01:00
select week(19981231,0) as '0', week(19981231,1) as '1', week(19981231,2) as '2', week(19981231,3) as '3', week(19981231,4) as '4', week(19981231,5) as '5', week(19981231,6) as '6', week(19981231,7) as '7';
select week(20000101,0) as '0', week(20000101,1) as '1', week(20000101,2) as '2', week(20000101,3) as '3', week(20000101,4) as '4', week(20000101,5) as '5', week(20000101,6) as '6', week(20000101,7) as '7';
select week(20000106,0) as '0', week(20000106,1) as '1', week(20000106,2) as '2', week(20000106,3) as '3', week(20000106,4) as '4', week(20000106,5) as '5', week(20000106,6) as '6', week(20000106,7) as '7';
select week(20001231,0) as '0', week(20001231,1) as '1', week(20001231,2) as '2', week(20001231,3) as '3', week(20001231,4) as '4', week(20001231,5) as '5', week(20001231,6) as '6', week(20001231,7) as '7';
select week(20010101,0) as '0', week(20010101,1) as '1', week(20010101,2) as '2', week(20010101,3) as '3', week(20010101,4) as '4', week(20010101,5) as '5', week(20010101,6) as '6', week(20010101,7) as '7';
select yearweek(20001231,0), yearweek(20001231,1), yearweek(20001231,2), yearweek(20001231,3), yearweek(20001231,4), yearweek(20001231,5), yearweek(20001231,6), yearweek(20001231,7);
set default_week_format = 6;
select week(20001231), week(20001231,6);
set default_week_format = 0;
2003-02-19 13:05:35 +01:00
set default_week_format = 2;
select week(20001231),week(20001231,2),week(20001231,0);
set default_week_format = 0;
2000-12-28 02:56:38 +01:00
select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v');
select date_format('1999-12-31','%x-%v'),date_format('2000-01-01','%x-%v');
select dayname("1962-03-03"),dayname("1962-03-03")+0;
select monthname("1972-03-04"),monthname("1972-03-04")+0;
2011-06-06 20:28:15 +02:00
select time_format(000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
select time_format(010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
select time_format(131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
select time_format(010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T'),date_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
2000-12-28 02:56:38 +01:00
select date_format(concat('19980131',131415),'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
select date_format(19980021000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
select date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
select date_add("1997-12-31 23:59:59",INTERVAL 1 MINUTE);
select date_add("1997-12-31 23:59:59",INTERVAL 1 HOUR);
select date_add("1997-12-31 23:59:59",INTERVAL 1 DAY);
select date_add("1997-12-31 23:59:59",INTERVAL 1 MONTH);
select date_add("1997-12-31 23:59:59",INTERVAL 1 YEAR);
select date_add("1997-12-31 23:59:59",INTERVAL "1:1" MINUTE_SECOND);
select date_add("1997-12-31 23:59:59",INTERVAL "1:1" HOUR_MINUTE);
select date_add("1997-12-31 23:59:59",INTERVAL "1:1" DAY_HOUR);
select date_add("1997-12-31 23:59:59",INTERVAL "1 1" YEAR_MONTH);
select date_add("1997-12-31 23:59:59",INTERVAL "1:1:1" HOUR_SECOND);
select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1" DAY_MINUTE);
select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1:1" DAY_SECOND);
select date_sub("1998-01-01 00:00:00",INTERVAL 1 SECOND);
select date_sub("1998-01-01 00:00:00",INTERVAL 1 MINUTE);
select date_sub("1998-01-01 00:00:00",INTERVAL 1 HOUR);
select date_sub("1998-01-01 00:00:00",INTERVAL 1 DAY);
select date_sub("1998-01-01 00:00:00",INTERVAL 1 MONTH);
select date_sub("1998-01-01 00:00:00",INTERVAL 1 YEAR);
select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" MINUTE_SECOND);
select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" HOUR_MINUTE);
select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" DAY_HOUR);
select date_sub("1998-01-01 00:00:00",INTERVAL "1 1" YEAR_MONTH);
select date_sub("1998-01-01 00:00:00",INTERVAL "1:1:1" HOUR_SECOND);
select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1" DAY_MINUTE);
select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1:1" DAY_SECOND);
select date_add("1997-12-31 23:59:59",INTERVAL 100000 SECOND);
select date_add("1997-12-31 23:59:59",INTERVAL -100000 MINUTE);
select date_add("1997-12-31 23:59:59",INTERVAL 100000 HOUR);
select date_add("1997-12-31 23:59:59",INTERVAL -100000 DAY);
select date_add("1997-12-31 23:59:59",INTERVAL 100000 MONTH);
select date_add("1997-12-31 23:59:59",INTERVAL -100000 YEAR);
select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" MINUTE_SECOND);
select date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE);
select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" DAY_HOUR);
select date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH);
select date_add("1997-12-31 23:59:59",INTERVAL "10000:99:99" HOUR_SECOND);
select date_add("1997-12-31 23:59:59",INTERVAL " -10000 99:99" DAY_MINUTE);
select date_add("1997-12-31 23:59:59",INTERVAL "10000 99:99:99" DAY_SECOND);
select "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
select INTERVAL 1 DAY + "1997-12-31";
select "1998-01-01 00:00:00" - INTERVAL 1 SECOND;
select date_sub("1998-01-02",INTERVAL 31 DAY);
select date_add("1997-12-31",INTERVAL 1 SECOND);
select date_add("1997-12-31",INTERVAL 1 DAY);
select date_add(NULL,INTERVAL 100000 SECOND);
select date_add("1997-12-31 23:59:59",INTERVAL NULL SECOND);
select date_add("1997-12-31 23:59:59",INTERVAL NULL MINUTE_SECOND);
select date_add("9999-12-31 23:59:59",INTERVAL 1 SECOND);
select date_sub("0000-00-00 00:00:00",INTERVAL 1 SECOND);
select date_add('1998-01-30',Interval 1 month);
select date_add('1998-01-30',Interval '2:1' year_month);
select date_add('1996-02-29',Interval '1' year);
select extract(YEAR FROM "1999-01-02 10:11:12");
select extract(YEAR_MONTH FROM "1999-01-02");
select extract(DAY FROM "1999-01-02");
select extract(DAY_HOUR FROM "1999-01-02 10:11:12");
select extract(DAY_MINUTE FROM "02 10:11:12");
select extract(DAY_SECOND FROM "225 10:11:12");
select extract(HOUR FROM "1999-01-02 10:11:12");
select extract(HOUR_MINUTE FROM "10:11:12");
select extract(HOUR_SECOND FROM "10:11:12");
select extract(MINUTE FROM "10:11:12");
select extract(MINUTE_SECOND FROM "10:11:12");
select extract(SECOND FROM "1999-01-02 10:11:12");
2001-05-23 01:40:24 +02:00
select extract(MONTH FROM "2001-02-00");
2001-01-15 20:21:06 +01:00
2006-04-07 11:15:15 +02:00
#
# test EXTRACT QUARTER (Bug #18100)
#
SELECT EXTRACT(QUARTER FROM '2004-01-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-02-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-03-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-04-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-05-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-06-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-07-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-08-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-09-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-10-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-11-15') AS quarter;
SELECT EXTRACT(QUARTER FROM '2004-12-15') AS quarter;
2006-06-27 17:33:59 +02:00
#
# MySQL Bugs: #12356: DATE_SUB or DATE_ADD incorrectly returns null
#
SELECT DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
SELECT DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
2006-04-07 11:15:15 +02:00
2004-04-28 16:45:08 +02:00
#
# Test big intervals (Bug #3498)
#
SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND;
SELECT "1900-01-01 00:00:00" + INTERVAL "1:2147483647" MINUTE_SECOND;
SELECT "1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND;SELECT "1900-01-01 00:00:00" + INTERVAL 1<<37 SECOND;
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<31 MINUTE;
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<20 HOUR;
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<38 SECOND;
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<33 MINUTE;
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<30 HOUR;
SELECT "1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND;
#
# Bug #614 (multiple extracts in where)
#
2001-01-15 20:21:06 +01:00
create table t1 (ctime varchar(20));
insert into t1 values ('2001-01-12 12:23:40');
select ctime, hour(ctime) from t1;
2003-06-11 19:07:23 +02:00
select ctime from t1 where extract(MONTH FROM ctime) = 1 AND extract(YEAR FROM ctime) = 2001;
2001-01-15 20:21:06 +01:00
drop table t1;
2001-01-31 03:47:25 +01:00
#
# Test bug with monthname() and NULL
#
create table t1 (id int);
create table t2 (id int, date date);
insert into t1 values (1);
insert into t2 values (1, "0000-00-00");
insert into t1 values (2);
insert into t2 values (2, "2000-01-01");
select monthname(date) from t1 inner join t2 on t1.id = t2.id;
select monthname(date) from t1 inner join t2 on t1.id = t2.id order by t1.id;
drop table t1,t2;
2001-04-09 20:08:56 +02:00
#
# Test bug with month() and year() on text fields with wrong information
2003-12-10 05:31:42 +01:00
CREATE TABLE t1 (updated text) ENGINE=MyISAM;
2001-04-09 20:08:56 +02:00
INSERT INTO t1 VALUES ('');
SELECT month(updated) from t1;
SELECT year(updated) from t1;
drop table t1;
2001-10-31 17:27:49 +01:00
#
# Check that functions work identically on 0000-00-00 as a constant and on a
# column
#
create table t1 (d date, dt datetime, t timestamp, c char(10));
insert into t1 values ("0000-00-00", "0000-00-00", "0000-00-00", "0000-00-00");
select dayofyear("0000-00-00"),dayofyear(d),dayofyear(dt),dayofyear(t),dayofyear(c) from t1;
select dayofmonth("0000-00-00"),dayofmonth(d),dayofmonth(dt),dayofmonth(t),dayofmonth(c) from t1;
select month("0000-00-00"),month(d),month(dt),month(t),month(c) from t1;
select quarter("0000-00-00"),quarter(d),quarter(dt),quarter(t),quarter(c) from t1;
select week("0000-00-00"),week(d),week(dt),week(t),week(c) from t1;
select year("0000-00-00"),year(d),year(dt),year(t),year(c) from t1;
select yearweek("0000-00-00"),yearweek(d),yearweek(dt),yearweek(t),yearweek(c) from t1;
select to_days("0000-00-00"),to_days(d),to_days(dt),to_days(t),to_days(c) from t1;
select extract(MONTH FROM "0000-00-00"),extract(MONTH FROM d),extract(MONTH FROM dt),extract(MONTH FROM t),extract(MONTH FROM c) from t1;
drop table t1;
2002-11-05 21:45:42 +01:00
2002-11-22 12:52:40 +01:00
2002-11-05 21:45:42 +01:00
#
# Test problem with TIMESTAMP and BETWEEN
#
CREATE TABLE t1 ( start datetime default NULL);
INSERT INTO t1 VALUES ('2002-10-21 00:00:00'),('2002-10-28 00:00:00'),('2002-11-04 00:00:00');
bug#10466: Datatype "timestamp" displays "YYYYMMDDHHMMSS" irrespective of display sizes.
- Print warning that says display width is not supported for datatype TIMESTAMP, if user tries to create a TIMESTAMP column with display width.
- Use display width for TIMESTAMP only in type_timestamp test to make sure warning is displayed correctly.
mysql-test/include/ps_create.inc:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/alias.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/func_date_add.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/func_str.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/func_time.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/group_by.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/innodb.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_1general.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_2myisam.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_3innodb.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_4heap.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_5merge.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_6bdb.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/ps_7ndb.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/select.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/r/type_timestamp.result:
When display width is used for a TIMESTAMP column a warning is printed that the display width will be ignored.
mysql-test/r/update.result:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/alias.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/func_date_add.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/func_str.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/func_time.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/group_by.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/innodb.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/ps.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/ps_4heap.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/ps_5merge.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/select.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
mysql-test/t/update.test:
Reove all uses of display width in for TIMESTAMP columns, except in the type_timestamp test.
sql/share/errmsg.txt:
Correct swedish error message
sql/sql_parse.cc:
Print warning if datatype is TIMESTAMP and display width is used.
2005-06-20 12:09:00 +02:00
CREATE TABLE t2 ( ctime1 timestamp NOT NULL, ctime2 timestamp NOT NULL);
2002-11-05 21:45:42 +01:00
INSERT INTO t2 VALUES (20021029165106,20021105164731);
CREATE TABLE t3 (ctime1 char(19) NOT NULL, ctime2 char(19) NOT NULL);
INSERT INTO t3 VALUES ("2002-10-29 16:51:06","2002-11-05 16:47:31");
# The following statement should be fixed to return a row in 4.1
select * from t1, t2 where t1.start between t2.ctime1 and t2.ctime2;
select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2;
select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2;
drop table t1,t2,t3;
2002-12-14 16:43:01 +01:00
2003-12-12 21:26:58 +01:00
#
# Test unix timestamp
#
select @a:=FROM_UNIXTIME(1);
select unix_timestamp(@a);
select unix_timestamp('1969-12-01 19:00:01');
2003-12-17 16:35:34 +01:00
2004-11-15 14:11:13 +01:00
#
2006-11-01 14:47:40 +01:00
# Tests for bug #6439 "unix_timestamp() function returns wrong datetime
# values for too big argument", bug #7515 "from_unixtime(0) now
# returns NULL instead of the epoch" and bug #9191
# "TIMESTAMP/from_unixtime() no longer accepts 2^31-1."
# unix_timestamp() should return error for too big or negative argument.
# It should return Epoch value for zero argument since it seems that many
# users rely on this fact, from_unixtime() should work with values
# up to INT_MAX32 because of the same reason.
2004-11-15 14:11:13 +01:00
#
2004-12-30 19:18:10 +01:00
select from_unixtime(-1);
2006-11-01 14:47:40 +01:00
# check for from_unixtime(2^31-1) and from_unixtime(2^31)
select from_unixtime(2147483647);
select from_unixtime(2147483648);
2004-12-30 19:18:10 +01:00
select from_unixtime(0);
2004-11-19 17:19:45 +01:00
2006-11-01 14:47:40 +01:00
#
# Some more tests for bug #9191 "TIMESTAMP/from_unixtime() no
# longer accepts 2^31-1". Here we test that from_unixtime and
# unix_timestamp are consistent, when working with boundary dates.
#
select unix_timestamp(from_unixtime(2147483647));
select unix_timestamp(from_unixtime(2147483648));
# check for invalid dates
# bad year
select unix_timestamp('2039-01-20 01:00:00');
select unix_timestamp('1968-01-20 01:00:00');
# bad month
select unix_timestamp('2038-02-10 01:00:00');
select unix_timestamp('1969-11-20 01:00:00');
# bad day
select unix_timestamp('2038-01-20 01:00:00');
select unix_timestamp('1969-12-30 01:00:00');
#
# Check negative shift (we subtract several days for boundary dates during
# conversion).
select unix_timestamp('2038-01-17 12:00:00');
#
# Check positive shift. (it happens only on
# platfroms with unsigned time_t, such as QNX)
#
select unix_timestamp('1970-01-01 03:00:01');
# check bad date, close to the boundary (we cut them off in the very end)
select unix_timestamp('2038-01-19 07:14:07');
2008-12-23 15:08:04 +01:00
#
# Bug #28759: DAYNAME() and MONTHNAME() return binary string
#
SELECT CHARSET(DAYNAME(19700101));
SELECT CHARSET(MONTHNAME(19700101));
SELECT LOWER(DAYNAME(19700101));
SELECT LOWER(MONTHNAME(19700101));
SELECT COERCIBILITY(MONTHNAME('1970-01-01')),COERCIBILITY(DAYNAME('1970-01-01'));
2006-11-01 14:47:40 +01:00
2002-12-14 16:43:01 +01:00
#
# Test types from + INTERVAL
#
CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time);
INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08");
SELECT * from t1;
select date_add("1997-12-31",INTERVAL 1 SECOND);
select date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH);
select date_add(datetime, INTERVAL 1 SECOND) from t1;
select date_add(datetime, INTERVAL 1 YEAR) from t1;
select date_add(date,INTERVAL 1 SECOND) from t1;
select date_add(date,INTERVAL 1 MINUTE) from t1;
select date_add(date,INTERVAL 1 HOUR) from t1;
select date_add(date,INTERVAL 1 DAY) from t1;
select date_add(date,INTERVAL 1 MONTH) from t1;
select date_add(date,INTERVAL 1 YEAR) from t1;
select date_add(date,INTERVAL "1:1" MINUTE_SECOND) from t1;
select date_add(date,INTERVAL "1:1" HOUR_MINUTE) from t1;
select date_add(date,INTERVAL "1:1" DAY_HOUR) from t1;
select date_add(date,INTERVAL "1 1" YEAR_MONTH) from t1;
select date_add(date,INTERVAL "1:1:1" HOUR_SECOND) from t1;
select date_add(date,INTERVAL "1 1:1" DAY_MINUTE) from t1;
select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1;
WL#530&531: TIMESTAMPADD, TIMESTAMPDIFF functions
Syntax for TIMESTAMPADD:
TIMESTAMPADD(interval, integer_expression, datetime_expression)
interval:= FRAC_SECOND | SECOND | MINUTE | HOUR | DAY | WEEK | MONTH |
QUARTER | YEAR
Supported SQL_TSI_ prefix (like SQL_TSI_SECOND)
Syntax for TIMESTAMPDIFF:
TIMESTAMPDIFF(interval, datetime_expression1, datetime_expression2)
interval:= FRAC_SECOND | SECOND | MINUTE | HOUR | DAY | WEEK | MONTH |
QUARTER | YEAR
Supported SQL_TSI_ prefix (like SQL_TSI_SECOND)
mysql-test/r/func_sapdb.result:
Additional tests for timediff
mysql-test/r/func_time.result:
Tests for timestampadd, timestampdiff functions
mysql-test/r/keywords.result:
Test for new keywords
mysql-test/t/func_sapdb.test:
Additional tests for timediff
mysql-test/t/func_time.test:
Tests for timestampadd, timestampdiff functions
mysql-test/t/keywords.test:
Test for new keywords
sql/item_create.cc:
WL#530&531: TIMESTAMPADD, TIMESTAMPDIFF functions
sql/item_create.h:
WL#530&531: TIMESTAMPADD, TIMESTAMPDIFF functions
sql/item_timefunc.cc:
WL#530&531: TIMESTAMPADD, TIMESTAMPDIFF functions
sql/item_timefunc.h:
WL#530&531: TIMESTAMPADD, TIMESTAMPDIFF functions
sql/lex.h:
WL#530&531: TIMESTAMPADD, TIMESTAMPDIFF functions
sql/sql_yacc.yy:
WL#530&531: TIMESTAMPADD, TIMESTAMPDIFF functions
2003-12-08 11:41:41 +01:00
select date_add(date,INTERVAL "1" WEEK) from t1;
select date_add(date,INTERVAL "1" QUARTER) from t1;
select timestampadd(MINUTE, 1, date) from t1;
select timestampadd(WEEK, 1, date) from t1;
select timestampadd(SQL_TSI_SECOND, 1, date) from t1;
select timestampdiff(MONTH, '2001-02-01', '2001-05-01') as a;
select timestampdiff(YEAR, '2002-05-01', '2001-01-01') as a;
select timestampdiff(QUARTER, '2002-05-01', '2001-01-01') as a;
select timestampdiff(MONTH, '2000-03-28', '2000-02-29') as a;
select timestampdiff(MONTH, '1991-03-28', '2000-02-29') as a;
select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a;
select timestampdiff(SQL_TSI_HOUR, '2001-02-01', '2001-05-01') as a;
select timestampdiff(SQL_TSI_DAY, '2001-02-01', '2001-05-01') as a;
select timestampdiff(SQL_TSI_MINUTE, '2001-02-01 12:59:59', '2001-05-01 12:58:59') as a;
select timestampdiff(SQL_TSI_SECOND, '2001-02-01 12:59:59', '2001-05-01 12:58:58') as a;
select timestampdiff(SQL_TSI_DAY, '1986-02-01', '1986-03-01') as a1,
timestampdiff(SQL_TSI_DAY, '1900-02-01', '1900-03-01') as a2,
timestampdiff(SQL_TSI_DAY, '1996-02-01', '1996-03-01') as a3,
timestampdiff(SQL_TSI_DAY, '2000-02-01', '2000-03-01') as a4;
2006-07-29 05:51:17 +02:00
# bug 16226
SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27');
SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28');
SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29');
SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27');
SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28');
SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29');
SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27');
SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28');
SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29');
SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27');
SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28');
SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29');
SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27');
SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28');
SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29');
SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27');
SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28');
SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29');
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27');
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28');
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29');
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27');
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28');
SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29');
# end of bug
2002-12-14 16:43:01 +01:00
select date_add(time,INTERVAL 1 SECOND) from t1;
drop table t1;
2003-08-11 21:43:01 +02:00
2003-11-17 15:02:08 +01:00
# test for last_day
select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2,
last_day('2003-03-32') as f3, last_day('2003-04-01') as f4,
last_day('2001-01-01 01:01:01') as f5, last_day(NULL),
last_day('2001-02-12');
2004-03-15 15:28:21 +01:00
create table t1 select last_day('2000-02-05') as a,
from_days(to_days("960101")) as b;
2003-11-17 15:02:08 +01:00
describe t1;
select * from t1;
drop table t1;
2004-03-15 15:28:21 +01:00
select last_day('2000-02-05') as a,
from_days(to_days("960101")) as b;
2003-11-17 15:02:08 +01:00
2004-03-15 15:28:21 +01:00
select date_add(last_day("1997-12-1"), INTERVAL 1 DAY);
select length(last_day("1997-12-1"));
select last_day("1997-12-1")+0;
select last_day("1997-12-1")+0.0;
2003-11-17 15:02:08 +01:00
2003-08-11 21:43:01 +02:00
# Test SAPDB UTC_% functions. This part is TZ dependant (It is supposed that
# TZ variable set to GMT-3
2006-06-22 20:23:22 +02:00
2003-08-11 21:43:01 +02:00
select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0;
select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0;
select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0;
select strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0;
select strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0;
select strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0;
2003-10-30 11:57:26 +01:00
explain extended select period_add("9602",-12),period_diff(199505,"9404"),from_days(to_days("960101")),dayofmonth("1997-01-02"), month("1997-01-02"), monthname("1972-03-04"),dayofyear("0000-00-00"),HOUR("1997-03-03 23:03:22"),MINUTE("23:03:22"),SECOND(230322),QUARTER(980303),WEEK("1998-03-03"),yearweek("2000-01-01",1),week(19950101,1),year("98-02-03"),weekday(curdate())-weekday(now()),dayname("1962-03-03"),unix_timestamp(),sec_to_time(time_to_sec("0:30:47")/6.21),curtime(),utc_time(),curdate(),utc_date(),utc_timestamp(),date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w"),from_unixtime(unix_timestamp("1994-03-02 10:11:12")),"1997-12-31 23:59:59" + INTERVAL 1 SECOND,"1998-01-01 00:00:00" - INTERVAL 1 SECOND,INTERVAL 1 DAY + "1997-12-31", extract(YEAR FROM "1999-01-02 10:11:12"),date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
2003-12-08 14:44:56 +01:00
2007-08-01 10:28:08 +02:00
SET @TMP='2007-08-01 12:22:49';
2004-03-23 18:10:23 +01:00
CREATE TABLE t1 (d DATETIME);
2007-08-01 10:28:08 +02:00
INSERT INTO t1 VALUES ('2007-08-01 12:22:59');
INSERT INTO t1 VALUES ('2007-08-01 12:23:01');
INSERT INTO t1 VALUES ('2007-08-01 12:23:20');
2004-03-25 21:11:22 +01:00
SELECT count(*) FROM t1 WHERE d>FROM_DAYS(TO_DAYS(@TMP)) AND d<=FROM_DAYS(TO_DAYS(@TMP)+1);
2004-03-23 18:10:23 +01:00
DROP TABLE t1;
2005-06-24 11:04:48 +02:00
#
# Bug #10568
#
select last_day('2005-00-00');
select last_day('2005-00-01');
select last_day('2005-01-00');
2005-07-28 02:22:47 +02:00
2006-04-25 11:34:19 +02:00
#
# Bug #18501: monthname and NULLs
#
select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
2005-07-28 16:09:54 +02:00
2006-05-17 14:00:30 +02:00
#
# Bug #16327: problem with timestamp < 1970
#
set time_zone='-6:00';
create table t1(a timestamp);
insert into t1 values (19691231190001);
select * from t1;
drop table t1;
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
All date/time functions has the STRING result type thus their results are
compared as strings. The string date representation allows a user to skip
some of leading zeros. This can lead to wrong comparison result if a date/time
function result is compared to such a string constant.
The idea behind this bug fix is to compare results of date/time functions
and data/time constants as ints, because that date/time representation is
more exact. To achieve this the agg_cmp_type() is changed to take in the
account that a date/time field or an date/time item should be compared
as ints.
This bug fix is partially back ported from 5.0.
The agg_cmp_type() function now accepts THD as one of parameters.
In addition, it now checks if a date/time field/function is present in the
list. If so, it tries to coerce all constants to INT to make date/time
comparison return correct result. The field for the constant coercion is
taken from the Item_field or constructed from the Item_func. In latter case
the constructed field will be freed after conversion of all constant items.
Otherwise the result is same as before - aggregated with help of the
item_cmp_type() function.
From the Item_func_between::fix_length_and_dec() function removed the part
which was converting date/time constants to int if possible. Now this is
done by the agg_cmp_type() function.
The new function result_as_longlong() is added to the Item class.
It indicates that the item is a date/time item and result of it can be
compared as int. Such items are date/time fields/functions.
Correct val_int() methods are implemented for classes Item_date_typecast,
Item_func_makedate, Item_time_typecast, Item_datetime_typecast. All these
classes are derived from Item_str_func and Item_str_func::val_int() converts
its string value to int without regard to the date/time type of these items.
Arg_comparator::set_compare_func() and Arg_comparator::set_cmp_func()
functions are changed to substitute result type of an item with the INT_RESULT
if the item is a date/time item and another item is a constant. This is done
to get a correct result of comparisons like date_time_function() = string_constant.
mysql-test/r/cast.result:
Fixed wrong test case result after bug fix#16377.
sql/item_timefunc.h:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
The result_as_longlong() function is set to return TRUE for these classes:
Item_date, Item_date_func, Item_func_curtime, Item_func_sec_to_time,
Item_date_typecast, Item_time_typecast, Item_datetime_typecast,
Item_func_makedate.
sql/item_timefunc.cc:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.Correct val_int() methods are implemented for classes Item_date_typecast,
Item_func_makedate, Item_time_typecast, Item_datetime_typecast.
sql/item_cmpfunc.h:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
Arg_comparator::set_compare_func() and Arg_comparator::set_cmp_func()
functions are changed to substitute result type of an item with the INT_RESULT
if the item is a date/time item and another item is a constant.
sql/field.cc:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
Field::set_warning(), Field::set_datetime_warning() now use current_thd to get thd if table isn't set.
sql/item_cmpfunc.cc:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
The agg_cmp_type() function now accepts THD as one of parameters.
In addition, it now checks if a date/time field/function is present in the
list. If so, it tries to coerce all constants to INT to make date/time
comparison return correct result. The field for the constant coercion is
taken from the Item_field or constructed from the Item_func. In latter case
the constructed field will be freed after conversion of all constant items.
Otherwise the result is same as before - aggregated with help of the
item_cmp_type() function.
sql/item.h:
The new function result_as_longlong() is added to the Item class.
It indicates that the item is a date/time item and result of it can be
compared as int. Such items are date/time fields/functions.
mysql-test/t/func_time.test:
Added test case fot bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
mysql-test/r/func_time.result:
Added test case fot bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
2006-06-13 17:09:24 +02:00
#
# Bug#16377 result of DATE/TIME functions were compared as strings which
# can lead to a wrong result.
2006-09-07 22:59:34 +02:00
# Now wrong dates should be compared only with CAST()
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
All date/time functions has the STRING result type thus their results are
compared as strings. The string date representation allows a user to skip
some of leading zeros. This can lead to wrong comparison result if a date/time
function result is compared to such a string constant.
The idea behind this bug fix is to compare results of date/time functions
and data/time constants as ints, because that date/time representation is
more exact. To achieve this the agg_cmp_type() is changed to take in the
account that a date/time field or an date/time item should be compared
as ints.
This bug fix is partially back ported from 5.0.
The agg_cmp_type() function now accepts THD as one of parameters.
In addition, it now checks if a date/time field/function is present in the
list. If so, it tries to coerce all constants to INT to make date/time
comparison return correct result. The field for the constant coercion is
taken from the Item_field or constructed from the Item_func. In latter case
the constructed field will be freed after conversion of all constant items.
Otherwise the result is same as before - aggregated with help of the
item_cmp_type() function.
From the Item_func_between::fix_length_and_dec() function removed the part
which was converting date/time constants to int if possible. Now this is
done by the agg_cmp_type() function.
The new function result_as_longlong() is added to the Item class.
It indicates that the item is a date/time item and result of it can be
compared as int. Such items are date/time fields/functions.
Correct val_int() methods are implemented for classes Item_date_typecast,
Item_func_makedate, Item_time_typecast, Item_datetime_typecast. All these
classes are derived from Item_str_func and Item_str_func::val_int() converts
its string value to int without regard to the date/time type of these items.
Arg_comparator::set_compare_func() and Arg_comparator::set_cmp_func()
functions are changed to substitute result type of an item with the INT_RESULT
if the item is a date/time item and another item is a constant. This is done
to get a correct result of comparisons like date_time_function() = string_constant.
mysql-test/r/cast.result:
Fixed wrong test case result after bug fix#16377.
sql/item_timefunc.h:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
The result_as_longlong() function is set to return TRUE for these classes:
Item_date, Item_date_func, Item_func_curtime, Item_func_sec_to_time,
Item_date_typecast, Item_time_typecast, Item_datetime_typecast,
Item_func_makedate.
sql/item_timefunc.cc:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.Correct val_int() methods are implemented for classes Item_date_typecast,
Item_func_makedate, Item_time_typecast, Item_datetime_typecast.
sql/item_cmpfunc.h:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
Arg_comparator::set_compare_func() and Arg_comparator::set_cmp_func()
functions are changed to substitute result type of an item with the INT_RESULT
if the item is a date/time item and another item is a constant.
sql/field.cc:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
Field::set_warning(), Field::set_datetime_warning() now use current_thd to get thd if table isn't set.
sql/item_cmpfunc.cc:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
The agg_cmp_type() function now accepts THD as one of parameters.
In addition, it now checks if a date/time field/function is present in the
list. If so, it tries to coerce all constants to INT to make date/time
comparison return correct result. The field for the constant coercion is
taken from the Item_field or constructed from the Item_func. In latter case
the constructed field will be freed after conversion of all constant items.
Otherwise the result is same as before - aggregated with help of the
item_cmp_type() function.
sql/item.h:
The new function result_as_longlong() is added to the Item class.
It indicates that the item is a date/time item and result of it can be
compared as int. Such items are date/time fields/functions.
mysql-test/t/func_time.test:
Added test case fot bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
mysql-test/r/func_time.result:
Added test case fot bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
2006-06-13 17:09:24 +02:00
create table t1(f1 date, f2 time, f3 datetime);
insert into t1 values ("2006-01-01", "12:01:01", "2006-01-01 12:01:01");
insert into t1 values ("2006-01-02", "12:01:02", "2006-01-02 12:01:02");
2006-09-07 22:59:34 +02:00
select f1 from t1 where f1 between CAST("2006-1-1" as date) and CAST(20060101 as date);
select f1 from t1 where f1 between cast("2006-1-1" as date) and cast("2006.1.1" as date);
select f1 from t1 where date(f1) between cast("2006-1-1" as date) and cast("2006.1.1" as date);
select f2 from t1 where f2 between cast("12:1:2" as time) and cast("12:2:2" as time);
select f2 from t1 where time(f2) between cast("12:1:2" as time) and cast("12:2:2" as time);
select f3 from t1 where f3 between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
select f3 from t1 where timestamp(f3) between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
select f1 from t1 where cast("2006-1-1" as date) between f1 and f3;
select f1 from t1 where cast("2006-1-1" as date) between date(f1) and date(f3);
2006-09-18 12:14:27 +02:00
select f1 from t1 where cast("2006-1-1" as date) between f1 and cast('zzz' as date);
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
All date/time functions has the STRING result type thus their results are
compared as strings. The string date representation allows a user to skip
some of leading zeros. This can lead to wrong comparison result if a date/time
function result is compared to such a string constant.
The idea behind this bug fix is to compare results of date/time functions
and data/time constants as ints, because that date/time representation is
more exact. To achieve this the agg_cmp_type() is changed to take in the
account that a date/time field or an date/time item should be compared
as ints.
This bug fix is partially back ported from 5.0.
The agg_cmp_type() function now accepts THD as one of parameters.
In addition, it now checks if a date/time field/function is present in the
list. If so, it tries to coerce all constants to INT to make date/time
comparison return correct result. The field for the constant coercion is
taken from the Item_field or constructed from the Item_func. In latter case
the constructed field will be freed after conversion of all constant items.
Otherwise the result is same as before - aggregated with help of the
item_cmp_type() function.
From the Item_func_between::fix_length_and_dec() function removed the part
which was converting date/time constants to int if possible. Now this is
done by the agg_cmp_type() function.
The new function result_as_longlong() is added to the Item class.
It indicates that the item is a date/time item and result of it can be
compared as int. Such items are date/time fields/functions.
Correct val_int() methods are implemented for classes Item_date_typecast,
Item_func_makedate, Item_time_typecast, Item_datetime_typecast. All these
classes are derived from Item_str_func and Item_str_func::val_int() converts
its string value to int without regard to the date/time type of these items.
Arg_comparator::set_compare_func() and Arg_comparator::set_cmp_func()
functions are changed to substitute result type of an item with the INT_RESULT
if the item is a date/time item and another item is a constant. This is done
to get a correct result of comparisons like date_time_function() = string_constant.
mysql-test/r/cast.result:
Fixed wrong test case result after bug fix#16377.
sql/item_timefunc.h:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
The result_as_longlong() function is set to return TRUE for these classes:
Item_date, Item_date_func, Item_func_curtime, Item_func_sec_to_time,
Item_date_typecast, Item_time_typecast, Item_datetime_typecast,
Item_func_makedate.
sql/item_timefunc.cc:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.Correct val_int() methods are implemented for classes Item_date_typecast,
Item_func_makedate, Item_time_typecast, Item_datetime_typecast.
sql/item_cmpfunc.h:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
Arg_comparator::set_compare_func() and Arg_comparator::set_cmp_func()
functions are changed to substitute result type of an item with the INT_RESULT
if the item is a date/time item and another item is a constant.
sql/field.cc:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
Field::set_warning(), Field::set_datetime_warning() now use current_thd to get thd if table isn't set.
sql/item_cmpfunc.cc:
Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
The agg_cmp_type() function now accepts THD as one of parameters.
In addition, it now checks if a date/time field/function is present in the
list. If so, it tries to coerce all constants to INT to make date/time
comparison return correct result. The field for the constant coercion is
taken from the Item_field or constructed from the Item_func. In latter case
the constructed field will be freed after conversion of all constant items.
Otherwise the result is same as before - aggregated with help of the
item_cmp_type() function.
sql/item.h:
The new function result_as_longlong() is added to the Item class.
It indicates that the item is a date/time item and result of it can be
compared as int. Such items are date/time fields/functions.
mysql-test/t/func_time.test:
Added test case fot bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
mysql-test/r/func_time.result:
Added test case fot bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.
2006-06-13 17:09:24 +02:00
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
select f1 from t1 where makedate(2006,2) between date(f1) and date(f3);
drop table t1;
2006-06-16 22:58:36 +02:00
2006-05-02 15:00:44 +02:00
#
# Bug #16546
#
2006-06-19 10:03:29 +02:00
create table t1 select now() - now(), curtime() - curtime(),
sec_to_time(1) + 0, from_unixtime(1) + 0;
show create table t1;
drop table t1;
2006-05-02 15:00:44 +02:00
2006-08-10 15:37:24 +02:00
#
2006-10-04 15:13:32 +02:00
# Bug #11655: Wrong time is returning from nested selects - maximum time exists
#
# check if SEC_TO_TIME() handles out-of-range values correctly
SELECT SEC_TO_TIME(3300000);
SELECT SEC_TO_TIME(3300000)+0;
SELECT SEC_TO_TIME(3600 * 4294967296);
# check if TIME_TO_SEC() handles out-of-range values correctly
SELECT TIME_TO_SEC('916:40:00');
# check if ADDTIME() handles out-of-range values correctly
SELECT ADDTIME('500:00:00', '416:40:00');
SELECT ADDTIME('916:40:00', '416:40:00');
# check if SUBTIME() handles out-of-range values correctly
SELECT SUBTIME('916:40:00', '416:40:00');
SELECT SUBTIME('-916:40:00', '416:40:00');
# check if MAKETIME() handles out-of-range values correctly
SELECT MAKETIME(916,0,0);
SELECT MAKETIME(4294967296, 0, 0);
SELECT MAKETIME(-4294967296, 0, 0);
SELECT MAKETIME(0, 4294967296, 0);
SELECT MAKETIME(0, 0, 4294967296);
SELECT MAKETIME(CAST(-1 AS UNSIGNED), 0, 0);
# check if EXTRACT() handles out-of-range values correctly
2012-09-08 12:15:55 +02:00
SELECT EXTRACT(HOUR FROM '10000:02:03');
2006-10-04 15:13:32 +02:00
# check if we get proper warnings if both input string truncation
# and out-of-range value occur
CREATE TABLE t1(f1 TIME);
2017-02-08 21:28:00 +01:00
INSERT IGNORE INTO t1 VALUES('916:00:00 a');
2006-10-04 15:13:32 +02:00
SELECT * FROM t1;
DROP TABLE t1;
#
# Bug #20927: sec_to_time treats big unsigned as signed
#
# check if SEC_TO_TIME() handles BIGINT UNSIGNED values correctly
2011-05-28 04:11:32 +02:00
--replace_regex /'1.8446.*e.*19'/'1.84467440737096e+19'/
2006-10-04 15:13:32 +02:00
SELECT SEC_TO_TIME(CAST(-1 AS UNSIGNED));
2006-10-17 18:00:36 +02:00
2006-09-04 09:13:40 +02:00
#
# 21913: DATE_FORMAT() Crashes mysql server if I use it through
# mysql-connector-j driver.
#
SET NAMES latin1;
SET character_set_results = NULL;
SHOW VARIABLES LIKE 'character_set_results';
CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY);
INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd');
SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868;
DROP TABLE testBug8868;
SET NAMES DEFAULT;
2007-10-09 14:58:09 +02:00
#
# Bug #31160: MAKETIME() crashes server when returning NULL in ORDER BY using
# filesort
#
CREATE TABLE t1 (
a TIMESTAMP
);
INSERT INTO t1 VALUES (now()), (now());
SELECT 1 FROM t1 ORDER BY MAKETIME(1, 1, a);
DROP TABLE t1;
2006-08-10 15:37:24 +02:00
#
# Bug #19844 time_format in Union truncates values
#
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H)
union
(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
2006-11-09 13:17:50 +01:00
#
# Bug #23653: crash if last_day('0000-00-00')
#
select last_day('0000-00-00');
2006-12-26 12:08:41 +01:00
#
# Bug 23616: datetime functions with double argumets
#
select isnull(week(now() + 0)), isnull(week(now() + 0.2)),
week(20061108), week(20061108.01), week(20061108085411.000002);
2006-05-16 03:32:24 +02:00
--echo End of 4.1 tests
2005-07-28 16:09:54 +02:00
2005-05-28 01:41:53 +02:00
#
# Bug #10590: %h, %I, and %l format specifies should all return results in
# the 0-11 range
#
select time_format('100:00:00', '%H %k %h %I %l');
2005-08-25 00:50:58 +02:00
#
# Bug #12562: Make SYSDATE behave like it does in Oracle: always the current
# time, regardless of magic to make NOW() always the same for the
# entirety of a statement.
BUG#37975: wait_for_slave_* should increase the timeout
Problem 1: tests often fail in pushbuild with a timeout when waiting
for the slave to start/stop/receive error.
Fix 1: Updated the wait_for_slave_* macros in the following way:
- The timeout is increased by a factor ten
- Refactored the macros so that wait_for_slave_param does the work for
the other macros.
Problem 2: Tests are often incorrectly written, lacking a
source include/wait_for_slave_to_[start|stop].inc.
Fix 2: Improved the chance to get it right by adding
include/start_slave.inc and include/stop_slave.inc, and updated tests
to use these.
Problem 3: The the built-in test language command
wait_for_slave_to_stop is a misnomer (does not wait for the slave io
thread) and does not give as much debug info in case of failure as
the otherwise equivalent macro
source include/wait_for_slave_sql_to_stop.inc
Fix 3: Replaced all calls to the built-in command by a call to the
macro.
Problem 4: Some, but not all, of the wait_for_slave_* macros had an
implicit connection slave. This made some tests confusing to read,
and made it more difficult to use the macro in circular replication
scenarios, where the connection named master needs to wait.
Fix 4: Removed the implicit connection slave from all
wait_for_slave_* macros, and updated tests to use an explicit
connection slave where necessary.
Problem 5: The macros wait_slave_status.inc and wait_show_pattern.inc
were unused. Moreover, using them is difficult and error-prone.
Fix 5: remove these macros.
Problem 6: log_bin_trust_function_creators_basic failed when running
tests because it assumed @@global.log_bin_trust_function_creators=1,
and some tests modified this variable without resetting it to its
original value.
Fix 6: All tests that use this variable have been updated so that
they reset the value at end of test.
mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test:
Replaced wait_for_slave_to_stop by include/wait_for_slave_sql_to_stop.inc
mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test:
Replaced wait_for_slave_to_stop by include/wait_for_slave_sql_to_stop.inc
Added connection slave since includ/wait_for_slave_sql_to_stop.inc
does not do that anymore.
mysql-test/extra/rpl_tests/rpl_log.test:
Replaced start slave+wait_slave_status by start_slave.inc
mysql-test/include/reset_master_and_slave.inc:
replaced start/stop slave by start_slave.inc/stop_slave.inc
mysql-test/include/sync_slave_io_with_master.inc:
Improved comments and error message.
mysql-test/include/wait_for_slave_io_to_stop.inc:
Refactored to use wait_for_slave_param.inc.
Removed connection slave.
mysql-test/include/wait_for_slave_param.inc:
- Improved usage instructions
- Added more debug info in case of timeout
- Added parameters $slave_param_comparison, $slave_timeout,
$slave_keep_connection, $slave_error_message
mysql-test/include/wait_for_slave_sql_error.inc:
Refactored to use wait_for_slave_param.inc.
Removed connection slave.
mysql-test/include/wait_for_slave_sql_to_start.inc:
Refactored to use wait_for_slave_param.inc.
Removed connection slave.
mysql-test/include/wait_for_slave_sql_to_stop.inc:
Refactored to use wait_for_slave_param.inc.
Removed connection slave.
mysql-test/include/wait_for_slave_to_start.inc:
Refactored to use wait_for_slave_param.inc.
Removed connection slave.
mysql-test/include/wait_for_slave_to_stop.inc:
Refactored to use wait_for_slave_param.inc.
Removed connection slave.
mysql-test/include/wait_show_pattern.inc:
Removed unused (and error-prone) file
mysql-test/include/wait_slave_status.inc:
Removed unused (and error-prone) file
mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test:
Renamed $keep_connection to $slave_keep_connection.
mysql-test/suite/rpl/t/rpl_bug26395.test:
Replace stop slave by stop_slave.inc
mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test:
Replace start/stop slave by start_slave.inc/stop_slave.inc.
Replace wait_for_slave_param by wait_for_slave_sql_to_stop.inc.
mysql-test/suite/rpl/t/rpl_dual_pos_advance.test:
Renamed $keep_connection to $slave_keep_connection.
mysql-test/suite/rpl/t/rpl_flushlog_loop.test:
Replace wait_slave_status by start_slave.inc
mysql-test/suite/rpl/t/rpl_idempotency.test:
Added connection slave since wait_for_slave_sql_to_stop.inc does not
do that any more.
mysql-test/suite/rpl/t/rpl_incident.test:
Replaced wait_for_slave_to_stop by wait_for_slave_sql_to_stop.inc
mysql-test/suite/rpl/t/rpl_init_slave.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
Replaced save_master_pos;connection slave;sync_with_master by
sync_slave_with_master.
mysql-test/suite/rpl/t/rpl_log_pos.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
Replaced wait_for_slave_param by other wait_for_slave_* macros.
mysql-test/suite/rpl/t/rpl_packet.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_row_until.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
Replaced save_master_pos;connection slave;sync_with_master by
sync_slave_with_master.
mysql-test/suite/rpl/t/rpl_server_id1.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_slave_grp_exec.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_slave_skip.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_slave_status.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_sp.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/suite/rpl/t/rpl_sp_effects.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/suite/rpl/t/rpl_stm_until.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
Replaced save_master_pos;connection slave;sync_with_master by
sync_slave_with_master.
mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test:
Replaced start slave by start_slave.inc.
Added explicit connection slave since wait_for_slave_sql_to_stop.inc
does not do that anymore.
mysql-test/t/disabled.def:
Disabled failing test.
mysql-test/t/func_time.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/t/grant.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/t/grant2.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/t/innodb_notembedded.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/t/log_bin_trust_function_creators_func.test:
Restore @@global.log_bin_trust_function_creators at end of test.
Clean up at end of test by dropping the created user.
mysql-test/t/query_cache.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/t/query_cache_notembedded.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/t/rpl_init_slave_func.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/t/timezone2.test:
Restore @@global.log_bin_trust_function_creators at end of test.
2008-07-10 18:09:39 +02:00
SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Fix tests for new behaviour: an error is thrown if a NON DETERMINISTIC
stored function (SF) is called during statement-based replication (SBR).
mysql-test/r/func_time.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/r/gis.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Mark function as DETERMINISTIC so it can be called with no error while
doing statement-based replication (SBR).
mysql-test/r/grant2.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/r/innodb_notembedded.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/r/ps.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Mark function as DETERMINISTIC so it can be called with no error while
doing statement-based replication (SBR).
mysql-test/r/query_cache.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/r/query_cache_notembedded.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/r/rpl_sp.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Move test for SF-calls in different replication modes to its own file, rpl_sf.
mysql-test/r/rpl_sp_effects.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/r/sp.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Mark function as DETERMINISTIC so it can be called with no error while
doing statement-based replication (SBR).
mysql-test/r/timezone2.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/func_time.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/gis.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Mark function as DETERMINISTIC so it can be called with no error while
doing statement-based replication (SBR).
mysql-test/t/grant2.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/innodb_notembedded.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/ps.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/query_cache.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/query_cache_notembedded.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/rpl_sp.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/rpl_sp_effects.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/sp.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Mark function as DETERMINISTIC so it can be called with no error while
doing statement-based replication (SBR).
mysql-test/t/timezone2.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
sql/item_func.cc:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
If 'log_bin_trust_function_creators' variable is set, don't throw an error
on calling a non-deterministc function in statement-based replication (SBR).
sql/sql_parse.cc:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Do not throw an error on calling a NON DETERMINISTIC stored procedure (SP)
while doing statement-based replication (SBR), as the routine body is
executed statement-by-statement.
mysql-test/r/rpl_sf.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Test for stored function (SF) calls in different replication modes.
NON DETERMINISTIC SFs are not allowed while doing
statement-based replication (SBR).
mysql-test/t/rpl_sf.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Test for stored function (SF) calls in different replication modes.
NON DETERMINISTIC SFs are not allowed while doing
statement-based replication (SBR).
2006-11-17 21:30:28 +01:00
SET GLOBAL log_bin_trust_function_creators = 1;
2005-08-25 00:50:58 +02:00
create table t1 (a timestamp default '2005-05-05 01:01:01',
b timestamp default '2005-05-05 01:01:01');
delimiter //;
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),
- New optional handler function introduced: reset()
This is called after every DML statement to make it easy for a handler to
statement specific cleanups.
(The only case it's not called is if force the file to be closed)
- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
should be moved to handler::reset()
- table->read_set contains a bitmap over all columns that are needed
in the query. read_row() and similar functions only needs to read these
columns
- table->write_set contains a bitmap over all columns that will be updated
in the query. write_row() and update_row() only needs to update these
columns.
The above bitmaps should now be up to date in all context
(including ALTER TABLE, filesort()).
The handler is informed of any changes to the bitmap after
fix_fields() by calling the virtual function
handler::column_bitmaps_signal(). If the handler does caching of
these bitmaps (instead of using table->read_set, table->write_set),
it should redo the caching in this code. as the signal() may be sent
several times, it's probably best to set a variable in the signal
and redo the caching on read_row() / write_row() if the variable was
set.
- Removed the read_set and write_set bitmap objects from the handler class
- Removed all column bit handling functions from the handler class.
(Now one instead uses the normal bitmap functions in my_bitmap.c instead
of handler dedicated bitmap functions)
- field->query_id is removed. One should instead instead check
table->read_set and table->write_set if a field is used in the query.
- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
instead use table->read_set to check for which columns to retrieve.
- If a handler needs to call Field->val() or Field->store() on columns
that are not used in the query, one should install a temporary
all-columns-used map while doing so. For this, we provide the following
functions:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
field->val();
dbug_tmp_restore_column_map(table->read_set, old_map);
and similar for the write map:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
field->val();
dbug_tmp_restore_column_map(table->write_set, old_map);
If this is not done, you will sooner or later hit a DBUG_ASSERT
in the field store() / val() functions.
(For not DBUG binaries, the dbug_tmp_restore_column_map() and
dbug_tmp_restore_column_map() are inline dummy functions and should
be optimized away be the compiler).
- If one needs to temporary set the column map for all binaries (and not
just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
methods) one should use the functions tmp_use_all_columns() and
tmp_restore_column_map() instead of the above dbug_ variants.
- All 'status' fields in the handler base class (like records,
data_file_length etc) are now stored in a 'stats' struct. This makes
it easier to know what status variables are provided by the base
handler. This requires some trivial variable names in the extra()
function.
- New virtual function handler::records(). This is called to optimize
COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
(stats.records is not supposed to be an exact value. It's only has to
be 'reasonable enough' for the optimizer to be able to choose a good
optimization path).
- Non virtual handler::init() function added for caching of virtual
constants from engine.
- Removed has_transactions() virtual method. Now one should instead return
HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
transactions.
- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
that is to be used with 'new handler_name()' to allocate the handler
in the right area. The xxxx_create_handler() function is also
responsible for any initialization of the object before returning.
For example, one should change:
static handler *myisam_create_handler(TABLE_SHARE *table)
{
return new ha_myisam(table);
}
->
static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
{
return new (mem_root) ha_myisam(table);
}
- New optional virtual function: use_hidden_primary_key().
This is called in case of an update/delete when
(table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
but we don't have a primary key. This allows the handler to take precisions
in remembering any hidden primary key to able to update/delete any
found row. The default handler marks all columns to be read.
- handler::table_flags() now returns a ulonglong (to allow for more flags).
- New/changed table_flags()
- HA_HAS_RECORDS Set if ::records() is supported
- HA_NO_TRANSACTIONS Set if engine doesn't support transactions
- HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
Set if we should mark all primary key columns for
read when reading rows as part of a DELETE
statement. If there is no primary key,
all columns are marked for read.
- HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some
cases (based on table->read_set)
- HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- HA_DUPP_POS Renamed to HA_DUPLICATE_POS
- HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
Set this if we should mark ALL key columns for
read when when reading rows as part of a DELETE
statement. In case of an update we will mark
all keys for read for which key part changed
value.
- HA_STATS_RECORDS_IS_EXACT
Set this if stats.records is exact.
(This saves us some extra records() calls
when optimizing COUNT(*))
- Removed table_flags()
- HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if
handler::records() gives an exact count() and
HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
- HA_READ_RND_SAME Removed (no one supported this one)
- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()
- Renamed handler::dupp_pos to handler::dup_pos
- Removed not used variable handler::sortkey
Upper level handler changes:
- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
cache is updated on engine creation time and updated on open.
MySQL level changes (not obvious from the above):
- DBUG_ASSERT() added to check that column usage matches what is set
in the column usage bit maps. (This found a LOT of bugs in current
column marking code).
- In 5.1 before, all used columns was marked in read_set and only updated
columns was marked in write_set. Now we only mark columns for which we
need a value in read_set.
- Column bitmaps are created in open_binary_frm() and open_table_from_share().
(Before this was in table.cc)
- handler::table_flags() calls are replaced with handler::ha_table_flags()
- For calling field->val() you must have the corresponding bit set in
table->read_set. For calling field->store() you must have the
corresponding bit set in table->write_set. (There are asserts in
all store()/val() functions to catch wrong usage)
- thd->set_query_id is renamed to thd->mark_used_columns and instead
of setting this to an integer value, this has now the values:
MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
Changed also all variables named 'set_query_id' to mark_used_columns.
- In filesort() we now inform the handler of exactly which columns are needed
doing the sort and choosing the rows.
- The TABLE_SHARE object has a 'all_set' column bitmap one can use
when one needs a column bitmap with all columns set.
(This is used for table->use_all_columns() and other places)
- The TABLE object has 3 column bitmaps:
- def_read_set Default bitmap for columns to be read
- def_write_set Default bitmap for columns to be written
- tmp_set Can be used as a temporary bitmap when needed.
The table object has also two pointer to bitmaps read_set and write_set
that the handler should use to find out which columns are used in which way.
- count() optimization now calls handler::records() instead of using
handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).
- Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
- Added TABLE parameter to cp_buffer_from_ref()
- Don't close tables created with CREATE ... SELECT but keep them in
the table cache. (Faster usage of newly created tables).
New interfaces:
- table->clear_column_bitmaps() to initialize the bitmaps for tables
at start of new statements.
- table->column_bitmaps_set() to set up new column bitmaps and signal
the handler about this.
- table->column_bitmaps_set_no_signal() for some few cases where we need
to setup new column bitmaps but don't signal the handler (as the handler
has already been signaled about these before). Used for the momement
only in opt_range.cc when doing ROR scans.
- table->use_all_columns() to install a bitmap where all columns are marked
as use in the read and the write set.
- table->default_column_bitmaps() to install the normal read and write
column bitmaps, but not signaling the handler about this.
This is mainly used when creating TABLE instances.
- table->mark_columns_needed_for_delete(),
table->mark_columns_needed_for_delete() and
table->mark_columns_needed_for_insert() to allow us to put additional
columns in column usage maps if handler so requires.
(The handler indicates what it neads in handler->table_flags())
- table->prepare_for_position() to allow us to tell handler that it
needs to read primary key parts to be able to store them in
future table->position() calls.
(This replaces the table->file->ha_retrieve_all_pk function)
- table->mark_auto_increment_column() to tell handler are going to update
columns part of any auto_increment key.
- table->mark_columns_used_by_index() to mark all columns that is part of
an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
it to quickly know that it only needs to read colums that are part
of the key. (The handler can also use the column map for detecting this,
but simpler/faster handler can just monitor the extra() call).
- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
also mark all columns that is used by the given key.
- table->restore_column_maps_after_mark_index() to restore to default
column maps after a call to table->mark_columns_used_by_index().
- New item function register_field_in_read_map(), for marking used columns
in table->read_map. Used by filesort() to mark all used columns
- Maintain in TABLE->merge_keys set of all keys that are used in query.
(Simplices some optimization loops)
- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
but the field in the clustered key is not assumed to be part of all index.
(used in opt_range.cc for faster loops)
- dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
mark all columns as usable. The 'dbug_' version is primarily intended
inside a handler when it wants to just call Field:store() & Field::val()
functions, but don't need the column maps set for any other usage.
(ie:: bitmap_is_set() is never called)
- We can't use compare_records() to skip updates for handlers that returns
a partial column set and the read_set doesn't cover all columns in the
write set. The reason for this is that if we have a column marked only for
write we can't in the MySQL level know if the value changed or not.
The reason this worked before was that MySQL marked all to be written
columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
bug'.
- open_table_from_share() does not anymore setup temporary MEM_ROOT
object as a thread specific variable for the handler. Instead we
send the to-be-used MEMROOT to get_new_handler().
(Simpler, faster code)
Bugs fixed:
- Column marking was not done correctly in a lot of cases.
(ALTER TABLE, when using triggers, auto_increment fields etc)
(Could potentially result in wrong values inserted in table handlers
relying on that the old column maps or field->set_query_id was correct)
Especially when it comes to triggers, there may be cases where the
old code would cause lost/wrong values for NDB and/or InnoDB tables.
- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
This allowed me to remove some wrong warnings about:
"Some non-transactional changed tables couldn't be rolled back"
- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
(thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
some warnings about
"Some non-transactional changed tables couldn't be rolled back")
- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
which could cause delete_table to report random failures.
- Fixed core dumps for some tests when running with --debug
- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after
crash)
- slow_logs was not properly initialized, which could maybe cause
extra/lost entries in slow log.
- If we get an duplicate row on insert, change column map to read and
write all columns while retrying the operation. This is required by
the definition of REPLACE and also ensures that fields that are only
part of UPDATE are properly handled. This fixed a bug in NDB and
REPLACE where REPLACE wrongly copied some column values from the replaced
row.
- For table handler that doesn't support NULL in keys, we would give an error
when creating a primary key with NULL fields, even after the fields has been
automaticly converted to NOT NULL.
- Creating a primary key on a SPATIAL key, would fail if field was not
declared as NOT NULL.
Cleanups:
- Removed not used condition argument to setup_tables
- Removed not needed item function reset_query_id_processor().
- Field->add_index is removed. Now this is instead maintained in
(field->flags & FIELD_IN_ADD_INDEX)
- Field->fieldnr is removed (use field->field_index instead)
- New argument to filesort() to indicate that it should return a set of
row pointers (not used columns). This allowed me to remove some references
to sql_command in filesort and should also enable us to return column
results in some cases where we couldn't before.
- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
bitmap, which allowed me to use bitmap functions instead of looping over
all fields to create some needed bitmaps. (Faster and smaller code)
- Broke up found too long lines
- Moved some variable declaration at start of function for better code
readability.
- Removed some not used arguments from functions.
(setup_fields(), mysql_prepare_insert_check_table())
- setup_fields() now takes an enum instead of an int for marking columns
usage.
- For internal temporary tables, use handler::write_row(),
handler::delete_row() and handler::update_row() instead of
handler::ha_xxxx() for faster execution.
- Changed some constants to enum's and define's.
- Using separate column read and write sets allows for easier checking
of timestamp field was set by statement.
- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()
- Don't build table->normalized_path as this is now identical to table->path
(after bar's fixes to convert filenames)
- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
do comparision with the 'convert-dbug-for-diff' tool.
Things left to do in 5.1:
- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
Mats has promised to look into this.
- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
(I added several test cases for this, but in this case it's better that
someone else also tests this throughly).
Lars has promosed to do this.
BitKeeper/etc/ignore:
added mysys/test_bitmap
include/base64.h:
Removed my_global.h, as this must be included first in any program
include/heap.h:
Added heap_reset() (Required by new handler interface)
include/my_base.h:
Removed HA_EXTRA_RESET. MySQL will now call ::reset() instead of ::extra(HA_EXTRA_RESET).
HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIVE_PRIMARY key are deleted as the column bitmaps makes these unnecessary
include/my_bitmap.h:
Remove my_pthread.h (should be included at upper level)
Introduced my_bitmap_map typedef to make it the bitmap handling more like a black box
Added bitmap_is_overlapping(), bitmap_test_and_clear(), bitmap_copy() and bitmap_cmp()
Made bitmap_set_bit(), bitmap_flip_bit(), bitmap_clear_bit() return void
include/myisam.h:
Added mi_reset() (Required by new handler interface)
include/myisammrg.h:
Added myrg_reset() (Required by new handler interface)
include/mysql_com.h:
Added flag FIELD_IN_ADD_INDEX to be able to remove Field->add_index
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test:
Added testing of CREATE ... SELECT in a mixed environment
(This found some bugs that Mats is going to fix shortly)
mysql-test/install_test_db.sh:
Simplify ldata usage
Added --tmpdir=. option to mysqld bootstrap (Removed some warnings when TMPDIR was wrongly set)
mysql-test/mysql-test-run.pl:
Added --tmpdir=. to bootstrap
mysql-test/mysql-test-run.sh:
Use copy instead of INSTALL_DB for master and slave databases.
(Speeds up startup time a lot!)
Remove snapshot directories at startup (removes some strange warnings)
mysql-test/r/binlog_row_mix_innodb_myisam.result:
Added testing of CREATE ... SELECT in a mixed environment
(This found some bugs that Mats is going to fix shortly)
mysql-test/r/binlog_stm_mix_innodb_myisam.result:
Added testing of CREATE ... SELECT in a mixed environment
mysql-test/r/create.result:
Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/r/federated.result:
Drop some left over tables
Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/r/func_gconcat.result:
Enable some disabled tests (converted them slightly to be predictable)
mysql-test/r/func_time.result:
Added drop of test function
mysql-test/r/innodb_mysql.result:
Added tests for CREATE ... SELECT
mysql-test/r/insert.result:
More tests
Added testing of duplicate columns in insert
mysql-test/r/loaddata.result:
Added testing LOAD DATA ... SET ...
mysql-test/r/multi_update.result:
Test multi updates and deletes using primary key and without
mysql-test/r/ndb_index_unique.result:
Better error message
mysql-test/r/ndb_replace.result:
New correct result after fixing REPLACE handling with NDB
mysql-test/r/rpl_ddl.result:
Now we don't get these (wrong) warnings anymore
mysql-test/r/view_grant.result:
Drop used views
mysql-test/t/create.test:
Some extra tests of warnings and number of tables opened by CREATE ... SELECT
mysql-test/t/federated.test:
Drop some left over tables
Added testing of multiple table update and multiple table delete (with and without keys)
mysql-test/t/func_gconcat.test:
Enable some disabled tests (converted them slightly to be predictable)
mysql-test/t/func_time.test:
Added drop of test function
mysql-test/t/innodb_mysql.test:
Added tests for CREATE ... SELECT
mysql-test/t/insert.test:
More tests
Added testing of duplicate columns in insert
mysql-test/t/loaddata.test:
Added testing LOAD DATA ... SET ...
mysql-test/t/multi_update.test:
Test multi updates and deletes using primary key and without
mysql-test/t/view_grant.test:
Drop used views
mysql-test/valgrind.supp:
Added supression of not needed warnings when printing stack trace
mysys/base64.c:
Include my_global.h first
mysys/my_bitmap.c:
Added bitmap_is_overlapping(), bitmap_test_and_clear() and bitmap_copy()
Changed logic of bitmap handling to be a bit more efficent (Did this together with Mikael Ronström)
Now the 'extra, not used bits' in the bitmap are assumed to have a 'random value' and the bitmap functions are free to change them whenever needed.
Changed how mutex is allocated to make 'bitmap_free()' function simpler.
mysys/thr_lock.c:
Added 0x before thread pointers (for easier comparison of DBUG traces)
sql/event.cc:
Ensure 'use_all_columns()' is used for event tables
Don't print warning that event table is damaged if it doesn't exists.
sql/field.cc:
Added ASSERT_COLUMN_MARKED_FOR_WRITE in all store() methods and ASSERT_COLUMN_MARKED_FOR_READ in all val() methods to catch wrong setting if table->read_set and table->write_set
(Rest of changes are only indentation cleanups)
sql/field.h:
Removed Field->query_id (replaced by table->read_set and table->write_set)
Removed Field->fieldnr (use Field->field_index instead)
Removed Field->add_index (Use Field->flags instead)
Add Field->part_of_key_not_clustered (for usage in opt_range.cc)
sql/filesort.cc:
Added paramater sort_postion to filesort() to force sorting by position instead of storing all fields in the result set.
This allowed me to remove checking of sql_command.
Create a temporary column bitmap for fields that are used by the sorting process.
Use column bitmaps instead of query_id
sql/ha_berkeley.cc:
Update to 'newer' table handler interface
sql/ha_berkeley.h:
Update to 'newer' table handler interface
sql/ha_federated.cc:
Update to 'newer' table handler interface
Only read columns that are needed from remote server.
In case of eq ranges, don't generate two conditions in the WHERE clause
(this can still be optimized, but would require a bigger code change)
Use 'simpler to use' XXXX_LEN' macros
A bit simpler logic in ::write_row() when creating statements.
In update, only include test of fields actually read.
(This greatly simplifies the queries sent by the federated engine)
Similar changes done for delete_row()
sql/ha_federated.h:
Update to 'newer' table handler interface
Changed XXX_LEN macros to use sizeof(...)-1, to simplify usage in ha_federated.cc
Added HA_PRIMARY_KEY_REQUIRED_FOR_DELETE to tell MySQL to read all primary key columns in case of DELETE
sql/ha_heap.cc:
Update to 'newer' table handler interface
sql/ha_heap.h:
Update to 'newer' table handler interface
sql/ha_innodb.cc:
Update to 'newer' table handler interface
- Update innobase_create_handler() to new interface
- Removed HA_NOT_EXACT_COUNT (not needed)
- Renamed HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- Prefixed base status variables with 'stats'
- Use table column bitmaps instead of ha_get_bit_in_read_set()
- Added ::reset(), with code from ::extra(HA_EXTRA_RESET)
- Removed HA_EXTRA_RETRIVE_ALL_COLS and HA_EXTRA_RETRIEVE_PRIMARY_KEY as
the table->read_set and table->write_set bitmaps now are accurate
sql/ha_innodb.h:
Update to 'newer' table handler interface
- table_flags are now ulonglong
- Added reset() method
- Removed not needed ha_retrieve_all_cols() and ha_retrieve_all_pk() columns.
- Made build_template() a class function to be able to easier access class variables
sql/ha_myisam.cc:
Update to 'newer' table handler interface
sql/ha_myisam.h:
Update to 'newer' table handler interface
sql/ha_myisammrg.cc:
Update to 'newer' table handler interface
sql/ha_myisammrg.h:
Update to 'newer' table handler interface
sql/ha_ndbcluster.cc:
Update to 'newer' table handler interface
Fixed use_blob_value() to be accurate
In ::complemented_read() we have to check both the read and write bitmap as the old code did mark all changed columns also in the read map
Correct dumping of field data with DBUG_DUMP
Prefix addresses in DBUG_PRINT with 0x
Fixed usage of not initialized memory
Update to use field->flags & FIELD_IN_ADD_INDEX instead of field->add_index.
sql/ha_ndbcluster.h:
Update to 'newer' table handler interface
sql/ha_ndbcluster_binlog.cc:
Mark usage of all columns in ndbcluster binlog tables
false -> FALSE, true -> TRUE
Use table->s->all_set instead of creating a temporary bitmap.
sql/ha_partition.cc:
Update to 'newer' table handler interface
Added memroot to initialise_partitions() and related functions to get faster memory allocation.
partition_create_handler() is now responsible for initialisation of the partition object
Some trivial optimizations and indentation fixes
Ensure that table_flags() are up to date
Removed documentation for removed HA_EXTRA flags
Fixed 'strange' usage of m_file[i] in new_handlers_from_part_info()that worked in current code 'by chance'
sql/ha_partition.h:
Update to 'newer' table handler interface
sql/handler.cc:
create_xxx handler now takes MEMROOT as an argument to simplify memory allocation.
Much simpler get_new_handler()
(Initialization of the object is now handled by the create method for the engine)
Moved all allocation of bitmap handling to the TABLE object (in table.cc)
Added column_bitmaps_signal() to signal column usage changes.
Changed binlog_log_row() to use the exiusting all_set bitmap in the table object.
Added ha_reset() function to test that the file object is ok at end of statement and call handler::reset()
Added use_hidden_primary_key() to signal handler that we we are going to read and update + delete the row and the handler should thus remember the position for the row
sql/handler.h:
Added HA_NO_TRANSACTIONS, HA_PARTIAL_COLUMN_READ, HA_REQUIRES_KEY_COLUMNS_FOR_DELETE,HA_PRIMARY_KEY_REQUIRED_FOR_DELETE and HA_HAS_RECORDS
Removed HA_NOT_EXACT_COUNT, HA_READ_RND_SAME
HA_DUPP_POS -> HA_DUPLICATE_POS
HA_NOT_EXACT_COUNT replaced by HA_STATS_RECORDS_IS_EXACT, HA_HAS_RECORDS and records()
HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION
Added future row type 'ROW_TYPE_PAGES'
Added MEM_ROOT to handlerton 'create' function
Added ha_statistics, a structure for all status variable in the base handler class.
Moved all status variables in the handler class into a stats structs to improve readability.
ha_table_flags() is now a cached (not virtual) version of table_flags()
reset() doesn't anymore call extra(HA_EXTRA_RESET) but is a function of it's own.
Renamed dupp_ref to dup_ref
Renamed not used handler::sortkey
Moved read_set and write_set to TABLE structure
handler::init() function added for cacheing of virtual constants from engine.
sql/item.cc:
Added register_field_in_read_map() for marking used columns in expression.
This is used by filesort() for creating an optimal column bitmap while retrieving columns for sorting.
Initalize value.cs_info.character_set_client to fix core dump bug with --debug
set_query_id -> mark_used_columns
Mark used columns in read_set OR write_set.
sql/item.h:
Removed reset_query_id_processor() as it's not needed anymore.
Added register_field_in_read_map()
Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
sql/item_cmpfunc.cc:
Temporary mark used columns to be read/writable
Update Item::walk to new interface
sql/item_cmpfunc.h:
Added extra argument to Item::walk() to indicate if we should also traverse sub queries.
sql/item_func.cc:
Update Item::walk() to new interface
table_flags() -> ha_table_flags()
sql/item_func.h:
Update Item::walk() to new interface
sql/item_row.cc:
Update Item::walk() to new interface
sql/item_row.h:
Update Item::walk() to new interface
sql/item_strfunc.h:
Update Item::walk() to new interface
sql/item_subselect.cc:
Added Item_subselect::walk()
(It was a bug it was missing before. Not sure what kind of bugs this could have caused)
sql/item_subselect.h:
Update Item::walk() to new interface
sql/item_sum.cc:
Update Item::walk() to new interface
Updates for new handler interace
sql/item_sum.h:
Update Item::walk() to new interface
sql/key.cc:
Updates for new handler interace
sql/log.cc:
Mark all columns used for log tables
Split options flag
Ensured that second argument to trans_register_ha is a bool
sql/log_event.cc:
Fixed comments to be withing 79 characters
Use OPTION_KEEP_LOG instead of OPTION_STATUS_NO_TRANS_UPDATE to remove wrong warnings
Updates for new handler interface
Use 0x%lx instead of %p (portability problem)
sql/mysql_priv.h:
Added OPTION_KEEP_LOG to indicate that we should replicate the binlog even on rollback
Removed not used 'conds' argument to setup_tables
sql/mysqld.cc:
Indentation fixes and removed old comment
sql/opt_range.cc:
Update to new handler and bitmap interface.
Fixed calls to cp_buffer_from_ref() and walk() (new argument).
Create new temporary bitmaps for ror scans.
(Needed because of handler changes and to get more accurate column bitmaps than before)
Remove not needed file->ha_reset() call before file->close().
Some trivial optimization and indentation fixes.
Use Field->part_of_key_not_clustered() to check if field is part of a key, instead of looping over all key parts.
Added flag 'in_ror_merged_scan' to allow ::get_next() to know that we need a special column bitmap to only fetch pointer to record.
This is needed because ror scan uses the same TABLE object but different file objects, which creates problem for the column bitmap handling.
(This is a temporary solution. A better one would be to allocate an own TABLE object for ROR scans)
Optimized bitmap handling in ror scans:
- Start bitmap at position 0, not 1
- Use same bitmap size as in TABLE
- Use table->read_set and table->write_set to create column bitmaps instead of looping over all fields in table
sql/opt_range.h:
Added 'in_ror_merged_scan' to indicate if we are doing a ROR scan
Added temporary column bitmaps used in ROR scans
sql/opt_sum.cc:
Added get_ext_record_count() which is used in COUNT() optimization if handler has HA_HAS_RECORDS
Note that we don't call this if handler has HA_STATS_RECORDS_IS_EXACT set.
sql/protocol.cc:
We need to mark columns as readable in ::store() as we sometimes return default value for fields to the user
sql/records.cc:
Updates for new handler interface
sql/set_var.cc:
Handle splitting OPTION_STATUS_NO_TRANS_UPDATE to two flags
sql/share/errmsg.txt:
Fixed wrong
sql/sp.cc:
Mark that we are using all columns for the proc table
Update call to setup_tables() to use new prototype
sql/sp_head.cc:
Removed QQ comment
sql/spatial.cc:
Removed wrong QQ comment
sql/sql_acl.cc:
Mark that we need all columns for acl tables
Supply memroot to some 'new' calls.
Indentation fixes
sql/sql_base.cc:
set_query_id removed
Ensure we call ha_reset() at end of each statement
Mark read columns in read_set and changed columns in write_set (Before all columns was marked in read set)
Fixed marking of some columns that was not proplerly marked before
Maintain in TABLE->merge_keys set of all keys that are used in some way
Removed not used 'conds' argument from setup_tables()
Remove not used setting of 'dupp_field' in insert_fields()
Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after crash)
sql/sql_bitmap.h:
Added is_overlapping()
sql/sql_class.cc:
Slow_logs was not properly initialized, which could maybe cause extra/lost entries in slow log.
set_query_id -> mark_used_columns
Simpler variable usage in pack_row() (cleanup)
Moved some variable declartion at start of function for better code readability
sql/sql_class.h:
Added enum_mark_columns
Updated comments
Renamed dupp_field -> dup_field
Added virtual function 'can_rollback_data()' to select_insert() to be used in CREATE ... SELECT to optimize use of OPTION_STATUS_NO_TRANS_UPDATE.
(This fixes a bug in CREATE ... SELECT where we did give wrong warnings when using non transacational tables)
sql/sql_delete.cc:
Updates to new handler interface
Call table->mark_columns_needed_for_delete() to allow us to put additional columns in column usage maps if handler so requires.
Call table->prepare_for_position() to tell handler that we are going to call ha_position().
Removed call to free_io_cache(). (io_cache is now removed in ha_reset()).
Fixed calls to setup_tables()
sql/sql_do.cc:
Update call to setup_fields()
sql/sql_handler.cc:
Tell handler tables to always read all columns.
Use temporary column map when storing value in field for later index usage
sql/sql_help.cc:
Makr all used fields to be read
Update call to setup_fields()
sql/sql_insert.cc:
Tell handler we are going to update the auto_increment column
dupp_field -> dup_field
Set column usage bits for timestamp field.
Call table->mark_columns_needed_for_insert() and table->mark_auto_increment_column()
Removed not used argument from mysql_prepare_insert_check_table().
If we get an duplicate row on insert, change column map to read and write all columns while retrying the operatation.
This is required by the definition of REPLACE and also ensures that fields that are only part of UPDATE are properly handled.
This fixed a bug in NDB and REPLACE where REPLACE wrongly copied some column values from the replaced row.
Setup new bitmaps for delayed insert rows
Remove reseting of next_number_fields as it will be reset on next call to handler_insert()
Fixed usage of thd->options and OPTION_STATUS_NO_TRANS_UPDATE.
The issue was that one should not to reset this flag as it may be set by a previous statement.
The way it was now used caused us to loose some warnings and get other wrong warnings when using non transactional tables mixed with transactional.
I fixed it by introducing 'select_insert::can_rollback_data' to inform send_error() that the given statement can be rolled back (which in case of CREATE TABLE can always be done)
Don't close tables created with CREATE ... SELECT but keep them in the table cache.
Moved out MY_HOOKS from inside function (better readability)
sql/sql_load.cc:
Update to use new handler and column marking interface
Update using setup_tables()
sql/sql_olap.cc:
Update calls to setup_tables
Use enums instead of constants to setup_fields()
sql/sql_parse.cc:
Handle OPTION_KEEP_LOG:
- Set it on CREATE TEMPORARY TABLE / DROP TABLE
- Reset it when OPTION_STATUS_NO_TRANS_UPDATE is reset
- Don't set it for CREATE ... SELECT (this is handled in select_create class)
Remove reseting of OPTION_STATUS_NO_TRANS_UPDATE in begin_trans() as this should already be reset.
If in autocommit mode, reset OPTION_KEEP_LOG and OPTION_STATUS_NO_TRANS_UPDATE to not give warnings in future commands
sql/sql_partition.cc:
Update walk() usage
Trivial indentation fixes
sql/sql_plugin.cc:
Mark all columns as used for plugins
sql/sql_prepare.cc:
Added assert to find out hidden bugs in character_set_client (got an error in debug binary when this not set correctly)
Updates for new handler interface
Update calls to setup_fields()
sql/sql_repl.cc:
Indentation fixes
sql/sql_select.cc:
Update call to setup_tables() and setup_fields()
Remove some old disabled code
Update to new hadler interface
Indentation cleanups
Added column bitmaps for temporary tables.
Remove updating of the removed slots in the Field class
Added TABLE argument to cp_buffer_from_ref() (To be able to install temporary column maps)
For internal temporary tables, use handler::write_row(), handler::delete_row() and handler::update_row() instead of handler::ha_xxxx() for faster execution.
sql/sql_select.h:
Indentaition fixes.
Install temporary column usage maps when needed
Added TABLE element to cp_buffer_from_ref()
sql/sql_show.cc:
Update to new handler interface
Mark all columns used for internal tables.
Style fixes.
Added support for 'future' ROW_TYPE_PAGES.
Don't allocate TMP_TABLE_PARAM with calloc. The 'init()' function will initialize the structure properly.
sql/sql_table.cc:
Update to new handler interface
Simple my_snprintf -> strmake()
Changed some constants to defines
Don't test for NULL in primary key (as we a couple of line above force the PRIMARY KEY to be NOT NULL)
Change field->add_index to use field->flags & FIELD_IN_ADD_INDEX
Mark all columns as used for ALTER TABLE
Style fixes
Update call to filesort()
sql/sql_trigger.h:
Added friend functions to be able to test if triggers exists for table we are going to insert/update or delete in.
sql/sql_udf.cc:
Mark all columns as used for udf system table.
sql/sql_union.cc:
Update call to walk()
Update to new handler interface
sql/sql_update.cc:
Remove query_id argument from compare_record()
Use column bitmaps instead of query_id.
We can't use compare_records() to skip updates for handlers that returns a partial column set and the read_set doesn't cover all columns in the write set, because compare_record() can't in this case know if a not read column changed value.
Update call to setup_fields()
Using separate column read and write sets allows for easier checking of timestamp field was set by statement.
Removed call to free_io_cache() as this is now done in ha_reset()
Call table->mark_columns_needed_for_update() and table->prepare_for_position()
Style fixes
sql/sql_view.cc:
Style fixes
sql/table.cc:
Remove implicitely include 'errno.h'
Remove code for building normalized path, as this is now identical to 'path'
Remove field->fieldnr
Added update of field->part_of_key_not_clustered()
Create column bitmaps in TABLE and TABLE_SHARE
Don't setup a temporary MEM_ROOT object as a thread specific variable for the handler. Instead we send the to-be-used MEMROOT to get_new_handler()
Update to new handler interface
Update call to walk()
Added new functions:
- st_table::clear_column_bitmaps()
- st_table::prepare_for_position()
- st_table::mark_columns_used_by_index()
- st_table::restore_column_maps_after_mark_index()
- st_table::mark_columns_used_by_index_no_reset()
- st_table::mark_auto_increment_column()
- st_table::mark_columns_needed_for_delete()
- st_table::mark_columns_needed_for_update()
- st_table::mark_columns_needed_for_insert()
sql/table.h:
Moved column usage bitmaps from handler to TABLE
Added to TABLE_SHARE all_set and column_bitmap_size
Added to TABLE merge_keys, bitmap_init_values, def_read_set, def_write_set, tmp_set, read_set and write_set.
Declared all new table column bitmap functions
Added TABLE functions column_bitmaps_set(), column_bitmaps_set_no_signal(), use_all_columns() and default_column_bitmaps()
Added functions: tmp_use_all_columns() and tmp_restore_column_map() to temporarly switch column bitmaps
Added functions: dbug_tmp_use_all_columns() and dbug_tmp_restore_column_map() to temporarly switch column bitmaps to avoid asserts in Field::store() and Field::val().
sql/tztime.cc:
Mark all columns as used for timezone tables
storage/archive/ha_archive.cc:
Update to new handler interface
storage/archive/ha_archive.h:
Update to new handler interface
storage/blackhole/ha_blackhole.cc:
Update to new handler interface
storage/blackhole/ha_blackhole.h:
Update to new handler interface
removed not needed flag HA_DUPP_POS
storage/csv/ha_tina.cc:
Update to new handler interface
storage/csv/ha_tina.h:
Update to new handler interface
storage/example/ha_example.cc:
Update to new handler interface
storage/example/ha_example.h:
Update to new handler interface
storage/heap/hp_extra.c:
Added heap_reset() (Required by new handler interface)
storage/heap/hp_test2.c:
Use heap_reset()
storage/myisam/ft_boolean_search.c:
Fixed compiler warning
storage/myisam/mi_extra.c:
Added mi_reset() (Required by new handler interface)
storage/myisam/mi_search.c:
Fixed DBUG_PRINT messages to use 0x%lx instead of %lx
storage/myisam/mi_test2.c:
Use mi_reset()
storage/myisam/myisampack.c:
Use mi_reset()
storage/myisammrg/myrg_extra.c:
Added myrg_reset() (Required by new handler interface)
unittest/mysys/base64.t.c:
Include my_global.h
Don't include implictely include file 'stdlib.h'
2006-06-04 17:52:22 +02:00
drop function if exists t_slow_sysdate;
2005-08-25 00:50:58 +02:00
create function t_slow_sysdate() returns timestamp
begin
do sleep(2);
return sysdate();
end;
//
insert into t1 set a = sysdate(), b = t_slow_sysdate();//
create trigger t_before before insert on t1
for each row begin
set new.b = t_slow_sysdate();
end
//
delimiter ;//
insert into t1 set a = sysdate();
select a != b from t1;
drop trigger t_before;
drop function t_slow_sysdate;
drop table t1;
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Fix tests for new behaviour: an error is thrown if a NON DETERMINISTIC
stored function (SF) is called during statement-based replication (SBR).
mysql-test/r/func_time.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/r/gis.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Mark function as DETERMINISTIC so it can be called with no error while
doing statement-based replication (SBR).
mysql-test/r/grant2.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/r/innodb_notembedded.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/r/ps.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Mark function as DETERMINISTIC so it can be called with no error while
doing statement-based replication (SBR).
mysql-test/r/query_cache.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/r/query_cache_notembedded.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/r/rpl_sp.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Move test for SF-calls in different replication modes to its own file, rpl_sf.
mysql-test/r/rpl_sp_effects.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/r/sp.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Mark function as DETERMINISTIC so it can be called with no error while
doing statement-based replication (SBR).
mysql-test/r/timezone2.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/func_time.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/gis.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Mark function as DETERMINISTIC so it can be called with no error while
doing statement-based replication (SBR).
mysql-test/t/grant2.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/innodb_notembedded.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/ps.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/query_cache.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/query_cache_notembedded.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/rpl_sp.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/rpl_sp_effects.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
mysql-test/t/sp.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Mark function as DETERMINISTIC so it can be called with no error while
doing statement-based replication (SBR).
mysql-test/t/timezone2.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Modify test that contains non-deterministic functions so it can still be
called with no error while doing statement-based replication (SBR).
sql/item_func.cc:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
If 'log_bin_trust_function_creators' variable is set, don't throw an error
on calling a non-deterministc function in statement-based replication (SBR).
sql/sql_parse.cc:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Do not throw an error on calling a NON DETERMINISTIC stored procedure (SP)
while doing statement-based replication (SBR), as the routine body is
executed statement-by-statement.
mysql-test/r/rpl_sf.result:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Test for stored function (SF) calls in different replication modes.
NON DETERMINISTIC SFs are not allowed while doing
statement-based replication (SBR).
mysql-test/t/rpl_sf.test:
Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
Test for stored function (SF) calls in different replication modes.
NON DETERMINISTIC SFs are not allowed while doing
statement-based replication (SBR).
2006-11-17 21:30:28 +01:00
SET GLOBAL log_bin_trust_function_creators = 0;
2005-08-25 00:50:58 +02:00
create table t1 (a datetime, i int, b datetime);
2010-04-08 11:47:31 +02:00
insert into t1 select sysdate(), sleep(2), sysdate() from dual;
2005-08-25 00:50:58 +02:00
select a != b from t1;
drop table t1;
delimiter //;
create procedure t_sysdate()
begin
select sysdate() into @a;
do sleep(2);
select sysdate() into @b;
select @a != @b;
end;
//
delimiter ;//
call t_sysdate();
drop procedure t_sysdate;
BUG#37975: wait_for_slave_* should increase the timeout
Problem 1: tests often fail in pushbuild with a timeout when waiting
for the slave to start/stop/receive error.
Fix 1: Updated the wait_for_slave_* macros in the following way:
- The timeout is increased by a factor ten
- Refactored the macros so that wait_for_slave_param does the work for
the other macros.
Problem 2: Tests are often incorrectly written, lacking a
source include/wait_for_slave_to_[start|stop].inc.
Fix 2: Improved the chance to get it right by adding
include/start_slave.inc and include/stop_slave.inc, and updated tests
to use these.
Problem 3: The the built-in test language command
wait_for_slave_to_stop is a misnomer (does not wait for the slave io
thread) and does not give as much debug info in case of failure as
the otherwise equivalent macro
source include/wait_for_slave_sql_to_stop.inc
Fix 3: Replaced all calls to the built-in command by a call to the
macro.
Problem 4: Some, but not all, of the wait_for_slave_* macros had an
implicit connection slave. This made some tests confusing to read,
and made it more difficult to use the macro in circular replication
scenarios, where the connection named master needs to wait.
Fix 4: Removed the implicit connection slave from all
wait_for_slave_* macros, and updated tests to use an explicit
connection slave where necessary.
Problem 5: The macros wait_slave_status.inc and wait_show_pattern.inc
were unused. Moreover, using them is difficult and error-prone.
Fix 5: remove these macros.
Problem 6: log_bin_trust_function_creators_basic failed when running
tests because it assumed @@global.log_bin_trust_function_creators=1,
and some tests modified this variable without resetting it to its
original value.
Fix 6: All tests that use this variable have been updated so that
they reset the value at end of test.
mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test:
Replaced wait_for_slave_to_stop by include/wait_for_slave_sql_to_stop.inc
mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test:
Replaced wait_for_slave_to_stop by include/wait_for_slave_sql_to_stop.inc
Added connection slave since includ/wait_for_slave_sql_to_stop.inc
does not do that anymore.
mysql-test/extra/rpl_tests/rpl_log.test:
Replaced start slave+wait_slave_status by start_slave.inc
mysql-test/include/reset_master_and_slave.inc:
replaced start/stop slave by start_slave.inc/stop_slave.inc
mysql-test/include/sync_slave_io_with_master.inc:
Improved comments and error message.
mysql-test/include/wait_for_slave_io_to_stop.inc:
Refactored to use wait_for_slave_param.inc.
Removed connection slave.
mysql-test/include/wait_for_slave_param.inc:
- Improved usage instructions
- Added more debug info in case of timeout
- Added parameters $slave_param_comparison, $slave_timeout,
$slave_keep_connection, $slave_error_message
mysql-test/include/wait_for_slave_sql_error.inc:
Refactored to use wait_for_slave_param.inc.
Removed connection slave.
mysql-test/include/wait_for_slave_sql_to_start.inc:
Refactored to use wait_for_slave_param.inc.
Removed connection slave.
mysql-test/include/wait_for_slave_sql_to_stop.inc:
Refactored to use wait_for_slave_param.inc.
Removed connection slave.
mysql-test/include/wait_for_slave_to_start.inc:
Refactored to use wait_for_slave_param.inc.
Removed connection slave.
mysql-test/include/wait_for_slave_to_stop.inc:
Refactored to use wait_for_slave_param.inc.
Removed connection slave.
mysql-test/include/wait_show_pattern.inc:
Removed unused (and error-prone) file
mysql-test/include/wait_slave_status.inc:
Removed unused (and error-prone) file
mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test:
Renamed $keep_connection to $slave_keep_connection.
mysql-test/suite/rpl/t/rpl_bug26395.test:
Replace stop slave by stop_slave.inc
mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.test:
Replace start/stop slave by start_slave.inc/stop_slave.inc.
Replace wait_for_slave_param by wait_for_slave_sql_to_stop.inc.
mysql-test/suite/rpl/t/rpl_dual_pos_advance.test:
Renamed $keep_connection to $slave_keep_connection.
mysql-test/suite/rpl/t/rpl_flushlog_loop.test:
Replace wait_slave_status by start_slave.inc
mysql-test/suite/rpl/t/rpl_idempotency.test:
Added connection slave since wait_for_slave_sql_to_stop.inc does not
do that any more.
mysql-test/suite/rpl/t/rpl_incident.test:
Replaced wait_for_slave_to_stop by wait_for_slave_sql_to_stop.inc
mysql-test/suite/rpl/t/rpl_init_slave.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
Replaced save_master_pos;connection slave;sync_with_master by
sync_slave_with_master.
mysql-test/suite/rpl/t/rpl_log_pos.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
Replaced wait_for_slave_param by other wait_for_slave_* macros.
mysql-test/suite/rpl/t/rpl_packet.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_row_until.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
Replaced save_master_pos;connection slave;sync_with_master by
sync_slave_with_master.
mysql-test/suite/rpl/t/rpl_server_id1.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_slave_grp_exec.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_slave_skip.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_slave_status.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/suite/rpl/t/rpl_sp.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/suite/rpl/t/rpl_sp_effects.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/suite/rpl/t/rpl_stm_until.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
Replaced save_master_pos;connection slave;sync_with_master by
sync_slave_with_master.
mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test:
Replaced start slave by start_slave.inc.
Added explicit connection slave since wait_for_slave_sql_to_stop.inc
does not do that anymore.
mysql-test/t/disabled.def:
Disabled failing test.
mysql-test/t/func_time.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/t/grant.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/t/grant2.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/t/innodb_notembedded.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/t/log_bin_trust_function_creators_func.test:
Restore @@global.log_bin_trust_function_creators at end of test.
Clean up at end of test by dropping the created user.
mysql-test/t/query_cache.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/t/query_cache_notembedded.test:
Restore @@global.log_bin_trust_function_creators at end of test.
mysql-test/t/rpl_init_slave_func.test:
Replaced start/stop slave by start_slave.inc/stop_slave.inc.
mysql-test/t/timezone2.test:
Restore @@global.log_bin_trust_function_creators at end of test.
2008-07-10 18:09:39 +02:00
SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
2005-08-25 00:50:58 +02:00
2005-10-14 00:32:31 +02:00
#
# Bug #13534: timestampdiff() returned incorrect results across leap years
#
select timestampdiff(month,'2004-09-11','2004-09-11');
select timestampdiff(month,'2004-09-11','2005-09-11');
select timestampdiff(month,'2004-09-11','2006-09-11');
select timestampdiff(month,'2004-09-11','2007-09-11');
select timestampdiff(month,'2005-09-11','2004-09-11');
select timestampdiff(month,'2005-09-11','2003-09-11');
select timestampdiff(month,'2004-02-28','2005-02-28');
select timestampdiff(month,'2004-02-29','2005-02-28');
select timestampdiff(month,'2004-02-28','2005-02-28');
select timestampdiff(month,'2004-03-29','2005-03-28');
select timestampdiff(month,'2003-02-28','2004-02-29');
select timestampdiff(month,'2003-02-28','2005-02-28');
select timestampdiff(month,'1999-09-11','2001-10-10');
select timestampdiff(month,'1999-09-11','2001-9-11');
select timestampdiff(year,'1999-09-11','2001-9-11');
select timestampdiff(year,'2004-02-28','2005-02-28');
select timestampdiff(year,'2004-02-29','2005-02-28');
2006-04-11 19:03:37 +02:00
#
# Bug #18618: BETWEEN for dates with the second argument being a constant
# expression and the first and the third arguments being fields
#
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, day date);
CREATE TABLE t2 (id int NOT NULL PRIMARY KEY, day date);
INSERT INTO t1 VALUES
(1, '2005-06-01'), (2, '2005-02-01'), (3, '2005-07-01');
INSERT INTO t2 VALUES
(1, '2005-08-01'), (2, '2005-06-15'), (3, '2005-07-15');
SELECT * FROM t1, t2
WHERE t1.day BETWEEN
'2005.09.01' - INTERVAL 6 MONTH AND t2.day;
SELECT * FROM t1, t2
WHERE CAST(t1.day AS DATE) BETWEEN
'2005.09.01' - INTERVAL 6 MONTH AND t2.day;
DROP TABLE t1,t2;
2006-06-22 20:23:22 +02:00
# Restore timezone to default
set time_zone= @@global.time_zone;
2006-09-04 07:01:15 +02:00
2006-09-04 06:16:34 +02:00
#
2006-11-29 06:42:59 +01:00
# Bug #22229: bug in DATE_ADD()
2006-09-04 06:16:34 +02:00
#
2006-11-29 06:42:59 +01:00
select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
2011-05-19 19:16:17 +02:00
select str_to_date("1997-00-04 22:23:00","%Y-%m-%D") + interval 10 minute;
2007-01-30 16:43:34 +01:00
Bug #21103: DATE column not compared as DATE
If we compare two items A and B, with B being (a constant) of a
larger type, then A gets promoted to B's type for comparison if
it's a constant, function, or CAST() column, but B gets demoted
to A's type if A is a (not explicitly CAST()) column. This is
counter-intuitive and not mandated by the standard.
Disabling optimisation where it would be lossy so field value
will properly get promoted and compared as binary string (rather
than as integers).
mysql-test/include/ps_conv.inc:
Bug #21103: DATE column not compared as DATE
When comparing a DATE field with a DATETIME constant, we now compare
as DATETIMEs, not as DATEs. Fix certain queries to still work.
mysql-test/r/func_time.result:
Bug #21103: DATE column not compared as DATE
When comparing a DATE field with a DATETIME constant, we now compare
as DATETIMEs, not as DATEs. Show that everything works as expected.
mysql-test/r/ps_2myisam.result:
Bug #21103: DATE column not compared as DATE
When comparing a DATE field with a DATETIME constant, we now compare
as DATETIMEs, not as DATEs. Fix certain queries to still work.
mysql-test/r/ps_3innodb.result:
Bug #21103: DATE column not compared as DATE
When comparing a DATE field with a DATETIME constant, we now compare
as DATETIMEs, not as DATEs. Fix certain queries to still work.
mysql-test/r/ps_4heap.result:
Bug #21103: DATE column not compared as DATE
When comparing a DATE field with a DATETIME constant, we now compare
as DATETIMEs, not as DATEs. Fix certain queries to still work.
mysql-test/r/ps_5merge.result:
Bug #21103: DATE column not compared as DATE
When comparing a DATE field with a DATETIME constant, we now compare
as DATETIMEs, not as DATEs. Fix certain queries to still work.
mysql-test/r/ps_7ndb.result:
Bug #21103: DATE column not compared as DATE
When comparing a DATE field with a DATETIME constant, we now compare
as DATETIMEs, not as DATEs. Fix certain queries to still work.
mysql-test/t/func_time.test:
Bug #21103: DATE column not compared as DATE
When comparing a DATE field with a DATETIME constant, we now compare
as DATETIMEs, not as DATEs. Show that everything works as expected.
sql/field.cc:
Bug #21103: DATE column not compared as DATE
#0 stores the date only as a 3-byte integer; save_in_field() in
#1 saves 'this' in field's format (DATE), #2 "converts a constant
item to an int and replaces the original item" -- consequently,
this replaces the Item_string "2006-11-06 04:08:36.0" with the
Item_int_with_ref 20061106.
#0 Field_newdate::store (this=0x8d26880, from=0x8d5e658 "2006-11-06
04:08:36.0", len=21, cs=0x88022c0) at field.cc:5344
#1 0x0817e3b0 in Item_string::save_in_field (this=0x8d5e670, field=0x8d26880, no_conversions=true) at item.cc:4340
#2 0x081b22ae in convert_constant_item (thd=0x8d25240, field=0x8d26880, item=0x8d5e74c) at item_cmpfunc.cc:245
#3 0x081b8a36 in Item_bool_func2::fix_length_and_dec (this=0x8d5e6f8) at item_cmpfunc.cc:309
#4 0x081a3427 in Item_func::fix_fields (this=0x8d5e6f8, thd=0x8d25240, ref=0x8d5f5fc) at item_func.cc:190
#5 0x0825bc2d in setup_conds (thd=0x8d25240, tables=0x8d5e410, leaves=0x8d5e410, conds=0x8d5f5fc) at sql_base.cc:4941
...
Disabling optimisation where it would be lossy so field value will
properly get promoted and compared as binary string (rather than as
integers).
2007-03-02 15:23:13 +01:00
#
# Bug #21103: DATE column not compared as DATE
#
create table t1 (field DATE);
insert into t1 values ('2006-11-06');
select * from t1 where field < '2006-11-06 04:08:36.0';
select * from t1 where field = '2006-11-06 04:08:36.0';
select * from t1 where field = '2006-11-06';
select * from t1 where CAST(field as DATETIME) < '2006-11-06 04:08:36.0';
select * from t1 where CAST(field as DATE) < '2006-11-06 04:08:36.0';
drop table t1;
2007-01-30 16:43:34 +01:00
#
# Bug #25643: SEC_TO_TIME function problem
#
CREATE TABLE t1 (a int, t1 time, t2 time, d date, PRIMARY KEY (a));
INSERT INTO t1 VALUES (1, '10:00:00', NULL, NULL),
(2, '11:00:00', '11:15:00', '1972-02-06');
SELECT t1, t2, SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) ), QUARTER(d)
FROM t1;
SELECT t1, t2, SEC_TO_TIME( TIME_TO_SEC( t2 ) - TIME_TO_SEC( t1 ) ), QUARTER(d)
FROM t1 ORDER BY a DESC;
DROP TABLE t1;
2007-01-25 17:58:04 +01:00
#
# Bug #20293: group by cuts off value from time_format
#
# Check if using GROUP BY with TIME_FORMAT() produces correct results
SELECT TIME_FORMAT(SEC_TO_TIME(a),"%H:%i:%s") FROM (SELECT 3020399 AS a UNION SELECT 3020398 ) x GROUP BY 1;
2007-08-03 12:25:23 +02:00
#
# Bug#28875 Conversion between ASCII and LATIN1 charsets does not function
#
set names latin1;
create table t1 (a varchar(15) character set ascii not null);
insert into t1 values ('070514-000000');
# Conversion of date_format() result to ASCII
# is safe with the default locale en_US
--replace_column 1 #
select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
# Error for swe7: it is not ASCII compatible
set names swe7;
--error 1267
select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
set names latin1;
# Conversion of date_format() result to ASCII
# is not safe with the non-default locale fr_FR
# because month and day names can have accented characters
set lc_time_names=fr_FR;
--error 1267
select concat(a,ifnull(min(date_format(now(), '%Y-%m-%d')),' ull')) from t1;
set lc_time_names=en_US;
drop table t1;
2007-11-16 17:43:15 +01:00
#
# Bug#32180: DATE_ADD treats datetime numeric argument as DATE
# instead of DATETIME
#
select DATE_ADD('20071108181000', INTERVAL 1 DAY);
select DATE_ADD(20071108181000, INTERVAL 1 DAY);
select DATE_ADD('20071108', INTERVAL 1 DAY);
select DATE_ADD(20071108, INTERVAL 1 DAY);
2007-12-10 09:17:18 +01:00
#
# Bug#32770: LAST_DAY() returns a DATE, but somehow internally keeps
# track of the TIME.
#
select LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND;
2008-02-25 11:25:57 +01:00
# Bug#33834: FRAC_SECOND: Applicability not clear in documentation
#
2010-02-17 10:18:17 +01:00
# Test case removed since FRAC_SECOND was deprecated and
# removed as part of WL#5154
#
2008-02-25 11:25:57 +01:00
2009-11-03 23:29:16 +01:00
#
# Bug #36466:
# Adding days to day_microsecond changes interpretation of microseconds
#
# show that we treat fractions of seconds correctly (zerofill from right to
# six places) even if we left out fields on the left.
select date_add('1000-01-01 00:00:00', interval '1.03:02:01.05' day_microsecond);
select date_add('1000-01-01 00:00:00', interval '1.02' day_microsecond);
2011-02-02 17:51:35 +01:00
--echo #
--echo # Bug #52315 part 2 : utc_date() crashes when system time > year 2037
--echo #
--disable_result_log
SET TIMESTAMP=-147490000; SELECT UTC_TIMESTAMP();
2011-05-28 04:11:32 +02:00
--error 0,ER_WRONG_VALUE_FOR_VAR
2011-02-02 17:51:35 +01:00
SET TIMESTAMP=2147483648; SELECT UTC_TIMESTAMP();
SET TIMESTAMP=2147483646; SELECT UTC_TIMESTAMP();
SET TIMESTAMP=2147483647; SELECT UTC_TIMESTAMP();
SET TIMESTAMP=0; SELECT UTC_TIMESTAMP();
SET TIMESTAMP=-1; SELECT UTC_TIMESTAMP();
SET TIMESTAMP=1; SELECT UTC_TIMESTAMP();
--enable_result_log
2011-02-02 19:10:57 +01:00
#reset back the timestamp value
SET TIMESTAMP=0;
2011-02-02 17:51:35 +01:00
2006-05-16 03:32:24 +02:00
--echo End of 5.0 tests
#
# Bug #18997
#
select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND);
select date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND);
select date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND);
select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND);
select date_sub("0200-01-01 00:00:01",INTERVAL 1 SECOND);
select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND);
select date_add("2001-01-01 23:59:59",INTERVAL -2000 YEAR);
select date_sub("50-01-01 00:00:01",INTERVAL 2 SECOND);
select date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND);
select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND);
select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
2010-08-13 15:05:46 +02:00
#
# Bug #55565: debug assertion when ordering by expressions with user
# variable assignments
#
CREATE TABLE t1(a DOUBLE NOT NULL);
INSERT INTO t1 VALUES (0),(9.216e-096);
--echo # should not crash
SELECT 1 FROM t1 ORDER BY @x:=makedate(a,a);
DROP TABLE t1;
2010-10-31 17:04:38 +01:00
--echo #
--echo # Bug #52160: crash and inconsistent results when grouping
--echo # by a function and column
--echo #
CREATE TABLE t1(a CHAR(10) NOT NULL);
INSERT INTO t1 VALUES (''),('');
SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a);
DROP TABLE t1;
2011-03-28 09:53:18 +02:00
--echo #
--echo # Bug#11766112 59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...
--echo #
SELECT STR_TO_DATE(SPACE(2),'1');
2011-03-28 15:24:25 +02:00
--echo #
--echo # Bug#11765216 58154: UNINITIALIZED VARIABLE FORMAT IN STR_TO_DATE FUNCTION
--echo #
SET GLOBAL SQL_MODE='';
2013-04-09 23:27:19 +02:00
--disable_warnings
2011-03-28 15:24:25 +02:00
DO STR_TO_DATE((''), FROM_DAYS(@@GLOBAL.SQL_MODE));
2013-04-09 23:27:19 +02:00
--enable_warnings
2011-03-28 15:24:25 +02:00
SET GLOBAL SQL_MODE=DEFAULT;
2011-03-28 15:27:44 +02:00
--echo #
--echo # Bug#11766087 59125: VALGRIND UNINITIALISED VALUE WARNING IN ULL2DEC, LONGLONG2DECIMAL
--echo #
SELECT FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1);
2011-03-30 09:00:41 +02:00
--echo #
--echo # Bug#11766126 59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
--echo #
2011-05-28 04:11:32 +02:00
--disable_result_log
2011-03-30 09:00:41 +02:00
SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025));
2011-05-28 04:11:32 +02:00
--enable_result_log
2011-03-30 09:00:41 +02:00
2011-03-30 09:08:35 +02:00
--echo #
--echo # Bug#11766124 59164: VALGRIND: UNINITIALIZED VALUE IN NUMBER_TO_DATETIME
--echo #
SELECT ADDDATE(MONTH(FROM_UNIXTIME(NULL)),INTERVAL 1 HOUR);
2011-04-27 09:35:57 +02:00
--echo #
--echo # Bug#11889186 60503: CRASH IN MAKE_DATE_TIME WITH DATE_FORMAT / STR_TO_DATE COMBINATION
--echo #
SELECT DATE_FORMAT('0000-00-11', '%W');
SELECT DATE_FORMAT('0000-00-11', '%a');
SELECT DATE_FORMAT('0000-00-11', '%w');
2011-05-18 08:47:43 +02:00
--echo #
--echo # Bug#12403504 AFTER FIX FOR #11889186 : ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0
--echo #
SELECT MAKEDATE(11111111,1);
SELECT WEEK(DATE_ADD(FROM_DAYS(1),INTERVAL 1 MONTH), 1);
2011-07-27 10:34:25 +02:00
--echo #
--echo # Bug#12584302 AFTER FIX FOR #12403504: ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0,
--echo #
DO WEEK((DATE_ADD((CAST(0 AS DATE)), INTERVAL 1 YEAR_MONTH)), 5);
2012-01-24 10:00:13 +01:00
--echo #
--echo # BUG#13458237 INCONSISTENT HANDLING OF INVALIDE DATES WITH ZERO DAY
--echo # SIMILAR TO '2009-10-00'
--echo #
query_vertical SELECT
DATE('20091000'),
STR_TO_DATE('200910','%Y%m'),
LAST_DAY('2009-10-00'),
LAST_DAY(DATE('2009-10-00')),
LAST_DAY(DATE'2009-10-00'),
LAST_DAY(STR_TO_DATE('200910','%Y%m')),
WEEK('2009-10-00'),
WEEK(DATE('2009-10-00')),
WEEK(DATE'2009-10-00'),
WEEK(STR_TO_DATE('200910','%Y%m')),
WEEKOFYEAR('2009-10-00'),
WEEKOFYEAR(DATE('2009-10-00')),
WEEKOFYEAR(DATE'2009-10-00'),
WEEKOFYEAR(STR_TO_DATE('200910','%Y%m')),
DAYOFYEAR('2009-10-00'),
DAYOFYEAR(DATE('2009-10-00')),
DAYOFYEAR(DATE'2009-10-00'),
DAYOFYEAR(STR_TO_DATE('200910','%Y%m')),
WEEKDAY('2009-10-00'),
WEEKDAY(DATE('2009-10-00')),
WEEKDAY(DATE'2009-10-00'),
WEEKDAY(STR_TO_DATE('200910','%Y%m')),
TO_DAYs('2009-10-00'),
TO_DAYs(DATE('2009-10-00')),
TO_DAYs(DATE'2009-10-00'),
TO_DAYs(STR_TO_DATE('200910','%Y%m'));
query_vertical SELECT
DATE('00000100'),
STR_TO_DATE('000001','%Y%m'),
LAST_DAY('0000-01-00'),
LAST_DAY(DATE('0000-01-00')),
LAST_DAY(DATE'0000-01-00'),
LAST_DAY(STR_TO_DATE('000001','%Y%m')),
WEEK('0000-01-00'),
WEEK(DATE('0000-01-00')),
WEEK(DATE'0000-01-00'),
WEEK(STR_TO_DATE('000001','%Y%m')),
WEEKOFYEAR('0000-01-00'),
WEEKOFYEAR(DATE('0000-01-00')),
WEEKOFYEAR(DATE'0000-01-00'),
WEEKOFYEAR(STR_TO_DATE('000001','%Y%m')),
DAYOFYEAR('0000-01-00'),
DAYOFYEAR(DATE('0000-01-00')),
DAYOFYEAR(DATE'0000-01-00'),
DAYOFYEAR(STR_TO_DATE('000001','%Y%m')),
WEEKDAY('0000-01-00'),
WEEKDAY(DATE('0000-01-00')),
WEEKDAY(DATE'0000-01-00'),
WEEKDAY(STR_TO_DATE('000001','%Y%m')),
TO_DAYs('0000-01-00'),
TO_DAYs(DATE('0000-01-00')),
TO_DAYs(DATE'0000-01-00'),
TO_DAYs(STR_TO_DATE('000001','%Y%m'));
2006-05-16 03:32:24 +02:00
--echo End of 5.1 tests
2010-10-07 09:07:56 +02:00
--echo #
--echo # Bug#57039: constant subtime expression returns incorrect result.
--echo #
CREATE TABLE t1 (`date_date` datetime NOT NULL);
INSERT INTO t1 VALUES ('2008-01-03 00:00:00'), ('2008-01-03 00:00:00');
SELECT * FROM t1 WHERE date_date >= subtime(now(), "00:30:00");
SELECT * FROM t1 WHERE date_date <= addtime(date_add("2000-1-1", INTERVAL "1:1:1" HOUR_SECOND), "00:20:00");
DROP TABLE t1;
2010-10-20 15:17:29 +02:00
--echo #
--echo # Bug#57512 str_to_date crash...
--echo #
SELECT WEEK(STR_TO_DATE(NULL,0));
SELECT SUBDATE(STR_TO_DATE(NULL,0), INTERVAL 1 HOUR);
2010-10-07 09:07:56 +02:00
--echo #
2011-02-18 09:10:30 +01:00
--echo # BUG#59895 - setting storage engine to null segfaults mysqld
--echo #
SELECT MONTHNAME(0), MONTHNAME(0) IS NULL, MONTHNAME(0) + 1;
--error ER_WRONG_VALUE_FOR_VAR
SET storage_engine=NULL;
2012-01-12 10:02:51 +01:00
--echo #
--echo # BUG#13354387 - CRASH IN IN MY_DECIMAL::OPERATOR FOR VIEW AND FUNCTION UNIX_TIMESTAMP
--echo # Part1 (5.5)
SET time_zone='+03:00';
CREATE TABLE t1 (a DATETIME NOT NULL);
INSERT INTO t1 VALUES ('2009-09-20 07:32:39.06');
INSERT INTO t1 VALUES ('0000-00-00 00:00:00.00');
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT CAST(UNIX_TIMESTAMP(a) AS DECIMAL(25,3)) AS c1 FROM v1 ORDER BY 1;
DROP VIEW v1;
DROP TABLE t1;
SET time_zone=DEFAULT;
2011-02-18 09:10:30 +01:00
--echo #
2011-02-11 16:20:27 +01:00
--echo # Bug #59686 crash in String::copy() with time data type
--echo #
SELECT min(timestampadd(month, 1>'', from_days('%Z')));
2010-10-07 09:07:56 +02:00
2015-09-28 10:51:02 +02:00
SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00');
2011-02-11 16:20:27 +01:00
create table t1(a time);
insert into t1 values ('00:00:00'),('00:01:00');
select 1 from t1 where 1 < some (select cast(a as datetime) from t1);
drop table t1;
2015-09-28 10:51:02 +02:00
SET timestamp=DEFAULT;
2011-10-19 21:45:18 +02:00
2015-12-31 03:01:12 +01:00
--echo #
--echo # Bug #21564557: INCONSISTENT OUTPUT FROM 5.5 AND 5.6
--echo # UNIX_TIMESTAMP(STR_TO_DATE('201506', "%Y%M"
--echo #
SELECT UNIX_TIMESTAMP(STR_TO_DATE('201506', "%Y%m"));
SELECT UNIX_TIMESTAMP('2015-06-00');
SELECT UNIX_TIMESTAMP(STR_TO_DATE('0000-00-00 10:30:30', '%Y-%m-%d %h:%i:%s'));
set sql_mode= 'TRADITIONAL';
SELECT @@sql_mode;
SELECT UNIX_TIMESTAMP(STR_TO_DATE('201506', "%Y%m"));
SELECT UNIX_TIMESTAMP('2015-06-00');
SELECT UNIX_TIMESTAMP(STR_TO_DATE('0000-00-00 10:30:30', '%Y-%m-%d %h:%i:%s'));
set sql_mode= default;
2016-02-09 11:27:40 +01:00
2011-03-18 13:50:39 +01:00
select time('10:10:10') > 10;
select time('10:10:10') > 1010;
select time('10:10:09') > 101010;
select time('10:10:10') > 101010;
select time('10:10:11') > 101010;
wl#173 - temporal types with sub-second resolution
and collateral changes.
* introduce my_hrtime_t, my_timediff_t, and conversion macros
* inroduce TIME_RESULT, but it can only be returned from Item::cmp_type(),
never from Item::result_type()
* pack_time/unpack_time function for "packed" representation of
MYSQL_TIME in a longlong that can be compared
* ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values
* numbers aren't quoted in EXPLAIN EXTENDED
* new column I_S.COLUMNS.DATETIME_PRECISION
* date/time values are compares to anything as date/time, not as strings or numbers.
* old timestamp(X) is no longer supported
* MYSQL_TIME to string conversion functions take precision as an argument
* unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
* Field_timestamp_hires, Field_datetime_hires, Field_time_hires
* Field_temporal
* Lazy_string class to pass a value (string, number, time) polymorphically down the stack
* make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
* removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead
* introduced Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
* in many cases date/time types are treated like other types, not as special cases
* greatly simplified Arg_comparator (regarding date/time/year code)
* SEC_TO_TIME is real function, not integer.
* microsecond precision in NOW, CURTIME, etc
* Item_temporal. All items derived from it only provide get_date, but no val* methods
* replication of NOW(6)
* Protocol::store(time) now takes the precision as an argument
* @@TIMESTAMP is a double
client/mysqlbinlog.cc:
remove unneded casts
include/my_sys.h:
introduce my_hrtime_t, my_timediff_t, and conversion macros
include/my_time.h:
pack_time/unpack_time, etc.
convenience functions to work with MYSQL_TIME::second_part
libmysql/libmysql.c:
str_to_time() is gone. str_to_datetime() does it now.
my_TIME_to_str() takes the precision as an argument
mysql-test/include/ps_conv.inc:
time is not equal to datetime anymore
mysql-test/r/distinct.result:
a test for an old MySQL bug
mysql-test/r/explain.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_default.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_sapdb.result:
when decimals=NOT_FIXED_DEC it means "not fixed" indeed
mysql-test/r/func_test.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_time.result:
ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values
mysql-test/r/having.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/information_schema.result:
new column I_S.COLUMNS.DATETIME_PRECISION
mysql-test/r/join_outer.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/metadata.result:
TIMESTAMP no longer has zerofill flag
mysql-test/r/range.result:
invalid datetime is not compared with as a string
mysql-test/r/select.result:
NO_ZERO_IN_DATE, etc only affect storage - according to the manual
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/subselect.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/sysdate_is_now.result:
when decimals=NOT_FIXED_DEC it means "not fixed" indeed
mysql-test/r/type_blob.result:
TIMESTAMP(N) is not deprecated
mysql-test/r/type_timestamp.result:
old TIMESTAMP(X) semantics is not supported anymore
mysql-test/r/union.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/varbinary.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/t/distinct.test:
test for an old MySQL bug
mysql-test/t/func_time.test:
+- INTERVAL now works with TIME values
mysql-test/t/select.test:
typo
mysql-test/t/subselect.test:
only one error per statement, please
mysql-test/t/system_mysql_db_fix40123.test:
old timestamp(X) is no longer supported
mysql-test/t/system_mysql_db_fix50030.test:
old timestamp(X) is no longer supported
mysql-test/t/system_mysql_db_fix50117.test:
old timestamp(X) is no longer supported
mysql-test/t/type_blob.test:
old timestamp(X) is no longer supported
mysql-test/t/type_timestamp.test:
old timestamp(X) is no longer supported
mysys/my_getsystime.c:
functions to get the time with microsecond precision
mysys/my_init.c:
move the my_getsystime.c initialization code to my_getsystime.c
mysys/my_static.c:
no need to make these variables extern
mysys/my_static.h:
no need to make these variables extern
scripts/mysql_system_tables.sql:
old timestamp(X) is no longer supported
scripts/mysql_system_tables_fix.sql:
old timestamp(X) is no longer supported
scripts/mysqlhotcopy.sh:
old timestamp(X) is no longer supported
sql-common/my_time.c:
* call str_to_time from str_to_datetime, as appropriate
* date/time to string conversions take precision as an argument
* number_to_time()
* TIME_to_double()
* pack_time() and unpack_time()
sql/event_data_objects.cc:
cast is not needed
my_datetime_to_str() takes precision as an argument
sql/event_db_repository.cc:
avoid dangerous downcast (because the pointer is
not always Field_timestamp, see events_1.test)
sql/event_queue.cc:
avoid silly double-work for cond_wait
(having an endpoint of wait, subtract the current time to get the timeout,
and use set_timespec() macro to fill in struct timespec, by adding the current
time to the timeout)
sql/field.cc:
* remove virtual Field::get_time(), everyone should use only Field::get_date()
* remove lots of #ifdef WORDS_BIGENDIAN
* unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
* Field_timestamp_hires, Field_datetime_hires, Field_time_hires
* Field_temporal
* make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
sql/field.h:
* remove virtual Field::get_time(), everyone should use only Field::get_date()
* remove lots of #ifdef WORDS_BIGENDIAN
* unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
* Field_timestamp_hires, Field_datetime_hires, Field_time_hires
* Field_temporal
* make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
* removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead
sql/filesort.cc:
TIME_RESULT, cmp_time()
sql/item.cc:
* numbers aren't quoted in EXPLAIN EXTENDED
* Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
* virtual Item::get_time() is gone
* Item_param::field_type() is set correctly
* Item_datetime, for a datetime constant
* time to anything is compared as a time
* Item_cache::print() prints the value is available
* bug fixed in Item_cache_int::val_str()
sql/item.h:
* Item::print_value(), to be used from Item_xxx::print() when needed
* Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
* virtual Item::get_time() is gone
* Item_datetime, for a datetime constant
* better default for cast_to_int_type()
* Item_cache objects now *always* have the field_type() set
sql/item_cmpfunc.cc:
* get_year_value, get_time_value are gone. get_datetime_value does it all
* get_value_a_func, get_value_b_func are gone
* can_compare_as_dates() is gone too, TIME_RESULT is used instead
* cmp_type() instead or result_type() when doing a comparison
* compare_datetime and compate_e_datetime in the comparator_matrix, is_nulls_eq is gone
* Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
sql/item_cmpfunc.h:
greatly simplified Arg_comparator
sql/item_create.cc:
* fix a bug in error messages in CAST
sql/item_func.cc:
Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
mention all possibitiles in switch over Item_result values, or use default:
sql/item_row.h:
overwrite the default cmp_type() for Item_row,
as no MYSQL_TYPE_xxx value corresponds to ROW_RESULT
sql/item_timefunc.cc:
rewrite make_datetime to support precision argument
SEC_TO_TIME is real function, not integer.
many functions that returned temporal values had duplicate code in val_* methods,
some of them did not have get_date() which resulted in unnecessary date->str->date conversions.
Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods.
many fixes to set decimals (datetime precision) correctly.
sql/item_timefunc.h:
SEC_TO_TIME is real function, not integer.
many functions that returned temporal values had duplicate code in val_* methods,
some of them did not have get_date() which resulted in unnecessary date->str->date conversions.
Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods.
many fixes to set decimals (datetime precision) correctly.
sql/log_event.cc:
replication of NOW(6)
sql/log_event.h:
replication of NOW(6)
sql/mysql_priv.h:
Lazy_string class to pass a value (string, number, time) polymorphically down the stack.
make_truncated_value_warning() that uses it.
sql/mysqld.cc:
datetime in Arg_comparator::comparator_matrix
sql/opt_range.cc:
cleanup: don't disable warnings before calling save_in_field_no_warnings()
sql/protocol.cc:
Protocol::store(time) now takes the precision as an argument
sql/protocol.h:
Protocol::store(time) now takes the precision as an argument
sql/rpl_rli.cc:
small cleanup
sql/set_var.cc:
SET TIMESTAMP=double
sql/set_var.h:
@@TIMESTAMP is a double
sql/share/errmsg.txt:
precision and scale are unsigned
sql/slave.cc:
replication of NOW(6)
sql/sp_head.cc:
cleanup
sql/sql_class.cc:
support for NOW(6)
sql/sql_class.h:
support for NOW(6)
sql/sql_insert.cc:
support for NOW(6)
sql/sql_select.cc:
use item->cmp_type().
move a comment where it belongs
sql/sql_show.cc:
new column I_S.COLUMNS.DATETIME_PRECISION
sql/sql_yacc.yy:
TIME(X), DATETIME(X), cast, NOW(X), CURTIME(X), etc
sql/time.cc:
fix date_add_interval() to support MYSQL_TIMESTAMP_TIME argument
storage/myisam/ha_myisam.cc:
TIMESTAMP no longer carries ZEROFIELD flag, still we keep MYI file compatible.
strings/my_vsnprintf.c:
warnings
tests/mysql_client_test.c:
old timestamp(X) does not work anymore
datetime is no longer equal to time
2011-03-01 13:24:36 +01:00
select time(' 1 02:03:04') + interval 9 microsecond;
select time(' 1 02:03:04') - interval 9 microsecond;
select time('-1 02:03:04') + interval 9 microsecond;
select time('-1 02:03:04') - interval 9 microsecond;
select time(' 1 02:03:04') + interval '4:4:4' hour_second;
select time(' 1 02:03:04') - interval '4:4:4' hour_second;
select time('-1 02:03:04') + interval '4:4:4' hour_second;
select time('-1 02:03:04') - interval '4:4:4' hour_second;
select time(' 1 02:03:04') + interval 2 day;
select time(' 1 02:03:04') - interval 2 day;
select time('-1 02:03:04') + interval 2 day;
select time('-1 02:03:04') - interval 2 day;
2011-06-06 20:28:15 +02:00
select time('10 02:03:04') + interval 30 day;
select time('10 02:03:04') + interval 1 year;
wl#173 - temporal types with sub-second resolution
and collateral changes.
* introduce my_hrtime_t, my_timediff_t, and conversion macros
* inroduce TIME_RESULT, but it can only be returned from Item::cmp_type(),
never from Item::result_type()
* pack_time/unpack_time function for "packed" representation of
MYSQL_TIME in a longlong that can be compared
* ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values
* numbers aren't quoted in EXPLAIN EXTENDED
* new column I_S.COLUMNS.DATETIME_PRECISION
* date/time values are compares to anything as date/time, not as strings or numbers.
* old timestamp(X) is no longer supported
* MYSQL_TIME to string conversion functions take precision as an argument
* unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
* Field_timestamp_hires, Field_datetime_hires, Field_time_hires
* Field_temporal
* Lazy_string class to pass a value (string, number, time) polymorphically down the stack
* make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
* removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead
* introduced Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
* in many cases date/time types are treated like other types, not as special cases
* greatly simplified Arg_comparator (regarding date/time/year code)
* SEC_TO_TIME is real function, not integer.
* microsecond precision in NOW, CURTIME, etc
* Item_temporal. All items derived from it only provide get_date, but no val* methods
* replication of NOW(6)
* Protocol::store(time) now takes the precision as an argument
* @@TIMESTAMP is a double
client/mysqlbinlog.cc:
remove unneded casts
include/my_sys.h:
introduce my_hrtime_t, my_timediff_t, and conversion macros
include/my_time.h:
pack_time/unpack_time, etc.
convenience functions to work with MYSQL_TIME::second_part
libmysql/libmysql.c:
str_to_time() is gone. str_to_datetime() does it now.
my_TIME_to_str() takes the precision as an argument
mysql-test/include/ps_conv.inc:
time is not equal to datetime anymore
mysql-test/r/distinct.result:
a test for an old MySQL bug
mysql-test/r/explain.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_default.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_sapdb.result:
when decimals=NOT_FIXED_DEC it means "not fixed" indeed
mysql-test/r/func_test.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/func_time.result:
ADDTIME()/SUBTIME()/+- INTERVAL now work with TIME values
mysql-test/r/having.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/information_schema.result:
new column I_S.COLUMNS.DATETIME_PRECISION
mysql-test/r/join_outer.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/metadata.result:
TIMESTAMP no longer has zerofill flag
mysql-test/r/range.result:
invalid datetime is not compared with as a string
mysql-test/r/select.result:
NO_ZERO_IN_DATE, etc only affect storage - according to the manual
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/subselect.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/sysdate_is_now.result:
when decimals=NOT_FIXED_DEC it means "not fixed" indeed
mysql-test/r/type_blob.result:
TIMESTAMP(N) is not deprecated
mysql-test/r/type_timestamp.result:
old TIMESTAMP(X) semantics is not supported anymore
mysql-test/r/union.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/r/varbinary.result:
numbers aren't quoted in EXPLAIN EXTENDED
mysql-test/t/distinct.test:
test for an old MySQL bug
mysql-test/t/func_time.test:
+- INTERVAL now works with TIME values
mysql-test/t/select.test:
typo
mysql-test/t/subselect.test:
only one error per statement, please
mysql-test/t/system_mysql_db_fix40123.test:
old timestamp(X) is no longer supported
mysql-test/t/system_mysql_db_fix50030.test:
old timestamp(X) is no longer supported
mysql-test/t/system_mysql_db_fix50117.test:
old timestamp(X) is no longer supported
mysql-test/t/type_blob.test:
old timestamp(X) is no longer supported
mysql-test/t/type_timestamp.test:
old timestamp(X) is no longer supported
mysys/my_getsystime.c:
functions to get the time with microsecond precision
mysys/my_init.c:
move the my_getsystime.c initialization code to my_getsystime.c
mysys/my_static.c:
no need to make these variables extern
mysys/my_static.h:
no need to make these variables extern
scripts/mysql_system_tables.sql:
old timestamp(X) is no longer supported
scripts/mysql_system_tables_fix.sql:
old timestamp(X) is no longer supported
scripts/mysqlhotcopy.sh:
old timestamp(X) is no longer supported
sql-common/my_time.c:
* call str_to_time from str_to_datetime, as appropriate
* date/time to string conversions take precision as an argument
* number_to_time()
* TIME_to_double()
* pack_time() and unpack_time()
sql/event_data_objects.cc:
cast is not needed
my_datetime_to_str() takes precision as an argument
sql/event_db_repository.cc:
avoid dangerous downcast (because the pointer is
not always Field_timestamp, see events_1.test)
sql/event_queue.cc:
avoid silly double-work for cond_wait
(having an endpoint of wait, subtract the current time to get the timeout,
and use set_timespec() macro to fill in struct timespec, by adding the current
time to the timeout)
sql/field.cc:
* remove virtual Field::get_time(), everyone should use only Field::get_date()
* remove lots of #ifdef WORDS_BIGENDIAN
* unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
* Field_timestamp_hires, Field_datetime_hires, Field_time_hires
* Field_temporal
* make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
sql/field.h:
* remove virtual Field::get_time(), everyone should use only Field::get_date()
* remove lots of #ifdef WORDS_BIGENDIAN
* unified the warnings from Field_timestamp/datetime/time/date/newdate store methods
* Field_timestamp_hires, Field_datetime_hires, Field_time_hires
* Field_temporal
* make_truncated_value_warning and Field::set_datetime_warning use Lazy_string as an argument, removed char*/int/double variants
* removed Field::can_be_compared_as_longlong(). Use Field::cmp_type() == INT_RESULT instead
sql/filesort.cc:
TIME_RESULT, cmp_time()
sql/item.cc:
* numbers aren't quoted in EXPLAIN EXTENDED
* Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
* virtual Item::get_time() is gone
* Item_param::field_type() is set correctly
* Item_datetime, for a datetime constant
* time to anything is compared as a time
* Item_cache::print() prints the value is available
* bug fixed in Item_cache_int::val_str()
sql/item.h:
* Item::print_value(), to be used from Item_xxx::print() when needed
* Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
* virtual Item::get_time() is gone
* Item_datetime, for a datetime constant
* better default for cast_to_int_type()
* Item_cache objects now *always* have the field_type() set
sql/item_cmpfunc.cc:
* get_year_value, get_time_value are gone. get_datetime_value does it all
* get_value_a_func, get_value_b_func are gone
* can_compare_as_dates() is gone too, TIME_RESULT is used instead
* cmp_type() instead or result_type() when doing a comparison
* compare_datetime and compate_e_datetime in the comparator_matrix, is_nulls_eq is gone
* Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
sql/item_cmpfunc.h:
greatly simplified Arg_comparator
sql/item_create.cc:
* fix a bug in error messages in CAST
sql/item_func.cc:
Item::cmp_result() instead of Item::is_datetime() and Item::result_as_longlong()
mention all possibitiles in switch over Item_result values, or use default:
sql/item_row.h:
overwrite the default cmp_type() for Item_row,
as no MYSQL_TYPE_xxx value corresponds to ROW_RESULT
sql/item_timefunc.cc:
rewrite make_datetime to support precision argument
SEC_TO_TIME is real function, not integer.
many functions that returned temporal values had duplicate code in val_* methods,
some of them did not have get_date() which resulted in unnecessary date->str->date conversions.
Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods.
many fixes to set decimals (datetime precision) correctly.
sql/item_timefunc.h:
SEC_TO_TIME is real function, not integer.
many functions that returned temporal values had duplicate code in val_* methods,
some of them did not have get_date() which resulted in unnecessary date->str->date conversions.
Now they all are derived from Item_temporal_func and *only* provide get_date, not val* methods.
many fixes to set decimals (datetime precision) correctly.
sql/log_event.cc:
replication of NOW(6)
sql/log_event.h:
replication of NOW(6)
sql/mysql_priv.h:
Lazy_string class to pass a value (string, number, time) polymorphically down the stack.
make_truncated_value_warning() that uses it.
sql/mysqld.cc:
datetime in Arg_comparator::comparator_matrix
sql/opt_range.cc:
cleanup: don't disable warnings before calling save_in_field_no_warnings()
sql/protocol.cc:
Protocol::store(time) now takes the precision as an argument
sql/protocol.h:
Protocol::store(time) now takes the precision as an argument
sql/rpl_rli.cc:
small cleanup
sql/set_var.cc:
SET TIMESTAMP=double
sql/set_var.h:
@@TIMESTAMP is a double
sql/share/errmsg.txt:
precision and scale are unsigned
sql/slave.cc:
replication of NOW(6)
sql/sp_head.cc:
cleanup
sql/sql_class.cc:
support for NOW(6)
sql/sql_class.h:
support for NOW(6)
sql/sql_insert.cc:
support for NOW(6)
sql/sql_select.cc:
use item->cmp_type().
move a comment where it belongs
sql/sql_show.cc:
new column I_S.COLUMNS.DATETIME_PRECISION
sql/sql_yacc.yy:
TIME(X), DATETIME(X), cast, NOW(X), CURTIME(X), etc
sql/time.cc:
fix date_add_interval() to support MYSQL_TIMESTAMP_TIME argument
storage/myisam/ha_myisam.cc:
TIMESTAMP no longer carries ZEROFIELD flag, still we keep MYI file compatible.
strings/my_vsnprintf.c:
warnings
tests/mysql_client_test.c:
old timestamp(X) does not work anymore
datetime is no longer equal to time
2011-03-01 13:24:36 +01:00
# specially constructed queries to reach obscure places in the code
# not touched by the more "normal" queries (and to increase the coverage)
select cast('131415.123e0' as time);
select cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04';
select least(time('1:2:3'), '01:02:04', null) div 1;
select truncate(least(time('1:2:3'), '01:02:04', null), 6);
select cast(least(time('1:2:3'), '01:02:04', null) as decimal(3,1));
select unix_timestamp(null);
select truncate(date('2010-40-10'), 6);
select extract(month from '2010-40-50');
select subtime('0000-00-10 10:10:10', '30 10:00:00');
2011-03-07 23:19:26 +01:00
#
# lp:730637 Valgrind warnings in 5.1-micro
#
2011-03-07 21:57:17 +01:00
select cast(str_to_date(NULL, '%H:%i:%s') as time);
2011-03-07 23:19:26 +01:00
create table t1 (f1 datetime, key (f1));
insert into t1 values ('2000-09-12 00:00:00'), ('2007-04-25 05:08:49');
select * from t1 where f1 > time('-23:00:06');
2011-03-07 21:57:17 +01:00
drop table t1;
2011-03-07 16:27:49 +01:00
#
# lp:730627 TIME_to_ulonglong: Assertion `0' failed in 5.1-micro on wrong argument to MAKETIME
#
select maketime(20,61,10)+0;
2011-03-08 10:14:43 +01:00
#
# lp:731103 Assertion `maybe_null && item->null_value' failed with ORDER BY LAST_DAY()
#
create table t1 (f2 int not null) ;
insert into t1 values (0),(0);
select last_day(f2) from t1;
select last_day(f2) from t1 where last_day(f2) is null;
select * from t1 order by last_day (f2);
drop table t1;
2011-03-09 11:59:47 +01:00
#
# lp:731815 Crash/valgrind warning Item::send with 5.1-micro
#
2014-03-06 21:21:25 +01:00
SET timestamp=unix_timestamp('2001-02-03 10:20:30');
2011-03-09 11:59:47 +01:00
select convert_tz(timediff('0000-00-00 00:00:00', cast('2008-03-26 07:09:06' as datetime)), 'UTC', 'Europe/Moscow');
2014-03-06 21:21:25 +01:00
SET timestamp=DEFAULT;
2011-03-17 15:57:04 +01:00
#
# lp:736370 Datetime functions in subquery context cause wrong result and bogus warnings in mysql-5.1-micr
#
create table t1 (f1 integer, f2 date);
2011-05-19 19:01:46 +02:00
insert into t1 values (1,'2011-05-05'),(2,'2011-05-05'),(3,'2011-05-05'),(4,'2011-05-05'),(5,'2011-05-05'),(6, '2011-05-06');
2011-03-17 18:19:47 +01:00
select * from t1 where 1 and concat(f2)=MAKEDATE(2011, 125);
2011-03-17 15:57:04 +01:00
drop table t1;
#
2011-03-17 22:38:34 +01:00
# lp:736791 Crash in make_truncated_value_warning with LEAST()/GREATEST/COALESCE
2011-03-17 15:57:04 +01:00
#
create table t1 (f1 timestamp);
insert into t1 values ('0000-00-00 00:00:00');
select least(1, f1) from t1;
drop table t1;
2011-03-17 22:04:45 +01:00
#
# lp:737092 Assertion `item->null_value' failed in get_datetime_value in 5.1-micro
#
2014-06-06 08:29:52 +02:00
SET timestamp=UNIX_TIMESTAMP('2014-04-14 10:10:10');
2011-03-17 22:04:45 +01:00
select now() > coalesce(time('21:43:24'), date('2010-05-03'));
2014-06-06 08:29:52 +02:00
SET timestamp=UNIX_TIMESTAMP('2014-04-14 22:22:22');
select now() > coalesce(time('21:43:24'), date('2010-05-03'));
SET timestamp=DEFAULT;
2011-03-17 22:04:45 +01:00
2011-03-17 22:38:34 +01:00
#
# lp:737104 Crash in DTCollation::set in 5.1-micro
#
create table t1 (f1 timestamp);
select * from t1 where f1 > f1 and f1 <=> timestampadd(hour, 9 , '2010-01-01 16:55:35');
drop table t1;
2011-03-18 13:43:33 +01:00
#
# lp:737111 Different behavior for TIMESTAMPADD with 0000-00-00 argument in 5.1-micro
#
create table t1 (f1 date);
insert into t1 values ('0000-00-00');
select timestampadd(week, 1, f1) from t1;
select timestampadd(week, 1, date("0000-00-00"));
drop table t1;
2011-03-18 19:23:32 +01:00
#
# lp:737450 Second Assertion `item->null_value' failed in 5.1-micro
#
create table t1 (f2 time not null, f3 datetime, f4 int not null, f5 timestamp);
insert ignore t1 values ('04:38:11','0000-00-00 00:00:00',0,'0000-00-00 00:00:00');
select least(greatest(f3, f2, f4), f5) from t1;
drop table t1;
2011-03-18 19:29:52 +01:00
#
# lp:737474 Wrong result with DAY(COALESCE(NULL)) in 5.1-micro
#
select day(coalesce(null));
2011-03-19 14:54:46 +01:00
#
# lp:738067 Crash in get_datetime_value() in 5.1-micro
#
select timestamp(greatest('2002-08-20', '0000-00-00 00:00:00'));
2011-03-19 15:19:05 +01:00
#
# lp:738091 cast(timestamp() AS time returns NULL for 0000-00-00 00:00:00 in 5.1-micro
#
create table t1 (f1 datetime);
insert into t1 values ('0000-00-00 00:00:00');
select cast(f1 AS time) from t1;
drop table t1;
2014-06-06 08:29:52 +02:00
SET timestamp=UNIX_TIMESTAMP('2014-06-01 10:20:30');
2011-05-19 19:16:17 +02:00
select greatest(cast("0-0-0" as date), cast("10:20:05" as time));
select greatest(cast("0-0-0" as date), cast("10:20:05" as time)) = '0000-00-00';
2014-06-06 08:29:52 +02:00
select greatest(cast("0-0-0" as date), cast("10:20:05" as time)) = '2014-06-01';
2015-10-01 18:01:35 +02:00
select greatest(cast("0-0-0" as date), cast("10:20:05" as time)) = '2014-06-01 10:20:05';
2011-05-19 19:16:17 +02:00
select cast(greatest(cast("0-0-0" as date), cast("10:20:05" as time)) as datetime(6));
2014-06-06 08:29:52 +02:00
SET timestamp=DEFAULT;
2011-05-19 19:16:17 +02:00
2011-06-09 17:23:39 +02:00
select microsecond('12:00:00.123456'), microsecond('2009-12-31 23:59:59.000010');
2012-08-30 09:05:27 +02:00
--error ER_TOO_BIG_PRECISION
select now(258);
2013-03-20 16:13:00 +01:00
#
# MDEV-4293 Valgrind warnings (Conditional jump or move depends on uninitialised value) in remove_eq_conds on time functions with NULL argument in WHERE
#
SELECT 1 FROM DUAL WHERE YEAR(TIMEDIFF(NULL, '12:12:12'));
SELECT 1 FROM DUAL WHERE MONTH(TIMEDIFF(NULL, '12:12:12'));
SELECT 1 FROM DUAL WHERE DAYOFMONTH(TIMEDIFF(NULL, '12:12:12'));
SELECT 1 FROM DUAL WHERE HOUR(TIMEDIFF(NULL, '12:12:12'));
SELECT 1 FROM DUAL WHERE MINUTE(TIMEDIFF(NULL, '12:12:12'));
SELECT 1 FROM DUAL WHERE SECOND(TIMEDIFF(NULL, '12:12:12'));
2013-06-17 17:25:55 +02:00
2014-04-24 14:59:01 +02:00
--echo #
--echo # MDEV-4511 Assertion `scale <= precision' fails on GROUP BY TIMEDIFF with incorrect types
--echo #
CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
SELECT a FROM t1 GROUP BY TIMEDIFF('2004-06-12',a) * 1;
DROP TABLE t1;
CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
SELECT a FROM t1 GROUP BY ADDTIME(a,'10')*1;
DROP TABLE t1;
CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
SELECT * FROM t1 GROUP BY SEC_TO_TIME(concat(a,'10'))*1;
DROP TABLE t1;
CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
SELECT * FROM t1 GROUP BY ADDTIME(timestamp('2001-01-01 00:00:00'),CAST(a AS SIGNED)&0xF)*1;
DROP TABLE t1;
CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
SELECT * FROM t1 GROUP BY STR_TO_DATE(a,concat('%Y-%m-%d.%f',if(rand(),'','')))*1;
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
STR_TO_DATE('2001-01-01', '%Y-%m-%d') AS date_only,
STR_TO_DATE('10:10:10', '%H:%i:%s') AS time_only,
STR_TO_DATE('10:10:10.123', '%H:%i:%s.%f') AS time_microsecond,
STR_TO_DATE('2001-01-01 10:10:10', '%Y-%m-%d %H:%i:%s') AS date_time,
STR_TO_DATE('2001-01-01 10:10:10.123', '%Y-%m-%d %H:%i:%s.%f') AS date_time_microsecond;
SHOW COLUMNS FROM t1;
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
SEC_TO_TIME(1)+0.1,
SEC_TO_TIME(1.1)+0.1,
SEC_TO_TIME(1.12)+0.1,
SEC_TO_TIME(1.123456)+0.1,
SEC_TO_TIME(1.1234567)+0.1;
SHOW COLUMNS FROM t1;
DROP TABLE t1;
2014-07-28 11:47:55 +02:00
CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))*1;
SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')))*1;
SELECT * FROM t1 GROUP BY (-FROM_UNIXTIME(concat(a,'10')));
SELECT * FROM t1 GROUP BY ABS(FROM_UNIXTIME(concat(a,'10')));
SELECT * FROM t1 GROUP BY @a:=(FROM_UNIXTIME(concat(a,'10'))*1);
DROP TABLE t1;
2013-06-17 17:25:55 +02:00
SET TIME_ZONE='+02:00';
2014-07-28 11:47:55 +02:00
--echo #
--echo # MDEV-6302 Wrong result set when using GROUP BY FROM_UNIXTIME(...)+0
--echo #
CREATE TABLE t1 (a DATE);
INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
SELECT a, FROM_UNIXTIME(CONCAT(a,'10')) AS f1, FROM_UNIXTIME(CONCAT(a,'10'))+0 AS f2 FROM t1;
SELECT * FROM t1 GROUP BY FROM_UNIXTIME(CONCAT(a,'10'))+0;
DROP TABLE t1;
CREATE TABLE t1 (a DATE) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23');
SELECT * FROM t1 GROUP BY FROM_UNIXTIME(concat(a,'10'))/1;
DROP TABLE t1;
CREATE TABLE t1 (a DATE);
INSERT INTO t1 VALUES ('2005-05-04');
SELECT CONCAT(FROM_UNIXTIME(CONCAT(a,'10')) MOD FROM_UNIXTIME(CONCAT(a,'10'))) AS f2 FROM t1;
SELECT CHAR_LENGTH(CONCAT(FROM_UNIXTIME(CONCAT(a,'10')) MOD FROM_UNIXTIME(CONCAT(a,'10')))) AS f2 FROM t1;
2017-02-08 21:28:00 +01:00
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
2014-07-28 11:47:55 +02:00
CREATE TABLE t2 AS SELECT CONCAT(FROM_UNIXTIME(CONCAT(a,'10')) MOD FROM_UNIXTIME(CONCAT(a,'10'))) AS f2 FROM t1;
SHOW CREATE TABLE t2;
SELECT * FROM t2;
DROP TABLE t1,t2;
2013-06-17 17:25:55 +02:00
--echo #
--echo # MDEV-4635 Crash in UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'))
--echo #
SELECT UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'));
2013-09-09 13:32:25 +02:00
2014-08-01 12:04:55 +02:00
SET TIME_ZONE=DEFAULT;
2013-09-09 13:32:25 +02:00
--echo #
--echo # MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context
--echo #
CREATE TABLE t1 (a TIMESTAMP(3));
INSERT INTO t1 VALUES ('2001-01-01 10:20:30.999');
SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2 FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a TIME(3));
INSERT INTO t1 VALUES ('10:20:30.999');
SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2 FROM t1;
DROP TABLE t1;
SELECT
CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
CONCAT(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
TIME(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
DATE(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
TIMESTAMP(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
SELECT
CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1,
CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2,
COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))+0e0 AS c3,
CONCAT(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c4,
TIME(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5,
DATE(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6,
TIMESTAMP(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7;
SELECT
CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
CONCAT(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
TIME(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
DATE(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
TIMESTAMP(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
SELECT
CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1,
CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2,
IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))+0e0 AS c3,
CONCAT(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c4,
TIME(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5,
DATE(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6,
TIMESTAMP(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7;
SELECT
CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
CONCAT(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
TIME(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
DATE(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
TIMESTAMP(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
SELECT
CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2,
IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3,
CONCAT(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4,
TIME(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5,
DATE(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6,
TIMESTAMP(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7;
SELECT
CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1,
CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2,
CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END+0e0 AS c3,
CONCAT(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c4,
TIME(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c5,
DATE(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6,
TIMESTAMP(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7;
SELECT
CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1,
CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2,
CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END+0e0 AS c3,
CONCAT(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c4,
TIME(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c5,
DATE(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6,
TIMESTAMP(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7;
CREATE TABLE t1 AS SELECT
CONCAT(COALESCE(TIME(101010),TIME(101010))) AS c1,
CONCAT(IF(0,TIME(101010),TIME(101010))) AS c2,
CONCAT(IFNULL(TIME(101010),TIME(101010))) AS c3,
CONCAT(CASE WHEN 1 THEN TIME(101010) ELSE TIME(101010) END) AS c4;
SHOW CREATE TABLE t1;
DROP TABLE t1;
2013-09-12 19:31:14 +02:00
2013-09-16 11:52:13 +02:00
--echo #
--echo # MDEV-4870 Wrong values of CASE, COALESCE, IFNULL on a combination of different temporal types
--echo #
2014-06-06 08:29:52 +02:00
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30');
2013-09-16 11:52:13 +02:00
CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE);
INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01');
SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1;
CREATE TABLE t2 AS SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1;
SELECT * FROM t2;
SHOW COLUMNS FROM t2;
DROP TABLE t2;
SELECT CASE WHEN 1 THEN dt2 ELSE t3 END FROM t1;
SELECT CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END) FROM t1;
SELECT CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END) FROM t1;
SELECT CONCAT(CASE WHEN 1 THEN d ELSE t3 END) FROM t1;
SELECT CASE WHEN 1 THEN t3 ELSE d END FROM t1;
SELECT COALESCE(d, t3) FROM t1;
SELECT CONCAT(COALESCE(d, t3)) FROM t1;
SELECT COALESCE(dt2, t3) FROM t1;
SELECT CONCAT(COALESCE(dt2, t3)) FROM t1;
SELECT IFNULL(dt2, t3), CONCAT(IFNULL(dt2, t3)) FROM t1;
SELECT IFNULL(d, t3), CONCAT(IFNULL(d, t3)) FROM t1;
DROP TABLE t1;
2014-06-06 08:29:52 +02:00
SET timestamp=DEFAULT;
2013-09-16 11:52:13 +02:00
2013-09-12 19:31:14 +02:00
--echo #
--echo # MDEV-4724 Some temporal functions do not preserve microseconds
--echo #
SELECT MAKETIME(10,10,10.231);
SELECT MAKETIME(0, 0, 59.9);
CREATE TABLE t1 AS SELECT
MAKETIME(10,00,00),
MAKETIME(10,00,00.1),
MAKETIME(10,00,00.12),
MAKETIME(10,00,00.123),
MAKETIME(10,00,00.1234),
MAKETIME(10,00,00.12345),
MAKETIME(10,00,00.123456);
SHOW COLUMNS FROM t1;
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
TIME('10:00:00'),
TIME('10:00:00.1'),
TIME('10:00:00.12'),
TIME('10:00:00.123'),
TIME('10:00:00.1234'),
TIME('10:00:00.12345'),
TIME('10:00:00.12346');
SHOW COLUMNS FROM t1;
DROP TABLE t1;
SET TIME_ZONE='+00:00';
SET TIMESTAMP=UNIX_TIMESTAMP('2012-10-16 22:46:17');
SELECT NOW(), UNIX_TIMESTAMP(), UNIX_TIMESTAMP(NOW()),UNIX_TIMESTAMP('2012-10-16 22:46:17');
SET TIMESTAMP=UNIX_TIMESTAMP('1970-01-02 03:04:05.123456');
SELECT @@timestamp, FROM_UNIXTIME(@@timestamp);
SET TIME_ZONE=DEFAULT;
SET TIMESTAMP=DEFAULT;
SELECT TIME('2012-10-16 15:54:16.12');
SELECT TIMESTAMP('2012-10-16 15:54:16.12');
SELECT TIMEDIFF('10:10:10.1','00:00:00');
SELECT TIME_TO_SEC('10:10:10');
SELECT ADDTIME(TIME('10:10:10.1'),'10:10:10.12');
SELECT ADDTIME(TIMESTAMP('2001-01-01 10:10:10.1'),'10:10:10.12');
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00.1', INTERVAL 1 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00.12', INTERVAL 1 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00.123', INTERVAL 1 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00.1234', INTERVAL 1 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00.12345', INTERVAL 1 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1234 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12345 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123456 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1234 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND);
SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND);
SELECT CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00');
2013-09-16 08:14:41 +02:00
2013-09-16 12:07:01 +02:00
--echo #
--echo # MDEV-4861 TIME/DATETIME arithmetics does not preserve INTERVAL precision
--echo #
CREATE TABLE t1 (t0 TIME);
INSERT INTO t1 VALUES ('00:00:00');
SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
CREATE TABLE t2 AS SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
SHOW COLUMNS FROM t2;
DROP TABLE t1,t2;
CREATE TABLE t1 (t0 DATETIME);
INSERT INTO t1 VALUES ('2001-01-01 00:00:00');
SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
CREATE TABLE t2 AS SELECT t0 + INTERVAL 1.1 SECOND FROM t1;
SHOW COLUMNS FROM t2;
DROP TABLE t1, t2;
2013-09-16 08:14:41 +02:00
--echo #
--echo # MDEV-4843 Wrong data type for TIMESTAMP('2001-01-01','10:10:10')
--echo #
CREATE TABLE t1 AS SELECT
TIMESTAMP('2001-01-01','10:10:10'),
TIMESTAMP('2001-01-01','10:10:10.1'),
TIMESTAMP('2001-01-01','10:10:10.12'),
TIMESTAMP('2001-01-01','10:10:10.123'),
TIMESTAMP('2001-01-01','10:10:10.1234'),
TIMESTAMP('2001-01-01','10:10:10.12345'),
TIMESTAMP('2001-01-01','10:10:10.123456'),
TIMESTAMP('2001-01-01','10:10:10.1234567');
SHOW COLUMNS FROM t1;
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
TIMESTAMP('2001-01-01 00:00:00','10:10:10'),
TIMESTAMP('2001-01-01 00:00:00.1','10:10:10'),
TIMESTAMP('2001-01-01 00:00:00.12','10:10:10'),
TIMESTAMP('2001-01-01 00:00:00.123','10:10:10'),
TIMESTAMP('2001-01-01 00:00:00.1234','10:10:10'),
TIMESTAMP('2001-01-01 00:00:00.12345','10:10:10'),
TIMESTAMP('2001-01-01 00:00:00.123456','10:10:10'),
TIMESTAMP('2001-01-01 00:00:00.1234567','10:10:10');
SHOW COLUMNS FROM t1;
SELECT * FROM t1;
DROP TABLE t1;
2014-03-06 21:21:25 +01:00
SET timestamp=unix_timestamp('2001-02-03 10:20:30');
2013-09-16 08:14:41 +02:00
CREATE TABLE t1 AS SELECT
TIMESTAMP('00:00:00','10:10:10'),
TIMESTAMP(TIME('00:00:00'),'10:10:10');
SHOW COLUMNS FROM t1;
SELECT * FROM t1;
DROP TABLE t1;
2014-03-06 21:21:25 +01:00
SET timestamp=DEFAULT;
2013-09-16 11:03:49 +02:00
--echo #
--echo # MDEV-4869 Wrong result of MAKETIME(0, 0, -0.1)
--echo #
SELECT MAKETIME(0, 0, -0.1);
2013-12-02 12:09:34 +01:00
--echo #
--echo # MDEV-4857 Wrong result of HOUR('1 00:00:00')
--echo #
2014-03-06 21:21:25 +01:00
SET timestamp=unix_timestamp('2001-02-03 10:20:30');
2013-12-02 12:09:34 +01:00
SELECT HOUR('1 02:00:00'), HOUR('26:00:00');
SELECT HOUR(TIME'1 02:00:00'), HOUR(TIME'26:00:00');
SELECT HOUR(TIME('1 02:00:00')), HOUR(TIME('26:00:00'));
SELECT DAY(TIME('1 02:00:00')), DAY(TIME('26:00:00'));
SELECT EXTRACT(HOUR FROM '1 02:00:00'), EXTRACT(HOUR FROM '26:00:00');
SELECT EXTRACT(HOUR FROM TIME'1 02:00:00'), EXTRACT(HOUR FROM TIME'26:00:00');
SELECT EXTRACT(HOUR FROM TIME('1 02:00:00')), EXTRACT(HOUR FROM TIME('26:00:00'));
SELECT EXTRACT(DAY FROM TIME('1 02:00:00')), EXTRACT(DAY FROM TIME('26:00:00'));
2014-03-06 21:21:25 +01:00
SET timestamp=DEFAULT;
2013-12-19 09:39:40 +01:00
2014-01-27 10:15:40 +01:00
--echo #
--echo # MDEV-5458 RQG hits 'sql/tztime.cc:799: my_time_t sec_since_epoch(int, int, int, int, int, int): Assertion `mon > 0 && mon < 13' failed.'
--echo #
SET TIMESTAMP=UNIX_TIMESTAMP('2014-01-22 18:19:20');
CREATE TABLE t1 (t TIME);
INSERT INTO t1 VALUES ('03:22:30'),('18:30:05');
SELECT CONVERT_TZ(GREATEST(t, CURRENT_DATE()), '+02:00', '+10:00') FROM t1;
SELECT GREATEST(t, CURRENT_DATE()) FROM t1;
DROP TABLE t1;
SET TIMESTAMP=DEFAULT;
2014-01-24 13:50:39 +01:00
--echo #
--echo # MDEV-5504 Server crashes in String::length on SELECT with MONTHNAME, GROUP BY, ROLLUP
--echo #
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (1),(2);
SELECT 1 FROM t1 GROUP BY MONTHNAME(0) WITH ROLLUP;
DROP TABLE t1;
2013-12-19 09:39:40 +01:00
2014-06-04 18:32:57 +02:00
--echo #
--echo # MDEV-6099 Bad results for DATE_ADD(.., INTERVAL 2000000000000000000.0 SECOND)
--echo #
SELECT DATE_ADD('2001-01-01 10:20:30',INTERVAL 250000000000.0 SECOND) AS c1, DATE_ADD('2001-01-01 10:20:30',INTERVAL 2000000000000000000.0 SECOND) AS c2;
2014-06-06 00:07:27 +02:00
2013-12-19 09:39:40 +01:00
--echo #
--echo # MDEV-4838 Wrong metadata for DATE_ADD('string', INVERVAL)
--echo #
--enable_metadata
SELECT DATE_ADD('2011-01-02 12:13:14', INTERVAL 1 MINUTE);
--disable_metadata
2014-02-03 20:29:22 +01:00
--echo #
--echo # MDEV-5450 Assertion `cached_field_ type == MYSQL_TYPE_STRING || ltime.time_type == MYSQL_TIMESTAMP_NONE || mysql_type_to_time_type(cached_field_type) == ltime.time_type' fails with IF, ISNULL, ADDDATE
--echo #
CREATE TABLE t1 (a DATETIME, b DATE);
INSERT INTO t1 VALUES (NULL, '2012-12-21');
SELECT IF(1,ADDDATE(IFNULL(a,b),0),1) FROM t1;
SELECT CAST(ADDDATE(IFNULL(a,b),0) AS CHAR) FROM t1;
SELECT CAST(ADDDATE(COALESCE(a,b),0) AS CHAR) FROM t1;
SELECT CAST(ADDDATE(CASE WHEN 0 THEN a ELSE b END,0) AS CHAR) FROM t1;
SELECT IF(1,ADDTIME(IFNULL(a,b),0),1) FROM t1;
SELECT CAST(ADDTIME(IFNULL(a,b),0) AS CHAR) FROM t1;
SELECT CAST(ADDTIME(COALESCE(a,b),0) AS CHAR) FROM t1;
SELECT CAST(ADDTIME(CASE WHEN 0 THEN a ELSE b END,0) AS CHAR) FROM t1;
DROP TABLE t1;
2014-03-06 21:21:25 +01:00
SET timestamp=unix_timestamp('2001-02-03 10:20:30');
2014-02-03 20:29:22 +01:00
CREATE TABLE t1 (a DATETIME, b TIME);
INSERT INTO t1 VALUES (NULL, '00:20:12');
SELECT IF(1,ADDDATE(IFNULL(a,b),0),1) FROM t1;
SELECT CAST(ADDDATE(IFNULL(a,b),0) AS CHAR) FROM t1;
SELECT CAST(ADDDATE(COALESCE(a,b),0) AS CHAR) FROM t1;
SELECT CAST(ADDDATE(CASE WHEN 0 THEN a ELSE b END,0) AS CHAR) FROM t1;
SELECT IF(1,ADDTIME(IFNULL(a,b),0),1) FROM t1;
SELECT CAST(ADDTIME(IFNULL(a,b),0) AS CHAR) FROM t1;
SELECT CAST(ADDTIME(COALESCE(a,b),0) AS CHAR) FROM t1;
SELECT CAST(ADDTIME(CASE WHEN 0 THEN a ELSE b END,0) AS CHAR) FROM t1;
DROP TABLE t1;
2014-03-06 21:21:25 +01:00
SET timestamp=DEFAULT;
2014-03-23 11:22:44 +01:00
--echo #
--echo # MDEV-5870 Assertion `ltime->neg == 0' fails with COALESCE, ADDDATE, MAKEDATE
--echo #
CREATE TABLE t1 (dt DATETIME);
INSERT INTO t1 VALUES ('2003-05-13 19:36:05'), ('2012-12-12 09:20:06');
SELECT COALESCE(ADDDATE(MAKEDATE(2011,121), dt), '2006-09-12' ) FROM t1;
DROP TABLE t1;
2014-06-06 08:29:52 +02:00
--echo #
--echo # MDEV-6101 Hybrid functions do not add CURRENT_DATE when converting TIME to DATETIME
--echo #
SET timestamp=UNIX_TIMESTAMP('2014-04-15 01:02:03');
SELECT IF(1,TIME'10:20:30',DATE'2001-01-01');
SELECT IFNULL(TIME'10:20:30',DATE'2001-01-01');
SELECT CASE WHEN 1 THEN TIME'10:20:30' ELSE DATE'2001-01-01' END;
SELECT COALESCE(TIME'10:20:30',DATE'2001-01-01');
SET timestamp=DEFAULT;
2014-07-23 11:38:48 +02:00
--echo #
--echo # MDEV-5750 Assertion `ltime->year == 0' fails on a query with EXTRACT DAY_MINUTE and TIME column
--echo #
2015-10-01 18:01:35 +02:00
SET timestamp=UNIX_TIMESTAMP('2010-01-01 00:00:00');
2014-07-23 11:38:48 +02:00
CREATE TABLE t1 ( d DATE, t TIME );
INSERT INTO t1 VALUES ('2008-12-05','22:34:09'),('2005-03-27','14:26:02');
SELECT EXTRACT(DAY_MINUTE FROM GREATEST(t,d)), GREATEST(t,d) FROM t1;
DROP TABLE t1;
2015-10-01 18:01:35 +02:00
SET timestamp=DEFAULT;
2014-12-16 12:33:13 +01:00
--echo #
--echo # MDEV-7221 from_days fails after null value
--echo #
CREATE TABLE t1 (
id INT(11) NOT NULL PRIMARY KEY,
date1 DATE NULL DEFAULT NULL
);
INSERT INTO t1 VALUES (12, '2011-05-12');
INSERT INTO t1 VALUES (13, NULL);
INSERT INTO t1 VALUES (14, '2009-10-23');
INSERT INTO t1 VALUES (15, '2014-10-30');
INSERT INTO t1 VALUES (16, NULL);
INSERT INTO t1 VALUES (17, NULL);
INSERT INTO t1 VALUES (18, '2010-10-13');
SELECT a.id,a.date1,FROM_DAYS(TO_DAYS(a.date1)-10) as date2, DATE_ADD(a.date1,INTERVAL -10 DAY),TO_DAYS(a.date1)-10 FROM t1 a ORDER BY a.id;
DROP TABLE t1;
2015-06-15 09:04:06 +02:00
2016-12-19 11:28:08 +01:00
--echo #
--echo # MDEV-10524 Assertion `arg1_int >= 0' failed in Item_func_additive_op::result_precision()
--echo #
SELECT 1 MOD ADDTIME( '13:58:57', '00:00:01' ) + 2;
2017-01-06 16:09:59 +01:00
2017-10-06 16:23:40 +02:00
--echo #
--echo # MDEV-11819 NO_ZERO_IN_DATE: Incorrect generated column value
--echo #
SET sql_mode='NO_ZERO_IN_DATE';
CREATE TABLE t1 (a TIME(6));
INSERT INTO t1 SELECT timediff(timestamp'2008-12-31 23:59:59.000001',timestamp'2008-12-30 01:01:01.000002');
SELECT * FROM t1;
DROP TABLE t1;
SET sql_mode=DEFAULT;
2017-10-10 08:35:12 +02:00
--echo #
--echo # MDEV-13972 crash in Item_func_sec_to_time::get_date
--echo #
# The below query can return warning sporadically
--disable_warnings
DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(UUID()))));
--enable_warnings
DO TO_DAYS(SEC_TO_TIME(MAKEDATE('',RAND(~('')))));
SELECT SEC_TO_TIME(MAKEDATE(0,RAND(~0)));
2018-08-11 12:11:59 +02:00
#
# MDEV-16810 AddressSanitizer: stack-buffer-overflow in int10_to_str
#
SELECT PERIOD_DIFF(2018, AES_ENCRYPT('Rae Bareli', 'Rae Bareli'));
2015-06-15 09:04:06 +02:00
2018-09-20 14:02:58 +02:00
--echo #
--echo # MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result
--echo #
--vertical_results
SELECT
MAKETIME(1e10,0,0),
MAKETIME(-1e10,0,0),
MAKETIME(1e50,0,0),
MAKETIME(-1e50,0,0),
MAKETIME(COALESCE(1e50),0,0),
MAKETIME(COALESCE(-1e50),0,0);
--horizontal_results
CREATE TABLE t1 (a FLOAT);
INSERT INTO t1 VALUES (1e30),(-1e30);
SELECT MAKETIME(a,0,0) FROM t1;
DROP TABLE t1;
2018-09-20 14:51:56 +02:00
--echo #
--echo # MDEV-17244 MAKETIME(900,0,0.111) returns a wrong result
--echo #
SELECT MAKETIME(900,0,0);
SELECT MAKETIME(900,0,0.1);
SELECT MAKETIME(900,0,0.11);
SELECT MAKETIME(900,0,0.111);
SELECT MAKETIME(900,0,0.1111);
SELECT MAKETIME(900,0,0.11111);
SELECT MAKETIME(900,0,0.111111);
SELECT MAKETIME(900,0,0.1111111);
SELECT MAKETIME(900,0,0.11111111);
SELECT MAKETIME(900,0,0.111111111);
SELECT MAKETIME(900,0,EXP(1));
SELECT MAKETIME(-900,0,0);
SELECT MAKETIME(-900,0,0.1);
SELECT MAKETIME(-900,0,0.11);
SELECT MAKETIME(-900,0,0.111);
SELECT MAKETIME(-900,0,0.1111);
SELECT MAKETIME(-900,0,0.11111);
SELECT MAKETIME(-900,0,0.111111);
SELECT MAKETIME(-900,0,0.1111111);
SELECT MAKETIME(-900,0,0.11111111);
SELECT MAKETIME(-900,0,0.111111111);
SELECT MAKETIME(-900,0,EXP(1));
2018-09-20 14:02:58 +02:00
2015-06-15 09:04:06 +02:00
--echo #
2017-10-06 16:23:40 +02:00
--echo # End of 5.5 tests
2015-06-15 09:04:06 +02:00
--echo #
--echo #
--echo # MDEV-8205 timediff returns null when comparing decimal time to time string value
--echo #
# 1h difference
SELECT
TIMEDIFF('2014-01-01 00:00:00' , '2014-01-01 01:00:00' ) AS str_str,
TIMEDIFF('2014-01-01 00:00:00' , 20140101010000.000 ) AS str_dec,
TIMEDIFF(20140101000000.000 , 20140101010000.000 ) AS dec_dec,
TIMEDIFF(20140101000000.000 , '2014-01-01 01:00:00' ) AS dec_str;
# 1D1h difference
SELECT
TIMEDIFF('2014-01-01 00:00:00' , '2014-01-02 01:00:00' ) AS str_str,
TIMEDIFF('2014-01-01 00:00:00' , 20140102010000.000 ) AS str_dec,
TIMEDIFF(20140101000000.000 , 20140102010000.000 ) AS dec_dec,
TIMEDIFF(20140101000000.000 , '2014-01-02 01:00:00' ) AS dec_str;
# 1M1D1h difference
SELECT
TIMEDIFF('2014-01-01 00:00:00' , '2014-02-02 01:00:00' ) AS str_str,
TIMEDIFF('2014-01-01 00:00:00' , 20140202010000.000 ) AS str_dec,
TIMEDIFF(20140101000000.000 , 20140202010000.000 ) AS dec_dec,
TIMEDIFF(20140101000000.000 , '2014-02-02 01:00:00' ) AS dec_str;
# 2M1D1h difference
SELECT
TIMEDIFF('2014-01-01 00:00:00' , '2014-03-02 01:00:00' ) AS str_str,
TIMEDIFF('2014-01-01 00:00:00' , 20140302010000.000 ) AS str_dec,
TIMEDIFF(20140101000000.000 , 20140302010000.000 ) AS dec_dec,
TIMEDIFF(20140101000000.000 , '2014-03-02 01:00:00' ) AS dec_str;
2016-12-07 15:05:13 +01:00
--echo #
--echo # MDEV-10787 Assertion `ltime->neg == 0' failed in void date_to_datetime(MYSQL_TIME*)
--echo #
CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('2005-07-20'),('2012-12-21');
SELECT REPLACE( ADDDATE( d, INTERVAL 0.6732771076944444 HOUR_SECOND ), '2', 'x' ) FROM t1;
SELECT REPLACE( ADDDATE( d, INTERVAL '0.6732771076944444' HOUR_SECOND ), '2', 'x' ) FROM t1;
SELECT CAST(ADDDATE( d, INTERVAL 6732771076944444 SECOND) AS CHAR) FROM t1;
SELECT CAST(ADDDATE( d, INTERVAL '67327710769444:44' HOUR_SECOND) AS CHAR) FROM t1;
SELECT CAST(ADDDATE( d, INTERVAL '673277107694:44:44' HOUR_SECOND) AS CHAR) FROM t1;
DROP TABLE t1;
# Maximum possible DAY_SECOND values in various formats
SELECT ADDDATE(DATE'0000-01-01', INTERVAL '3652423:23:59:59' DAY_SECOND);
SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:87658175:59:59' DAY_SECOND);
SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:0:5259490559:59' DAY_SECOND);
SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:0:0:315569433599' DAY_SECOND);
# Out-of-range INTERVAL DAY_SECOND values
SELECT ADDDATE(DATE'0000-01-01', INTERVAL '3652423:0:0:315569433559' DAY_SECOND);
SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:87658175:0:315569433559' DAY_SECOND);
SELECT ADDDATE(DATE'0000-01-01', INTERVAL '0:0:5259490559:315569433599' DAY_SECOND);
2018-03-13 09:42:41 +01:00
--echo #
--echo # MDEV-13202 Assertion `ltime->neg == 0' failed in date_to_datetime
--echo #
CREATE TABLE t1 (i INT, d DATE);
INSERT INTO t1 VALUES (1, '1970-01-01');
SELECT MAX(NULLIF(i,1)) FROM t1 ORDER BY DATE_SUB(d,INTERVAL 17300000 HOUR);
DROP TABLE t1;
CREATE TABLE t1 (i INT, d DATE);
INSERT INTO t1 VALUES (1, '1970-01-01');
SELECT CONCAT(DATE_SUB(d, INTERVAL 17300000 HOUR)) FROM t1;
DROP TABLE t1;
SELECT CONCAT(DATE_SUB(TIMESTAMP'1970-01-01 00:00:00', INTERVAL 17300000 HOUR));
2016-12-07 15:05:13 +01:00
2015-06-15 09:04:06 +02:00
--echo #
--echo # End of 10.0 tests
--echo #
2016-07-03 11:52:06 +02:00
--echo #
--echo # Start of 10.1 tests
--echo #
--echo #
--echo # MDEV-10317 EXCTACT(MINUTE_MICROSECOND) truncates data
--echo #
let $query=
SELECT
a,
EXTRACT(YEAR FROM a),
EXTRACT(YEAR_MONTH FROM a),
EXTRACT(QUARTER FROM a),
EXTRACT(MONTH FROM a),
EXTRACT(WEEK FROM a),
EXTRACT(DAY FROM a),
EXTRACT(DAY_HOUR FROM a),
EXTRACT(DAY_MINUTE FROM a),
EXTRACT(DAY_SECOND FROM a),
EXTRACT(HOUR FROM a),
EXTRACT(HOUR_MINUTE FROM a),
EXTRACT(HOUR_SECOND FROM a),
EXTRACT(MINUTE FROM a),
EXTRACT(MINUTE_SECOND FROM a),
EXTRACT(SECOND FROM a),
EXTRACT(MICROSECOND FROM a),
EXTRACT(DAY_MICROSECOND FROM a),
EXTRACT(HOUR_MICROSECOND FROM a),
EXTRACT(MINUTE_MICROSECOND FROM a),
EXTRACT(SECOND_MICROSECOND FROM a)
FROM t1;
CREATE TABLE t1 (a DATETIME(6));
INSERT INTO t1 VALUES ('1999-12-31 23:59:59.999999');
--vertical_results
--enable_metadata
--disable_ps_protocol
--eval $query
--enable_ps_protocol
--disable_metadata
--horizontal_results
--eval CREATE TABLE t2 AS $query
--vertical_results
SELECT * FROM t2;
--horizontal_results
SHOW CREATE TABLE t2;
DROP TABLE t1,t2;
CREATE TABLE t1 (a TIME(6));
INSERT INTO t1 VALUES ('-838:59:59.999999'),('838:59:59.999999');
--vertical_results
--enable_metadata
--disable_ps_protocol
--eval $query
--enable_ps_protocol
--disable_metadata
--horizontal_results
--eval CREATE TABLE t2 AS $query
--vertical_results
SELECT * FROM t2;
--horizontal_results
SHOW CREATE TABLE t2;
DROP TABLE t1,t2;
2019-03-14 07:05:38 +01:00
--echo #
--echo # MDEV-14926 AddressSanitizer: heap-use-after-free in make_date_time on weird combination of functions
--echo #
DO INET_ATON( FROM_UNIXTIME( @@timestamp, ( TRIM( UNHEX(HEX('%m.%d.%Y') ) ) ) ) );
CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('1989-03-10');
SELECT TIME_FORMAT('23:59:43', BINARY d) AS f FROM t1 GROUP BY 'foo';
DROP TABLE t1;
CREATE TABLE t1 (d DATE) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('1900-01-01');
SELECT LENGTH( DATE_FORMAT( d, BINARY DATABASE() ) ) AS f FROM t1 GROUP BY d;
DROP TABLE t1;
2019-03-14 07:14:37 +01:00
--echo #
--echo # MDEV-18667 ASAN heap-use-after-free in make_date_time / Arg_comparator::compare_string / Item_func_nullif::compare
--echo #
SELECT NULLIF('foo', FROM_UNIXTIME('2012-12-12 12:12:12', TRIM(0)));
2019-03-14 07:05:38 +01:00
2019-03-14 11:40:33 +01:00
--echo #
--echo # MDEV-18626 ASAN stack-buffer-overflow in int10_to_str / make_date_time upon DATE_FORMAT
--echo #
SELECT DATE_FORMAT(100000000000, '%j');
2016-07-03 11:52:06 +02:00
--echo #
--echo # End of 10.1 tests
--echo #
2018-08-07 15:28:58 +02:00
--echo #
--echo # MDEV-16217: Assertion `!table || (!table->read_set ||
--echo # bitmap_is_set(table->read_set, field_index))'
--echo # failed in Field_num::get_date
--echo #
CREATE TABLE t1 (pk int default 0, a1 date);
INSERT INTO t1 VALUES (1,'1900-01-01'),(2,NULL),(3,NULL),(4,NULL);
CREATE VIEW v1 AS
SELECT t1.pk AS pk, t1.a1 AS a1 FROM t1;
SELECT a1 BETWEEN (('2018-08-24')) AND (DEFAULT(pk)) FROM v1;
SELECT a1 BETWEEN (('2018-08-24')) AND (~ DEFAULT(pk)) FROM v1;
CREATE TABLE t2 (pk int default 1, a1 date);
INSERT INTO t2 VALUES (4,NULL);
CREATE view v2 as SELECT default(t1.pk), default(t2.pk), t1.pk from t1,t2;
select * from v2;
show create view v2;
CREATE view v3 as SELECT default(pk) from t2;
select * from v3;
explain extended select * from v3;
explain extended select default(pk) from t2;
show create view v3;
DROP VIEW v1,v2,v3;
DROP TABLE t1,t2;
--echo #
--echo # End of 10.2 tests
--echo #