~drizzle-trunk/drizzle/development

813.1.21 by Jay Pipes
Fixes the WEEKDAY() function use the new temporal system and enable proper error throwing on bad datetimes. Adds test case for the WEEKDAY() function.
1
#
2
# Tests for the WEEKDAY() function
3
#
4
# The Drizzle WEEKDAY() function differs from the MySQL WEEKDAY()
5
# function in these ways:
6
#
7
#  * Does not accept invalid parameters.  This results in an error
8
#    in Drizzle.
9
#
10
11
# WEEKDAY() on a NULL should produce
12
# a NULL.
13
SELECT WEEKDAY(NULL);
14
15
# 
16
# Test improper argument list 
17
#
18
# 1 arg is required.
19
--error 1582 # Wrong parameter count...
20
SELECT WEEKDAY();
21
--error 1582 # Wrong parameter count...
22
SELECT WEEKDAY(1, 0);
23
24
# 
25
# Test invalid dates passed to WEEKDAY
26
# produce an error, not a NULL or anything
27
# else...
28
#
29
--error 1686
30
SELECT WEEKDAY("xxx");
31
32
# Indy, bad dates!
33
--error 1686
34
SELECT WEEKDAY("0000-00-00"); # No 0000-00-00 dates!...
35
--error 1686
36
SELECT WEEKDAY("0000-01-01"); # No zero year parts
37
--error 1686
38
SELECT WEEKDAY("0001-00-01"); # No zero month parts
39
--error 1686
40
SELECT WEEKDAY("0001-01-00"); # No zero day parts
41
--error 1686
42
SELECT WEEKDAY("2000-02-30"); # No Feb 30th!
43
--error 1686
44
SELECT WEEKDAY("1900-02-29"); # Not a leap YEAR since not divisible evenly by 400...
45
--error 1686
46
SELECT WEEKDAY('1976-15-15'); # No 15th month!
47
48
# A good date, which should output 0
49
SELECT WEEKDAY("2009-01-12");
50
51
# A good date, which should output 3 
52
# Test of 2 digit year conversion...shouldn't mess with weekday functionality
53
SELECT WEEKDAY("70-12-31");
54
55
# A good date, which should output 4
56
SELECT WEEKDAY("99-12-31");
57
58
# A good date, which should output 1
59
SELECT WEEKDAY("69-12-31");
60
61
# A good date, which should output 0
62
SELECT WEEKDAY("0001-12-31");
63
64
# A good date, which should output 4
65
SELECT WEEKDAY("9999-12-31");
66
67
# A good date in the common USA format, should output 4
68
SELECT WEEKDAY('07/31/2009');