813.1.11
by Jay Pipes
Fixed DAYOFYEAR() to use new Temporal system, corrected func_time.test |
1 |
#
|
2 |
# Tests for the DAYOFYEAR() function |
|
3 |
#
|
|
4 |
# The Drizzle DAYOFYEAR() function differs from the MySQL DAYOFYEAR() |
|
5 |
# function in these ways: |
|
6 |
#
|
|
7 |
# * Does not accept invalid parameters. This results in an error |
|
8 |
# in Drizzle. |
|
9 |
#
|
|
10 |
||
11 |
# DAYOFYEAR() on a NULL should produce |
|
12 |
# a NULL. |
|
13 |
SELECT DAYOFYEAR(NULL); |
|
14 |
||
15 |
#
|
|
16 |
# Test improper argument list |
|
17 |
#
|
|
18 |
# 1 arg is required. |
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
19 |
--error ER_WRONG_PARAMCOUNT_TO_FUNCTION # Wrong parameter count...
|
813.1.11
by Jay Pipes
Fixed DAYOFYEAR() to use new Temporal system, corrected func_time.test |
20 |
SELECT DAYOFYEAR(); |
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
21 |
--error ER_WRONG_PARAMCOUNT_TO_FUNCTION # Wrong parameter count...
|
813.1.11
by Jay Pipes
Fixed DAYOFYEAR() to use new Temporal system, corrected func_time.test |
22 |
SELECT DAYOFYEAR(1, 0); |
23 |
||
24 |
#
|
|
25 |
# Test invalid dates passed to DAYOFYEAR |
|
26 |
# produce an error, not a NULL or anything |
|
27 |
# else... |
|
28 |
#
|
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
29 |
--error ER_INVALID_DATETIME_VALUE
|
813.1.11
by Jay Pipes
Fixed DAYOFYEAR() to use new Temporal system, corrected func_time.test |
30 |
SELECT DAYOFYEAR("xxx"); |
31 |
||
32 |
# Indy, bad dates! |
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
33 |
--error ER_INVALID_DATETIME_VALUE
|
813.1.11
by Jay Pipes
Fixed DAYOFYEAR() to use new Temporal system, corrected func_time.test |
34 |
SELECT DAYOFYEAR("0000-00-00"); # No 0000-00-00 dates!... |
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
35 |
--error ER_INVALID_DATETIME_VALUE
|
813.1.11
by Jay Pipes
Fixed DAYOFYEAR() to use new Temporal system, corrected func_time.test |
36 |
SELECT DAYOFYEAR("0000-01-01"); # No zero year parts |
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
37 |
--error ER_INVALID_DATETIME_VALUE
|
813.1.11
by Jay Pipes
Fixed DAYOFYEAR() to use new Temporal system, corrected func_time.test |
38 |
SELECT DAYOFYEAR("0001-00-01"); # No zero month parts |
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
39 |
--error ER_INVALID_DATETIME_VALUE
|
813.1.11
by Jay Pipes
Fixed DAYOFYEAR() to use new Temporal system, corrected func_time.test |
40 |
SELECT DAYOFYEAR("0001-01-00"); # No zero day parts |
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
41 |
--error ER_INVALID_DATETIME_VALUE
|
813.1.11
by Jay Pipes
Fixed DAYOFYEAR() to use new Temporal system, corrected func_time.test |
42 |
SELECT DAYOFYEAR("2000-02-30"); # No Feb 30th! |
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
43 |
--error ER_INVALID_DATETIME_VALUE
|
813.1.11
by Jay Pipes
Fixed DAYOFYEAR() to use new Temporal system, corrected func_time.test |
44 |
SELECT DAYOFYEAR("1900-02-29"); # Not a leap DAYOFYEAR since not divisible evenly by 400... |
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
45 |
--error ER_INVALID_DATETIME_VALUE
|
813.1.11
by Jay Pipes
Fixed DAYOFYEAR() to use new Temporal system, corrected func_time.test |
46 |
SELECT DAYOFYEAR('1976-15-15'); # No 15th month! |
47 |
||
48 |
# A good date, which should output 1 |
|
49 |
SELECT DAYOFYEAR("2009-01-01"); |
|
50 |
||
51 |
# A good date, which should output 12 |
|
52 |
SELECT DAYOFYEAR("2009-01-12"); |
|
53 |
||
54 |
# A good date, which should output 365 - Test of 2 digit DAYOFYEAR conversion and proper day... |
|
55 |
SELECT DAYOFYEAR("70-12-31"); |
|
56 |
||
57 |
# A good date, which should output 366 - Test of 2 digit DAYOFYEAR conversion and proper day in a leap year... |
|
58 |
SELECT DAYOFYEAR("00-12-31"); |
|
59 |
||
60 |
# A good date, which should output 31 |
|
61 |
SELECT DAYOFYEAR("0001-01-31"); |
|
62 |
||
63 |
# A good date in the common USA format, should output 31+28+31+30+31+30+31= 212 |
|
64 |
SELECT DAYOFYEAR('07/31/2009'); |
|
65 |
||
66 |
#
|
|
67 |
# Tests for alternate DATETIME syntaxes |
|
68 |
# in string and numeric formats. All should |
|
69 |
# return 31+28+31+30+31+30+31+31+16= 259 |
|
70 |
#
|
|
71 |
SELECT DAYOFYEAR('20090916'); |
|
72 |
SELECT DAYOFYEAR('20090916091528'); |
|
73 |
SELECT DAYOFYEAR("20090916091528.000000"); |
|
74 |
SELECT DAYOFYEAR('09-09-16'); |
|
75 |
SELECT DAYOFYEAR('09.09.16'); |
|
76 |
SELECT DAYOFYEAR('09/09/16'); |
|
77 |
SELECT DAYOFYEAR('09-09-16'); |
|
78 |
SELECT DAYOFYEAR('09-9-2'); |
|
79 |
SELECT DAYOFYEAR(20090916); |
|
80 |
SELECT DAYOFYEAR(20090916091528); |
|
813.1.19
by Jay Pipes
To remain in compatibility with MySQL, added ability to interpret |
81 |
SELECT DAYOFYEAR(20090916091528.000001); |
813.1.11
by Jay Pipes
Fixed DAYOFYEAR() to use new Temporal system, corrected func_time.test |
82 |
|
83 |
# Now test field values of different types |
|
84 |
||
85 |
USE test; |
|
86 |
--disable_warnings
|
|
87 |
DROP TABLE IF EXISTS t1; |
|
88 |
--enable_warnings
|
|
89 |
CREATE TABLE t1 ( |
|
90 |
int_fld INT NOT NULL |
|
91 |
, date_fld DATE NOT NULL |
|
92 |
, datetime_fld DATETIME NOT NULL |
|
93 |
, timestamp_fld TIMESTAMP NOT NULL |
|
94 |
, char_fld CHAR(22) NOT NULL |
|
95 |
, varchar_fld VARCHAR(22) NOT NULL |
|
96 |
, text_fld TEXT NOT NULL |
|
97 |
, blob_fld BLOB NOT NULL |
|
98 |
);
|
|
99 |
||
100 |
# Should all output 31+28+30+31+31+30+31+31+30+31+30= 334 |
|
101 |
INSERT INTO t1 VALUES ( |
|
102 |
20071130
|
|
103 |
, "2007-11-30" |
|
104 |
, "2007-11-30 16:30:19" |
|
105 |
, "2007-11-30T16:30:19" |
|
106 |
, "2007-11-30 16:30:19" |
|
107 |
, "2007-11-30 16:30:19" |
|
108 |
, "2007-11-30T16:30:19" |
|
109 |
, "2007-11-30T16:30:19" |
|
110 |
);
|
|
111 |
||
112 |
SELECT DAYOFYEAR(int_fld) FROM t1; |
|
113 |
SELECT DAYOFYEAR(date_fld) FROM t1; |
|
114 |
SELECT DAYOFYEAR(datetime_fld) FROM t1; |
|
115 |
SELECT DAYOFYEAR(timestamp_fld) FROM t1; |
|
116 |
SELECT DAYOFYEAR(char_fld) FROM t1; |
|
117 |
SELECT DAYOFYEAR(varchar_fld) FROM t1; |
|
118 |
SELECT DAYOFYEAR(text_fld) FROM t1; |
|
119 |
SELECT DAYOFYEAR(blob_fld) FROM t1; |
|
120 |
||
121 |
DROP TABLE t1; |
|
122 |