summaryrefslogtreecommitdiff
path: root/mysql-test/suite/storage_engine/type_date_time.inc
blob: d0b953984be7209ba68d67768f7b46585710a66a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#
# Date and time column types
# (DATE, DATETIME, TIMESTAMP, TIME, YEAR)
#

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

let $create_definition =
  d DATE $col_opts,
  dt DATETIME $col_opts,
  ts TIMESTAMP $col_opts,
  t TIME $col_opts,
  y YEAR $col_opts,
  y4 YEAR(4) $col_opts,
  y2 YEAR(2) $col_opts
;
--source create_table.inc
if ($mysql_errname)
{
  --let $my_last_stmt = $create_statement
  --let $functionality = Date and time types
  --source unexpected_result.inc
}
if (!$mysql_errname)
{
  --replace_column 3 # 4 # 5 #
  SHOW COLUMNS IN t1;

  SET @tm = '2012-04-09 05:27:00';

  # Valid values 
  # '1970-01-01 00:00:01'
  INSERT INTO t1 VALUES
  ('1000-01-01', '1000-01-01 00:00:00', FROM_UNIXTIME(1), '-838:59:59', '1901', '1901', '00'),
  ('9999-12-31', '9999-12-31 23:59:59', FROM_UNIXTIME(2147483647), '838:59:59', '2155', '2155', '99'),
  ('0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '00:00:00', '0', '0', '0'),
  (DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),YEAR(@tm),YEAR(@tm)); 

  --sorted_result
  SELECT * FROM t1;

  # Invalid values

  INSERT INTO t1 VALUES
  ('999-13-32', '999-11-31 00:00:00', '0', '-839:00:00', '1900', '1900', '-1' );

  --sorted_result
  SELECT * FROM t1;

  DROP TABLE t1;
}