2
# Tests for the MINUTE() function
4
# The Drizzle MINUTE() function differs from the MySQL MINUTE()
5
# function in these ways:
7
# * Does not accept invalid parameters. This results in an error
11
# MINUTE() on a NULL should produce
16
# Test improper argument list
20
# Wrong parameter count...but unfortunately produces 1064 Syntax Error due to limitations of
21
# the SQL parser, which considers MINUTE a keyword before being a function symbol
24
# Wrong parameter count...but unfortunately produces 1064 Syntax Error due to limitations of
25
# the SQL parser, which considers MINUTE a keyword before being a function symbol
29
# Test invalid dates passed to MINUTE
30
# produce an error, not a NULL or anything
39
# The following are all bad dates, with no possibility of interpreting
40
# the values as TIME-only components.
43
SELECT MINUTE("0000-00-00"); # No 0000-00-00 dates!...
45
SELECT MINUTE("0000-01-01"); # No zero year parts
47
SELECT MINUTE("0001-00-01"); # No zero month parts
49
SELECT MINUTE("0001-01-00"); # No zero day parts
51
SELECT MINUTE("2000-02-30"); # No Feb 30th!
53
SELECT MINUTE("1900-02-29"); # Not a leap MINUTE since not divisible evenly by 400...
55
SELECT MINUTE('1976-15-15'); # No 15th month!
57
SELECT MINUTE('23:59:70'); # No 70th second!
59
SELECT MINUTE('23:70:59'); # No 70th minute!
61
SELECT MINUTE('26:00:00'); # No 26th hour!
63
# A good date, which cannot be interpreted as a TIME component. Should return 0.
64
SELECT MINUTE("2009-01-12");
66
# A good date, which should output 0 since no TIME component - Test of 2 digit year conversion...
67
SELECT MINUTE("70-12-31");
69
# A good date in the common USA format, should output 0 since no TIME component
70
SELECT MINUTE('07/31/2009');
72
# A good datetime, should output 30
73
SELECT MINUTE("2008-11-30 03:30:15");
75
# A good datetime, should output 30
76
SELECT MINUTE("2008-11-30T03:30:15");
78
# A good datetime, should output 30
79
SELECT MINUTE("20081130033015");
81
# A good datetime, interpreted int->string, should output 30
82
SELECT MINUTE(20081130033015);
84
# A good datetime with subsecond component, interpreted int->string, should output 30
85
SELECT MINUTE(20081130033015.01);
87
# A good time (according to MySQL, not Jay Pipes...), should output 11
88
SELECT MINUTE(231115);
90
# A good time (according to MySQL, not Jay Pipes...), should output 11
91
SELECT MINUTE("231115");
93
# A good time, should output 59
94
SELECT MINUTE("23:59:59");
96
# Now test field values of different types
100
DROP TABLE IF EXISTS t1;
104
, date_fld DATE NOT NULL
105
, datetime_fld DATETIME NOT NULL
106
, timestamp_fld TIMESTAMP NOT NULL
107
, char_fld CHAR(22) NOT NULL
108
, varchar_fld VARCHAR(22) NOT NULL
109
, text_fld TEXT NOT NULL
110
, blob_fld BLOB NOT NULL
113
# Should all output 30 except first 2, which should output 0.
114
INSERT INTO t1 VALUES (
117
, "2007-11-30 16:30:19"
118
, "2007-11-30T16:30:19"
119
, "2007-11-30 16:30:19"
120
, "2007-11-30 16:30:19"
121
, "2007-11-30T16:30:19"
122
, "2007-11-30T16:30:19"
125
SELECT MINUTE(int_fld) FROM t1;
126
SELECT MINUTE(date_fld) FROM t1;
127
SELECT MINUTE(datetime_fld) FROM t1;
128
SELECT MINUTE(timestamp_fld) FROM t1;
129
SELECT MINUTE(char_fld) FROM t1;
130
SELECT MINUTE(varchar_fld) FROM t1;
131
SELECT MINUTE(text_fld) FROM t1;
132
SELECT MINUTE(blob_fld) FROM t1;