~mordred/blitzdb/out-of-tree

« back to all changes in this revision

Viewing changes to tests/t/second.test

  • Committer: Monty Taylor
  • Date: 2010-01-04 01:23:00 UTC
  • Revision ID: mordred@inaugust.com-20100104012300-k9etllo2yyt1flap
Split blitzdb into its own tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Tests for the SECOND() function
3
 
#
4
 
# The Drizzle SECOND() function differs from the MySQL SECOND()
5
 
# function in these ways:
6
 
#
7
 
#  * Does not accept invalid parameters.  This results in an error
8
 
#    in Drizzle.
9
 
#
10
 
 
11
 
# SECOND() on a NULL should produce
12
 
# a NULL.
13
 
SELECT SECOND(NULL);
14
 
 
15
 
16
 
# Test improper argument list 
17
 
#
18
 
# 1 arg is required.
19
 
--error 1064 
20
 
# Wrong parameter count...but unfortunately produces 1064 Syntax Error due to limitations of 
21
 
# the SQL parser, which considers SECOND a keyword before being a function symbol
22
 
SELECT SECOND();
23
 
--error 1064
24
 
# Wrong parameter count...but unfortunately produces 1064 Syntax Error due to limitations of 
25
 
# the SQL parser, which considers SECOND a keyword before being a function symbol
26
 
SELECT SECOND(1, 0);
27
 
 
28
 
29
 
# Test invalid dates passed to SECOND
30
 
# produce an error, not a NULL or anything
31
 
# else...
32
 
#
33
 
--error 1686
34
 
SELECT SECOND("xxx");
35
 
 
36
 
37
 
# Indy, bad dates!
38
 
#
39
 
# The following are all bad dates, with no possibility of interpreting
40
 
# the values as TIME-only components.
41
 
#
42
 
--error 1686
43
 
SELECT SECOND("0000-00-00"); # No 0000-00-00 dates!...
44
 
--error 1686
45
 
SELECT SECOND("0000-01-01"); # No zero year parts
46
 
--error 1686
47
 
SELECT SECOND("0001-00-01"); # No zero month parts
48
 
--error 1686
49
 
SELECT SECOND("0001-01-00"); # No zero day parts
50
 
--error 1686
51
 
SELECT SECOND("2000-02-30"); # No Feb 30th!
52
 
--error 1686
53
 
SELECT SECOND("1900-02-29"); # Not a leap SECOND since not divisible evenly by 400...
54
 
--error 1686
55
 
SELECT SECOND('1976-15-15'); # No 15th month!
56
 
--error 1686
57
 
SELECT SECOND('23:59:70'); # No 70th second!
58
 
--error 1686
59
 
SELECT SECOND('23:70:59'); # No 70th minute!
60
 
--error 1686
61
 
SELECT SECOND('26:00:00'); # No 26th hour!
62
 
 
63
 
# A good date, which cannot be interpreted as a TIME component.  Should return 0.
64
 
SELECT SECOND("2009-01-12");
65
 
 
66
 
# A good date, which should output 0 since no TIME component - Test of 2 digit year conversion...
67
 
SELECT SECOND("70-12-31");
68
 
 
69
 
# A good date in the common USA format, should output 0 since no TIME component
70
 
SELECT SECOND('07/31/2009');
71
 
 
72
 
# A good datetime, should output 15
73
 
SELECT SECOND("2008-11-30 03:30:15");
74
 
 
75
 
# A good datetime, should output 15
76
 
SELECT SECOND("2008-11-30T03:30:15");
77
 
 
78
 
# A good datetime, should output 15
79
 
SELECT SECOND("20081130033015");
80
 
 
81
 
# A good datetime, interpreted int->string, should output 15
82
 
SELECT SECOND(20081130033015);
83
 
 
84
 
# A good datetime with subsecond component, interpreted int->string, should output 15
85
 
SELECT SECOND(20081130033015.01);
86
 
 
87
 
# A good time (according to MySQL, not Jay Pipes...), should output 15
88
 
SELECT SECOND(231115);
89
 
 
90
 
# A good time (according to MySQL, not Jay Pipes...), should output 15
91
 
SELECT SECOND("231115");
92
 
 
93
 
# A good time, should output 59
94
 
SELECT SECOND("23:59:59");
95
 
 
96
 
# Now test field values of different types
97
 
 
98
 
USE test;
99
 
--disable_warnings
100
 
DROP TABLE IF EXISTS t1;
101
 
--enable_warnings
102
 
CREATE TABLE t1 (
103
 
  int_fld INT NOT NULL
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
111
 
);
112
 
 
113
 
# Should all output 19 except first two, which should output 0
114
 
INSERT INTO t1 VALUES (
115
 
20071130
116
 
, "2007-11-30"
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"
123
 
);
124
 
 
125
 
SELECT SECOND(int_fld) FROM t1;
126
 
SELECT SECOND(date_fld) FROM t1;
127
 
SELECT SECOND(datetime_fld) FROM t1;
128
 
SELECT SECOND(timestamp_fld) FROM t1;
129
 
SELECT SECOND(char_fld) FROM t1;
130
 
SELECT SECOND(varchar_fld) FROM t1;
131
 
SELECT SECOND(text_fld) FROM t1;
132
 
SELECT SECOND(blob_fld) FROM t1;
133
 
 
134
 
DROP TABLE t1;
135