github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/function/func_datetime_now.test (about)

     1  #SELECT,  算术运算,嵌套
     2  #select now()-now(),weekday("2022-06-02")-weekday(now()),unix_timestamp()-unix_timestamp(now());
     3  #select now()-current_timestamp();
     4  
     5  #0.5 not supported curdate and curtime 
     6  #select now()-curdate()*1000000-curtime();
     7  
     8  #INSERT
     9  #0.5 not support MAKETIME function
    10  #CREATE TABLE t1 (a TIMESTAMP);
    11  #INSERT INTO t1 VALUES (now()), (now());
    12  #SELECT 1 FROM t1 ORDER BY MAKETIME(1, 1, a);
    13  #DROP TABLE t1;
    14  
    15  #CREATE TABLE t1 (a TIMESTAMP);
    16  #INSERT INTO t1 select (now());
    17  #INSERT INTO t1 select (now());
    18  #SELECT 1 FROM t1 ORDER BY 1;
    19  #DROP TABLE t1;
    20  
    21  #INSERT
    22  #DROP TABLE if exists t1;
    23  #create table t1 (a int primary key, b int, c int, d timestamp default current_timestamp);
    24  #insert into t1 select 1,1,1,now();
    25  #insert into t1 select 2,0,0,null;
    26  #select a,b,c,year(d) from t1;
    27  #DROP TABLE t1;
    28  
    29  #比较运算,数据类型
    30  #CREATE TABLE t1 (a TIMESTAMP);
    31  #INSERT INTO t1 select (now());
    32  #INSERT INTO t1 select (now());
    33  #INSERT INTO t1 select (now());
    34  #SELECT year(a) FROM t1 WHERE a > '2008-01-01';
    35  #DROP TABLE t1;
    36  
    37  #算术运算,CREATE SELECT
    38  #0.5 not supported
    39  #create table t1 select now() - now(), curtime() - curtime(), sec_to_time(1) + 0, from_unixtime(1) + 0;
    40  #select * from t1;
    41  #drop table t1;
    42  
    43  #ALTER TABLE
    44  #DROP TABLE IF EXISTS t1;
    45  #DROP TABLE IF EXISTS t2;
    46  #SET TIMESTAMP=1558818549;
    47  #CREATE TABLE t1 (i INT PRIMARY KEY, no_default DATETIME);
    48  #CREATE TABLE t2(i INT, alter_date DATETIME);
    49  #INSERT INTO t2 select 0, now();
    50  #INSERT INTO t2 select 1, now();
    51  #INSERT INTO t2 select 2, now();
    52  #SET TIMESTAMP=1558818554;
    53  #INSERT INTO t1 (i, no_default) select 0, now();
    54  #INSERT INTO t1 (i, no_default) select 1, now();
    55  #INSERT INTO t1 (i, no_default) select 2, now();
    56  #SELECT (t1.no_default > t2.alter_date) AS no_default_newer_than_alter,(t1.no_default > t2.alter_date) AS alter_default_newer_than_alter FROM t1 NATURAL JOIN t2;
    57  #DROP TABLE t2;
    58  #DROP TABLE t1;
    59  
    60  
    61  #DROP TABLE if exists t1;
    62  #create table t1 (a int primary key, b int, c int, d timestamp default current_timestamp);
    63  #insert into t1 select 1,1,1,now();
    64  #insert into t1 select 2,0,0,null;
    65  #0.5 not supported
    66  #replace into t1 values(null,1,0,null);
    67  #select last_insert_id();
    68  #select a, b, c, year(d) from t1;
    69  #drop table t1;
    70  #create table t1 (a int primary key, b int, c int, e int, d timestamp default current_timestamp);
    71  #insert into t1 select 1,1,1,1,now();
    72  #insert into t1 select 2,0,0,0,null;
    73  #0.5 not supported
    74  #replace into t1 values(null,1,0,2,null);
    75  #select last_insert_id();
    76  #select a, b, c, year(d) from t1;
    77  #drop table t1;
    78  
    79  select now()=now();
    80  create table t1(a timestamp,b int auto_increment);
    81  prepare s1 from 'insert into t1(a) select now()';
    82  execute s1;
    83  execute s1;
    84  select t1.a=t2.a from t1,(select a from t1  where b=2)as t2 where b=1;
    85  
    86  delete from t1;
    87  deallocate prepare s1;
    88  prepare s1 from 'insert into t1(a,b) values(now(),?)';
    89  set @b=1;
    90  execute s1 using @b;
    91  set @b=2;
    92  execute s1 using @b;
    93  select t1.a=t2.a from t1,(select a from t1  where b=2)as t2 where b=1;
    94  
    95  select a=b,c from  (select now(6) as a,  sleep(1) as c, now(6) as b) t1;
    96  
    97  -- case for issue 11550
    98  set @ts=now();
    99  select sleep(1);
   100  set @ts_after=now();
   101  select timestampdiff(microsecond, @ts, @ts_after) > 1000000 checked;
   102  -- END case
   103  
   104  drop table if exists t1;
   105  create table t1(a timestamp,b int auto_increment);
   106  insert into t1(a) select current_timestamp () from mo_catalog.mo_sessions limit 1;
   107  select sleep(1);
   108  insert into t1(a) select current_timestamp () from mo_catalog.mo_sessions limit 1;
   109  select t1.a=t2.a from t1,(select a from t1  where b=2)as t2 where b=1;
   110  drop table t1;
   111  
   112  select timestampdiff(second, t1, t2), a from (select sysdate() as t1, sleep(2) as a, sysdate() as t2);