~skinny.moey/drizzle/innodb-replication

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#
# Tests for the HOUR() function
#
# The Drizzle HOUR() function differs from the MySQL HOUR()
# function in these ways:
#
#  * Does not accept invalid parameters.  This results in an error
#    in Drizzle.
#

# HOUR() on a NULL should produce
# a NULL.
SELECT HOUR(NULL);

# 
# Test improper argument list 
#
# 1 arg is required.
--error ER_PARSE_ERROR 
# Wrong parameter count...but unfortunately produces 1064 Syntax Error due to limitations of 
# the SQL parser, which considers HOUR a keyword before being a function symbol
SELECT HOUR();
--error ER_PARSE_ERROR
# Wrong parameter count...but unfortunately produces 1064 Syntax Error due to limitations of 
# the SQL parser, which considers HOUR a keyword before being a function symbol
SELECT HOUR(1, 0);

# 
# Test invalid dates passed to HOUR
# produce an error, not a NULL or anything
# else...
#
--error ER_INVALID_DATETIME_VALUE
SELECT HOUR("xxx");

# 
# Indy, bad dates!
#
# The following are all bad dates, with no possibility of interpreting
# the values as TIME-only components.
#
--error ER_INVALID_DATETIME_VALUE
SELECT HOUR("0000-00-00"); # No 0000-00-00 dates!...
--error ER_INVALID_DATETIME_VALUE
SELECT HOUR("0000-01-01"); # No zero year parts
--error ER_INVALID_DATETIME_VALUE
SELECT HOUR("0001-00-01"); # No zero month parts
--error ER_INVALID_DATETIME_VALUE
SELECT HOUR("0001-01-00"); # No zero day parts
--error ER_INVALID_DATETIME_VALUE
SELECT HOUR("2000-02-30"); # No Feb 30th!
--error ER_INVALID_DATETIME_VALUE
SELECT HOUR("1900-02-29"); # Not a leap HOUR since not divisible evenly by 400...
--error ER_INVALID_DATETIME_VALUE
SELECT HOUR('1976-15-15'); # No 15th month!
--error ER_INVALID_DATETIME_VALUE
SELECT HOUR('23:59:70'); # No 70th second!
--error ER_INVALID_DATETIME_VALUE
SELECT HOUR('23:70:59'); # No 70th minute!
--error ER_INVALID_DATETIME_VALUE
SELECT HOUR('26:00:00'); # No 26th hour!

# A good date, which cannot be interpreted as a TIME component.  Should return 0.
SELECT HOUR("2009-01-12");

# A good date, which should output 0 since no TIME component - Test of 2 digit year conversion...
SELECT HOUR("70-12-31");

# A good date in the common USA format, should output 0 since no TIME component
SELECT HOUR('07/31/2009');

# A good datetime, should output 3
SELECT HOUR("2008-11-30 03:30:15");

# A good datetime, should output 3
SELECT HOUR("2008-11-30T03:30:15");

# A good datetime, should output 3
SELECT HOUR("20081130033015");

# A good datetime, interpreted int->string, should output 3
SELECT HOUR(20081130033015);

# A good datetime with subsecond component, interpreted int->string, should output 3
SELECT HOUR(20081130033015.01);

# A good time (according to MySQL, not Jay Pipes...), should output 23
SELECT HOUR(231115);

# A good time (according to MySQL, not Jay Pipes...), should output 23
SELECT HOUR("231115");

# A good time, should output 23
SELECT HOUR("23:59:59");

# Now test field values of different types

USE test;
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (
  int_fld INT NOT NULL
, date_fld DATE NOT NULL
, datetime_fld DATETIME NOT NULL
, timestamp_fld TIMESTAMP NOT NULL
, char_fld CHAR(22) NOT NULL
, varchar_fld VARCHAR(22) NOT NULL
, text_fld TEXT NOT NULL
, blob_fld BLOB NOT NULL
);

# Should all output 16 except first 2, which should output 0.
INSERT INTO t1 VALUES (
20071130
, "2007-11-30"
, "2007-11-30 16:30:19"
, "2007-11-30T16:30:19"
, "2007-11-30 16:30:19"
, "2007-11-30 16:30:19"
, "2007-11-30T16:30:19"
, "2007-11-30T16:30:19"
);

SELECT HOUR(int_fld) FROM t1;
SELECT HOUR(date_fld) FROM t1;
SELECT HOUR(datetime_fld) FROM t1;
SELECT HOUR(timestamp_fld) FROM t1;
SELECT HOUR(char_fld) FROM t1;
SELECT HOUR(varchar_fld) FROM t1;
SELECT HOUR(text_fld) FROM t1;
SELECT HOUR(blob_fld) FROM t1;

DROP TABLE t1;