2001-09-28 07:05:54 +02:00
|
|
|
drop table if exists 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
|
|
|
create table t1 (time time, date date, timestamp timestamp,
|
|
|
|
quarter int, week int, year int, timestampadd int, timestampdiff int);
|
|
|
|
insert into t1 values ("12:22:22","97:02:03","1997-01-02",1,2,3,4,5);
|
2001-09-28 07:05:54 +02:00
|
|
|
select * 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
|
|
|
time date timestamp quarter week year timestampadd timestampdiff
|
|
|
|
12:22:22 1997-02-03 1997-01-02 00:00:00 1 2 3 4 5
|
|
|
|
select t1.time+0,t1.date+0,t1.timestamp+0,concat(date," ",time),
|
|
|
|
t1.quarter+t1.week, t1.year+timestampadd, timestampdiff from t1;
|
|
|
|
t1.time+0 t1.date+0 t1.timestamp+0 concat(date," ",time) t1.quarter+t1.week t1.year+timestampadd timestampdiff
|
|
|
|
122222 19970203 19970102000000 1997-02-03 12:22:22 3 7 5
|
2001-09-28 07:05:54 +02:00
|
|
|
drop table t1;
|
2001-10-24 19:52:19 +02:00
|
|
|
create table events(binlog int);
|
|
|
|
insert into events values(1);
|
|
|
|
select events.binlog from events;
|
|
|
|
binlog
|
|
|
|
1
|
|
|
|
drop table events;
|
2006-07-20 21:54:01 +02:00
|
|
|
create procedure p1()
|
|
|
|
begin
|
|
|
|
declare n int default 2;
|
|
|
|
authors: while n > 0 do
|
|
|
|
set n = n -1;
|
|
|
|
end while authors;
|
|
|
|
end|
|
|
|
|
create procedure p2()
|
|
|
|
begin
|
|
|
|
declare n int default 2;
|
|
|
|
contributors: while n > 0 do
|
|
|
|
set n = n -1;
|
|
|
|
end while contributors;
|
|
|
|
end|
|
|
|
|
drop procedure p1;
|
|
|
|
drop procedure p2;
|
2007-02-23 12:13:55 +01:00
|
|
|
create table t1 (connection int, b int);
|
|
|
|
create procedure p1()
|
|
|
|
begin
|
|
|
|
declare connection int;
|
|
|
|
select max(t1.connection) into connection from t1;
|
|
|
|
select concat("max=",connection) 'p1';
|
|
|
|
end|
|
|
|
|
insert into t1 (connection) values (1);
|
|
|
|
call p1();
|
|
|
|
p1
|
|
|
|
max=1
|
|
|
|
drop procedure p1;
|
|
|
|
drop table t1;
|
2010-11-03 15:51:52 +01:00
|
|
|
CREATE TABLE slow (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
|
|
|
|
INSERT INTO slow(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
|
|
|
|
INSERT INTO slow(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
|
|
|
|
INSERT INTO slow(slow, general) VALUES (1,2), (5,6);
|
|
|
|
INSERT INTO slow(slow) VALUES (1), (5);
|
2010-11-05 09:23:39 +01:00
|
|
|
SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM slow ORDER BY slow;
|
|
|
|
slow general master_heartbeat_period ignore_server_ids
|
|
|
|
1 2 3 4
|
|
|
|
1 2 3 NULL
|
|
|
|
1 2 NULL NULL
|
|
|
|
1 NULL NULL NULL
|
|
|
|
5 6 7 8
|
|
|
|
5 6 7 NULL
|
|
|
|
5 6 NULL NULL
|
|
|
|
5 NULL NULL NULL
|
2010-11-03 15:51:52 +01:00
|
|
|
SELECT slow, general, master_heartbeat_period FROM slow ORDER BY slow;
|
|
|
|
slow general master_heartbeat_period
|
|
|
|
1 2 3
|
|
|
|
1 2 3
|
|
|
|
1 2 NULL
|
|
|
|
1 NULL NULL
|
|
|
|
5 6 7
|
|
|
|
5 6 7
|
|
|
|
5 6 NULL
|
|
|
|
5 NULL NULL
|
|
|
|
SELECT slow, master_heartbeat_period FROM slow ORDER BY slow;
|
|
|
|
slow master_heartbeat_period
|
|
|
|
1 3
|
|
|
|
1 3
|
|
|
|
1 NULL
|
|
|
|
1 NULL
|
|
|
|
5 7
|
|
|
|
5 7
|
|
|
|
5 NULL
|
|
|
|
5 NULL
|
|
|
|
SELECT slow FROM slow ORDER BY slow;
|
|
|
|
slow
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
5
|
|
|
|
5
|
|
|
|
5
|
|
|
|
5
|
|
|
|
DROP TABLE slow;
|
|
|
|
CREATE TABLE general (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
|
|
|
|
INSERT INTO general(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
|
|
|
|
INSERT INTO general(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
|
|
|
|
INSERT INTO general(slow, general) VALUES (1,2), (5,6);
|
|
|
|
INSERT INTO general(slow) VALUES (1), (5);
|
2010-11-05 09:23:39 +01:00
|
|
|
SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM general ORDER BY slow;
|
|
|
|
slow general master_heartbeat_period ignore_server_ids
|
|
|
|
1 2 3 4
|
|
|
|
1 2 3 NULL
|
|
|
|
1 2 NULL NULL
|
|
|
|
1 NULL NULL NULL
|
|
|
|
5 6 7 8
|
|
|
|
5 6 7 NULL
|
|
|
|
5 6 NULL NULL
|
|
|
|
5 NULL NULL NULL
|
2010-11-03 15:51:52 +01:00
|
|
|
SELECT slow, general, master_heartbeat_period FROM general ORDER BY slow;
|
|
|
|
slow general master_heartbeat_period
|
|
|
|
1 2 3
|
|
|
|
1 2 3
|
|
|
|
1 2 NULL
|
|
|
|
1 NULL NULL
|
|
|
|
5 6 7
|
|
|
|
5 6 7
|
|
|
|
5 6 NULL
|
|
|
|
5 NULL NULL
|
|
|
|
SELECT slow, master_heartbeat_period FROM general ORDER BY slow;
|
|
|
|
slow master_heartbeat_period
|
|
|
|
1 3
|
|
|
|
1 3
|
|
|
|
1 NULL
|
|
|
|
1 NULL
|
|
|
|
5 7
|
|
|
|
5 7
|
|
|
|
5 NULL
|
|
|
|
5 NULL
|
|
|
|
SELECT slow FROM general ORDER BY slow;
|
|
|
|
slow
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
5
|
|
|
|
5
|
|
|
|
5
|
|
|
|
5
|
|
|
|
DROP TABLE general;
|
|
|
|
CREATE TABLE master_heartbeat_period (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
|
|
|
|
INSERT INTO master_heartbeat_period(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
|
|
|
|
INSERT INTO master_heartbeat_period(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
|
|
|
|
INSERT INTO master_heartbeat_period(slow, general) VALUES (1,2), (5,6);
|
|
|
|
INSERT INTO master_heartbeat_period(slow) VALUES (1), (5);
|
2010-11-05 09:23:39 +01:00
|
|
|
SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM master_heartbeat_period ORDER BY slow;
|
|
|
|
slow general master_heartbeat_period ignore_server_ids
|
|
|
|
1 2 3 4
|
|
|
|
1 2 3 NULL
|
|
|
|
1 2 NULL NULL
|
|
|
|
1 NULL NULL NULL
|
|
|
|
5 6 7 8
|
|
|
|
5 6 7 NULL
|
|
|
|
5 6 NULL NULL
|
|
|
|
5 NULL NULL NULL
|
2010-11-03 15:51:52 +01:00
|
|
|
SELECT slow, general, master_heartbeat_period FROM master_heartbeat_period ORDER BY slow;
|
|
|
|
slow general master_heartbeat_period
|
|
|
|
1 2 3
|
|
|
|
1 2 3
|
|
|
|
1 2 NULL
|
|
|
|
1 NULL NULL
|
|
|
|
5 6 7
|
|
|
|
5 6 7
|
|
|
|
5 6 NULL
|
|
|
|
5 NULL NULL
|
|
|
|
SELECT slow, master_heartbeat_period FROM master_heartbeat_period ORDER BY slow;
|
|
|
|
slow master_heartbeat_period
|
|
|
|
1 3
|
|
|
|
1 3
|
|
|
|
1 NULL
|
|
|
|
1 NULL
|
|
|
|
5 7
|
|
|
|
5 7
|
|
|
|
5 NULL
|
|
|
|
5 NULL
|
|
|
|
SELECT slow FROM master_heartbeat_period ORDER BY slow;
|
|
|
|
slow
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
5
|
|
|
|
5
|
|
|
|
5
|
|
|
|
5
|
|
|
|
DROP TABLE master_heartbeat_period;
|
|
|
|
CREATE TABLE ignore_server_ids (slow INT, general INT, master_heartbeat_period INT, ignore_server_ids INT);
|
|
|
|
INSERT INTO ignore_server_ids(slow, general, master_heartbeat_period, ignore_server_ids) VALUES (1,2,3,4), (5,6,7,8);
|
|
|
|
INSERT INTO ignore_server_ids(slow, general, master_heartbeat_period) VALUES (1,2,3), (5,6,7);
|
|
|
|
INSERT INTO ignore_server_ids(slow, general) VALUES (1,2), (5,6);
|
|
|
|
INSERT INTO ignore_server_ids(slow) VALUES (1), (5);
|
2010-11-05 09:23:39 +01:00
|
|
|
SELECT slow, general, master_heartbeat_period, ignore_server_ids FROM ignore_server_ids ORDER BY slow;
|
|
|
|
slow general master_heartbeat_period ignore_server_ids
|
|
|
|
1 2 3 4
|
|
|
|
1 2 3 NULL
|
|
|
|
1 2 NULL NULL
|
|
|
|
1 NULL NULL NULL
|
|
|
|
5 6 7 8
|
|
|
|
5 6 7 NULL
|
|
|
|
5 6 NULL NULL
|
|
|
|
5 NULL NULL NULL
|
2010-11-03 15:51:52 +01:00
|
|
|
SELECT slow, general, master_heartbeat_period FROM ignore_server_ids ORDER BY slow;
|
|
|
|
slow general master_heartbeat_period
|
|
|
|
1 2 3
|
|
|
|
1 2 3
|
|
|
|
1 2 NULL
|
|
|
|
1 NULL NULL
|
|
|
|
5 6 7
|
|
|
|
5 6 7
|
|
|
|
5 6 NULL
|
|
|
|
5 NULL NULL
|
|
|
|
SELECT slow, master_heartbeat_period FROM ignore_server_ids ORDER BY slow;
|
|
|
|
slow master_heartbeat_period
|
|
|
|
1 3
|
|
|
|
1 3
|
|
|
|
1 NULL
|
|
|
|
1 NULL
|
|
|
|
5 7
|
|
|
|
5 7
|
|
|
|
5 NULL
|
|
|
|
5 NULL
|
|
|
|
SELECT slow FROM ignore_server_ids ORDER BY slow;
|
|
|
|
slow
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
5
|
|
|
|
5
|
|
|
|
5
|
|
|
|
5
|
|
|
|
DROP TABLE ignore_server_ids;
|
|
|
|
CREATE TABLE t1 (slow INT, general INT, ignore_server_ids INT, master_heartbeat_period INT);
|
|
|
|
INSERT INTO t1 VALUES (1,2,3,4);
|
|
|
|
CREATE PROCEDURE p1()
|
|
|
|
BEGIN
|
|
|
|
DECLARE slow INT;
|
|
|
|
DECLARE general INT;
|
|
|
|
DECLARE ignore_server_ids INT;
|
|
|
|
DECLARE master_heartbeat_period INT;
|
|
|
|
SELECT max(t1.slow) INTO slow FROM t1;
|
|
|
|
SELECT max(t1.general) INTO general FROM t1;
|
|
|
|
SELECT max(t1.ignore_server_ids) INTO ignore_server_ids FROM t1;
|
|
|
|
SELECT max(t1.master_heartbeat_period) INTO master_heartbeat_period FROM t1;
|
|
|
|
SELECT slow, general, ignore_server_ids, master_heartbeat_period;
|
|
|
|
END|
|
|
|
|
CREATE PROCEDURE p2()
|
|
|
|
BEGIN
|
|
|
|
DECLARE n INT DEFAULT 2;
|
|
|
|
general: WHILE n > 0 DO
|
|
|
|
SET n = n -1;
|
|
|
|
END WHILE general;
|
|
|
|
SET n = 2;
|
|
|
|
slow: WHILE n > 0 DO
|
|
|
|
SET n = n -1;
|
|
|
|
END WHILE slow;
|
|
|
|
SET n = 2;
|
|
|
|
ignore_server_ids: WHILE n > 0 DO
|
|
|
|
SET n = n -1;
|
|
|
|
END WHILE ignore_server_ids;
|
|
|
|
SET n = 2;
|
|
|
|
master_heartbeat_period: WHILE n > 0 DO
|
|
|
|
SET n = n -1;
|
|
|
|
END WHILE master_heartbeat_period;
|
|
|
|
END|
|
|
|
|
CALL p1();
|
|
|
|
slow general ignore_server_ids master_heartbeat_period
|
|
|
|
1 2 3 4
|
|
|
|
call p2();
|
|
|
|
DROP PROCEDURE p1;
|
|
|
|
DROP PROCEDURE p2;
|
|
|
|
DROP TABLE t1;
|
2013-03-14 17:39:22 +01:00
|
|
|
create table option (option int not null);
|
|
|
|
drop table option;
|
|
|
|
set option=1;
|
2013-04-15 15:09:22 +02:00
|
|
|
ERROR HY000: Unknown system variable 'option'
|
2013-03-14 17:39:22 +01:00
|
|
|
set option option=1;
|
|
|
|
ERROR HY000: Unknown system variable 'option'
|