~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/year.result

  • Committer: Jay Pipes
  • Date: 2009-01-28 02:39:29 UTC
  • mto: This revision was merged to the branch mainline in revision 815.
  • Revision ID: jpipes@serialcoder-20090128023929-gy7mot4ki11taytg
First function cleanup for temporal handling: YEAR()

* Added source files for calendrical calculations:
 drizzled/calendar.h
 drizzled/calendar.cc
* Added source files for new Temporal classes
 drizzled/temporal.h
 drizzled/temporal.cc
 drizzled/temporal_format.h
 drizzled/temporal_format.cc

Modified drizzled/function/time/year.cc to use the new
Temporal classes instead of the DRIZZLE_TIME struct and 
get_date().

Added new error codes for invalid DATETIME values and ensured
bad datetimes throw errors in calls to YEAR().

Added new test case specifically for the YEAR() function

Modified existing func_time and type_date test cases to expect
errors when calling YEAR() with bad datetimes.

Edited Makefile.am in drizzled/ to ensure libpcre is used during
build and that calendar.cc, temporal.cc and temporal_format.cc are
built.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
SELECT YEAR(NULL);
 
2
YEAR(NULL)
 
3
NULL
 
4
SELECT YEAR();
 
5
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near ')' at line 1
 
6
SELECT YEAR(1, 0);
 
7
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near ' 0)' at line 1
 
8
SELECT YEAR("xxx");
 
9
ERROR HY000: Received an invalid datetime value 'xxx'.
 
10
SELECT YEAR("0000-00-00");
 
11
ERROR HY000: Received an invalid datetime value '0000-00-00'.
 
12
SELECT YEAR("0000-01-01");
 
13
ERROR HY000: Received an invalid datetime value '0000-01-01'.
 
14
SELECT YEAR("0001-00-01");
 
15
ERROR HY000: Received an invalid datetime value '0001-00-01'.
 
16
SELECT YEAR("0001-01-00");
 
17
ERROR HY000: Received an invalid datetime value '0001-01-00'.
 
18
SELECT YEAR("2000-02-30");
 
19
ERROR HY000: Received an invalid datetime value '2000-02-30'.
 
20
SELECT YEAR("1900-02-29");
 
21
ERROR HY000: Received an invalid datetime value '1900-02-29'.
 
22
SELECT YEAR('1976-15-15');
 
23
ERROR HY000: Received an invalid datetime value '1976-15-15'.
 
24
SELECT YEAR("2009-01-12");
 
25
YEAR("2009-01-12")
 
26
2009
 
27
SELECT YEAR("70-12-31");
 
28
YEAR("70-12-31")
 
29
1970
 
30
SELECT YEAR("99-12-31");
 
31
YEAR("99-12-31")
 
32
1999
 
33
SELECT YEAR("69-12-31");
 
34
YEAR("69-12-31")
 
35
2069
 
36
SELECT YEAR("0001-12-31");
 
37
YEAR("0001-12-31")
 
38
1
 
39
SELECT YEAR("9999-12-31");
 
40
YEAR("9999-12-31")
 
41
9999
 
42
SELECT YEAR('07/31/2009');
 
43
YEAR('07/31/2009')
 
44
2009
 
45
SELECT YEAR('20090916');
 
46
YEAR('20090916')
 
47
2009
 
48
SELECT YEAR('20090916091528');
 
49
YEAR('20090916091528')
 
50
2009
 
51
SELECT YEAR("20090916091528.000000");
 
52
YEAR("20090916091528.000000")
 
53
2009
 
54
SELECT YEAR('09-09-16');
 
55
YEAR('09-09-16')
 
56
2009
 
57
SELECT YEAR('09.09.16');
 
58
YEAR('09.09.16')
 
59
2009
 
60
SELECT YEAR('09/09/16');
 
61
YEAR('09/09/16')
 
62
2009
 
63
SELECT YEAR('09-09-16');
 
64
YEAR('09-09-16')
 
65
2009
 
66
SELECT YEAR('09-9-2');
 
67
YEAR('09-9-2')
 
68
2009
 
69
SELECT YEAR(20090916);
 
70
YEAR(20090916)
 
71
2009
 
72
SELECT YEAR(20090916091528);
 
73
YEAR(20090916091528)
 
74
2009
 
75
SELECT YEAR(20090916091528.000000);
 
76
ERROR HY000: Received an invalid datetime value '20090916091528.000000'.
 
77
USE test;
 
78
DROP TABLE IF EXISTS t1;
 
79
CREATE TABLE t1 (
 
80
int_fld INT NOT NULL
 
81
, date_fld DATE NOT NULL
 
82
, datetime_fld DATETIME NOT NULL
 
83
, timestamp_fld TIMESTAMP NOT NULL
 
84
, char_fld CHAR(22) NOT NULL
 
85
, varchar_fld VARCHAR(22) NOT NULL
 
86
, text_fld TEXT NOT NULL
 
87
, blob_fld BLOB NOT NULL
 
88
);
 
89
INSERT INTO t1 VALUES (
 
90
20071130
 
91
, "2007-11-30"
 
92
, "2007-11-30 16:30:19"
 
93
, "2007-11-30T16:30:19"
 
94
, "2007-11-30 16:30:19"
 
95
, "2007-11-30 16:30:19"
 
96
, "2007-11-30T16:30:19"
 
97
, "2007-11-30T16:30:19"
 
98
);
 
99
SELECT YEAR(int_fld) FROM t1;
 
100
YEAR(int_fld)
 
101
2007
 
102
SELECT YEAR(date_fld) FROM t1;
 
103
YEAR(date_fld)
 
104
2007
 
105
SELECT YEAR(datetime_fld) FROM t1;
 
106
YEAR(datetime_fld)
 
107
2007
 
108
SELECT YEAR(timestamp_fld) FROM t1;
 
109
YEAR(timestamp_fld)
 
110
2007
 
111
SELECT YEAR(char_fld) FROM t1;
 
112
YEAR(char_fld)
 
113
2007
 
114
SELECT YEAR(varchar_fld) FROM t1;
 
115
YEAR(varchar_fld)
 
116
2007
 
117
SELECT YEAR(text_fld) FROM t1;
 
118
YEAR(text_fld)
 
119
2007
 
120
SELECT YEAR(blob_fld) FROM t1;
 
121
YEAR(blob_fld)
 
122
2007
 
123
DROP TABLE t1;