Merge lp:~brianaker/drizzle/bug-592690 into lp:drizzle/7.0

Proposed by Brian Aker
Status: Merged
Approved by: Brian Aker
Approved revision: no longer in the source branch.
Merged at revision: 2098
Proposed branch: lp:~brianaker/drizzle/bug-592690
Merge into: lp:drizzle/7.0
Diff against target: 4508 lines (+1331/-843)
82 files modified
drizzled/calendar.cc (+13/-29)
drizzled/calendar.h (+0/-1)
drizzled/error.cc (+1/-0)
drizzled/error_t.h (+12/-10)
drizzled/field.cc (+10/-8)
drizzled/field.h (+4/-4)
drizzled/field/date.cc (+14/-11)
drizzled/field/date.h (+1/-1)
drizzled/field/datetime.cc (+5/-5)
drizzled/field/datetime.h (+1/-1)
drizzled/field/decimal.cc (+1/-1)
drizzled/field/decimal.h (+1/-1)
drizzled/field/epoch.cc (+32/-27)
drizzled/field/epoch.h (+7/-4)
drizzled/field/microtime.cc (+63/-54)
drizzled/field/microtime.h (+4/-2)
drizzled/field/time.cc (+4/-4)
drizzled/field/uuid.cc (+3/-14)
drizzled/function/cast/time.cc (+4/-3)
drizzled/function/time/curdate.cc (+1/-1)
drizzled/function/time/date.cc (+4/-4)
drizzled/function/time/date_add_interval.cc (+4/-4)
drizzled/function/time/date_format.cc (+15/-15)
drizzled/function/time/from_unixtime.cc (+25/-21)
drizzled/function/time/makedate.cc (+4/-2)
drizzled/function/time/now.cc (+15/-25)
drizzled/function/time/now.h (+1/-1)
drizzled/function/time/sysdate_local.cc (+9/-5)
drizzled/function/time/typecast.cc (+12/-5)
drizzled/item.cc (+38/-32)
drizzled/item/cmpfunc.cc (+4/-5)
drizzled/plugin/client.cc (+6/-5)
drizzled/session.h (+5/-5)
drizzled/sql_yacc.yy (+1/-1)
drizzled/temporal.cc (+19/-18)
drizzled/temporal_interval.cc (+2/-3)
drizzled/time_functions.cc (+43/-75)
drizzled/time_functions.h (+5/-16)
drizzled/type/decimal.cc (+7/-1)
drizzled/type/decimal.h (+88/-83)
drizzled/type/time.cc (+174/-114)
drizzled/type/time.h (+102/-38)
drizzled/tztime.cc (+13/-18)
drizzled/tztime.h (+9/-17)
drizzled/util/gmtime.cc (+284/-0)
drizzled/util/gmtime.h (+46/-0)
drizzled/util/include.am (+2/-0)
plugin/csv/tests/t/uuid_type.test (+1/-1)
plugin/haildb/tests/r/type_timestamp.result (+3/-3)
plugin/haildb/tests/t/type_timestamp.test (+3/-3)
plugin/memory/tests/t/primary_key.test (+1/-1)
plugin/myisam/tests/r/mix2_myisam.result (+6/-4)
plugin/transaction_log/tests/r/transaction_log_data_type.result (+26/-27)
plugin/transaction_log/tests/t/transaction_log_data_type.test (+4/-5)
tests/include/mix2.inc (+6/-5)
tests/r/data_dictionary_like_info.result (+2/-2)
tests/r/func_time.result (+65/-62)
tests/r/information_schema.result (+1/-1)
tests/r/insert.result (+1/-1)
tests/r/parser.result (+1/-1)
tests/r/timezone.result (+3/-2)
tests/r/type_datetime.result (+2/-2)
tests/r/type_timestamp.result (+3/-3)
tests/suite/microtime_type/r/basic.result (+3/-3)
tests/suite/microtime_type/r/decimal.result (+19/-0)
tests/suite/microtime_type/r/max.result (+8/-0)
tests/suite/microtime_type/t/basic.test (+3/-3)
tests/suite/microtime_type/t/decimal.test (+17/-0)
tests/suite/microtime_type/t/max.test (+10/-0)
tests/suite/regression/r/592690.result (+3/-0)
tests/suite/regression/t/592690.test (+2/-0)
tests/suite/uuid_type/t/insert_null_no_key.test (+1/-1)
tests/suite/uuid_type/t/primary_key.test (+1/-1)
tests/t/func_time.test (+6/-6)
tests/t/insert.test (+1/-1)
tests/t/timezone.test (+1/-1)
tests/t/type_timestamp.test (+3/-3)
unittests/calendar_test.cc (+1/-1)
unittests/micro_timestamp_test.cc (+1/-1)
unittests/nano_timestamp_test.cc (+1/-1)
unittests/plugin/client_test.cc (+3/-3)
unittests/timestamp_test.cc (+1/-1)
To merge this branch: bzr merge lp:~brianaker/drizzle/bug-592690
Reviewer Review Type Date Requested Status
Lee Bieber (community) Needs Fixing
Review via email: mp+46352@code.launchpad.net

This proposal supersedes a proposal from 2011-01-13.

To post a comment you must log in.
Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote : Posted in a previous version of this proposal

Getting unit test failures:

FAILED  ] 4 tests, listed below:
[  FAILED  ] TimestampTest.is_valid_oneSecondAfterTimestampMaxOfRange_shouldReturn_False
[  FAILED  ] NanoTimestampTest.is_valid_oneMicroSecondAfterNanoTimestampMaxOfRange_shouldReturn_False
[  FAILED  ] MicroTimestampTest.is_valid_oneMicroSecondAfterMicroTimestampMaxOfRange_shouldReturn_False
[  FAILED  ] calendar_in_unix_epoch_range_test.OneSecondAfterMaxOfRange
[1/13/11 7:09:36 PM] Lee: brb, have to walk the dog

review: Needs Fixing
lp:~brianaker/drizzle/bug-592690 updated
2086. By Lee Bieber

Merge Andrew - fix bug 702881: data_dictionary.tables row_format incorrect
Merge Marisa - Document new data types and change in build file to treat warnings as errors
Merge Lee - 690773: RabbitMQ plugin needs to start rabbitmq for its test

Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :

http://hudson.drizzle.org/view/Drizzle-build/job/drizzle-build-sparc-solaris10/1700/console

/bin/bash ./libtool --tag=CXX --mode=link CC -xlang=c99 -D_REENTRANT -mt -compat=5 -library=stlport4 -library=Crun -template=no%extdef -g0 -xO3 -xlibmil -xdepend -xbuiltin +w +w2 -xwe -xport64 -errtags=yes -erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint -errwarn=%all -DBUILDING_DRIZZLED -D_REENTRANT -m64 -L/usr/local/lib/sparcv9 -L/usr/local/lib -o plugin/libcollation_dictionary_plugin.la plugin/collation_dictionary/plugin_libcollation_dictionary_plugin_la-character_sets.lo plugin/collation_dictionary/plugin_libcollation_dictionary_plugin_la-collations.lo plugin/collation_dictionary/plugin_libcollation_dictionary_plugin_la-dictionary.lo -lnsl -lpthread -lintl -lsocket -lrt -lintl -lumem
"drizzled/type/time.cc", line 1121: Error, notused: arg is defined but not used.
1 Error(s) detected.
gmake[2]: *** [drizzled/type/time.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....

review: Needs Fixing
lp:~brianaker/drizzle/bug-592690 updated
2087. By Lee Bieber

Merge Stewart - some documentation clean up
Merge Patrick - fix bug 693130: Tests depending on archive engine should be skipped if archive isn't enabled
Merge Patrick - fix bug 697292: The have_valgrind include file in the test has the opposite effect

2088. By Lee Bieber

Merge Monty - fix bug 702571: InnoDB should have file-per-table on by default
Merge Monty - fix bug 583375: support configure option to specify static/dynamic build for a plugin

2089. By Brian Aker

Rollup of all changes for identifier/error

2090. By Brian Aker

Rolls back patch on Inno/static build. Also removes experimental plugins
from test runs by default.

2091. By Brian Aker

First pass on fix for UTF-8, this checks all of our schema names.

2092. By Brian Aker

Add in reorder and see if this will speed up builds at all.

2093. By Brian Aker

Merge in update so that test-run.pl runs all of test/suite and fix for
create table like and FK.

2094. By Patrick Crews

Updated translations

2095. By Lee Bieber

Merge Brian - fix processlist test, was failing under lcov
Merge Marisa - fix bug 684803: Need to update Drizzledump documentation with migration conversions / caveats
Merge Marisa - fix bug #686641: Need to document removal of multi-table update/delete from Drizzle
Merge Monty - fix bug 567387: quotes now appearing around module name and author in data_dicionary view
Merge Monty - fix bug 658752: Incorrect datadir value being stored
Merge Andrew - fix bug 680872: max-connect-errors appears to be unused
Merge Stewart - Haildb updates, ANALYZE table as well as improved index statistics

2096. By Lee Bieber

Merge Shrews - Refactor the TransactionServices public interface
Merge Monty - fix bug 583375: support configure option to specify static/dynamic build for a plugin
Merge Shrews - fix bug 702505: transaction_reader utility does not check for errors from statement transformation
Merge Vijay - Convert structs to classes
Merge Joe - 702529: PRINT_TRANSACTION_MESSAGE udf does not output UUID

2097. By Brian Aker

Test cleanup for lcov

2098. By Brian Aker

Merge of all of the time fixes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzled/calendar.cc'
2--- drizzled/calendar.cc 2010-12-18 04:43:40 +0000
3+++ drizzled/calendar.cc 2011-01-18 01:47:30 +0000
4@@ -333,40 +333,24 @@
5 * @param Minute
6 * @param Second
7 */
8-bool in_unix_epoch_range(uint32_t year
9- , uint32_t month
10- , uint32_t day
11- , uint32_t hour
12- , uint32_t minute
13- , uint32_t second)
14+bool in_unix_epoch_range(uint32_t year,
15+ uint32_t month,
16+ uint32_t day,
17+ uint32_t hour,
18+ uint32_t minute,
19+ uint32_t second)
20 {
21+ (void)hour;
22+ (void)minute;
23+ (void)second;
24+
25 if (month == 0 || day == 0)
26 return false;
27- if (year < UNIX_EPOCH_MAX_YEARS
28- && year >= UNIX_EPOCH_MIN_YEARS)
29- return true;
30+
31 if (year < UNIX_EPOCH_MIN_YEARS)
32 return false;
33- if (year == UNIX_EPOCH_MAX_YEARS)
34- {
35- if (month > 1)
36- return false;
37- if (day > 19)
38- return false;
39- else if (day < 19)
40- return true;
41- else
42- {
43- /* We are on the final day of UNIX Epoch */
44- uint32_t seconds= (hour * 60 * 60)
45- + (minute * 60)
46- + (second);
47- if (seconds <= ((3 * 60 * 60) + (14 * 60) + 7))
48- return true;
49- return false;
50- }
51- }
52- return false;
53+
54+ return true;
55 }
56
57 /**
58
59=== modified file 'drizzled/calendar.h'
60--- drizzled/calendar.h 2010-12-18 04:43:40 +0000
61+++ drizzled/calendar.h 2011-01-18 01:47:30 +0000
62@@ -48,7 +48,6 @@
63 #define GREGORIAN_START_MONTH 10
64 #define GREGORIAN_START_DAY 15
65
66-#define UNIX_EPOCH_MAX_YEARS 2038
67 #define UNIX_EPOCH_MIN_YEARS 1970
68
69 #define CALENDAR_YY_PART_YEAR 70
70
71=== modified file 'drizzled/error.cc'
72--- drizzled/error.cc 2011-01-13 09:25:42 +0000
73+++ drizzled/error.cc 2011-01-18 01:47:30 +0000
74@@ -468,6 +468,7 @@
75 ADD_ERROR_MESSAGE(ER_LOAD_DATA_INVALID_COLUMN, N_("Invalid column reference (%-.64s) in LOAD DATA"));
76 ADD_ERROR_MESSAGE(ER_INVALID_UNIX_TIMESTAMP_VALUE, N_("Received an invalid value '%s' for a UNIX timestamp."));
77 ADD_ERROR_MESSAGE(ER_INVALID_DATETIME_VALUE, N_("Received an invalid datetime value '%s'."));
78+ ADD_ERROR_MESSAGE(ER_INVALID_TIMESTAMP_VALUE, N_("Received an invalid timestamp value '%s'."));
79 ADD_ERROR_MESSAGE(ER_INVALID_NULL_ARGUMENT, N_("Received a NULL argument for function '%s'."));
80 ADD_ERROR_MESSAGE(ER_ARGUMENT_OUT_OF_RANGE, N_("Received an out-of-range argument '%s' for function '%s'."));
81 ADD_ERROR_MESSAGE(ER_INVALID_ENUM_VALUE, N_("Received an invalid enum value '%s'."));
82
83=== modified file 'drizzled/error_t.h'
84--- drizzled/error_t.h 2011-01-13 09:25:42 +0000
85+++ drizzled/error_t.h 2011-01-18 01:47:30 +0000
86@@ -833,18 +833,8 @@
87 ER_KILL_DENY_SELF_ERROR,
88 ER_INVALID_ALTER_TABLE_FOR_NOT_NULL,
89 ER_ADMIN_ACCESS,
90- ER_INVALID_UUID_VALUE,
91- ER_INVALID_UUID_TIME,
92- ER_CORRUPT_TABLE_DEFINITION_ENUM,
93- ER_CORRUPT_TABLE_DEFINITION_UNKNOWN_COLLATION,
94- ER_CORRUPT_TABLE_DEFINITION_UNKNOWN,
95- ER_INVALID_CAST_TO_SIGNED,
96- ER_INVALID_CAST_TO_UNSIGNED,
97- ER_SQL_KEYWORD,
98- ER_INVALID_BOOLEAN_VALUE,
99 ER_ASSERT,
100 ER_ASSERT_NULL,
101- ER_TABLE_DROP,
102 ER_CATALOG_CANNOT_CREATE,
103 ER_CATALOG_CANNOT_CREATE_PERMISSION,
104 ER_CATALOG_CANNOT_DROP,
105@@ -853,8 +843,20 @@
106 ER_CATALOG_NO_DROP_LOCAL,
107 ER_CATALOG_NO_LOCK,
108 ER_CORRUPT_CATALOG_DEFINITION,
109+ ER_CORRUPT_TABLE_DEFINITION_ENUM,
110+ ER_CORRUPT_TABLE_DEFINITION_UNKNOWN,
111+ ER_CORRUPT_TABLE_DEFINITION_UNKNOWN_COLLATION,
112+ ER_INVALID_BOOLEAN_VALUE,
113+ ER_INVALID_CAST_TO_SIGNED,
114+ ER_INVALID_CAST_TO_UNSIGNED,
115+ ER_INVALID_TIMESTAMP_VALUE,
116+ ER_INVALID_UUID_TIME,
117+ ER_INVALID_UUID_VALUE,
118+ ER_SQL_KEYWORD,
119+ ER_TABLE_DROP,
120 ER_TABLE_DROP_ERROR_OCCURRED,
121 ER_TABLE_PERMISSION_DENIED,
122+
123 ER_INVALID_CAST_TO_BOOLEAN,
124
125 // Leave ER_INVALID_BOOLEAN_VALUE as LAST, and force people to use tags
126
127=== modified file 'drizzled/field.cc'
128--- drizzled/field.cc 2011-01-05 17:21:13 +0000
129+++ drizzled/field.cc 2011-01-18 01:47:30 +0000
130@@ -1015,7 +1015,7 @@
131 char buff[40];
132 String tmp(buff,sizeof(buff),&my_charset_bin),*res;
133 if (!(res=val_str_internal(&tmp)) || str_to_datetime_with_warn(res->ptr(), res->length(),
134- ltime, fuzzydate) <= DRIZZLE_TIMESTAMP_ERROR)
135+ ltime, fuzzydate) <= type::DRIZZLE_TIMESTAMP_ERROR)
136 {
137 return 1;
138 }
139@@ -1036,11 +1036,13 @@
140 return 0;
141 }
142
143-int Field::store_time(type::Time *ltime, enum enum_drizzle_timestamp_type)
144+int Field::store_time(type::Time *ltime, type::timestamp_t)
145 {
146- char buff[MAX_DATE_STRING_REP_LENGTH];
147- uint32_t length= (uint32_t) my_TIME_to_str(ltime, buff);
148- return store(buff, length, &my_charset_bin);
149+ String tmp;
150+
151+ ltime->convert(tmp);
152+
153+ return store(tmp.ptr(), tmp.length(), &my_charset_bin);
154 }
155
156 bool Field::optimize_range(uint32_t idx, uint32_t)
157@@ -1195,7 +1197,7 @@
158 unsigned int code,
159 const char *str,
160 uint32_t str_length,
161- enum enum_drizzle_timestamp_type ts_type,
162+ type::timestamp_t ts_type,
163 int cuted_increment)
164 {
165 Session *session= table ? table->in_use : current_session;
166@@ -1209,7 +1211,7 @@
167 void Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level,
168 uint32_t code,
169 int64_t nr,
170- enum enum_drizzle_timestamp_type ts_type,
171+ type::timestamp_t ts_type,
172 int cuted_increment)
173 {
174 Session *session= table ? table->in_use : current_session;
175@@ -1226,7 +1228,7 @@
176 void Field::set_datetime_warning(DRIZZLE_ERROR::enum_warning_level level,
177 const uint32_t code,
178 double nr,
179- enum enum_drizzle_timestamp_type ts_type)
180+ type::timestamp_t ts_type)
181 {
182 Session *session= table ? table->in_use : current_session;
183 if (session->really_abort_on_warning() ||
184
185=== modified file 'drizzled/field.h'
186--- drizzled/field.h 2011-01-13 01:04:53 +0000
187+++ drizzled/field.h 2011-01-18 01:47:30 +0000
188@@ -211,7 +211,7 @@
189 @note
190 Needs to be changed if/when we want to support different time formats.
191 */
192- virtual int store_time(type::Time *ltime, enum enum_drizzle_timestamp_type t_type);
193+ virtual int store_time(type::Time *ltime, type::timestamp_t t_type);
194 virtual double val_real()=0;
195 virtual int64_t val_int()=0;
196 virtual type::Decimal *val_decimal(type::Decimal *);
197@@ -644,7 +644,7 @@
198 uint32_t code,
199 const char *str,
200 uint32_t str_len,
201- enum enum_drizzle_timestamp_type ts_type,
202+ type::timestamp_t ts_type,
203 int cuted_increment);
204 /**
205 Produce warning or note about integer datetime value saved into field.
206@@ -663,7 +663,7 @@
207 void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level,
208 uint32_t code,
209 int64_t nr,
210- enum enum_drizzle_timestamp_type ts_type,
211+ type::timestamp_t ts_type,
212 int cuted_increment);
213 /**
214 Produce warning or note about double datetime data saved into field.
215@@ -681,7 +681,7 @@
216 void set_datetime_warning(DRIZZLE_ERROR::enum_warning_level,
217 const uint32_t code,
218 double nr,
219- enum enum_drizzle_timestamp_type ts_type);
220+ type::timestamp_t ts_type);
221 bool check_overflow(int op_result)
222 {
223 return (op_result == E_DEC_OVERFLOW);
224
225=== modified file 'drizzled/field/date.cc'
226--- drizzled/field/date.cc 2010-12-25 04:38:28 +0000
227+++ drizzled/field/date.cc 2011-01-18 01:47:30 +0000
228@@ -124,34 +124,35 @@
229 }
230
231 int Field_date::store_time(type::Time *ltime,
232- enum enum_drizzle_timestamp_type time_type)
233+ type::timestamp_t time_type)
234 {
235 long tmp;
236 int error= 0;
237- if (time_type == DRIZZLE_TIMESTAMP_DATE ||
238- time_type == DRIZZLE_TIMESTAMP_DATETIME)
239+ if (time_type == type::DRIZZLE_TIMESTAMP_DATE || time_type == type::DRIZZLE_TIMESTAMP_DATETIME)
240 {
241 tmp= ltime->year*10000 + ltime->month*100 + ltime->day;
242+
243 if (check_date(ltime, tmp != 0,
244 (TIME_FUZZY_DATE |
245 (current_session->variables.sql_mode &
246 (MODE_NO_ZERO_DATE | MODE_INVALID_DATES))), &error))
247 {
248- char buff[MAX_DATE_STRING_REP_LENGTH];
249+ char buff[type::Time::MAX_STRING_LENGTH];
250 String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
251- make_date(ltime, &str);
252+ ltime->convert(str, type::DRIZZLE_TIMESTAMP_DATE);
253 set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED,
254- str.ptr(), str.length(), DRIZZLE_TIMESTAMP_DATE, 1);
255+ str.ptr(), str.length(), type::DRIZZLE_TIMESTAMP_DATE, 1);
256 }
257- if (!error && ltime->time_type != DRIZZLE_TIMESTAMP_DATE &&
258+
259+ if (not error && ltime->time_type != type::DRIZZLE_TIMESTAMP_DATE &&
260 (ltime->hour || ltime->minute || ltime->second || ltime->second_part))
261 {
262- char buff[MAX_DATE_STRING_REP_LENGTH];
263+ char buff[type::Time::MAX_STRING_LENGTH];
264 String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
265- make_datetime(ltime, &str);
266+ ltime->convert(str);
267 set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_NOTE,
268 ER_WARN_DATA_TRUNCATED,
269- str.ptr(), str.length(), DRIZZLE_TIMESTAMP_DATE, 1);
270+ str.ptr(), str.length(), type::DRIZZLE_TIMESTAMP_DATE, 1);
271 error= 3;
272 }
273 }
274@@ -161,7 +162,9 @@
275 error= 1;
276 set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
277 }
278+
279 int4store(ptr,tmp);
280+
281 return error;
282 }
283
284@@ -215,7 +218,7 @@
285 ltime->day= (int) (tmp%100);
286 ltime->month= (int) (tmp/100%100);
287 ltime->year= (int) (tmp/10000);
288- ltime->time_type= DRIZZLE_TIMESTAMP_DATE;
289+ ltime->time_type= type::DRIZZLE_TIMESTAMP_DATE;
290 ltime->hour= ltime->minute= ltime->second= ltime->second_part= ltime->neg= 0;
291 return ((!(fuzzydate & TIME_FUZZY_DATE) && (!ltime->month || !ltime->day)) ?
292 1 : 0);
293
294=== modified file 'drizzled/field/date.h'
295--- drizzled/field/date.h 2010-12-25 04:38:28 +0000
296+++ drizzled/field/date.h 2011-01-18 01:47:30 +0000
297@@ -64,7 +64,7 @@
298 const CHARSET_INFO * const charset);
299 int store(double nr);
300 int store(int64_t nr, bool unsigned_val);
301- int store_time(type::Time *ltime, enum enum_drizzle_timestamp_type type);
302+ int store_time(type::Time *ltime, type::timestamp_t type);
303 int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
304 double val_real(void);
305 int64_t val_int(void);
306
307=== modified file 'drizzled/field/datetime.cc'
308--- drizzled/field/datetime.cc 2010-12-25 04:38:28 +0000
309+++ drizzled/field/datetime.cc 2011-01-18 01:47:30 +0000
310@@ -121,7 +121,7 @@
311 return 0;
312 }
313
314-int Field_datetime::store_time(type::Time *ltime, enum enum_drizzle_timestamp_type)
315+int Field_datetime::store_time(type::Time *ltime, type::timestamp_t)
316 {
317 DateTime temporal;
318
319@@ -134,11 +134,11 @@
320
321 if (! temporal.is_valid())
322 {
323- char tmp_string[MAX_DATE_STRING_REP_LENGTH];
324+ char tmp_string[type::Time::MAX_STRING_LENGTH];
325 size_t tmp_string_len;
326
327- tmp_string_len= temporal.to_string(tmp_string, MAX_DATE_STRING_REP_LENGTH);
328- assert(tmp_string_len < MAX_DATE_STRING_REP_LENGTH);
329+ tmp_string_len= temporal.to_string(tmp_string, type::Time::MAX_STRING_LENGTH);
330+ assert(tmp_string_len < type::Time::MAX_STRING_LENGTH);
331 my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp_string);
332 return 1;
333 }
334@@ -223,7 +223,7 @@
335 part1=(uint32_t) (tmp/INT64_C(1000000));
336 part2=(uint32_t) (tmp - (uint64_t) part1*INT64_C(1000000));
337
338- ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME;
339+ ltime->time_type= type::DRIZZLE_TIMESTAMP_DATETIME;
340 ltime->neg= 0;
341 ltime->second_part= 0;
342 ltime->second= (int) (part2%100);
343
344=== modified file 'drizzled/field/datetime.h'
345--- drizzled/field/datetime.h 2010-12-25 04:38:28 +0000
346+++ drizzled/field/datetime.h 2011-01-18 01:47:30 +0000
347@@ -63,7 +63,7 @@
348 int store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
349 int store(double nr);
350 int store(int64_t nr, bool unsigned_val);
351- int store_time(type::Time *ltime, enum enum_drizzle_timestamp_type type);
352+ int store_time(type::Time *ltime, type::timestamp_t type);
353 int reset(void)
354 {
355 ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0;
356
357=== modified file 'drizzled/field/decimal.cc'
358--- drizzled/field/decimal.cc 2010-12-27 19:16:17 +0000
359+++ drizzled/field/decimal.cc 2011-01-18 01:47:30 +0000
360@@ -258,7 +258,7 @@
361
362
363 int Field_decimal::store_time(type::Time *ltime,
364- enum enum_drizzle_timestamp_type )
365+ type::timestamp_t )
366 {
367 type::Decimal decimal_value;
368 return store_value(date2_class_decimal(ltime, &decimal_value));
369
370=== modified file 'drizzled/field/decimal.h'
371--- drizzled/field/decimal.h 2010-12-25 04:38:28 +0000
372+++ drizzled/field/decimal.h 2011-01-18 01:47:30 +0000
373@@ -68,7 +68,7 @@
374 int store(const char *to, uint32_t length, const CHARSET_INFO * const charset);
375 int store(double nr);
376 int store(int64_t nr, bool unsigned_val);
377- int store_time(type::Time *ltime, enum enum_drizzle_timestamp_type t_type);
378+ int store_time(type::Time *ltime, type::timestamp_t t_type);
379 int store_decimal(const type::Decimal *);
380 double val_real(void);
381 int64_t val_int(void);
382
383=== modified file 'drizzled/field/epoch.cc'
384--- drizzled/field/epoch.cc 2011-01-06 18:00:47 +0000
385+++ drizzled/field/epoch.cc 2011-01-18 01:47:30 +0000
386@@ -162,7 +162,7 @@
387
388 if (not temporal.from_string(from, (size_t) len))
389 {
390- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), from);
391+ my_error(ER_INVALID_TIMESTAMP_VALUE, MYF(ME_FATALERROR), from);
392 return 1;
393 }
394
395@@ -178,19 +178,33 @@
396 {
397 ASSERT_COLUMN_MARKED_FOR_WRITE;
398
399- if (from < 0 || from > 99991231235959.0)
400+ uint64_t from_tmp= (uint64_t)from;
401+
402+ Timestamp temporal;
403+ if (not temporal.from_int64_t(from_tmp))
404 {
405- /* Convert the double to a string using stringstream */
406- std::stringstream ss;
407- std::string tmp;
408- ss.precision(18); /* 18 places should be fine for error display of double input. */
409- ss << from;
410- ss >> tmp;
411+ /* Convert the integer to a string using boost::lexical_cast */
412+ std::string tmp(boost::lexical_cast<std::string>(from));
413
414- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
415+ my_error(ER_INVALID_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
416 return 2;
417 }
418- return Epoch::store((int64_t) rint(from), false);
419+
420+ time_t tmp;
421+ temporal.to_time_t(tmp);
422+
423+ uint64_t tmp_micro= tmp;
424+ pack_num(tmp_micro);
425+
426+ return 0;
427+}
428+
429+int Epoch::store_decimal(const type::Decimal *value)
430+{
431+ double tmp;
432+ value->convert(tmp);
433+
434+ return store(tmp);
435 }
436
437 int Epoch::store(int64_t from, bool)
438@@ -202,12 +216,12 @@
439 * if unable to create a valid DateTime.
440 */
441 Timestamp temporal;
442- if (! temporal.from_int64_t(from))
443+ if (not temporal.from_int64_t(from))
444 {
445 /* Convert the integer to a string using boost::lexical_cast */
446 std::string tmp(boost::lexical_cast<std::string>(from));
447
448- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
449+ my_error(ER_INVALID_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
450 return 2;
451 }
452
453@@ -269,30 +283,21 @@
454 bool Epoch::get_date(type::Time *ltime, uint32_t)
455 {
456 uint64_t temp;
457+ type::Time::epoch_t time_temp;
458
459 unpack_num(temp);
460+ time_temp= temp;
461
462- memset(ltime, 0, sizeof(*ltime));
463-
464- Timestamp temporal;
465- (void) temporal.from_time_t((time_t) temp);
466-
467- /* @TODO Goodbye the below code when type::Time is finally gone.. */
468-
469- ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME;
470- ltime->year= temporal.years();
471- ltime->month= temporal.months();
472- ltime->day= temporal.days();
473- ltime->hour= temporal.hours();
474- ltime->minute= temporal.minutes();
475- ltime->second= temporal.seconds();
476+ ltime->reset();
477+
478+ ltime->store(time_temp);
479
480 return 0;
481 }
482
483 bool Epoch::get_time(type::Time *ltime)
484 {
485- return Epoch::get_date(ltime,0);
486+ return Epoch::get_date(ltime, 0);
487 }
488
489 int Epoch::cmp(const unsigned char *a_ptr, const unsigned char *b_ptr)
490
491=== modified file 'drizzled/field/epoch.h'
492--- drizzled/field/epoch.h 2011-01-06 18:00:47 +0000
493+++ drizzled/field/epoch.h 2011-01-18 01:47:30 +0000
494@@ -50,10 +50,13 @@
495 enum_field_types type() const { return DRIZZLE_TYPE_TIMESTAMP;}
496 enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
497 enum Item_result cmp_type () const { return INT_RESULT; }
498- int store(const char *to,uint32_t length,
499- const CHARSET_INFO * const charset);
500- int store(double nr);
501- int store(int64_t nr, bool unsigned_val);
502+
503+ int store(const char *to,uint32_t length,
504+ const CHARSET_INFO * const charset);
505+ int store(double nr);
506+ int store(int64_t nr, bool unsigned_val);
507+ int store_decimal(const type::Decimal *value);
508+
509 int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; return 0; }
510 double val_real(void);
511 int64_t val_int(void);
512
513=== modified file 'drizzled/field/microtime.cc'
514--- drizzled/field/microtime.cc 2011-01-11 00:57:46 +0000
515+++ drizzled/field/microtime.cc 2011-01-18 01:47:30 +0000
516@@ -54,8 +54,8 @@
517 unireg_check_arg,
518 field_name_arg,
519 share)
520- {
521- }
522+{
523+}
524
525 Microtime::Microtime(bool maybe_null_arg,
526 const char *field_name_arg) :
527@@ -74,7 +74,7 @@
528
529 if (not temporal.from_string(from, (size_t) len))
530 {
531- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), from);
532+ my_error(ER_INVALID_TIMESTAMP_VALUE, MYF(ME_FATALERROR), from);
533 return 1;
534 }
535
536@@ -90,12 +90,12 @@
537 return 0;
538 }
539
540-int Microtime::store_time(type::Time *ltime, enum enum_drizzle_timestamp_type )
541+int Microtime::store_time(type::Time *ltime, type::timestamp_t )
542 {
543 long my_timezone;
544 bool in_dst_time_gap;
545
546- time_t time_tmp= my_system_gmt_sec(ltime, &my_timezone, &in_dst_time_gap, true);
547+ type::Time::epoch_t time_tmp= my_system_gmt_sec(ltime, &my_timezone, &in_dst_time_gap, true);
548 uint64_t tmp_seconds= time_tmp;
549 uint32_t tmp_micro= ltime->second_part;
550
551@@ -109,19 +109,27 @@
552 {
553 ASSERT_COLUMN_MARKED_FOR_WRITE;
554
555- if (from < 0 || from > 99991231235959.0)
556+ uint64_t from_tmp= (uint64_t)from;
557+ type::Time::usec_t fractional_seconds= (type::Time::usec_t)((from - from_tmp) * type::Time::FRACTIONAL_DIGITS) % type::Time::FRACTIONAL_DIGITS;
558+
559+ MicroTimestamp temporal;
560+ if (not temporal.from_int64_t(from_tmp))
561 {
562- /* Convert the double to a string using stringstream */
563- std::stringstream ss;
564- std::string tmp;
565- ss.precision(18); /* 18 places should be fine for error display of double input. */
566- ss << from;
567- ss >> tmp;
568+ /* Convert the integer to a string using boost::lexical_cast */
569+ std::string tmp(boost::lexical_cast<std::string>(from));
570
571- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
572+ my_error(ER_INVALID_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
573 return 2;
574 }
575- return Microtime::store((int64_t) rint(from), false);
576+
577+ time_t tmp;
578+ temporal.to_time_t(tmp);
579+
580+ uint64_t tmp_micro= tmp;
581+ pack_num(tmp_micro);
582+ pack_num(fractional_seconds, ptr +8);
583+
584+ return 0;
585 }
586
587 int Microtime::store(int64_t from, bool)
588@@ -134,7 +142,7 @@
589 /* Convert the integer to a string using boost::lexical_cast */
590 std::string tmp(boost::lexical_cast<std::string>(from));
591
592- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
593+ my_error(ER_INVALID_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
594 return 2;
595 }
596
597@@ -150,7 +158,33 @@
598
599 double Microtime::val_real(void)
600 {
601- return (double) Microtime::val_int();
602+ uint64_t temp;
603+ type::Time::usec_t micro_temp;
604+
605+ ASSERT_COLUMN_MARKED_FOR_READ;
606+
607+ unpack_num(temp);
608+ unpack_num(micro_temp, ptr +8);
609+
610+ Timestamp temporal;
611+ (void) temporal.from_time_t((time_t) temp);
612+
613+ /* We must convert into a "timestamp-formatted integer" ... */
614+ int64_t result;
615+ temporal.to_int64_t(&result);
616+
617+ result+= micro_temp % type::Time::FRACTIONAL_DIGITS;
618+
619+ return result;
620+}
621+
622+type::Decimal *Microtime::val_decimal(type::Decimal *decimal_value)
623+{
624+ type::Time ltime;
625+
626+ get_date(&ltime, 0);
627+
628+ return date2_class_decimal(&ltime, decimal_value);
629 }
630
631 int64_t Microtime::val_int(void)
632@@ -174,29 +208,16 @@
633 String *Microtime::val_str(String *val_buffer, String *)
634 {
635 uint64_t temp= 0;
636- uint32_t micro_temp= 0;
637- char *to;
638- int to_len= field_length + 1 + 8;
639-
640- val_buffer->alloc(to_len);
641- to= (char *) val_buffer->ptr();
642+ type::Time::usec_t micro_temp= 0;
643
644 unpack_num(temp);
645 unpack_num(micro_temp, ptr +8);
646
647- val_buffer->set_charset(&my_charset_bin); /* Safety */
648-
649- struct timeval buffer;
650- buffer.tv_sec= temp;
651- buffer.tv_usec= micro_temp;
652-
653- MicroTimestamp temporal;
654- (void) temporal.from_timeval(buffer);
655-
656- int rlen= temporal.to_string(to, to_len);
657- assert(rlen <= to_len);
658-
659- val_buffer->length(rlen);
660+ type::Time tmp_time;
661+ tmp_time.store(temp, micro_temp);
662+
663+ tmp_time.convert(*val_buffer);
664+
665
666 return val_buffer;
667 }
668@@ -209,28 +230,16 @@
669 unpack_num(temp);
670 unpack_num(micro_temp, ptr +8);
671
672- memset(ltime, 0, sizeof(*ltime));
673-
674- Timestamp temporal;
675- (void) temporal.from_time_t((time_t) temp);
676-
677- /* @TODO Goodbye the below code when type::Time is finally gone.. */
678-
679- ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME;
680- ltime->year= temporal.years();
681- ltime->month= temporal.months();
682- ltime->day= temporal.days();
683- ltime->hour= temporal.hours();
684- ltime->minute= temporal.minutes();
685- ltime->second= temporal.seconds();
686- ltime->second_part= temporal.useconds();
687-
688- return 0;
689+ ltime->reset();
690+
691+ ltime->store(temp, micro_temp);
692+
693+ return false;
694 }
695
696 bool Microtime::get_time(type::Time *ltime)
697 {
698- return Microtime::get_date(ltime,0);
699+ return Microtime::get_date(ltime, 0);
700 }
701
702 int Microtime::cmp(const unsigned char *a_ptr, const unsigned char *b_ptr)
703@@ -275,7 +284,7 @@
704 {
705 Session *session= getTable() ? getTable()->in_use : current_session;
706
707- uint32_t fractional_seconds= 0;
708+ type::Time::usec_t fractional_seconds= 0;
709 uint64_t epoch_seconds= session->getCurrentTimestampEpoch(fractional_seconds);
710
711 set_notnull();
712
713=== modified file 'drizzled/field/microtime.h'
714--- drizzled/field/microtime.h 2011-01-11 00:57:46 +0000
715+++ drizzled/field/microtime.h 2011-01-18 01:47:30 +0000
716@@ -54,11 +54,13 @@
717 const CHARSET_INFO * const charset);
718 int store(double nr);
719 int store(int64_t nr, bool unsigned_val);
720- int store_time(type::Time *ltime, enum enum_drizzle_timestamp_type t_type);
721+ int store_time(type::Time *ltime, type::timestamp_t t_type);
722
723+ String *val_str(String*,String *);
724 double val_real(void);
725 int64_t val_int(void);
726- String *val_str(String*,String *);
727+ type::Decimal *val_decimal(type::Decimal *decimal_value);
728+
729 int cmp(const unsigned char *,const unsigned char *);
730 void sort_string(unsigned char *buff,uint32_t length);
731 uint32_t pack_length() const { return 12; }
732
733=== modified file 'drizzled/field/time.cc'
734--- drizzled/field/time.cc 2010-12-25 04:38:28 +0000
735+++ drizzled/field/time.cc 2011-01-18 01:47:30 +0000
736@@ -101,14 +101,14 @@
737 {
738 tmp= TIME_MAX_VALUE;
739 set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
740- ER_WARN_DATA_OUT_OF_RANGE, from, DRIZZLE_TIMESTAMP_TIME);
741+ ER_WARN_DATA_OUT_OF_RANGE, from, type::DRIZZLE_TIMESTAMP_TIME);
742 error= 1;
743 }
744 else if (from < (double) - TIME_MAX_VALUE)
745 {
746 tmp= -TIME_MAX_VALUE;
747 set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
748- ER_WARN_DATA_OUT_OF_RANGE, from, DRIZZLE_TIMESTAMP_TIME);
749+ ER_WARN_DATA_OUT_OF_RANGE, from, type::DRIZZLE_TIMESTAMP_TIME);
750 error= 1;
751 }
752 else
753@@ -123,7 +123,7 @@
754 tmp=0;
755 set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
756 ER_WARN_DATA_OUT_OF_RANGE, from,
757- DRIZZLE_TIMESTAMP_TIME);
758+ type::DRIZZLE_TIMESTAMP_TIME);
759 error= 1;
760 }
761 }
762@@ -227,7 +227,7 @@
763 drizzled::Time temporal;
764 unpack_time(temporal);
765
766- ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME;
767+ ltime->time_type= type::DRIZZLE_TIMESTAMP_DATETIME;
768 ltime->year= temporal.years();
769 ltime->month= temporal.months();
770 ltime->day= temporal.days();
771
772=== modified file 'drizzled/field/uuid.cc'
773--- drizzled/field/uuid.cc 2010-12-26 01:00:32 +0000
774+++ drizzled/field/uuid.cc 2011-01-18 01:47:30 +0000
775@@ -31,7 +31,6 @@
776 #include "drizzled/internal/my_sys.h"
777 #include "drizzled/session.h"
778 #include "drizzled/table.h"
779-#include "drizzled/temporal.h"
780
781 namespace drizzled
782 {
783@@ -167,27 +166,17 @@
784
785 if (uu.isTimeType())
786 {
787- Timestamp temporal;
788 struct timeval ret_tv;
789
790- ret_tv.tv_sec= ret_tv.tv_usec= 0;
791+ memset(&ret_tv, 0, sizeof(struct timeval));
792
793 uu.time(ret_tv);
794
795- temporal.from_time_t(ret_tv.tv_sec);
796-
797- ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME;
798- ltime->year= temporal.years();
799- ltime->month= temporal.months();
800- ltime->day= temporal.days();
801- ltime->hour= temporal.hours();
802- ltime->minute= temporal.minutes();
803- ltime->second= temporal.seconds();
804- ltime->second_part= temporal.nseconds();
805+ ltime->store(ret_tv);
806
807 return false;
808 }
809- memset(ltime, 0, sizeof(type::Time));
810+ ltime->reset();
811
812 return true;
813 }
814
815=== modified file 'drizzled/function/cast/time.cc'
816--- drizzled/function/cast/time.cc 2010-12-25 04:38:28 +0000
817+++ drizzled/function/cast/time.cc 2011-01-18 01:47:30 +0000
818@@ -31,10 +31,10 @@
819 {
820 bool res= get_arg0_time(ltime);
821
822- if (ltime->time_type == DRIZZLE_TIMESTAMP_DATETIME)
823+ if (ltime->time_type == type::DRIZZLE_TIMESTAMP_DATETIME)
824 ltime->year= ltime->month= ltime->day= 0;
825
826- ltime->time_type= DRIZZLE_TIMESTAMP_TIME;
827+ ltime->time_type= type::DRIZZLE_TIMESTAMP_TIME;
828
829 return res;
830 }
831@@ -47,7 +47,8 @@
832 if (not get_arg0_time(&ltime))
833 {
834 null_value= 0;
835- make_time(&ltime, str);
836+ ltime.convert(*str, type::DRIZZLE_TIMESTAMP_TIME);
837+
838 return str;
839 }
840
841
842=== modified file 'drizzled/function/time/curdate.cc'
843--- drizzled/function/time/curdate.cc 2011-01-06 23:02:43 +0000
844+++ drizzled/function/time/curdate.cc 2011-01-18 01:47:30 +0000
845@@ -37,7 +37,7 @@
846
847 /* We don't need to set second_part and neg because they already 0 */
848 ltime.hour= ltime.minute= ltime.second= 0;
849- ltime.time_type= DRIZZLE_TIMESTAMP_DATE;
850+ ltime.time_type= type::DRIZZLE_TIMESTAMP_DATE;
851
852 /**
853 * @TODO Remove ltime completely when timezones are reworked. Using this
854
855=== modified file 'drizzled/function/time/date.cc'
856--- drizzled/function/time/date.cc 2010-12-18 04:43:40 +0000
857+++ drizzled/function/time/date.cc 2011-01-18 01:47:30 +0000
858@@ -34,16 +34,16 @@
859 if (! get_temporal(temporal))
860 return (String *) NULL; /* get_temporal throws error. */
861
862- if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
863+ if (str->alloc(type::Time::MAX_STRING_LENGTH))
864 {
865 null_value= true;
866 return (String *) NULL;
867 }
868
869 /* Convert the Date to a string and return it */
870- int new_length;
871- new_length= temporal.to_string(str->c_ptr(), MAX_DATE_STRING_REP_LENGTH);
872- assert(new_length < MAX_DATE_STRING_REP_LENGTH);
873+ size_t new_length;
874+ new_length= temporal.to_string(str->c_ptr(), type::Time::MAX_STRING_LENGTH);
875+ assert(new_length < type::Time::MAX_STRING_LENGTH);
876 str->length(new_length);
877 return str;
878 }
879
880=== modified file 'drizzled/function/time/date_add_interval.cc'
881--- drizzled/function/time/date_add_interval.cc 2011-01-06 23:23:07 +0000
882+++ drizzled/function/time/date_add_interval.cc 2011-01-18 01:47:30 +0000
883@@ -113,9 +113,9 @@
884 if (Item_date_add_interval::get_date(&ltime, TIME_NO_ZERO_DATE))
885 return 0;
886
887- if (ltime.time_type == DRIZZLE_TIMESTAMP_DATE)
888+ if (ltime.time_type == type::DRIZZLE_TIMESTAMP_DATE)
889 {
890- make_date(&ltime, str);
891+ ltime.convert(*str, type::DRIZZLE_TIMESTAMP_DATE);
892 }
893 else if (ltime.second_part)
894 {
895@@ -135,7 +135,7 @@
896 }
897 else
898 {
899- make_datetime(&ltime, str);
900+ ltime.convert(*str);
901 }
902
903 return str;
904@@ -149,7 +149,7 @@
905 if (Item_date_add_interval::get_date(&ltime, TIME_NO_ZERO_DATE))
906 return (int64_t) 0;
907 date = (ltime.year*100L + ltime.month)*100L + ltime.day;
908- return ltime.time_type == DRIZZLE_TIMESTAMP_DATE ? date :
909+ return ltime.time_type == type::DRIZZLE_TIMESTAMP_DATE ? date :
910 ((date*100L + ltime.hour)*100L+ ltime.minute)*100L + ltime.second;
911 }
912
913
914=== modified file 'drizzled/function/time/date_format.cc'
915--- drizzled/function/time/date_format.cc 2010-12-25 04:38:28 +0000
916+++ drizzled/function/time/date_format.cc 2011-01-18 01:47:30 +0000
917@@ -36,7 +36,7 @@
918 */
919
920 static bool make_date_time(String *format, type::Time *l_time,
921- enum enum_drizzle_timestamp_type type, String *str)
922+ type::timestamp_t type, String *str)
923 {
924 char intbuff[15];
925 uint32_t hours_i;
926@@ -74,7 +74,7 @@
927 system_charset_info);
928 break;
929 case 'W':
930- if (type == DRIZZLE_TIMESTAMP_TIME)
931+ if (type == type::DRIZZLE_TIMESTAMP_TIME)
932 return 1;
933 weekday= calc_weekday(calc_daynr(l_time->year,l_time->month,
934 l_time->day),0);
935@@ -83,7 +83,7 @@
936 system_charset_info);
937 break;
938 case 'a':
939- if (type == DRIZZLE_TIMESTAMP_TIME)
940+ if (type == type::DRIZZLE_TIMESTAMP_TIME)
941 return 1;
942 weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
943 l_time->day),0);
944@@ -92,7 +92,7 @@
945 system_charset_info);
946 break;
947 case 'D':
948- if (type == DRIZZLE_TIMESTAMP_TIME)
949+ if (type == type::DRIZZLE_TIMESTAMP_TIME)
950 return 1;
951 length= internal::int10_to_str(l_time->day, intbuff, 10) - intbuff;
952 str->append_with_prefill(intbuff, length, 1, '0');
953@@ -159,7 +159,7 @@
954 str->append_with_prefill(intbuff, length, 2, '0');
955 break;
956 case 'j':
957- if (type == DRIZZLE_TIMESTAMP_TIME)
958+ if (type == type::DRIZZLE_TIMESTAMP_TIME)
959 return 1;
960 length= internal::int10_to_str(calc_daynr(l_time->year,l_time->month,
961 l_time->day) -
962@@ -205,7 +205,7 @@
963 case 'u':
964 {
965 uint32_t year;
966- if (type == DRIZZLE_TIMESTAMP_TIME)
967+ if (type == type::DRIZZLE_TIMESTAMP_TIME)
968 return 1;
969 length= internal::int10_to_str(calc_week(l_time,
970 (*ptr) == 'U' ?
971@@ -219,7 +219,7 @@
972 case 'V':
973 {
974 uint32_t year;
975- if (type == DRIZZLE_TIMESTAMP_TIME)
976+ if (type == type::DRIZZLE_TIMESTAMP_TIME)
977 return 1;
978 length= internal::int10_to_str(calc_week(l_time,
979 ((*ptr) == 'V' ?
980@@ -234,7 +234,7 @@
981 case 'X':
982 {
983 uint32_t year;
984- if (type == DRIZZLE_TIMESTAMP_TIME)
985+ if (type == type::DRIZZLE_TIMESTAMP_TIME)
986 return 1;
987 (void) calc_week(l_time,
988 ((*ptr) == 'X' ?
989@@ -246,7 +246,7 @@
990 }
991 break;
992 case 'w':
993- if (type == DRIZZLE_TIMESTAMP_TIME)
994+ if (type == type::DRIZZLE_TIMESTAMP_TIME)
995 return 1;
996 weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
997 l_time->day),1);
998@@ -410,12 +410,12 @@
999 goto null_date;
1000
1001 if (fixed_length)
1002- size=max_length;
1003+ size= max_length;
1004 else
1005- size=format_length(format);
1006+ size= format_length(format);
1007
1008- if (size < MAX_DATE_STRING_REP_LENGTH)
1009- size= MAX_DATE_STRING_REP_LENGTH;
1010+ if (size < type::Time::MAX_STRING_LENGTH)
1011+ size= type::Time::MAX_STRING_LENGTH;
1012
1013 if (format == str)
1014 str= &value; // Save result here
1015@@ -426,8 +426,8 @@
1016 /* Create the result string */
1017 str->set_charset(collation.collation);
1018 if (not make_date_time(format, &l_time,
1019- is_time_format ? DRIZZLE_TIMESTAMP_TIME :
1020- DRIZZLE_TIMESTAMP_DATE,
1021+ is_time_format ? type::DRIZZLE_TIMESTAMP_TIME :
1022+ type::DRIZZLE_TIMESTAMP_DATE,
1023 str))
1024 return str;
1025
1026
1027=== modified file 'drizzled/function/time/from_unixtime.cc'
1028--- drizzled/function/time/from_unixtime.cc 2010-12-25 04:38:28 +0000
1029+++ drizzled/function/time/from_unixtime.cc 2011-01-18 01:47:30 +0000
1030@@ -48,13 +48,13 @@
1031 if (get_date(&time_tmp, 0))
1032 return 0;
1033
1034- if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
1035+ if (str->alloc(type::Time::MAX_STRING_LENGTH))
1036 {
1037 null_value= 1;
1038 return 0;
1039 }
1040
1041- make_datetime(&time_tmp, str);
1042+ time_tmp.convert(*str);
1043
1044 return str;
1045 }
1046@@ -73,7 +73,27 @@
1047
1048 bool Item_func_from_unixtime::get_date(type::Time *ltime, uint32_t)
1049 {
1050- uint64_t tmp= (uint64_t)(args[0]->val_int());
1051+ uint64_t tmp= 0;
1052+ type::Time::usec_t fractional_tmp= 0;
1053+
1054+ switch (args[0]->result_type()) {
1055+ case REAL_RESULT:
1056+ case ROW_RESULT:
1057+ case DECIMAL_RESULT:
1058+ case STRING_RESULT:
1059+ {
1060+ double double_tmp= args[0]->val_real();
1061+
1062+ tmp= (uint64_t)(double_tmp);
1063+ fractional_tmp= (type::Time::usec_t)((double_tmp - tmp) * 1000000);
1064+
1065+ break;
1066+ }
1067+ case INT_RESULT:
1068+ tmp= (uint64_t)(args[0]->val_int());
1069+ break;
1070+ }
1071+
1072 /*
1073 "tmp > TIMESTAMP_MAX_VALUE" check also covers case of negative
1074 from_unixtime() argument since tmp is unsigned.
1075@@ -81,24 +101,8 @@
1076 if ((null_value= (args[0]->null_value || tmp > TIMESTAMP_MAX_VALUE)))
1077 return 1;
1078
1079- Timestamp temporal;
1080- if (! temporal.from_time_t((time_t) tmp))
1081- {
1082- null_value= true;
1083- std::string tmp_string(boost::lexical_cast<std::string>(tmp));
1084- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(0), tmp_string.c_str());
1085- return 0;
1086- }
1087-
1088- memset(ltime, 0, sizeof(*ltime));
1089-
1090- ltime->year= temporal.years();
1091- ltime->month= temporal.months();
1092- ltime->day= temporal.days();
1093- ltime->hour= temporal.hours();
1094- ltime->minute= temporal.minutes();
1095- ltime->second= temporal.seconds();
1096- ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME;
1097+ ltime->reset();
1098+ ltime->store(tmp, fractional_tmp);
1099
1100 return 0;
1101 }
1102
1103=== modified file 'drizzled/function/time/makedate.cc'
1104--- drizzled/function/time/makedate.cc 2010-12-25 04:38:28 +0000
1105+++ drizzled/function/time/makedate.cc 2011-01-18 01:47:30 +0000
1106@@ -56,9 +56,11 @@
1107 {
1108 null_value=0;
1109 get_date_from_daynr(days,&l_time.year,&l_time.month,&l_time.day);
1110- if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
1111+ if (str->alloc(type::Time::MAX_STRING_LENGTH))
1112 goto err;
1113- make_date(&l_time, str);
1114+
1115+ l_time.convert(*str, type::DRIZZLE_TIMESTAMP_DATE);
1116+
1117 return str;
1118 }
1119
1120
1121=== modified file 'drizzled/function/time/now.cc'
1122--- drizzled/function/time/now.cc 2011-01-06 23:02:43 +0000
1123+++ drizzled/function/time/now.cc 2011-01-18 01:47:30 +0000
1124@@ -31,6 +31,7 @@
1125 {
1126 assert(fixed == 1);
1127 str_value.set(buff, buff_length, &my_charset_bin);
1128+
1129 return &str_value;
1130 }
1131
1132@@ -40,15 +41,18 @@
1133 decimals= DATETIME_DEC;
1134 collation.set(&my_charset_bin);
1135
1136- memset(&ltime, 0, sizeof(type::Time));
1137+ ltime.reset();
1138
1139- ltime.time_type= DRIZZLE_TIMESTAMP_DATETIME;
1140+ ltime.time_type= type::DRIZZLE_TIMESTAMP_DATETIME;
1141
1142 store_now_in_TIME(&ltime);
1143+
1144 value= (int64_t) TIME_to_uint64_t_datetime(&ltime);
1145
1146- buff_length= (uint) my_datetime_to_str(&ltime, buff);
1147- max_length= buff_length;
1148+ size_t length= type::Time::MAX_STRING_LENGTH;
1149+ ltime.convert(buff, length);
1150+
1151+ max_length= buff_length= length;
1152 }
1153
1154 /**
1155@@ -61,15 +65,10 @@
1156 uint32_t fractional_seconds= 0;
1157 time_t tmp= session->getCurrentTimestampEpoch(fractional_seconds);
1158
1159- (void) cached_temporal.from_time_t(tmp);
1160-
1161- now_time->year= cached_temporal.years();
1162- now_time->month= cached_temporal.months();
1163- now_time->day= cached_temporal.days();
1164- now_time->hour= cached_temporal.hours();
1165- now_time->minute= cached_temporal.minutes();
1166- now_time->second= cached_temporal.seconds();
1167- now_time->second_part= fractional_seconds;
1168+#if 0
1169+ now_time->store(tmp, fractional_seconds, true);
1170+#endif
1171+ now_time->store(tmp, fractional_seconds);
1172 }
1173
1174
1175@@ -83,15 +82,7 @@
1176 uint32_t fractional_seconds= 0;
1177 time_t tmp= session->getCurrentTimestampEpoch(fractional_seconds);
1178
1179- (void) cached_temporal.from_time_t(tmp);
1180-
1181- now_time->year= cached_temporal.years();
1182- now_time->month= cached_temporal.months();
1183- now_time->day= cached_temporal.days();
1184- now_time->hour= cached_temporal.hours();
1185- now_time->minute= cached_temporal.minutes();
1186- now_time->second= cached_temporal.seconds();
1187- now_time->second_part= fractional_seconds;
1188+ now_time->store(tmp, fractional_seconds);
1189 }
1190
1191 bool Item_func_now::get_temporal(DateTime &to)
1192@@ -100,8 +91,7 @@
1193 return true;
1194 }
1195
1196-bool Item_func_now::get_date(type::Time *res,
1197- uint32_t )
1198+bool Item_func_now::get_date(type::Time *res, uint32_t )
1199 {
1200 *res= ltime;
1201 return 0;
1202@@ -111,7 +101,7 @@
1203 int Item_func_now::save_in_field(Field *to, bool )
1204 {
1205 to->set_notnull();
1206- return to->store_time(&ltime, DRIZZLE_TIMESTAMP_DATETIME);
1207+ return to->store_time(&ltime, type::DRIZZLE_TIMESTAMP_DATETIME);
1208 }
1209
1210 } /* namespace drizzled */
1211
1212=== modified file 'drizzled/function/time/now.h'
1213--- drizzled/function/time/now.h 2011-01-06 23:02:43 +0000
1214+++ drizzled/function/time/now.h 2011-01-18 01:47:30 +0000
1215@@ -33,7 +33,7 @@
1216 {
1217 protected:
1218 int64_t value;
1219- char buff[20*2+32]; // +32 to make my_snprintf_{8bit|ucs2} happy
1220+ char buff[type::Time::MAX_STRING_LENGTH];
1221 uint32_t buff_length;
1222 type::Time ltime;
1223 DateTime cached_temporal;
1224
1225=== modified file 'drizzled/function/time/sysdate_local.cc'
1226--- drizzled/function/time/sysdate_local.cc 2010-12-25 04:38:28 +0000
1227+++ drizzled/function/time/sysdate_local.cc 2011-01-18 01:47:30 +0000
1228@@ -41,8 +41,12 @@
1229 {
1230 assert(fixed == 1);
1231 store_now_in_TIME(&ltime);
1232- buff_length= (uint) my_datetime_to_str(&ltime, buff);
1233- str_value.set(buff, buff_length, &my_charset_bin);
1234+
1235+ size_t length= type::Time::MAX_STRING_LENGTH;
1236+ ltime.convert(buff, length);
1237+ buff_length= length;
1238+ str_value.set(buff, length, &my_charset_bin);
1239+
1240 return &str_value;
1241 }
1242
1243@@ -70,8 +74,7 @@
1244 }
1245
1246
1247-bool Item_func_sysdate_local::get_date(type::Time *res,
1248- uint32_t )
1249+bool Item_func_sysdate_local::get_date(type::Time *res, uint32_t )
1250 {
1251 store_now_in_TIME(&ltime);
1252 *res= ltime;
1253@@ -83,7 +86,8 @@
1254 {
1255 store_now_in_TIME(&ltime);
1256 to->set_notnull();
1257- to->store_time(&ltime, DRIZZLE_TIMESTAMP_DATETIME);
1258+ to->store_time(&ltime, type::DRIZZLE_TIMESTAMP_DATETIME);
1259+
1260 return 0;
1261 }
1262
1263
1264=== modified file 'drizzled/function/time/typecast.cc'
1265--- drizzled/function/time/typecast.cc 2010-12-25 04:38:28 +0000
1266+++ drizzled/function/time/typecast.cc 2011-01-18 01:47:30 +0000
1267@@ -214,7 +214,10 @@
1268 str->set_charset(&my_charset_bin);
1269 }
1270 else
1271- make_datetime(&ltime, str);
1272+ {
1273+ ltime.convert(*str);
1274+ }
1275+
1276 return str;
1277 }
1278
1279@@ -240,15 +243,18 @@
1280 bool Item_date_typecast::get_date(type::Time *ltime, uint32_t )
1281 {
1282 bool res= get_arg0_date(ltime, TIME_FUZZY_DATE);
1283+
1284 ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
1285- ltime->time_type= DRIZZLE_TIMESTAMP_DATE;
1286+ ltime->time_type= type::DRIZZLE_TIMESTAMP_DATE;
1287+
1288 return res;
1289 }
1290
1291
1292 bool Item_date_typecast::get_time(type::Time *ltime)
1293 {
1294- memset(ltime, 0, sizeof(type::Time));
1295+ ltime->reset();
1296+
1297 return args[0]->null_value;
1298 }
1299
1300@@ -259,9 +265,10 @@
1301 type::Time ltime;
1302
1303 if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) &&
1304- !str->alloc(MAX_DATE_STRING_REP_LENGTH))
1305+ !str->alloc(type::Time::MAX_STRING_LENGTH))
1306 {
1307- make_date(&ltime, str);
1308+ ltime.convert(*str, type::DRIZZLE_TIMESTAMP_DATE);
1309+
1310 return str;
1311 }
1312
1313
1314=== modified file 'drizzled/item.cc'
1315--- drizzled/item.cc 2011-01-08 10:35:13 +0000
1316+++ drizzled/item.cc 2011-01-18 01:47:30 +0000
1317@@ -245,7 +245,7 @@
1318 if (get_time(&ltime))
1319 return set_field_to_null(field);
1320 field->set_notnull();
1321- return field->store_time(&ltime, DRIZZLE_TIMESTAMP_TIME);
1322+ return field->store_time(&ltime, type::DRIZZLE_TIMESTAMP_TIME);
1323 }
1324
1325 int Item::save_date_in_field(Field *field)
1326@@ -254,7 +254,7 @@
1327 if (get_date(&ltime, TIME_FUZZY_DATE))
1328 return set_field_to_null(field);
1329 field->set_notnull();
1330- return field->store_time(&ltime, DRIZZLE_TIMESTAMP_DATETIME);
1331+ return field->store_time(&ltime, type::DRIZZLE_TIMESTAMP_DATETIME);
1332 }
1333
1334 /**
1335@@ -462,33 +462,38 @@
1336
1337 bool Item::get_date(type::Time *ltime,uint32_t fuzzydate)
1338 {
1339- if (result_type() == STRING_RESULT)
1340- {
1341- char buff[40];
1342- String tmp(buff,sizeof(buff), &my_charset_bin),*res;
1343- if (!(res=val_str(&tmp)) ||
1344- str_to_datetime_with_warn(res->ptr(), res->length(),
1345- ltime, fuzzydate) <= DRIZZLE_TIMESTAMP_ERROR)
1346- goto err;
1347- }
1348- else
1349- {
1350- int64_t value= val_int();
1351- int was_cut;
1352- if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == -1L)
1353- {
1354- char buff[22], *end;
1355- end= internal::int64_t10_to_str(value, buff, -10);
1356- make_truncated_value_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1357- buff, (int) (end-buff), DRIZZLE_TIMESTAMP_NONE,
1358- NULL);
1359- goto err;
1360- }
1361- }
1362- return false;
1363-
1364-err:
1365- memset(ltime, 0, sizeof(*ltime));
1366+ do
1367+ {
1368+ if (result_type() == STRING_RESULT)
1369+ {
1370+ char buff[40];
1371+ String tmp(buff,sizeof(buff), &my_charset_bin),*res;
1372+ if (!(res=val_str(&tmp)) ||
1373+ str_to_datetime_with_warn(res->ptr(), res->length(),
1374+ ltime, fuzzydate) <= type::DRIZZLE_TIMESTAMP_ERROR)
1375+ {
1376+ break;
1377+ }
1378+ }
1379+ else
1380+ {
1381+ int64_t value= val_int();
1382+ int was_cut;
1383+ if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == -1L)
1384+ {
1385+ char buff[22], *end;
1386+ end= internal::int64_t10_to_str(value, buff, -10);
1387+ make_truncated_value_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1388+ buff, (int) (end-buff), type::DRIZZLE_TIMESTAMP_NONE, NULL);
1389+ break;
1390+ }
1391+ }
1392+
1393+ return false;
1394+ } while (0);
1395+
1396+ ltime->reset();
1397+
1398 return true;
1399 }
1400
1401@@ -496,12 +501,13 @@
1402 {
1403 char buff[40];
1404 String tmp(buff,sizeof(buff),&my_charset_bin),*res;
1405- if (!(res=val_str(&tmp)) ||
1406- str_to_time_with_warn(res->ptr(), res->length(), ltime))
1407+ if (!(res=val_str(&tmp)) || str_to_time_with_warn(res->ptr(), res->length(), ltime))
1408 {
1409- memset(ltime, 0, sizeof(*ltime));
1410+ ltime->reset();
1411+
1412 return true;
1413 }
1414+
1415 return false;
1416 }
1417
1418
1419=== modified file 'drizzled/item/cmpfunc.cc'
1420--- drizzled/item/cmpfunc.cc 2011-01-06 05:17:09 +0000
1421+++ drizzled/item/cmpfunc.cc 2011-01-18 01:47:30 +0000
1422@@ -697,20 +697,20 @@
1423 */
1424
1425 static uint64_t
1426-get_date_from_str(Session *session, String *str, enum enum_drizzle_timestamp_type warn_type,
1427+get_date_from_str(Session *session, String *str, type::timestamp_t warn_type,
1428 char *warn_name, bool *error_arg)
1429 {
1430 uint64_t value= 0;
1431 int error;
1432 type::Time l_time;
1433- enum enum_drizzle_timestamp_type ret;
1434+ type::timestamp_t ret;
1435
1436 ret= str_to_datetime(str->ptr(), str->length(), &l_time,
1437 (TIME_FUZZY_DATE | MODE_INVALID_DATES |
1438 (session->variables.sql_mode & MODE_NO_ZERO_DATE)),
1439 &error);
1440
1441- if (ret == DRIZZLE_TIMESTAMP_DATETIME || ret == DRIZZLE_TIMESTAMP_DATE)
1442+ if (ret == type::DRIZZLE_TIMESTAMP_DATETIME || ret == type::DRIZZLE_TIMESTAMP_DATE)
1443 {
1444 /*
1445 Do not return yet, we may still want to throw a "trailing garbage"
1446@@ -993,8 +993,7 @@
1447 {
1448 bool error;
1449 enum_field_types f_type= warn_item->field_type();
1450- enum enum_drizzle_timestamp_type t_type= f_type ==
1451- DRIZZLE_TYPE_DATE ? DRIZZLE_TIMESTAMP_DATE : DRIZZLE_TIMESTAMP_DATETIME;
1452+ type::timestamp_t t_type= f_type == DRIZZLE_TYPE_DATE ? type::DRIZZLE_TIMESTAMP_DATE : type::DRIZZLE_TIMESTAMP_DATETIME;
1453 value= get_date_from_str(session, str, t_type, warn_item->name, &error);
1454 /*
1455 If str did not contain a valid date according to the current
1456
1457=== modified file 'drizzled/plugin/client.cc'
1458--- drizzled/plugin/client.cc 2010-12-25 04:38:28 +0000
1459+++ drizzled/plugin/client.cc 2011-01-18 01:47:30 +0000
1460@@ -33,7 +33,7 @@
1461
1462 switch (from->time_type)
1463 {
1464- case DRIZZLE_TIMESTAMP_DATETIME:
1465+ case type::DRIZZLE_TIMESTAMP_DATETIME:
1466 length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d %02d:%02d:%02d",
1467 (int) from->year,
1468 (int) from->month,
1469@@ -45,14 +45,14 @@
1470 length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
1471 break;
1472
1473- case DRIZZLE_TIMESTAMP_DATE:
1474+ case type::DRIZZLE_TIMESTAMP_DATE:
1475 length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d",
1476 (int) from->year,
1477 (int) from->month,
1478 (int) from->day);
1479 break;
1480
1481- case DRIZZLE_TIMESTAMP_TIME:
1482+ case type::DRIZZLE_TIMESTAMP_TIME:
1483 day= (from->year || from->month) ? 0 : from->day;
1484 length= snprintf(buff, (buff_len-length), "%s%02ld:%02d:%02d",
1485 from->neg ? "-" : "",
1486@@ -63,8 +63,8 @@
1487 length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
1488 break;
1489
1490- case DRIZZLE_TIMESTAMP_NONE:
1491- case DRIZZLE_TIMESTAMP_ERROR:
1492+ case type::DRIZZLE_TIMESTAMP_NONE:
1493+ case type::DRIZZLE_TIMESTAMP_ERROR:
1494 default:
1495 assert(0);
1496 return false;
1497@@ -77,6 +77,7 @@
1498 {
1499 if (from == NULL)
1500 return store();
1501+
1502 return store(from, strlen(from));
1503 }
1504
1505
1506=== modified file 'drizzled/session.h'
1507--- drizzled/session.h 2011-01-13 01:27:33 +0000
1508+++ drizzled/session.h 2011-01-18 01:47:30 +0000
1509@@ -1270,7 +1270,7 @@
1510 const char* enter_cond(boost::condition_variable_any &cond, boost::mutex &mutex, const char* msg);
1511 void exit_cond(const char* old_msg);
1512
1513- time_t query_start()
1514+ type::Time::epoch_t query_start()
1515 {
1516 return getCurrentTimestampEpoch();
1517 }
1518@@ -1306,9 +1306,9 @@
1519 /**
1520 * Returns the current micro-timestamp
1521 */
1522- uint64_t getCurrentTimestamp(bool actual= true) const
1523+ type::Time::epoch_t getCurrentTimestamp(bool actual= true) const
1524 {
1525- uint64_t t_mark;
1526+ type::Time::epoch_t t_mark;
1527
1528 if (actual)
1529 {
1530@@ -1324,7 +1324,7 @@
1531 }
1532
1533 // We may need to set user on this
1534- time_t getCurrentTimestampEpoch() const
1535+ type::Time::epoch_t getCurrentTimestampEpoch() const
1536 {
1537 if (not _user_time.is_not_a_date_time())
1538 return (_user_time - _epoch).total_seconds();
1539@@ -1332,7 +1332,7 @@
1540 return (_start_timer - _epoch).total_seconds();
1541 }
1542
1543- time_t getCurrentTimestampEpoch(uint32_t &fraction_arg) const
1544+ type::Time::epoch_t getCurrentTimestampEpoch(type::Time::usec_t &fraction_arg) const
1545 {
1546 if (not _user_time.is_not_a_date_time())
1547 {
1548
1549=== modified file 'drizzled/sql_yacc.yy'
1550--- drizzled/sql_yacc.yy 2011-01-13 09:25:42 +0000
1551+++ drizzled/sql_yacc.yy 2011-01-18 01:47:30 +0000
1552@@ -373,7 +373,7 @@
1553 const drizzled::CHARSET_INFO *charset;
1554 drizzled::thr_lock_type lock_type;
1555 drizzled::interval_type interval, interval_time_st;
1556- enum drizzled::enum_drizzle_timestamp_type date_time_type;
1557+ drizzled::type::timestamp_t date_time_type;
1558 drizzled::Select_Lex *select_lex;
1559 drizzled::chooser_compare_func_creator boolfunc2creator;
1560 struct drizzled::st_lex *lex;
1561
1562=== modified file 'drizzled/temporal.cc'
1563--- drizzled/temporal.cc 2011-01-06 18:00:47 +0000
1564+++ drizzled/temporal.cc 2011-01-18 01:47:30 +0000
1565@@ -44,6 +44,8 @@
1566 #include "drizzled/time_functions.h"
1567 #include "time.h"
1568
1569+#include <drizzled/util/gmtime.h>
1570+
1571 #include <time.h>
1572
1573 #include <cstdio>
1574@@ -59,19 +61,18 @@
1575 extern std::vector<TemporalFormat *> known_date_formats;
1576 extern std::vector<TemporalFormat *> known_time_formats;
1577
1578-Temporal::Temporal()
1579-:
1580- _calendar(GREGORIAN)
1581-, _years(0)
1582-, _months(0)
1583-, _days(0)
1584-, _hours(0)
1585-, _minutes(0)
1586-, _seconds(0)
1587-, _epoch_seconds(0)
1588-, _useconds(0)
1589-, _nseconds(0)
1590-, _overflow(false)
1591+Temporal::Temporal() :
1592+ _calendar(GREGORIAN),
1593+ _years(0),
1594+ _months(0),
1595+ _days(0),
1596+ _hours(0),
1597+ _minutes(0),
1598+ _seconds(0),
1599+ _epoch_seconds(0),
1600+ _useconds(0),
1601+ _nseconds(0),
1602+ _overflow(false)
1603 {}
1604
1605 uint64_t Temporal::_cumulative_seconds_in_time() const
1606@@ -100,7 +101,7 @@
1607 }
1608
1609 // Get the gmtime based on the local seconds since the Epoch
1610- gm_time = gmtime_r(&local_secs, &gm__rec);
1611+ gm_time = util::gmtime(local_secs, &gm__rec);
1612 gm_time->tm_isdst = 0;
1613
1614 // Interpret gmtime as the local time and convert it to seconds since the Epoch
1615@@ -1290,7 +1291,7 @@
1616 struct tm broken_time;
1617 struct tm *result;
1618
1619- result= gmtime_r(&from, &broken_time);
1620+ result= util::gmtime(from, &broken_time);
1621 if (result != NULL)
1622 {
1623 _years= 0;
1624@@ -1314,7 +1315,7 @@
1625 struct tm broken_time;
1626 struct tm *result;
1627
1628- result= gmtime_r(&from, &broken_time);
1629+ result= util::gmtime(from, &broken_time);
1630 if (result != NULL)
1631 {
1632 _years= 1900 + broken_time.tm_year;
1633@@ -1338,7 +1339,7 @@
1634 struct tm broken_time;
1635 struct tm *result;
1636
1637- result= gmtime_r(&timeval_arg.tv_sec, &broken_time);
1638+ result= util::gmtime(timeval_arg.tv_sec, &broken_time);
1639 if (result != NULL)
1640 {
1641 _years= 1900 + broken_time.tm_year;
1642@@ -1364,7 +1365,7 @@
1643 struct tm broken_time;
1644 struct tm *result;
1645
1646- result= gmtime_r(&from, &broken_time);
1647+ result= util::gmtime(from, &broken_time);
1648 if (result != NULL)
1649 {
1650 _years= 1900 + broken_time.tm_year;
1651
1652=== modified file 'drizzled/temporal_interval.cc'
1653--- drizzled/temporal_interval.cc 2010-12-25 04:38:28 +0000
1654+++ drizzled/temporal_interval.cc 2011-01-18 01:47:30 +0000
1655@@ -211,7 +211,7 @@
1656 case INTERVAL_DAY_MINUTE:
1657 case INTERVAL_DAY_HOUR:
1658 int64_t sec, days, daynr, microseconds, extra_sec;
1659- ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME; // Return full date
1660+ ltime->time_type= type::DRIZZLE_TIMESTAMP_DATETIME; // Return full date
1661 microseconds= ltime->second_part + sign*second_part;
1662 extra_sec= microseconds/1000000L;
1663 microseconds= microseconds%1000000L;
1664@@ -241,8 +241,7 @@
1665 /* Day number from year 0 to 9999-12-31 */
1666 if ((uint64_t) daynr > MAX_DAY_NUMBER)
1667 goto invalid_date;
1668- get_date_from_daynr((long) daynr, &ltime->year, &ltime->month,
1669- &ltime->day);
1670+ get_date_from_daynr((long) daynr, &ltime->year, &ltime->month, &ltime->day);
1671 break;
1672 case INTERVAL_DAY:
1673 case INTERVAL_WEEK:
1674
1675=== modified file 'drizzled/time_functions.cc'
1676--- drizzled/time_functions.cc 2010-12-25 04:38:28 +0000
1677+++ drizzled/time_functions.cc 2011-01-18 01:47:30 +0000
1678@@ -107,15 +107,15 @@
1679 {
1680 if (day_of_year > 31+28)
1681 {
1682- day_of_year--;
1683- if (day_of_year == 31+28)
1684- leap_day=1; /* Handle leapyears leapday */
1685+ day_of_year--;
1686+ if (day_of_year == 31+28)
1687+ leap_day=1; /* Handle leapyears leapday */
1688 }
1689 }
1690 *ret_month=1;
1691 for (month_pos= days_in_month ;
1692- day_of_year > (uint32_t) *month_pos ;
1693- day_of_year-= *(month_pos++), (*ret_month)++)
1694+ day_of_year > (uint32_t) *month_pos ;
1695+ day_of_year-= *(month_pos++), (*ret_month)++)
1696 ;
1697 *ret_year=year;
1698 *ret_day=day_of_year+leap_day;
1699@@ -124,14 +124,13 @@
1700 }
1701
1702
1703-enum enum_drizzle_timestamp_type
1704-str_to_datetime_with_warn(const char *str,
1705- uint32_t length,
1706- type::Time *l_time,
1707- uint32_t flags)
1708+type::timestamp_t str_to_datetime_with_warn(const char *str,
1709+ uint32_t length,
1710+ type::Time *l_time,
1711+ uint32_t flags)
1712 {
1713 int was_cut;
1714- enum enum_drizzle_timestamp_type ts_type;
1715+ type::timestamp_t ts_type;
1716 Session *session= current_session;
1717
1718 ts_type= str_to_datetime(str, length, l_time,
1719@@ -139,7 +138,7 @@
1720 (MODE_INVALID_DATES |
1721 MODE_NO_ZERO_DATE))),
1722 &was_cut);
1723- if (was_cut || ts_type <= DRIZZLE_TIMESTAMP_ERROR)
1724+ if (was_cut || ts_type <= type::DRIZZLE_TIMESTAMP_ERROR)
1725 make_truncated_value_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1726 str, length, ts_type, NULL);
1727 return ts_type;
1728@@ -153,54 +152,16 @@
1729 bool ret_val= str_to_time(str, length, l_time, &warning);
1730 if (ret_val || warning)
1731 make_truncated_value_warning(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1732- str, length, DRIZZLE_TIMESTAMP_TIME, NULL);
1733+ str, length, type::DRIZZLE_TIMESTAMP_TIME, NULL);
1734 return ret_val;
1735 }
1736
1737
1738-void localtime_to_TIME(type::Time *to, struct tm *from)
1739-{
1740- to->neg=0;
1741- to->second_part=0;
1742- to->year= (int) ((from->tm_year+1900) % 10000);
1743- to->month= (int) from->tm_mon+1;
1744- to->day= (int) from->tm_mday;
1745- to->hour= (int) from->tm_hour;
1746- to->minute= (int) from->tm_min;
1747- to->second= (int) from->tm_sec;
1748-}
1749-
1750-void make_time(const type::Time *l_time, String *str)
1751-{
1752- str->alloc(MAX_DATE_STRING_REP_LENGTH);
1753- uint32_t length= (uint32_t) my_time_to_str(l_time, str->c_ptr());
1754- str->length(length);
1755- str->set_charset(&my_charset_bin);
1756-}
1757-
1758-void make_date(const type::Time *l_time, String *str)
1759-{
1760- str->alloc(MAX_DATE_STRING_REP_LENGTH);
1761- uint32_t length= (uint32_t) my_date_to_str(l_time, str->c_ptr());
1762- str->length(length);
1763- str->set_charset(&my_charset_bin);
1764-}
1765-
1766-
1767-void make_datetime(const type::Time *l_time, String *str)
1768-{
1769- str->alloc(MAX_DATE_STRING_REP_LENGTH);
1770- uint32_t length= (uint32_t) my_datetime_to_str(l_time, str->c_ptr());
1771- str->length(length);
1772- str->set_charset(&my_charset_bin);
1773-}
1774-
1775-
1776 void make_truncated_value_warning(Session *session,
1777 DRIZZLE_ERROR::enum_warning_level level,
1778 const char *str_val,
1779 uint32_t str_length,
1780- enum enum_drizzle_timestamp_type time_type,
1781+ type::timestamp_t time_type,
1782 const char *field_name)
1783 {
1784 char warn_buff[DRIZZLE_ERRMSG_SIZE];
1785@@ -212,17 +173,20 @@
1786 str[str_length]= 0; // Ensure we have end 0 for snprintf
1787
1788 switch (time_type) {
1789- case DRIZZLE_TIMESTAMP_DATE:
1790- type_str= "date";
1791- break;
1792- case DRIZZLE_TIMESTAMP_TIME:
1793- type_str= "time";
1794- break;
1795- case DRIZZLE_TIMESTAMP_DATETIME: // FALLTHROUGH
1796- default:
1797- type_str= "datetime";
1798- break;
1799+ case type::DRIZZLE_TIMESTAMP_DATE:
1800+ type_str= "date";
1801+ break;
1802+
1803+ case type::DRIZZLE_TIMESTAMP_TIME:
1804+ type_str= "time";
1805+ break;
1806+
1807+ case type::DRIZZLE_TIMESTAMP_DATETIME: // FALLTHROUGH
1808+ default:
1809+ type_str= "datetime";
1810+ break;
1811 }
1812+
1813 if (field_name)
1814 {
1815 cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
1816@@ -232,13 +196,17 @@
1817 }
1818 else
1819 {
1820- if (time_type > DRIZZLE_TIMESTAMP_ERROR)
1821+ if (time_type > type::DRIZZLE_TIMESTAMP_ERROR)
1822+ {
1823 cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
1824 ER(ER_TRUNCATED_WRONG_VALUE),
1825 type_str, str.c_ptr());
1826+ }
1827 else
1828+ {
1829 cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
1830 ER(ER_WRONG_VALUE), type_str, str.c_ptr());
1831+ }
1832 }
1833 push_warning(session, level,
1834 ER_TRUNCATED_WRONG_VALUE, warn_buff);
1835@@ -258,30 +226,30 @@
1836 the second argument should be TIMESTAMP_TIME also.
1837 We should check it before calc_time_diff call.
1838 */
1839- if (l_time1->time_type == DRIZZLE_TIMESTAMP_TIME) // Time value
1840+ if (l_time1->time_type == type::DRIZZLE_TIMESTAMP_TIME) // Time value
1841 days= (long)l_time1->day - l_sign * (long)l_time2->day;
1842 else
1843 {
1844 days= calc_daynr((uint32_t) l_time1->year,
1845- (uint32_t) l_time1->month,
1846- (uint32_t) l_time1->day);
1847- if (l_time2->time_type == DRIZZLE_TIMESTAMP_TIME)
1848+ (uint32_t) l_time1->month,
1849+ (uint32_t) l_time1->day);
1850+ if (l_time2->time_type == type::DRIZZLE_TIMESTAMP_TIME)
1851 days-= l_sign * (long)l_time2->day;
1852 else
1853 days-= l_sign*calc_daynr((uint32_t) l_time2->year,
1854- (uint32_t) l_time2->month,
1855- (uint32_t) l_time2->day);
1856+ (uint32_t) l_time2->month,
1857+ (uint32_t) l_time2->day);
1858 }
1859
1860 microseconds= ((int64_t)days*86400L +
1861 (int64_t)(l_time1->hour*3600L +
1862- l_time1->minute*60L +
1863- l_time1->second) -
1864+ l_time1->minute*60L +
1865+ l_time1->second) -
1866 l_sign*(int64_t)(l_time2->hour*3600L +
1867- l_time2->minute*60L +
1868- l_time2->second)) * 1000000L +
1869- (int64_t)l_time1->second_part -
1870- l_sign*(int64_t)l_time2->second_part;
1871+ l_time2->minute*60L +
1872+ l_time2->second)) * 1000000L +
1873+ (int64_t)l_time1->second_part -
1874+ l_sign*(int64_t)l_time2->second_part;
1875
1876 neg= 0;
1877 if (microseconds < 0)
1878
1879=== modified file 'drizzled/time_functions.h'
1880--- drizzled/time_functions.h 2010-12-26 00:07:57 +0000
1881+++ drizzled/time_functions.h 2011-01-18 01:47:30 +0000
1882@@ -73,10 +73,10 @@
1883 NOTE
1884 See description of str_to_datetime() for more information.
1885 */
1886-enum enum_drizzle_timestamp_type str_to_datetime_with_warn(const char *str,
1887- uint32_t length,
1888- type::Time *l_time,
1889- uint32_t flags);
1890+type::timestamp_t str_to_datetime_with_warn(const char *str,
1891+ uint32_t length,
1892+ type::Time *l_time,
1893+ uint32_t flags);
1894
1895 /*
1896 Convert a time string to a type::Time struct and produce a warning
1897@@ -87,22 +87,11 @@
1898 */
1899 bool str_to_time_with_warn(const char *str, uint32_t length, type::Time *l_time);
1900
1901-/*
1902- Convert a system time structure to TIME
1903-*/
1904-void localtime_to_TIME(type::Time *to, struct tm *from);
1905-
1906-void make_time(const type::Time *l_time, String *str);
1907-
1908-void make_date(const type::Time *l_time, String *str);
1909-
1910-void make_datetime(const type::Time *l_time, String *str);
1911-
1912 void make_truncated_value_warning(Session *session,
1913 DRIZZLE_ERROR::enum_warning_level level,
1914 const char *str_val,
1915 uint32_t str_length,
1916- enum enum_drizzle_timestamp_type time_type,
1917+ type::timestamp_t time_type,
1918 const char *field_name);
1919
1920 /*
1921
1922=== modified file 'drizzled/type/decimal.cc'
1923--- drizzled/type/decimal.cc 2010-12-27 19:16:17 +0000
1924+++ drizzled/type/decimal.cc 2011-01-18 01:47:30 +0000
1925@@ -313,15 +313,21 @@
1926 return err;
1927 }
1928
1929+void type::Decimal::convert(double &result) const
1930+{
1931+ decimal2double(static_cast<const decimal_t*>(this), &result);
1932+}
1933
1934 type::Decimal *date2_class_decimal(type::Time *ltime, type::Decimal *dec)
1935 {
1936 int64_t date;
1937 date = (ltime->year*100L + ltime->month)*100L + ltime->day;
1938- if (ltime->time_type > DRIZZLE_TIMESTAMP_DATE)
1939+ if (ltime->time_type > type::DRIZZLE_TIMESTAMP_DATE)
1940 date= ((date*100L + ltime->hour)*100L+ ltime->minute)*100L + ltime->second;
1941+
1942 if (int2_class_decimal(E_DEC_FATAL_ERROR, date, false, dec))
1943 return dec;
1944+
1945 if (ltime->second_part)
1946 {
1947 dec->buf[(dec->intg-1) / 9 + 1]= ltime->second_part * 1000;
1948
1949=== modified file 'drizzled/type/decimal.h'
1950--- drizzled/type/decimal.h 2010-12-27 19:16:17 +0000
1951+++ drizzled/type/decimal.h 2011-01-18 01:47:30 +0000
1952@@ -23,8 +23,13 @@
1953 {
1954
1955 typedef enum
1956-{TRUNCATE=0, HALF_EVEN, HALF_UP, CEILING, FLOOR}
1957- decimal_round_mode;
1958+{
1959+ TRUNCATE= 0,
1960+ HALF_EVEN,
1961+ HALF_UP,
1962+ CEILING,
1963+ FLOOR
1964+} decimal_round_mode;
1965 typedef int32_t decimal_digit_t;
1966
1967 typedef struct st_decimal_t {
1968@@ -179,96 +184,96 @@
1969
1970 namespace type {
1971 /**
1972- type::Decimal class limits 'decimal_t' type to what we need in MySQL.
1973+ type Decimal class limits 'decimal_t' type to what we need in MySQL.
1974
1975 It contains internally all necessary space needed by the instance so
1976 no extra memory is needed. One should call fix_buffer_pointer() function
1977 when he moves type::Decimal objects in memory.
1978 */
1979
1980-class Decimal :public decimal_t
1981+class Decimal : public decimal_t
1982+{
1983+ decimal_digit_t buffer[DECIMAL_BUFF_LENGTH];
1984+
1985+public:
1986+
1987+ void init()
1988 {
1989- decimal_digit_t buffer[DECIMAL_BUFF_LENGTH];
1990-
1991- public:
1992-
1993- void init()
1994- {
1995- len= DECIMAL_BUFF_LENGTH;
1996- buf= buffer;
1997+ len= DECIMAL_BUFF_LENGTH;
1998+ buf= buffer;
1999 #if !defined (HAVE_VALGRIND)
2000- /* Set buffer to 'random' value to find wrong buffer usage */
2001- for (uint32_t i= 0; i < DECIMAL_BUFF_LENGTH; i++)
2002- buffer[i]= i;
2003+ /* Set buffer to 'random' value to find wrong buffer usage */
2004+ for (uint32_t i= 0; i < DECIMAL_BUFF_LENGTH; i++)
2005+ buffer[i]= i;
2006 #endif
2007- }
2008-
2009- Decimal()
2010- {
2011- init();
2012- }
2013- void fix_buffer_pointer() { buf= buffer; }
2014- bool sign() const { return decimal_t::sign; }
2015- void sign(bool s) { decimal_t::sign= s; }
2016- uint32_t precision() const { return intg + frac; }
2017-
2018- int val_int32(uint32_t mask, bool unsigned_flag, int64_t *l) const
2019- {
2020- type::Decimal rounded;
2021- /* decimal_round can return only E_DEC_TRUNCATED */
2022- decimal_round(static_cast<const decimal_t*>(this), &rounded, 0, HALF_UP);
2023- return check_result(mask, (unsigned_flag ?
2024- decimal2uint64_t(&rounded, reinterpret_cast<uint64_t *>(l)) :
2025- decimal2int64_t(&rounded, l)));
2026- }
2027-
2028- int string_length() const
2029- {
2030- return decimal_string_size(this);
2031- }
2032-
2033- int val_binary(uint32_t mask, unsigned char *bin, int prec, int scale) const;
2034-
2035-
2036- int set_zero()
2037- {
2038- decimal_make_zero(static_cast<decimal_t*> (this));
2039- return 0;
2040- }
2041-
2042-
2043- bool is_zero() const
2044- {
2045- return decimal_is_zero(static_cast<const decimal_t*>(this));
2046- }
2047-
2048-
2049- int store(uint32_t mask, const char *from, uint32_t length, const CHARSET_INFO * charset);
2050-
2051- int store(uint32_t mask, char *str, char **end)
2052- {
2053- return check_result_and_overflow(mask, string2decimal(str, static_cast<decimal_t*>(this), end));
2054- }
2055-
2056- int store(uint32_t mask, const String *str)
2057- {
2058- return store(mask, str->ptr(), str->length(), str->charset());
2059- }
2060-
2061- int check_result_and_overflow(uint32_t mask, int result)
2062- {
2063- if (check_result(mask, result) & E_DEC_OVERFLOW)
2064- {
2065- bool _sign= sign();
2066- fix_buffer_pointer();
2067- max_internal_decimal(this);
2068- sign(_sign);
2069- }
2070- return result;
2071-}
2072-
2073-
2074- };
2075+ }
2076+
2077+ Decimal()
2078+ {
2079+ init();
2080+ }
2081+ void fix_buffer_pointer() { buf= buffer; }
2082+ bool sign() const { return decimal_t::sign; }
2083+ void sign(bool s) { decimal_t::sign= s; }
2084+ uint32_t precision() const { return intg + frac; }
2085+
2086+ int val_int32(uint32_t mask, bool unsigned_flag, int64_t *l) const
2087+ {
2088+ type::Decimal rounded;
2089+ /* decimal_round can return only E_DEC_TRUNCATED */
2090+ decimal_round(static_cast<const decimal_t*>(this), &rounded, 0, HALF_UP);
2091+ return check_result(mask, (unsigned_flag ?
2092+ decimal2uint64_t(&rounded, reinterpret_cast<uint64_t *>(l)) :
2093+ decimal2int64_t(&rounded, l)));
2094+ }
2095+
2096+ int string_length() const
2097+ {
2098+ return decimal_string_size(this);
2099+ }
2100+
2101+ int val_binary(uint32_t mask, unsigned char *bin, int prec, int scale) const;
2102+
2103+
2104+ int set_zero()
2105+ {
2106+ decimal_make_zero(static_cast<decimal_t*> (this));
2107+ return 0;
2108+ }
2109+
2110+
2111+ bool is_zero() const
2112+ {
2113+ return decimal_is_zero(static_cast<const decimal_t*>(this));
2114+ }
2115+
2116+
2117+ int store(uint32_t mask, const char *from, uint32_t length, const CHARSET_INFO * charset);
2118+
2119+ int store(uint32_t mask, char *str, char **end)
2120+ {
2121+ return check_result_and_overflow(mask, string2decimal(str, static_cast<decimal_t*>(this), end));
2122+ }
2123+
2124+ int store(uint32_t mask, const String *str)
2125+ {
2126+ return store(mask, str->ptr(), str->length(), str->charset());
2127+ }
2128+
2129+ int check_result_and_overflow(uint32_t mask, int result)
2130+ {
2131+ if (check_result(mask, result) & E_DEC_OVERFLOW)
2132+ {
2133+ bool _sign= sign();
2134+ fix_buffer_pointer();
2135+ max_internal_decimal(this);
2136+ sign(_sign);
2137+ }
2138+ return result;
2139+ }
2140+
2141+ void convert(double &value) const;
2142+};
2143
2144 } // type
2145
2146
2147=== modified file 'drizzled/type/time.cc'
2148--- drizzled/type/time.cc 2011-01-11 00:57:46 +0000
2149+++ drizzled/type/time.cc 2011-01-18 01:47:30 +0000
2150@@ -17,10 +17,13 @@
2151
2152 #include "drizzled/type/time.h"
2153
2154+#include <drizzled/util/gmtime.h>
2155+
2156 #include "drizzled/internal/m_string.h"
2157 #include "drizzled/charset_info.h"
2158 #include <drizzled/util/test.h>
2159 #include "drizzled/definitions.h"
2160+#include <drizzled/sql_string.h>
2161
2162 #include <cstdio>
2163 #include <algorithm>
2164@@ -171,7 +174,7 @@
2165
2166 #define MAX_DATE_PARTS 8
2167
2168-enum enum_drizzle_timestamp_type
2169+type::timestamp_t
2170 str_to_datetime(const char *str, uint32_t length, type::Time *l_time,
2171 uint32_t flags, int *was_cut)
2172 {
2173@@ -194,7 +197,7 @@
2174 if (str == end || ! my_isdigit(&my_charset_utf8_general_ci, *str))
2175 {
2176 *was_cut= 1;
2177- return(DRIZZLE_TIMESTAMP_NONE);
2178+ return(type::DRIZZLE_TIMESTAMP_NONE);
2179 }
2180
2181 is_internal_format= 0;
2182@@ -241,7 +244,7 @@
2183 if (flags & TIME_DATETIME_ONLY)
2184 {
2185 *was_cut= 1;
2186- return(DRIZZLE_TIMESTAMP_NONE); /* Can't be a full datetime */
2187+ return(type::DRIZZLE_TIMESTAMP_NONE); /* Can't be a full datetime */
2188 }
2189 /* Date field. Set hour, minutes and seconds to 0 */
2190 date[0]= date[1]= date[2]= date[3]= date[4]= 0;
2191@@ -283,7 +286,7 @@
2192 if (tmp_value > 999999) /* Impossible date part */
2193 {
2194 *was_cut= 1;
2195- return(DRIZZLE_TIMESTAMP_NONE);
2196+ return(type::DRIZZLE_TIMESTAMP_NONE);
2197 }
2198 date[i]=tmp_value;
2199 not_zero_date|= tmp_value;
2200@@ -320,7 +323,7 @@
2201 if (!(allow_space & (1 << i)))
2202 {
2203 *was_cut= 1;
2204- return(DRIZZLE_TIMESTAMP_NONE);
2205+ return(type::DRIZZLE_TIMESTAMP_NONE);
2206 }
2207 found_space= 1;
2208 }
2209@@ -351,7 +354,7 @@
2210 if (found_delimitier && !found_space && (flags & TIME_DATETIME_ONLY))
2211 {
2212 *was_cut= 1;
2213- return(DRIZZLE_TIMESTAMP_NONE); /* Can't be a datetime */
2214+ return(type::DRIZZLE_TIMESTAMP_NONE); /* Can't be a datetime */
2215 }
2216
2217 str= last_field_pos;
2218@@ -369,7 +372,7 @@
2219 if (!year_length) /* Year must be specified */
2220 {
2221 *was_cut= 1;
2222- return(DRIZZLE_TIMESTAMP_NONE);
2223+ return(type::DRIZZLE_TIMESTAMP_NONE);
2224 }
2225
2226 l_time->year= date[(uint32_t) format_position[0]];
2227@@ -437,7 +440,7 @@
2228 goto err;
2229
2230 l_time->time_type= (number_of_fields <= 3 ?
2231- DRIZZLE_TIMESTAMP_DATE : DRIZZLE_TIMESTAMP_DATETIME);
2232+ type::DRIZZLE_TIMESTAMP_DATE : type::DRIZZLE_TIMESTAMP_DATETIME);
2233
2234 for (; str != end ; str++)
2235 {
2236@@ -449,12 +452,14 @@
2237 }
2238
2239 return(l_time->time_type=
2240- (number_of_fields <= 3 ? DRIZZLE_TIMESTAMP_DATE :
2241- DRIZZLE_TIMESTAMP_DATETIME));
2242+ (number_of_fields <= 3 ? type::DRIZZLE_TIMESTAMP_DATE :
2243+ type::DRIZZLE_TIMESTAMP_DATETIME));
2244
2245 err:
2246- memset(l_time, 0, sizeof(*l_time));
2247- return(DRIZZLE_TIMESTAMP_ERROR);
2248+
2249+ l_time->reset();
2250+
2251+ return(type::DRIZZLE_TIMESTAMP_ERROR);
2252 }
2253
2254
2255@@ -503,20 +508,19 @@
2256 length--;
2257 }
2258 if (str == end)
2259- return 1;
2260+ return true;
2261
2262 /* Check first if this is a full TIMESTAMP */
2263 if (length >= 12)
2264 { /* Probably full timestamp */
2265 int was_cut;
2266- enum enum_drizzle_timestamp_type
2267- res= str_to_datetime(str, length, l_time,
2268- (TIME_FUZZY_DATE | TIME_DATETIME_ONLY), &was_cut);
2269- if ((int) res >= (int) DRIZZLE_TIMESTAMP_ERROR)
2270+ type::timestamp_t res= str_to_datetime(str, length, l_time,
2271+ (TIME_FUZZY_DATE | TIME_DATETIME_ONLY), &was_cut);
2272+ if ((int) res >= (int) type::DRIZZLE_TIMESTAMP_ERROR)
2273 {
2274 if (was_cut)
2275 *warning|= DRIZZLE_TIME_WARN_TRUNCATED;
2276- return res == DRIZZLE_TIMESTAMP_ERROR;
2277+ return res == type::DRIZZLE_TIMESTAMP_ERROR;
2278 }
2279 }
2280
2281@@ -644,7 +648,7 @@
2282 l_time->minute= date[2];
2283 l_time->second= date[3];
2284 l_time->second_part= date[4];
2285- l_time->time_type= DRIZZLE_TIMESTAMP_TIME;
2286+ l_time->time_type= type::DRIZZLE_TIMESTAMP_TIME;
2287
2288 /* Check if the value is valid and fits into type::Time range */
2289 if (check_time_range(l_time, warning))
2290@@ -723,7 +727,7 @@
2291 bool not_used;
2292
2293 seconds= (time_t) time((time_t*) 0);
2294- localtime_r(&seconds,&tm_tmp);
2295+ localtime_r(&seconds, &tm_tmp);
2296 l_time= &tm_tmp;
2297 my_time_zone= 3600; /* Comp. for -3600 in my_gmt_sec */
2298 my_time.year= (uint32_t) l_time->tm_year+1900;
2299@@ -732,7 +736,7 @@
2300 my_time.hour= (uint32_t) l_time->tm_hour;
2301 my_time.minute= (uint32_t) l_time->tm_min;
2302 my_time.second= (uint32_t) l_time->tm_sec;
2303- my_time.time_type= DRIZZLE_TIMESTAMP_NONE;
2304+ my_time.time_type= type::DRIZZLE_TIMESTAMP_NONE;
2305 my_time.second_part= 0;
2306 my_time.neg= false;
2307 my_system_gmt_sec(&my_time, &my_time_zone, &not_used); /* Init my_time_zone */
2308@@ -812,12 +816,12 @@
2309 RETURN VALUE
2310 Time in UTC seconds since Unix Epoch representation.
2311 */
2312-time_t
2313+type::Time::epoch_t
2314 my_system_gmt_sec(const type::Time *t_src, long *my_timezone,
2315 bool *in_dst_time_gap, bool skip_timezone)
2316 {
2317 uint32_t loop;
2318- time_t tmp= 0;
2319+ type::Time::epoch_t tmp= 0;
2320 int shift= 0;
2321 type::Time tmp_time;
2322 type::Time *t= &tmp_time;
2323@@ -828,9 +832,9 @@
2324 Use temp variable to avoid trashing input data, which could happen in
2325 case of shift required for boundary dates processing.
2326 */
2327- memcpy(&tmp_time, t_src, sizeof(type::Time));
2328+ tmp_time= *t_src;
2329
2330- if (!validate_timestamp_range(t))
2331+ if (not validate_timestamp_range(t))
2332 return 0;
2333
2334 /*
2335@@ -883,18 +887,7 @@
2336 We are safe with shifts close to MAX_INT32, as there are no known
2337 time switches on Jan 2038 yet :)
2338 */
2339- if ((t->year == TIMESTAMP_MAX_YEAR) && (t->month == 1) && (t->day > 4))
2340- {
2341- /*
2342- Below we will pass (uint32_t) (t->day - shift) to calc_daynr.
2343- As we don't want to get an overflow here, we will shift
2344- only safe dates. That's why we have (t->day > 4) above.
2345- */
2346- t->day-= 2;
2347- shift= 2;
2348- }
2349 #ifdef TIME_T_UNSIGNED
2350- else
2351 {
2352 /*
2353 We can get 0 in time_t representaion only on 1969, 31 of Dec or on
2354@@ -923,7 +916,7 @@
2355 }
2356 #endif
2357
2358- tmp= (time_t) (((calc_daynr((uint32_t) t->year, (uint32_t) t->month, (uint32_t) t->day) -
2359+ tmp= (type::Time::epoch_t) (((calc_daynr((uint32_t) t->year, (uint32_t) t->month, (uint32_t) t->day) -
2360 (long) days_at_timestart)*86400L + (long) t->hour*3600L +
2361 (long) (t->minute*60 + t->second)) + (time_t) my_time_zone -
2362 3600);
2363@@ -931,14 +924,14 @@
2364 current_timezone= my_time_zone;
2365 if (skip_timezone)
2366 {
2367- gmtime_r(&tmp, &tm_tmp);
2368+ util::gmtime(tmp, &tm_tmp);
2369 }
2370 else
2371 {
2372- localtime_r(&tmp,&tm_tmp);
2373+ util::localtime(tmp, &tm_tmp);
2374 }
2375
2376- l_time=&tm_tmp;
2377+ l_time= &tm_tmp;
2378 for (loop=0;
2379 loop < 2 &&
2380 (t->hour != (uint32_t) l_time->tm_hour ||
2381@@ -959,11 +952,11 @@
2382 tmp+= (time_t) diff;
2383 if (skip_timezone)
2384 {
2385- gmtime_r(&tmp, &tm_tmp);
2386+ util::gmtime(tmp, &tm_tmp);
2387 }
2388 else
2389 {
2390- localtime_r(&tmp, &tm_tmp);
2391+ util::localtime(tmp, &tm_tmp);
2392 }
2393 l_time=&tm_tmp;
2394 }
2395@@ -1006,26 +999,17 @@
2396 First check will pass for platforms with signed time_t.
2397 instruction above (tmp+= shift*86400L) could exceed
2398 MAX_INT32 (== TIMESTAMP_MAX_VALUE) and overflow will happen.
2399- So, tmp < TIMESTAMP_MIN_VALUE will be triggered. On platfroms
2400- with unsigned time_t tmp+= shift*86400L might result in a number,
2401- larger then TIMESTAMP_MAX_VALUE, so another check will work.
2402+ So, tmp < TIMESTAMP_MIN_VALUE will be triggered.
2403 */
2404- if ((tmp < TIMESTAMP_MIN_VALUE) || (tmp > TIMESTAMP_MAX_VALUE))
2405+ if (tmp < TIMESTAMP_MIN_VALUE)
2406+ {
2407 tmp= 0;
2408+ }
2409
2410- return (time_t) tmp;
2411+ return tmp;
2412 } /* my_system_gmt_sec */
2413
2414
2415-/* Set type::Time structure to 0000-00-00 00:00:00.000000 */
2416-
2417-void set_zero_time(type::Time *tm, enum enum_drizzle_timestamp_type time_type)
2418-{
2419- memset(tm, 0, sizeof(*tm));
2420- tm->time_type= time_type;
2421-}
2422-
2423-
2424 /*
2425 Functions to convert time/date/datetime value to a string,
2426 using default format.
2427@@ -1039,66 +1023,139 @@
2428 number of characters written to 'to'
2429 */
2430
2431-int my_time_to_str(const type::Time *l_time, char *to)
2432+static int my_time_to_str(const type::Time *l_time, char *to)
2433 {
2434+ int32_t length;
2435 uint32_t extra_hours= 0;
2436- return sprintf(to, "%s%02u:%02u:%02u",
2437- (l_time->neg ? "-" : ""),
2438- extra_hours+ l_time->hour,
2439- l_time->minute,
2440- l_time->second);
2441+
2442+ length= sprintf(to, "%s%02u:%02u:%02u",
2443+ (l_time->neg ? "-" : ""),
2444+ extra_hours+ l_time->hour,
2445+ l_time->minute,
2446+ l_time->second);
2447+ if (length < 0)
2448+ return 0;
2449+
2450+ return static_cast<size_t>(length);
2451 }
2452
2453-int my_date_to_str(const type::Time *l_time, char *to)
2454+static int my_date_to_str(const type::Time *l_time, char *to)
2455 {
2456- return sprintf(to, "%04u-%02u-%02u",
2457+ int32_t length;
2458+ length= sprintf(to, "%04u-%02u-%02u",
2459 l_time->year,
2460 l_time->month,
2461 l_time->day);
2462-}
2463-
2464-int my_datetime_to_str(const type::Time *l_time, char *to)
2465-{
2466- return sprintf(to, "%04u-%02u-%02u %02u:%02u:%02u",
2467- l_time->year,
2468- l_time->month,
2469- l_time->day,
2470- l_time->hour,
2471- l_time->minute,
2472- l_time->second);
2473-}
2474-
2475-
2476-/*
2477- Convert struct DATE/TIME/DATETIME value to string using built-in
2478- MySQL time conversion formats.
2479-
2480- SYNOPSIS
2481- my_TIME_to_string()
2482-
2483- NOTE
2484- The string must have at least MAX_DATE_STRING_REP_LENGTH bytes reserved.
2485-*/
2486-
2487-int my_TIME_to_str(const type::Time *l_time, char *to)
2488-{
2489- switch (l_time->time_type) {
2490+ if (length < 0)
2491+ return 0;
2492+
2493+ return static_cast<size_t>(length);
2494+}
2495+
2496+static size_t my_datetime_to_str(const type::Time *l_time, char *to, size_t to_len)
2497+{
2498+ int32_t length;
2499+ length= snprintf(to, to_len,
2500+ "%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32
2501+ " %02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%06" PRIu32,
2502+ l_time->year,
2503+ l_time->month,
2504+ l_time->day,
2505+ l_time->hour,
2506+ l_time->minute,
2507+ l_time->second,
2508+ l_time->second_part);
2509+ if (length < 0)
2510+ return 0;
2511+
2512+ return static_cast<size_t>(length);
2513+}
2514+
2515+
2516+namespace type {
2517+
2518+void Time::store(const struct tm &from)
2519+{
2520+ _is_local_time= false;
2521+ neg= 0;
2522+ second_part= 0;
2523+ year= (int32_t) ((from.tm_year+1900) % 10000);
2524+ month= (int32_t) from.tm_mon+1;
2525+ day= (int32_t) from.tm_mday;
2526+ hour= (int32_t) from.tm_hour;
2527+ minute= (int32_t) from.tm_min;
2528+ second= (int32_t) from.tm_sec;
2529+
2530+ time_type= DRIZZLE_TIMESTAMP_DATETIME;
2531+}
2532+
2533+void Time::store(const struct timeval &from)
2534+{
2535+ store(from.tv_sec, (usec_t)from.tv_usec);
2536+ time_type= type::DRIZZLE_TIMESTAMP_DATETIME;
2537+}
2538+
2539+
2540+void Time::store(const time_t &from, bool use_localtime)
2541+{
2542+ store(from, 0, use_localtime);
2543+}
2544+
2545+void Time::store(const time_t &from_arg, const usec_t &from_fractional_seconds, bool use_localtime)
2546+{
2547+ epoch_t from= from_arg;
2548+
2549+ if (use_localtime)
2550+ {
2551+ util::localtime(from, *this);
2552+ _is_local_time= true;
2553+ }
2554+ else
2555+ {
2556+ util::gmtime(from, *this);
2557+ }
2558+
2559+ // Since time_t/epoch_t doesn't have fractional seconds, we have to
2560+ // collect them outside of the gmtime function.
2561+ second_part= from_fractional_seconds;
2562+ time_type= DRIZZLE_TIMESTAMP_DATETIME;
2563+}
2564+
2565+void Time::convert(String &str, timestamp_t arg)
2566+{
2567+ str.alloc(MAX_STRING_LENGTH);
2568+ size_t length= MAX_STRING_LENGTH;
2569+
2570+ convert(str.c_ptr(), length, arg);
2571+
2572+ str.length(length);
2573+ str.set_charset(&my_charset_bin);
2574+}
2575+
2576+void Time::convert(char *str, size_t &to_length, timestamp_t arg)
2577+{
2578+ switch (arg) {
2579 case DRIZZLE_TIMESTAMP_DATETIME:
2580- return my_datetime_to_str(l_time, to);
2581+ to_length= my_datetime_to_str(this, str, to_length);
2582+ break;
2583+
2584 case DRIZZLE_TIMESTAMP_DATE:
2585- return my_date_to_str(l_time, to);
2586+ to_length= (uint32_t) my_date_to_str(this, str);
2587+ break;
2588+
2589 case DRIZZLE_TIMESTAMP_TIME:
2590- return my_time_to_str(l_time, to);
2591+ to_length= (uint32_t) my_time_to_str(this, str);
2592+ break;
2593+
2594 case DRIZZLE_TIMESTAMP_NONE:
2595 case DRIZZLE_TIMESTAMP_ERROR:
2596- to[0]='\0';
2597- return 0;
2598- default:
2599 assert(0);
2600- return 0;
2601+ to_length= 0;
2602+ break;
2603 }
2604 }
2605
2606+}
2607
2608 /*
2609 Convert datetime value specified as number to broken-down TIME
2610@@ -1132,12 +1189,12 @@
2611 long part1,part2;
2612
2613 *was_cut= 0;
2614- memset(time_res, 0, sizeof(*time_res));
2615- time_res->time_type=DRIZZLE_TIMESTAMP_DATE;
2616+ time_res->reset();
2617+ time_res->time_type=type::DRIZZLE_TIMESTAMP_DATE;
2618
2619 if (nr == 0LL || nr >= 10000101000000LL)
2620 {
2621- time_res->time_type=DRIZZLE_TIMESTAMP_DATETIME;
2622+ time_res->time_type= type::DRIZZLE_TIMESTAMP_DATETIME;
2623 goto ok;
2624 }
2625 if (nr < 101)
2626@@ -1164,7 +1221,7 @@
2627 if (nr < 101000000L)
2628 goto err;
2629
2630- time_res->time_type=DRIZZLE_TIMESTAMP_DATETIME;
2631+ time_res->time_type= type::DRIZZLE_TIMESTAMP_DATETIME;
2632
2633 if (nr <= (YY_PART_YEAR-1) * 10000000000LL + 1231235959LL)
2634 {
2635@@ -1219,8 +1276,9 @@
2636
2637 static uint64_t TIME_to_uint64_t_date(const type::Time *my_time)
2638 {
2639- return (uint64_t) (my_time->year * 10000UL + my_time->month * 100UL +
2640- my_time->day);
2641+ return (uint64_t) (my_time->year * 10000UL +
2642+ my_time->month * 100UL +
2643+ my_time->day);
2644 }
2645
2646
2647@@ -1233,8 +1291,8 @@
2648 static uint64_t TIME_to_uint64_t_time(const type::Time *my_time)
2649 {
2650 return (uint64_t) (my_time->hour * 10000UL +
2651- my_time->minute * 100UL +
2652- my_time->second);
2653+ my_time->minute * 100UL +
2654+ my_time->second);
2655 }
2656
2657
2658@@ -1261,18 +1319,20 @@
2659 uint64_t TIME_to_uint64_t(const type::Time *my_time)
2660 {
2661 switch (my_time->time_type) {
2662- case DRIZZLE_TIMESTAMP_DATETIME:
2663+ case type::DRIZZLE_TIMESTAMP_DATETIME:
2664 return TIME_to_uint64_t_datetime(my_time);
2665- case DRIZZLE_TIMESTAMP_DATE:
2666+
2667+ case type::DRIZZLE_TIMESTAMP_DATE:
2668 return TIME_to_uint64_t_date(my_time);
2669- case DRIZZLE_TIMESTAMP_TIME:
2670+
2671+ case type::DRIZZLE_TIMESTAMP_TIME:
2672 return TIME_to_uint64_t_time(my_time);
2673- case DRIZZLE_TIMESTAMP_NONE:
2674- case DRIZZLE_TIMESTAMP_ERROR:
2675+
2676+ case type::DRIZZLE_TIMESTAMP_NONE:
2677+ case type::DRIZZLE_TIMESTAMP_ERROR:
2678 return 0ULL;
2679- default:
2680- assert(0);
2681 }
2682+
2683 return 0;
2684 }
2685
2686
2687=== modified file 'drizzled/type/time.h'
2688--- drizzled/type/time.h 2011-01-11 00:57:46 +0000
2689+++ drizzled/type/time.h 2011-01-18 01:47:30 +0000
2690@@ -32,6 +32,8 @@
2691 # endif
2692 #endif
2693
2694+#include <drizzled/sql_string.h>
2695+
2696 namespace drizzled
2697 {
2698
2699@@ -39,7 +41,6 @@
2700 extern unsigned char days_in_month[];
2701
2702 /* Time handling defaults */
2703-#define TIMESTAMP_MAX_YEAR 2038
2704 #define TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1)
2705 #define TIMESTAMP_MAX_VALUE INT32_MAX
2706 #define TIMESTAMP_MIN_VALUE 1
2707@@ -68,13 +69,6 @@
2708 #define TIME_MAX_VALUE_SECONDS (TIME_MAX_HOUR * 3600L + \
2709 TIME_MAX_MINUTE * 60L + TIME_MAX_SECOND)
2710
2711-enum enum_drizzle_timestamp_type
2712-{
2713- DRIZZLE_TIMESTAMP_NONE= -2, DRIZZLE_TIMESTAMP_ERROR= -1,
2714- DRIZZLE_TIMESTAMP_DATE= 0, DRIZZLE_TIMESTAMP_DATETIME= 1, DRIZZLE_TIMESTAMP_TIME= 2
2715-};
2716-
2717-
2718 /*
2719 Structure which is used to represent datetime values inside Drizzle.
2720
2721@@ -88,30 +82,117 @@
2722 bigger values.
2723 */
2724 namespace type {
2725+
2726+enum timestamp_t
2727+{
2728+ DRIZZLE_TIMESTAMP_NONE= -2, DRIZZLE_TIMESTAMP_ERROR= -1,
2729+ DRIZZLE_TIMESTAMP_DATE= 0, DRIZZLE_TIMESTAMP_DATETIME= 1, DRIZZLE_TIMESTAMP_TIME= 2
2730+};
2731+
2732+/*
2733+ datatime_t while being stored in an integer is actually a formatted value.
2734+*/
2735+struct datatime_t {
2736+ int64_t value;
2737+};
2738+
2739+
2740+
2741 class Time
2742 {
2743 public:
2744- unsigned int year, month, day, hour, minute, second;
2745- unsigned int second_part;
2746- bool neg;
2747- enum enum_drizzle_timestamp_type time_type;
2748+ typedef uint32_t usec_t;
2749+ typedef int64_t epoch_t;
2750+
2751+ Time()
2752+ {
2753+ reset();
2754+ }
2755+
2756+ Time(uint32_t year_arg,
2757+ uint32_t month_arg,
2758+ uint32_t day_arg,
2759+ uint32_t hour_arg,
2760+ uint32_t minute_arg,
2761+ uint32_t second_arg,
2762+ usec_t second_part_arg,
2763+ timestamp_t type_arg) :
2764+ year(year_arg),
2765+ month(month_arg),
2766+ day(day_arg),
2767+ hour(hour_arg),
2768+ minute(minute_arg),
2769+ second(second_arg),
2770+ second_part(second_part_arg),
2771+ neg(false),
2772+ time_type(type_arg),
2773+ _is_local_time(false)
2774+ {
2775+ }
2776+
2777+ Time(uint32_t hour_arg,
2778+ uint32_t minute_arg,
2779+ uint32_t second_arg,
2780+ usec_t second_part_arg,
2781+ bool neg_arg) :
2782+ year(0),
2783+ month(0),
2784+ day(0),
2785+ hour(hour_arg),
2786+ minute(minute_arg),
2787+ second(second_arg),
2788+ second_part(second_part_arg),
2789+ neg(neg_arg),
2790+ time_type(DRIZZLE_TIMESTAMP_TIME),
2791+ _is_local_time(false)
2792+ {
2793+ }
2794+
2795+ uint32_t year, month, day, hour, minute, second;
2796+ usec_t second_part;
2797+ bool neg;
2798+ timestamp_t time_type;
2799+ bool _is_local_time;
2800+
2801+ void reset()
2802+ {
2803+ year= month= day= hour= minute= second= second_part= 0;
2804+ neg= false;
2805+ time_type= DRIZZLE_TIMESTAMP_DATE;
2806+ _is_local_time= false;
2807+ }
2808+
2809+ timestamp_t type() const
2810+ {
2811+ return time_type;
2812+ }
2813+
2814+ void convert(drizzled::String &str, timestamp_t arg= type::DRIZZLE_TIMESTAMP_DATETIME);
2815+ void convert(char *str, size_t &to_length, timestamp_t arg= type::DRIZZLE_TIMESTAMP_DATETIME);
2816+
2817+ void store(const type::Time::epoch_t &from, bool use_localtime= false);
2818+ void store(const type::Time::epoch_t &from, const usec_t &from_fractional_seconds, bool use_localtime= false);
2819+ void store(const struct tm &from);
2820+ void store(const struct timeval &from);
2821+
2822+ static const uint32_t FRACTIONAL_DIGITS= 1000000;
2823+ static const size_t MAX_STRING_LENGTH= 32; // +32 to make my_snprintf_{8bit|ucs2} happy
2824 };
2825+
2826 }
2827
2828-
2829 bool check_date(const type::Time *ltime, bool not_zero_date,
2830 uint32_t flags, int *was_cut);
2831-enum enum_drizzle_timestamp_type
2832-str_to_datetime(const char *str, uint32_t length, type::Time *l_time,
2833- uint32_t flags, int *was_cut);
2834+
2835+type::timestamp_t str_to_datetime(const char *str, uint32_t length, type::Time *l_time, uint32_t flags, int *was_cut);
2836+
2837 int64_t number_to_datetime(int64_t nr, type::Time *time_res,
2838 uint32_t flags, int *was_cut);
2839 uint64_t TIME_to_uint64_t_datetime(const type::Time *);
2840 uint64_t TIME_to_uint64_t(const type::Time *);
2841
2842
2843-bool str_to_time(const char *str,uint32_t length, type::Time *l_time,
2844- int *warning);
2845+bool str_to_time(const char *str,uint32_t length, type::Time *l_time, int *warning);
2846
2847 long calc_daynr(uint32_t year,uint32_t month,uint32_t day);
2848 uint32_t calc_days_in_year(uint32_t year);
2849@@ -135,10 +216,10 @@
2850
2851 static inline bool validate_timestamp_range(const type::Time *t)
2852 {
2853- if ((t->year > TIMESTAMP_MAX_YEAR || t->year < TIMESTAMP_MIN_YEAR) ||
2854- (t->year == TIMESTAMP_MAX_YEAR && (t->month > 1 || t->day > 19)) ||
2855- (t->year == TIMESTAMP_MIN_YEAR && (t->month < 12 || t->day < 31)))
2856+ if ((t->year < TIMESTAMP_MIN_YEAR) or (t->year == TIMESTAMP_MIN_YEAR && (t->month < 12 || t->day < 31)))
2857+ {
2858 return false;
2859+ }
2860
2861 return true;
2862 }
2863@@ -147,23 +228,6 @@
2864 my_system_gmt_sec(const type::Time *t, long *my_timezone,
2865 bool *in_dst_time_gap, bool skip_timezone= false);
2866
2867-void set_zero_time(type::Time *tm, enum enum_drizzle_timestamp_type time_type);
2868-
2869-/*
2870- Required buffer length for my_time_to_str, my_date_to_str,
2871- my_datetime_to_str and TIME_to_string functions. Note, that the
2872- caller is still responsible to check that given TIME structure
2873- has values in valid ranges, otherwise size of the buffer could
2874- be not enough. We also rely on the fact that even wrong values
2875- sent using binary protocol fit in this buffer.
2876-*/
2877-#define MAX_DATE_STRING_REP_LENGTH 30
2878-
2879-int my_time_to_str(const type::Time *l_time, char *to);
2880-int my_date_to_str(const type::Time *l_time, char *to);
2881-int my_datetime_to_str(const type::Time *l_time, char *to);
2882-int my_TIME_to_str(const type::Time *l_time, char *to);
2883-
2884 /*
2885 Available interval types used in any statement.
2886
2887
2888=== modified file 'drizzled/tztime.cc'
2889--- drizzled/tztime.cc 2010-12-25 04:38:28 +0000
2890+++ drizzled/tztime.cc 2011-01-18 01:47:30 +0000
2891@@ -49,9 +49,9 @@
2892 {
2893 public:
2894 Time_zone_system() {} /* Remove gcc warning */
2895- virtual time_t TIME_to_gmt_sec(const type::Time *t,
2896- bool *in_dst_time_gap) const;
2897- virtual void gmt_sec_to_TIME(type::Time *tmp, time_t t) const;
2898+ virtual type::Time::epoch_t TIME_to_gmt_sec(const type::Time *t,
2899+ bool *in_dst_time_gap) const;
2900+ virtual void gmt_sec_to_TIME(type::Time *tmp, type::Time::epoch_t t) const;
2901 virtual const String * get_name() const;
2902 };
2903
2904@@ -59,14 +59,14 @@
2905 /**
2906 * @brief
2907 * Converts local time in system time zone in type::Time representation
2908- * to its time_t representation.
2909+ * to its type::Time::epoch_t representation.
2910 *
2911 * @details
2912 * This method uses system function (localtime_r()) for conversion
2913- * local time in system time zone in type::Time structure to its time_t
2914+ * local time in system time zone in type::Time structure to its type::Time::epoch_t
2915 * representation. Unlike the same function for Time_zone_db class
2916 * it it won't handle unnormalized input properly. Still it will
2917- * return lowest possible time_t in case of ambiguity or if we
2918+ * return lowest possible type::Time::epoch_t in case of ambiguity or if we
2919 * provide time corresponding to the time-gap.
2920 *
2921 * You should call init_time() function before using this function.
2922@@ -78,9 +78,9 @@
2923 * spring time-gap) and is not touched otherwise.
2924 *
2925 * @return
2926- * Corresponding time_t value or 0 in case of error
2927+ * Corresponding type::Time::epoch_t value or 0 in case of error
2928 */
2929-time_t
2930+type::Time::epoch_t
2931 Time_zone_system::TIME_to_gmt_sec(const type::Time *t, bool *in_dst_time_gap) const
2932 {
2933 long not_used;
2934@@ -90,27 +90,22 @@
2935
2936 /**
2937 * @brief
2938- * Converts time from UTC seconds since Epoch (time_t) representation
2939+ * Converts time from UTC seconds since Epoch (type::Time::epoch_t) representation
2940 * to system local time zone broken-down representation.
2941 *
2942 * @param tmp pointer to type::Time structure to fill-in
2943- * @param t time_t value to be converted
2944+ * @param t type::Time::epoch_t value to be converted
2945 *
2946- * Note: We assume that value passed to this function will fit into time_t range
2947+ * Note: We assume that value passed to this function will fit into type::Time::epoch_t range
2948 * supported by localtime_r. This conversion is putting restriction on
2949 * TIMESTAMP range in MySQL. If we can get rid of SYSTEM time zone at least
2950 * for interaction with client then we can extend TIMESTAMP range down to
2951 * the 1902 easily.
2952 */
2953 void
2954-Time_zone_system::gmt_sec_to_TIME(type::Time *tmp, time_t t) const
2955+Time_zone_system::gmt_sec_to_TIME(type::Time *tmp, type::Time::epoch_t t) const
2956 {
2957- struct tm tmp_tm;
2958- time_t tmp_t= (time_t)t;
2959-
2960- localtime_r(&tmp_t, &tmp_tm);
2961- localtime_to_TIME(tmp, &tmp_tm);
2962- tmp->time_type= DRIZZLE_TIMESTAMP_DATETIME;
2963+ tmp->store(t);
2964 }
2965
2966
2967
2968=== modified file 'drizzled/tztime.h'
2969--- drizzled/tztime.h 2010-12-25 04:38:28 +0000
2970+++ drizzled/tztime.h 2011-01-18 01:47:30 +0000
2971@@ -21,19 +21,10 @@
2972 #ifndef DRIZZLED_TZTIME_H
2973 #define DRIZZLED_TZTIME_H
2974
2975-#if TIME_WITH_SYS_TIME
2976-# include <sys/time.h>
2977-# include <time.h>
2978-#else
2979-# if HAVE_SYS_TIME_H
2980-# include <sys/time.h>
2981-# else
2982-# include <time.h>
2983-# endif
2984-#endif
2985-
2986 #include "drizzled/memory/sql_alloc.h"
2987
2988+#include "drizzled/type/time.h"
2989+
2990 namespace drizzled
2991 {
2992
2993@@ -45,7 +36,7 @@
2994
2995 /**
2996 This class represents abstract time zone and provides
2997- basic interface for type::Time <-> time_t conversion.
2998+ basic interface for type::Time <-> type::Time::epoch_t conversion.
2999 Actual time zones which are specified by DB, or via offset
3000 or use system functions are its descendants.
3001 */
3002@@ -55,17 +46,18 @@
3003 Time_zone() {} /* Remove gcc warning */
3004 /**
3005 Converts local time in broken down type::Time representation to
3006- time_t (UTC seconds since Epoch) represenation.
3007+ type::Time::epoch_t (UTC seconds since Epoch) represenation.
3008 Returns 0 in case of error. Sets in_dst_time_gap to true if date provided
3009 falls into spring time-gap (or lefts it untouched otherwise).
3010 */
3011- virtual time_t TIME_to_gmt_sec(const type::Time *t,
3012- bool *in_dst_time_gap) const = 0;
3013+ virtual type::Time::epoch_t TIME_to_gmt_sec(const type::Time *t,
3014+ bool *in_dst_time_gap) const = 0;
3015 /**
3016- Converts time in time_t representation to local time in
3017+ Converts time in type::Time::epoch_t representation to local time in
3018 broken down type::Time representation.
3019 */
3020- virtual void gmt_sec_to_TIME(type::Time *tmp, time_t t) const = 0;
3021+ virtual void gmt_sec_to_TIME(type::Time *tmp, type::Time::epoch_t t) const = 0;
3022+
3023 /**
3024 Because of constness of String returned by get_name() time zone name
3025 have to be already zeroended to be able to use String::ptr() instead
3026
3027=== added file 'drizzled/util/gmtime.cc'
3028--- drizzled/util/gmtime.cc 1970-01-01 00:00:00 +0000
3029+++ drizzled/util/gmtime.cc 2011-01-18 01:47:30 +0000
3030@@ -0,0 +1,284 @@
3031+//
3032+// time.c
3033+//
3034+// Time routines
3035+//
3036+// Copyright (C) 2002 Michael Ringgaard. All rights reserved.
3037+//
3038+// Redistribution and use in source and binary forms, with or without
3039+// modification, are permitted provided that the following conditions
3040+// are met:
3041+//
3042+// 1. Redistributions of source code must retain the above copyright
3043+// notice, this list of conditions and the following disclaimer.
3044+// 2. Redistributions in binary form must reproduce the above copyright
3045+// notice, this list of conditions and the following disclaimer in the
3046+// documentation and/or other materials provided with the distribution.
3047+// 3. Neither the name of the project nor the names of its contributors
3048+// may be used to endorse or promote products derived from this software
3049+// without specific prior written permission.
3050+//
3051+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
3052+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3053+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3054+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
3055+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3056+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3057+// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3058+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3059+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3060+// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3061+// SUCH DAMAGE.
3062+//
3063+
3064+#include "config.h"
3065+
3066+#include <drizzled/type/time.h>
3067+#include <drizzled/util/gmtime.h>
3068+
3069+namespace drizzled
3070+{
3071+namespace util
3072+{
3073+#define YEAR0 1900
3074+#define EPOCH_YR 1970
3075+#define SECS_DAY (24L * 60L * 60L)
3076+#define LEAPYEAR(year) (!((year) % 4) && (((year) % 100) || !((year) % 400)))
3077+#define YEARSIZE(year) (LEAPYEAR(year) ? 366 : 365)
3078+#define FIRSTSUNDAY(timp) (((timp)->tm_yday - (timp)->tm_wday + 420) % 7)
3079+#define FIRSTDAYOF(timp) (((timp)->tm_wday - (timp)->tm_yday + 420) % 7)
3080+
3081+#define TIME_MAX INT64_MIN
3082+
3083+int _daylight = 0; // Non-zero if daylight savings time is used
3084+long _dstbias = 0; // Offset for Daylight Saving Time
3085+type::Time::epoch_t _timezone = 0; // Difference in seconds between GMT and local time
3086+const char *_tzname[2] = {"GMT", "GMT"}; // Standard/daylight savings time zone names
3087+
3088+const char *_days[] =
3089+{
3090+ "Sunday", "Monday", "Tuesday", "Wednesday",
3091+ "Thursday", "Friday", "Saturday"
3092+};
3093+
3094+const char *_days_abbrev[] =
3095+{
3096+ "Sun", "Mon", "Tue", "Wed",
3097+ "Thu", "Fri", "Sat"
3098+};
3099+
3100+const char *_months[] =
3101+{
3102+ "January", "February", "March",
3103+ "April", "May", "June",
3104+ "July", "August", "September",
3105+ "October", "November", "December"
3106+};
3107+
3108+const char *_months_abbrev[] =
3109+{
3110+ "Jan", "Feb", "Mar",
3111+ "Apr", "May", "Jun",
3112+ "Jul", "Aug", "Sep",
3113+ "Oct", "Nov", "Dec"
3114+};
3115+
3116+const int _ytab[2][12] =
3117+{
3118+ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
3119+ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
3120+};
3121+
3122+struct tm *gmtime(const type::Time::epoch_t &timer, struct tm *tmbuf)
3123+{
3124+ uint64_t dayclock, dayno;
3125+ int year = EPOCH_YR;
3126+
3127+ dayclock = (uint64_t) timer % SECS_DAY;
3128+ dayno = (uint64_t) timer / SECS_DAY;
3129+
3130+ tmbuf->tm_sec = dayclock % 60;
3131+ tmbuf->tm_min = (dayclock % 3600) / 60;
3132+ tmbuf->tm_hour = dayclock / 3600;
3133+ tmbuf->tm_wday = (dayno + 4) % 7; // Day 0 was a thursday
3134+ while (dayno >= (uint64_t) YEARSIZE(year))
3135+ {
3136+ dayno -= YEARSIZE(year);
3137+ year++;
3138+ }
3139+ tmbuf->tm_year = year - YEAR0;
3140+ tmbuf->tm_yday = dayno;
3141+ tmbuf->tm_mon = 0;
3142+ while (dayno >= (uint64_t) _ytab[LEAPYEAR(year)][tmbuf->tm_mon])
3143+ {
3144+ dayno -= _ytab[LEAPYEAR(year)][tmbuf->tm_mon];
3145+ tmbuf->tm_mon++;
3146+ }
3147+ tmbuf->tm_mday = dayno + 1;
3148+ tmbuf->tm_isdst = 0;
3149+
3150+ return tmbuf;
3151+}
3152+
3153+void gmtime(const type::Time::epoch_t &timer, type::Time &tmbuf)
3154+{
3155+ uint64_t dayclock, dayno;
3156+ int32_t year= EPOCH_YR;
3157+
3158+ tmbuf.reset();
3159+
3160+ dayclock= (uint64_t) timer % SECS_DAY;
3161+ dayno= (uint64_t) timer / SECS_DAY;
3162+
3163+ tmbuf.second= dayclock % 60;
3164+ tmbuf.minute= (dayclock % 3600) / 60;
3165+ tmbuf.hour= dayclock / 3600;
3166+ while (dayno >= (uint64_t) YEARSIZE(year))
3167+ {
3168+ dayno -= YEARSIZE(year);
3169+ year++;
3170+ }
3171+ tmbuf.year= year;
3172+ while (dayno >= (uint64_t) _ytab[LEAPYEAR(year)][tmbuf.month])
3173+ {
3174+ dayno -= _ytab[LEAPYEAR(year)][tmbuf.month];
3175+ tmbuf.month++;
3176+ }
3177+ tmbuf.month++;
3178+ tmbuf.day= dayno +1;
3179+ tmbuf.time_type= type::DRIZZLE_TIMESTAMP_DATETIME;
3180+}
3181+
3182+void localtime(const type::Time::epoch_t &timer, type::Time &tmbuf)
3183+{
3184+ type::Time::epoch_t t;
3185+
3186+ t = timer - _timezone;
3187+ return util::gmtime(t, tmbuf);
3188+}
3189+
3190+struct tm *localtime(const type::Time::epoch_t &timer, struct tm *tmbuf)
3191+{
3192+ type::Time::epoch_t t;
3193+
3194+ t = timer - _timezone;
3195+ return util::gmtime(t, tmbuf);
3196+}
3197+
3198+time_t mktime(struct tm *tmbuf)
3199+{
3200+ long day, year;
3201+ int tm_year;
3202+ int yday, month;
3203+ /*unsigned*/ long seconds;
3204+ int overflow;
3205+ long dst;
3206+
3207+ tmbuf->tm_min += tmbuf->tm_sec / 60;
3208+ tmbuf->tm_sec %= 60;
3209+ if (tmbuf->tm_sec < 0)
3210+ {
3211+ tmbuf->tm_sec += 60;
3212+ tmbuf->tm_min--;
3213+ }
3214+ tmbuf->tm_hour += tmbuf->tm_min / 60;
3215+ tmbuf->tm_min = tmbuf->tm_min % 60;
3216+ if (tmbuf->tm_min < 0)
3217+ {
3218+ tmbuf->tm_min += 60;
3219+ tmbuf->tm_hour--;
3220+ }
3221+ day = tmbuf->tm_hour / 24;
3222+ tmbuf->tm_hour= tmbuf->tm_hour % 24;
3223+ if (tmbuf->tm_hour < 0)
3224+ {
3225+ tmbuf->tm_hour += 24;
3226+ day--;
3227+ }
3228+ tmbuf->tm_year += tmbuf->tm_mon / 12;
3229+ tmbuf->tm_mon %= 12;
3230+ if (tmbuf->tm_mon < 0)
3231+ {
3232+ tmbuf->tm_mon += 12;
3233+ tmbuf->tm_year--;
3234+ }
3235+ day += (tmbuf->tm_mday - 1);
3236+ while (day < 0)
3237+ {
3238+ if(--tmbuf->tm_mon < 0)
3239+ {
3240+ tmbuf->tm_year--;
3241+ tmbuf->tm_mon = 11;
3242+ }
3243+ day += _ytab[LEAPYEAR(YEAR0 + tmbuf->tm_year)][tmbuf->tm_mon];
3244+ }
3245+ while (day >= _ytab[LEAPYEAR(YEAR0 + tmbuf->tm_year)][tmbuf->tm_mon])
3246+ {
3247+ day -= _ytab[LEAPYEAR(YEAR0 + tmbuf->tm_year)][tmbuf->tm_mon];
3248+ if (++(tmbuf->tm_mon) == 12)
3249+ {
3250+ tmbuf->tm_mon = 0;
3251+ tmbuf->tm_year++;
3252+ }
3253+ }
3254+ tmbuf->tm_mday = day + 1;
3255+ year = EPOCH_YR;
3256+ if (tmbuf->tm_year < year - YEAR0) return (time_t) -1;
3257+ seconds = 0;
3258+ day = 0; // Means days since day 0 now
3259+ overflow = 0;
3260+
3261+ // Assume that when day becomes negative, there will certainly
3262+ // be overflow on seconds.
3263+ // The check for overflow needs not to be done for leapyears
3264+ // divisible by 400.
3265+ // The code only works when year (1970) is not a leapyear.
3266+ tm_year = tmbuf->tm_year + YEAR0;
3267+
3268+ if (TIME_MAX / 365 < tm_year - year) overflow++;
3269+ day = (tm_year - year) * 365;
3270+ if (TIME_MAX - day < (tm_year - year) / 4 + 1) overflow++;
3271+ day += (tm_year - year) / 4 + ((tm_year % 4) && tm_year % 4 < year % 4);
3272+ day -= (tm_year - year) / 100 + ((tm_year % 100) && tm_year % 100 < year % 100);
3273+ day += (tm_year - year) / 400 + ((tm_year % 400) && tm_year % 400 < year % 400);
3274+
3275+ yday = month = 0;
3276+ while (month < tmbuf->tm_mon)
3277+ {
3278+ yday += _ytab[LEAPYEAR(tm_year)][month];
3279+ month++;
3280+ }
3281+ yday += (tmbuf->tm_mday - 1);
3282+ if (day + yday < 0) overflow++;
3283+ day += yday;
3284+
3285+ tmbuf->tm_yday = yday;
3286+ tmbuf->tm_wday = (day + 4) % 7; // Day 0 was thursday (4)
3287+
3288+ seconds = ((tmbuf->tm_hour * 60L) + tmbuf->tm_min) * 60L + tmbuf->tm_sec;
3289+
3290+ if ((TIME_MAX - seconds) / SECS_DAY < day) overflow++;
3291+ seconds += day * SECS_DAY;
3292+
3293+ // Now adjust according to timezone and daylight saving time
3294+ if (((_timezone > 0) && (TIME_MAX - _timezone < seconds))
3295+ || ((_timezone < 0) && (seconds < -_timezone)))
3296+ overflow++;
3297+ seconds += _timezone;
3298+
3299+ if (tmbuf->tm_isdst)
3300+ dst = _dstbias;
3301+ else
3302+ dst = 0;
3303+
3304+ if (dst > seconds) overflow++; // dst is always non-negative
3305+ seconds -= dst;
3306+
3307+ if (overflow) return (time_t) -1;
3308+
3309+ if ((time_t) seconds != seconds) return (time_t) -1;
3310+ return (time_t) seconds;
3311+}
3312+
3313+} /* namespace util */
3314+} /* namespace drizzled */
3315
3316=== added file 'drizzled/util/gmtime.h'
3317--- drizzled/util/gmtime.h 1970-01-01 00:00:00 +0000
3318+++ drizzled/util/gmtime.h 2011-01-18 01:47:30 +0000
3319@@ -0,0 +1,46 @@
3320+/* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
3321+ * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3322+ *
3323+ * Copyright (C) 2010 Brian Aker
3324+ *
3325+ * This program is free software; you can redistribute it and/or modify
3326+ * it under the terms of the GNU General Public License as published by
3327+ * the Free Software Foundation; either version 2 of the License, or
3328+ * (at your option) any later version.
3329+ *
3330+ * This program is distributed in the hope that it will be useful,
3331+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3332+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3333+ * GNU General Public License for more details.
3334+ *
3335+ * You should have received a copy of the GNU General Public License
3336+ * along with this program; if not, write to the Free Software
3337+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3338+ */
3339+
3340+/*
3341+ * This is just the header file, the actual code is under a BSD license.
3342+ */
3343+
3344+#ifndef DRIZZLED_UTIL_GMTIME_H
3345+#define DRIZZLED_UTIL_GMTIME_H
3346+
3347+#include <time.h>
3348+
3349+namespace drizzled
3350+{
3351+
3352+namespace util
3353+{
3354+
3355+struct tm *gmtime(const type::Time::epoch_t &timer, struct tm *tmbuf);
3356+void gmtime(const type::Time::epoch_t &timer, type::Time &tmbuf);
3357+struct tm *localtime(const type::Time::epoch_t &timer, struct tm *tmbuf);
3358+void localtime(const type::Time::epoch_t &timer, type::Time &tmbuf);
3359+time_t mktime(struct tm *tmbuf);
3360+
3361+} /* namespace util */
3362+} /* namespace drizzled */
3363+
3364+#endif /* DRIZZLED_UTIL_GMTIME_H */
3365+
3366
3367=== modified file 'drizzled/util/include.am'
3368--- drizzled/util/include.am 2011-01-10 16:11:50 +0000
3369+++ drizzled/util/include.am 2011-01-18 01:47:30 +0000
3370@@ -20,6 +20,7 @@
3371 drizzled/util/backtrace.h \
3372 drizzled/util/convert.h \
3373 drizzled/util/functors.h \
3374+ drizzled/util/gmtime.h \
3375 drizzled/util/tablename_to_filename.h \
3376 drizzled/util/test.h \
3377 drizzled/util/tokenize.h
3378@@ -28,5 +29,6 @@
3379 drizzled_util_libutil_la_SOURCES= \
3380 drizzled/util/backtrace.cc \
3381 drizzled/util/convert.cc \
3382+ drizzled/util/gmtime.cc \
3383 drizzled/util/tablename_to_filename.cc
3384
3385
3386=== modified file 'plugin/csv/tests/t/uuid_type.test'
3387--- plugin/csv/tests/t/uuid_type.test 2010-12-17 22:39:43 +0000
3388+++ plugin/csv/tests/t/uuid_type.test 2011-01-18 01:47:30 +0000
3389@@ -19,7 +19,7 @@
3390 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883aaaa");
3391 SELECT a FROM t1 ORDER BY a;
3392
3393---error 1716
3394+--error ER_INVALID_UUID_VALUE
3395 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883");
3396 SELECT a FROM t1 ORDER BY a;
3397
3398
3399=== modified file 'plugin/haildb/tests/r/type_timestamp.result'
3400--- plugin/haildb/tests/r/type_timestamp.result 2010-12-10 05:45:44 +0000
3401+++ plugin/haildb/tests/r/type_timestamp.result 2011-01-18 01:47:30 +0000
3402@@ -112,17 +112,17 @@
3403 drop table t1;
3404 create table t1 (ix timestamp);
3405 insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
3406-ERROR HY000: Received an invalid value '0' for a UNIX timestamp.
3407+ERROR HY000: Received an invalid timestamp value '0'.
3408 select ix+0 from t1;
3409 ix+0
3410 truncate table t1;
3411 insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
3412-ERROR HY000: Received an invalid value '00000000000000' for a UNIX timestamp.
3413+ERROR HY000: Received an invalid timestamp value '00000000000000'.
3414 select ix+0 from t1;
3415 ix+0
3416 truncate table t1;
3417 insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
3418-ERROR HY000: Received an invalid value '0000-00-00 00:00:00 some trailer' for a UNIX timestamp.
3419+ERROR HY000: Received an invalid timestamp value '0000-00-00 00:00:00 some trailer'.
3420 select ix+0 from t1;
3421 ix+0
3422 drop table t1;
3423
3424=== modified file 'plugin/haildb/tests/t/type_timestamp.test'
3425--- plugin/haildb/tests/t/type_timestamp.test 2010-12-10 05:45:44 +0000
3426+++ plugin/haildb/tests/t/type_timestamp.test 2011-01-18 01:47:30 +0000
3427@@ -83,15 +83,15 @@
3428 # (for both strings and numbers)
3429 #
3430 create table t1 (ix timestamp);
3431---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix timestamp
3432+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix timestamp
3433 insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
3434 select ix+0 from t1;
3435 truncate table t1;
3436---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix timestamp
3437+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix timestamp
3438 insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
3439 select ix+0 from t1;
3440 truncate table t1;
3441---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix timestamp
3442+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix timestamp
3443 insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
3444 select ix+0 from t1;
3445 drop table t1;
3446
3447=== modified file 'plugin/memory/tests/t/primary_key.test'
3448--- plugin/memory/tests/t/primary_key.test 2010-12-17 22:39:43 +0000
3449+++ plugin/memory/tests/t/primary_key.test 2011-01-18 01:47:30 +0000
3450@@ -21,7 +21,7 @@
3451 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883aaaa");
3452 SELECT a FROM t1 ORDER BY a;
3453
3454---error 1716
3455+--error ER_INVALID_UUID_VALUE
3456 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883");
3457 SELECT a FROM t1 ORDER BY a;
3458
3459
3460=== modified file 'plugin/myisam/tests/r/mix2_myisam.result'
3461--- plugin/myisam/tests/r/mix2_myisam.result 2010-12-07 09:12:12 +0000
3462+++ plugin/myisam/tests/r/mix2_myisam.result 2011-01-18 01:47:30 +0000
3463@@ -873,10 +873,12 @@
3464 create TEMPORARY table t2 (col1 int,stamp TIMESTAMP,INDEX stamp_idx
3465 (stamp))ENGINE=MyISAM;
3466 insert into t1 values (1),(2),(3);
3467-insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
3468-ERROR HY000: Received an invalid value '20020204310000' for a UNIX timestamp.
3469-SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
3470-'20020204120000' GROUP BY col1;
3471+insert into t2 values (1, 20020204130000);
3472+insert into t2 values (2, 20020204130000);
3473+insert into t2 values (4, 20020204310000);
3474+ERROR HY000: Received an invalid timestamp value '20020204310000'.
3475+insert into t2 values (5, 20020204230000);
3476+SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp < '20020204120000' GROUP BY col1;
3477 col1
3478 1
3479 2
3480
3481=== modified file 'plugin/transaction_log/tests/r/transaction_log_data_type.result'
3482--- plugin/transaction_log/tests/r/transaction_log_data_type.result 2011-01-11 14:22:54 +0000
3483+++ plugin/transaction_log/tests/r/transaction_log_data_type.result 2011-01-18 01:47:30 +0000
3484@@ -3405,7 +3405,7 @@
3485
3486 Testing MIN-1 TIMESTAMP
3487 INSERT INTO t1 (b) VALUES('1969-12-31 23:59:59');
3488-ERROR HY000: Received an invalid value '1969-12-31 23:59:59' for a UNIX timestamp.
3489+ERROR HY000: Received an invalid timestamp value '1969-12-31 23:59:59'.
3490 Check transaction_log_entries
3491 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
3492 COUNT(*)
3493@@ -3460,16 +3460,15 @@
3494
3495 Testing MAX+1 TIMESTAMP
3496 INSERT INTO t1 (b) VALUES('2038-01-19 03:14:08');
3497-ERROR HY000: Received an invalid value '2038-01-19 03:14:08' for a UNIX timestamp.
3498 Check transaction_log_entries
3499 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
3500 COUNT(*)
3501-3
3502+4
3503
3504 Check transaction_log_transactions
3505 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
3506 COUNT(*)
3507-3
3508+4
3509 Check transaction log contents
3510 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
3511 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
3512@@ -3501,8 +3500,8 @@
3513 segment_id: 1
3514 end_segment: true
3515 record {
3516- insert_value: "2"
3517- insert_value: "2038-01-19 03:14:07"
3518+ insert_value: "3"
3519+ insert_value: "2038-01-19 03:14:08"
3520 is_null: false
3521 is_null: false
3522 }
3523@@ -3518,12 +3517,12 @@
3524 Check transaction_log_entries
3525 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
3526 COUNT(*)
3527-4
3528+5
3529
3530 Check transaction_log_transactions
3531 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
3532 COUNT(*)
3533-4
3534+5
3535 Check transaction log contents
3536 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
3537 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
3538@@ -3555,7 +3554,7 @@
3539 segment_id: 1
3540 end_segment: true
3541 record {
3542- insert_value: "3"
3543+ insert_value: "4"
3544 insert_value: "2000-01-01 12:15:59"
3545 is_null: false
3546 is_null: false
3547@@ -3572,12 +3571,12 @@
3548 Check transaction_log_entries
3549 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
3550 COUNT(*)
3551-5
3552+6
3553
3554 Check transaction_log_transactions
3555 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
3556 COUNT(*)
3557-5
3558+6
3559 Check transaction log contents
3560 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
3561 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
3562@@ -3609,7 +3608,7 @@
3563 segment_id: 1
3564 end_segment: true
3565 record {
3566- insert_value: "4"
3567+ insert_value: "5"
3568 insert_value: "1999-06-01 12:15:47"
3569 is_null: false
3570 is_null: false
3571@@ -3626,12 +3625,12 @@
3572 Check transaction_log_entries
3573 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
3574 COUNT(*)
3575-6
3576+7
3577
3578 Check transaction_log_transactions
3579 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
3580 COUNT(*)
3581-6
3582+7
3583 Check transaction log contents
3584 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
3585 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
3586@@ -3663,7 +3662,7 @@
3587 segment_id: 1
3588 end_segment: true
3589 record {
3590- insert_value: "5"
3591+ insert_value: "6"
3592 insert_value: ""
3593 is_null: false
3594 is_null: true
3595@@ -3677,16 +3676,16 @@
3596
3597 Testing BAD INPUT TIMESTAMP1
3598 INSERT INTO t1 (b) VALUES('2000-01-01 25:00:00');
3599-ERROR HY000: Received an invalid value '2000-01-01 25:00:00' for a UNIX timestamp.
3600+ERROR HY000: Received an invalid timestamp value '2000-01-01 25:00:00'.
3601 Check transaction_log_entries
3602 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
3603 COUNT(*)
3604-6
3605+7
3606
3607 Check transaction_log_transactions
3608 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
3609 COUNT(*)
3610-6
3611+7
3612 Check transaction log contents
3613 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
3614 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
3615@@ -3718,7 +3717,7 @@
3616 segment_id: 1
3617 end_segment: true
3618 record {
3619- insert_value: "5"
3620+ insert_value: "6"
3621 insert_value: ""
3622 is_null: false
3623 is_null: true
3624@@ -3732,16 +3731,16 @@
3625
3626 Testing BAD INPUT TIMESTAMP2
3627 INSERT INTO t1 (b) VALUES('2000-01-01 12:60:00');
3628-ERROR HY000: Received an invalid value '2000-01-01 12:60:00' for a UNIX timestamp.
3629+ERROR HY000: Received an invalid timestamp value '2000-01-01 12:60:00'.
3630 Check transaction_log_entries
3631 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
3632 COUNT(*)
3633-6
3634+7
3635
3636 Check transaction_log_transactions
3637 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
3638 COUNT(*)
3639-6
3640+7
3641 Check transaction log contents
3642 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
3643 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
3644@@ -3773,7 +3772,7 @@
3645 segment_id: 1
3646 end_segment: true
3647 record {
3648- insert_value: "5"
3649+ insert_value: "6"
3650 insert_value: ""
3651 is_null: false
3652 is_null: true
3653@@ -3787,16 +3786,16 @@
3654
3655 Testing BAD INPUT TIMESTAMP3
3656 INSERT INTO t1 (b) VALUES('2000-01-01 12:00:65');
3657-ERROR HY000: Received an invalid value '2000-01-01 12:00:65' for a UNIX timestamp.
3658+ERROR HY000: Received an invalid timestamp value '2000-01-01 12:00:65'.
3659 Check transaction_log_entries
3660 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
3661 COUNT(*)
3662-6
3663+7
3664
3665 Check transaction_log_transactions
3666 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
3667 COUNT(*)
3668-6
3669+7
3670 Check transaction log contents
3671 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
3672 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
3673@@ -3828,7 +3827,7 @@
3674 segment_id: 1
3675 end_segment: true
3676 record {
3677- insert_value: "5"
3678+ insert_value: "6"
3679 insert_value: ""
3680 is_null: false
3681 is_null: true
3682
3683=== modified file 'plugin/transaction_log/tests/t/transaction_log_data_type.test'
3684--- plugin/transaction_log/tests/t/transaction_log_data_type.test 2010-12-20 19:20:57 +0000
3685+++ plugin/transaction_log/tests/t/transaction_log_data_type.test 2011-01-18 01:47:30 +0000
3686@@ -470,13 +470,12 @@
3687 --echo
3688
3689 --echo Testing MIN-1 TIMESTAMP
3690---ERROR 1685
3691+--ERROR ER_INVALID_TIMESTAMP_VALUE
3692 INSERT INTO t1 (b) VALUES('1969-12-31 23:59:59');
3693 --source ../plugin/transaction_log/tests/t/check_transaction_log.inc
3694 --echo
3695
3696 --echo Testing MAX+1 TIMESTAMP
3697---ERROR 1685
3698 INSERT INTO t1 (b) VALUES('2038-01-19 03:14:08');
3699 --source ../plugin/transaction_log/tests/t/check_transaction_log.inc
3700 --echo
3701@@ -497,19 +496,19 @@
3702 --echo
3703
3704 --echo Testing BAD INPUT TIMESTAMP1
3705---ERROR 1685
3706+--ERROR ER_INVALID_TIMESTAMP_VALUE
3707 INSERT INTO t1 (b) VALUES('2000-01-01 25:00:00');
3708 --source ../plugin/transaction_log/tests/t/check_transaction_log.inc
3709 --echo
3710
3711 --echo Testing BAD INPUT TIMESTAMP2
3712---ERROR 1685
3713+--ERROR ER_INVALID_TIMESTAMP_VALUE
3714 INSERT INTO t1 (b) VALUES('2000-01-01 12:60:00');
3715 --source ../plugin/transaction_log/tests/t/check_transaction_log.inc
3716 --echo
3717
3718 --echo Testing BAD INPUT TIMESTAMP3
3719---ERROR 1685
3720+--ERROR ER_INVALID_TIMESTAMP_VALUE
3721 INSERT INTO t1 (b) VALUES('2000-01-01 12:00:65');
3722 --source ../plugin/transaction_log/tests/t/check_transaction_log.inc
3723 --echo
3724
3725=== modified file 'tests/include/mix2.inc'
3726--- tests/include/mix2.inc 2010-12-07 09:12:12 +0000
3727+++ tests/include/mix2.inc 2011-01-18 01:47:30 +0000
3728@@ -929,11 +929,12 @@
3729 eval create $temp table t2 (col1 int,stamp TIMESTAMP,INDEX stamp_idx
3730 (stamp))ENGINE=$engine_type;
3731 insert into t1 values (1),(2),(3);
3732-# Note that timestamp 3 is wrong
3733---error 1685 # Bad timestamp
3734-insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
3735-SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
3736-'20020204120000' GROUP BY col1;
3737+insert into t2 values (1, 20020204130000);
3738+insert into t2 values (2, 20020204130000);
3739+--error ER_INVALID_TIMESTAMP_VALUE # Bad timestamp
3740+insert into t2 values (4, 20020204310000);
3741+insert into t2 values (5, 20020204230000);
3742+SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp < '20020204120000' GROUP BY col1;
3743 drop table t1,t2;
3744
3745 #
3746
3747=== modified file 'tests/r/data_dictionary_like_info.result'
3748--- tests/r/data_dictionary_like_info.result 2010-12-29 21:23:43 +0000
3749+++ tests/r/data_dictionary_like_info.result 2011-01-18 01:47:30 +0000
3750@@ -308,7 +308,7 @@
3751 f5 NULL NO
3752 f6 10 NO
3753 f7 NULL NO
3754-f8 2006-01-01 00:00:00 NO
3755+f8 2006-01-01 00:00:00.000000 NO
3756 show columns from t1;
3757 Field Type Null Default Default_is_NULL On_Update
3758 f1 VARCHAR YES YES
3759@@ -318,7 +318,7 @@
3760 f5 BIGINT NO NO
3761 f6 BIGINT NO 10 NO
3762 f7 DATETIME NO NO
3763-f8 DATETIME YES 2006-01-01 00:00:00 NO
3764+f8 DATETIME YES 2006-01-01 00:00:00.000000 NO
3765 drop table t1;
3766 SET max_heap_table_size = DEFAULT;
3767 USE test;
3768
3769=== modified file 'tests/r/func_time.result'
3770--- tests/r/func_time.result 2011-01-08 10:35:13 +0000
3771+++ tests/r/func_time.result 2011-01-18 01:47:30 +0000
3772@@ -63,94 +63,94 @@
3773 NULL
3774 select date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
3775 date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND)
3776-1998-01-01 00:00:00
3777+1998-01-01 00:00:00.000000
3778 select date_add("1997-12-31 23:59:59",INTERVAL 1 MINUTE);
3779 date_add("1997-12-31 23:59:59",INTERVAL 1 MINUTE)
3780-1998-01-01 00:00:59
3781+1998-01-01 00:00:59.000000
3782 select date_add("1997-12-31 23:59:59",INTERVAL 1 HOUR);
3783 date_add("1997-12-31 23:59:59",INTERVAL 1 HOUR)
3784-1998-01-01 00:59:59
3785+1998-01-01 00:59:59.000000
3786 select date_add("1997-12-31 23:59:59",INTERVAL 1 DAY);
3787 date_add("1997-12-31 23:59:59",INTERVAL 1 DAY)
3788-1998-01-01 23:59:59
3789+1998-01-01 23:59:59.000000
3790 select date_add("1997-12-31 23:59:59",INTERVAL 1 MONTH);
3791 date_add("1997-12-31 23:59:59",INTERVAL 1 MONTH)
3792-1998-01-31 23:59:59
3793+1998-01-31 23:59:59.000000
3794 select date_add("1997-12-31 23:59:59",INTERVAL 1 YEAR);
3795 date_add("1997-12-31 23:59:59",INTERVAL 1 YEAR)
3796-1998-12-31 23:59:59
3797+1998-12-31 23:59:59.000000
3798 select date_add("1997-12-31 23:59:59",INTERVAL "1:1" MINUTE_SECOND);
3799 date_add("1997-12-31 23:59:59",INTERVAL "1:1" MINUTE_SECOND)
3800-1998-01-01 00:01:00
3801+1998-01-01 00:01:00.000000
3802 select date_add("1997-12-31 23:59:59",INTERVAL "1:1" HOUR_MINUTE);
3803 date_add("1997-12-31 23:59:59",INTERVAL "1:1" HOUR_MINUTE)
3804-1998-01-01 01:00:59
3805+1998-01-01 01:00:59.000000
3806 select date_add("1997-12-31 23:59:59",INTERVAL "1:1" DAY_HOUR);
3807 date_add("1997-12-31 23:59:59",INTERVAL "1:1" DAY_HOUR)
3808-1998-01-02 00:59:59
3809+1998-01-02 00:59:59.000000
3810 select date_add("1997-12-31 23:59:59",INTERVAL "1 1" YEAR_MONTH);
3811 date_add("1997-12-31 23:59:59",INTERVAL "1 1" YEAR_MONTH)
3812-1999-01-31 23:59:59
3813+1999-01-31 23:59:59.000000
3814 select date_add("1997-12-31 23:59:59",INTERVAL "1:1:1" HOUR_SECOND);
3815 date_add("1997-12-31 23:59:59",INTERVAL "1:1:1" HOUR_SECOND)
3816-1998-01-01 01:01:00
3817+1998-01-01 01:01:00.000000
3818 select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1" DAY_MINUTE);
3819 date_add("1997-12-31 23:59:59",INTERVAL "1 1:1" DAY_MINUTE)
3820-1998-01-02 01:00:59
3821+1998-01-02 01:00:59.000000
3822 select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1:1" DAY_SECOND);
3823 date_add("1997-12-31 23:59:59",INTERVAL "1 1:1:1" DAY_SECOND)
3824-1998-01-02 01:01:00
3825+1998-01-02 01:01:00.000000
3826 select date_sub("1998-01-01 00:00:00",INTERVAL 1 SECOND);
3827 date_sub("1998-01-01 00:00:00",INTERVAL 1 SECOND)
3828-1997-12-31 23:59:59
3829+1997-12-31 23:59:59.000000
3830 select date_sub("1998-01-01 00:00:00",INTERVAL 1 MINUTE);
3831 date_sub("1998-01-01 00:00:00",INTERVAL 1 MINUTE)
3832-1997-12-31 23:59:00
3833+1997-12-31 23:59:00.000000
3834 select date_sub("1998-01-01 00:00:00",INTERVAL 1 HOUR);
3835 date_sub("1998-01-01 00:00:00",INTERVAL 1 HOUR)
3836-1997-12-31 23:00:00
3837+1997-12-31 23:00:00.000000
3838 select date_sub("1998-01-01 00:00:00",INTERVAL 1 DAY);
3839 date_sub("1998-01-01 00:00:00",INTERVAL 1 DAY)
3840-1997-12-31 00:00:00
3841+1997-12-31 00:00:00.000000
3842 select date_sub("1998-01-01 00:00:00",INTERVAL 1 MONTH);
3843 date_sub("1998-01-01 00:00:00",INTERVAL 1 MONTH)
3844-1997-12-01 00:00:00
3845+1997-12-01 00:00:00.000000
3846 select date_sub("1998-01-01 00:00:00",INTERVAL 1 YEAR);
3847 date_sub("1998-01-01 00:00:00",INTERVAL 1 YEAR)
3848-1997-01-01 00:00:00
3849+1997-01-01 00:00:00.000000
3850 select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" MINUTE_SECOND);
3851 date_sub("1998-01-01 00:00:00",INTERVAL "1:1" MINUTE_SECOND)
3852-1997-12-31 23:58:59
3853+1997-12-31 23:58:59.000000
3854 select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" HOUR_MINUTE);
3855 date_sub("1998-01-01 00:00:00",INTERVAL "1:1" HOUR_MINUTE)
3856-1997-12-31 22:59:00
3857+1997-12-31 22:59:00.000000
3858 select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" DAY_HOUR);
3859 date_sub("1998-01-01 00:00:00",INTERVAL "1:1" DAY_HOUR)
3860-1997-12-30 23:00:00
3861+1997-12-30 23:00:00.000000
3862 select date_sub("1998-01-01 00:00:00",INTERVAL "1 1" YEAR_MONTH);
3863 date_sub("1998-01-01 00:00:00",INTERVAL "1 1" YEAR_MONTH)
3864-1996-12-01 00:00:00
3865+1996-12-01 00:00:00.000000
3866 select date_sub("1998-01-01 00:00:00",INTERVAL "1:1:1" HOUR_SECOND);
3867 date_sub("1998-01-01 00:00:00",INTERVAL "1:1:1" HOUR_SECOND)
3868-1997-12-31 22:58:59
3869+1997-12-31 22:58:59.000000
3870 select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1" DAY_MINUTE);
3871 date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1" DAY_MINUTE)
3872-1997-12-30 22:59:00
3873+1997-12-30 22:59:00.000000
3874 select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1:1" DAY_SECOND);
3875 date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1:1" DAY_SECOND)
3876-1997-12-30 22:58:59
3877+1997-12-30 22:58:59.000000
3878 select date_add("1997-12-31 23:59:59",INTERVAL 100000 SECOND);
3879 date_add("1997-12-31 23:59:59",INTERVAL 100000 SECOND)
3880-1998-01-02 03:46:39
3881+1998-01-02 03:46:39.000000
3882 select date_add("1997-12-31 23:59:59",INTERVAL -100000 MINUTE);
3883 date_add("1997-12-31 23:59:59",INTERVAL -100000 MINUTE)
3884-1997-10-23 13:19:59
3885+1997-10-23 13:19:59.000000
3886 select date_add("1997-12-31 23:59:59",INTERVAL 100000 HOUR);
3887 date_add("1997-12-31 23:59:59",INTERVAL 100000 HOUR)
3888-2009-05-29 15:59:59
3889+2009-05-29 15:59:59.000000
3890 select date_add("1997-12-31 23:59:59",INTERVAL -100000 DAY);
3891 date_add("1997-12-31 23:59:59",INTERVAL -100000 DAY)
3892-1724-03-17 23:59:59
3893+1724-03-17 23:59:59.000000
3894 select date_add("1997-12-31 23:59:59",INTERVAL 100000 MONTH);
3895 date_add("1997-12-31 23:59:59",INTERVAL 100000 MONTH)
3896 NULL
3897@@ -163,40 +163,40 @@
3898 Warning 1441 Datetime function: datetime field overflow
3899 select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" MINUTE_SECOND);
3900 date_add("1997-12-31 23:59:59",INTERVAL "10000:1" MINUTE_SECOND)
3901-1998-01-07 22:40:00
3902+1998-01-07 22:40:00.000000
3903 select date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE);
3904 date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE)
3905-1996-11-10 07:58:59
3906+1996-11-10 07:58:59.000000
3907 select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" DAY_HOUR);
3908 date_add("1997-12-31 23:59:59",INTERVAL "10000:1" DAY_HOUR)
3909-2025-05-19 00:59:59
3910+2025-05-19 00:59:59.000000
3911 select date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH);
3912 date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH)
3913-1897-11-30 23:59:59
3914+1897-11-30 23:59:59.000000
3915 select date_add("1997-12-31 23:59:59",INTERVAL "10000:99:99" HOUR_SECOND);
3916 date_add("1997-12-31 23:59:59",INTERVAL "10000:99:99" HOUR_SECOND)
3917-1999-02-21 17:40:38
3918+1999-02-21 17:40:38.000000
3919 select date_add("1997-12-31 23:59:59",INTERVAL " -10000 99:99" DAY_MINUTE);
3920 date_add("1997-12-31 23:59:59",INTERVAL " -10000 99:99" DAY_MINUTE)
3921-1970-08-11 19:20:59
3922+1970-08-11 19:20:59.000000
3923 select date_add("1997-12-31 23:59:59",INTERVAL "10000 99:99:99" DAY_SECOND);
3924 date_add("1997-12-31 23:59:59",INTERVAL "10000 99:99:99" DAY_SECOND)
3925-2025-05-23 04:40:38
3926+2025-05-23 04:40:38.000000
3927 select "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
3928 "1997-12-31 23:59:59" + INTERVAL 1 SECOND
3929-1998-01-01 00:00:00
3930+1998-01-01 00:00:00.000000
3931 select INTERVAL 1 DAY + "1997-12-31";
3932 INTERVAL 1 DAY + "1997-12-31"
3933 1998-01-01
3934 select "1998-01-01 00:00:00" - INTERVAL 1 SECOND;
3935 "1998-01-01 00:00:00" - INTERVAL 1 SECOND
3936-1997-12-31 23:59:59
3937+1997-12-31 23:59:59.000000
3938 select date_sub("1998-01-02",INTERVAL 31 DAY);
3939 date_sub("1998-01-02",INTERVAL 31 DAY)
3940 1997-12-02
3941 select date_add("1997-12-31",INTERVAL 1 SECOND);
3942 date_add("1997-12-31",INTERVAL 1 SECOND)
3943-1997-12-31 00:00:01
3944+1997-12-31 00:00:01.000000
3945 select date_add("1997-12-31",INTERVAL 1 DAY);
3946 date_add("1997-12-31",INTERVAL 1 DAY)
3947 1998-01-01
3948@@ -302,13 +302,13 @@
3949 4
3950 SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND;
3951 "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND
3952-1968-01-20 03:14:08
3953+1968-01-20 03:14:08.000000
3954 SELECT "1900-01-01 00:00:00" + INTERVAL "1:2147483647" MINUTE_SECOND;
3955 "1900-01-01 00:00:00" + INTERVAL "1:2147483647" MINUTE_SECOND
3956-1968-01-20 03:15:07
3957+1968-01-20 03:15:07.000000
3958 SELECT "1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND;
3959 "1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND
3960-8895-03-27 22:11:40
3961+8895-03-27 22:11:40.000000
3962 SELECT "1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND;
3963 "1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND
3964 NULL
3965@@ -382,7 +382,7 @@
3966 drop table t1,t2,t3;
3967 select @a:=FROM_UNIXTIME(1);
3968 @a:=FROM_UNIXTIME(1)
3969-1970-01-01 00:00:01
3970+1970-01-01 00:00:01.000000
3971 select unix_timestamp(@a);
3972 unix_timestamp(@a)
3973 1
3974@@ -408,15 +408,18 @@
3975 unix_timestamp(from_unixtime(2147483648))
3976 NULL
3977 select unix_timestamp('2039-01-20 01:00:00');
3978-ERROR HY000: Received an invalid value '2039-01-20 01:00:00' for a UNIX timestamp.
3979+unix_timestamp('2039-01-20 01:00:00')
3980+2179098000
3981 select unix_timestamp('1968-01-20 01:00:00');
3982 ERROR HY000: Received an invalid value '1968-01-20 01:00:00' for a UNIX timestamp.
3983 select unix_timestamp('2038-02-10 01:00:00');
3984-ERROR HY000: Received an invalid value '2038-02-10 01:00:00' for a UNIX timestamp.
3985+unix_timestamp('2038-02-10 01:00:00')
3986+2149376400
3987 select unix_timestamp('1969-11-20 01:00:00');
3988 ERROR HY000: Received an invalid value '1969-11-20 01:00:00' for a UNIX timestamp.
3989 select unix_timestamp('2038-01-20 01:00:00');
3990-ERROR HY000: Received an invalid value '2038-01-20 01:00:00' for a UNIX timestamp.
3991+unix_timestamp('2038-01-20 01:00:00')
3992+2147562000
3993 select unix_timestamp('1969-12-30 01:00:00');
3994 ERROR HY000: Received an invalid value '1969-12-30 01:00:00' for a UNIX timestamp.
3995 select unix_timestamp('2038-01-17 12:00:00');
3996@@ -432,7 +435,7 @@
3997 2001-01-02 03:04:05 2002-01-02 03:04:05 2003-01-02
3998 select date_add("1997-12-31",INTERVAL 1 SECOND);
3999 date_add("1997-12-31",INTERVAL 1 SECOND)
4000-1997-12-31 00:00:01
4001+1997-12-31 00:00:01.000000
4002 select date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH);
4003 date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH)
4004 1999-01-31
4005@@ -659,7 +662,7 @@
4006 19971231.0
4007 select strcmp(date_sub(localtimestamp(), interval 0 hour), utc_timestamp())=0;
4008 strcmp(date_sub(localtimestamp(), interval 0 hour), utc_timestamp())=0
4009-0
4010+1
4011 select strcmp(date_format(date_sub(localtimestamp(), interval 0 hour),"%Y-%m-%d"), utc_date())=0;
4012 strcmp(date_format(date_sub(localtimestamp(), interval 0 hour),"%Y-%m-%d"), utc_date())=0
4013 1
4014@@ -838,10 +841,10 @@
4015 drop table t1;
4016 select DATE_ADD('20071108181000', INTERVAL 1 DAY);
4017 DATE_ADD('20071108181000', INTERVAL 1 DAY)
4018-2007-11-09 18:10:00
4019+2007-11-09 18:10:00.000000
4020 select DATE_ADD(20071108181000, INTERVAL 1 DAY);
4021 DATE_ADD(20071108181000, INTERVAL 1 DAY)
4022-2007-11-09 18:10:00
4023+2007-11-09 18:10:00.000000
4024 select DATE_ADD('20071108', INTERVAL 1 DAY);
4025 DATE_ADD('20071108', INTERVAL 1 DAY)
4026 2007-11-09
4027@@ -868,35 +871,35 @@
4028 End of 5.0 tests
4029 select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND);
4030 date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND)
4031-0049-12-31 23:59:59
4032+0049-12-31 23:59:59.000000
4033 select date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND);
4034 date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND)
4035-0198-12-31 23:59:59
4036+0198-12-31 23:59:59.000000
4037 select date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND);
4038 date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND)
4039-0200-01-01 00:00:01
4040+0200-01-01 00:00:01.000000
4041 select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND);
4042 date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND)
4043-0199-12-31 23:59:59
4044+0199-12-31 23:59:59.000000
4045 select date_sub("0200-01-01 00:00:01",INTERVAL 1 SECOND);
4046 date_sub("0200-01-01 00:00:01",INTERVAL 1 SECOND)
4047-0200-01-01 00:00:00
4048+0200-01-01 00:00:00.000000
4049 select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND);
4050 date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND)
4051-0199-12-31 23:59:59
4052+0199-12-31 23:59:59.000000
4053 select date_add("2001-01-01 23:59:59",INTERVAL -2000 YEAR);
4054 date_add("2001-01-01 23:59:59",INTERVAL -2000 YEAR)
4055-0001-01-01 23:59:59
4056+0001-01-01 23:59:59.000000
4057 select date_sub("50-01-01 00:00:01",INTERVAL 2 SECOND);
4058 date_sub("50-01-01 00:00:01",INTERVAL 2 SECOND)
4059-2049-12-31 23:59:59
4060+2049-12-31 23:59:59.000000
4061 select date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND);
4062 date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND)
4063-1989-12-31 23:59:59
4064+1989-12-31 23:59:59.000000
4065 select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND);
4066 date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND)
4067-0068-12-31 23:59:59
4068+0068-12-31 23:59:59.000000
4069 select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
4070 date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND)
4071-0168-12-31 23:59:59
4072+0168-12-31 23:59:59.000000
4073 End of 5.1 tests
4074
4075=== modified file 'tests/r/information_schema.result'
4076--- tests/r/information_schema.result 2011-01-09 22:15:22 +0000
4077+++ tests/r/information_schema.result 2011-01-18 01:47:30 +0000
4078@@ -357,7 +357,7 @@
4079 f5 BIGINT NO NO
4080 f6 BIGINT NO 10 NO
4081 f7 DATETIME NO NO
4082-f8 DATETIME YES 2006-01-01 00:00:00 NO
4083+f8 DATETIME YES 2006-01-01 00:00:00.000000 NO
4084 drop table t1;
4085 SET max_heap_table_size = DEFAULT;
4086 USE test;
4087
4088=== modified file 'tests/r/insert.result'
4089--- tests/r/insert.result 2010-04-20 18:23:07 +0000
4090+++ tests/r/insert.result 2011-01-18 01:47:30 +0000
4091@@ -24,7 +24,7 @@
4092 insert into t1 values (default,default,default,default);
4093 insert into t1 values (default,default,default,default);
4094 insert into t1 values (4,0,"a",5);
4095-ERROR HY000: Received an invalid value '0' for a UNIX timestamp.
4096+ERROR HY000: Received an invalid timestamp value '0'.
4097 insert into t1 values (default,default,default,default);
4098 select a,t is not null,c,i from t1;
4099 a t is not null c i
4100
4101=== modified file 'tests/r/parser.result'
4102--- tests/r/parser.result 2010-09-13 22:32:32 +0000
4103+++ tests/r/parser.result 2011-01-18 01:47:30 +0000
4104@@ -439,7 +439,7 @@
4105 DROP TABLE IF EXISTS t1;
4106 SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
4107 "1997-12-31 23:59:59" + INTERVAL 1 SECOND
4108-1998-01-01 00:00:00
4109+1998-01-01 00:00:00.000000
4110 SELECT 1 + INTERVAL(1,0,1,2) + 1;
4111 1 + INTERVAL(1,0,1,2) + 1
4112 4
4113
4114=== modified file 'tests/r/timezone.result'
4115--- tests/r/timezone.result 2009-02-28 20:43:31 +0000
4116+++ tests/r/timezone.result 2011-01-18 01:47:30 +0000
4117@@ -3,7 +3,7 @@
4118 DROP TABLE IF EXISTS t1;
4119 select @a:=FROM_UNIXTIME(1);
4120 @a:=FROM_UNIXTIME(1)
4121-1970-01-01 00:00:01
4122+1970-01-01 00:00:01.000000
4123 select unix_timestamp(@a);
4124 unix_timestamp(@a)
4125 1
4126@@ -45,4 +45,5 @@
4127 unix_timestamp('2038-01-19 03:14:07')
4128 2147483647
4129 select unix_timestamp('2038-01-19 03:14:08');
4130-ERROR HY000: Received an invalid value '2038-01-19 03:14:08' for a UNIX timestamp.
4131+unix_timestamp('2038-01-19 03:14:08')
4132+2147483648
4133
4134=== modified file 'tests/r/type_datetime.result'
4135--- tests/r/type_datetime.result 2010-09-10 10:05:56 +0000
4136+++ tests/r/type_datetime.result 2011-01-18 01:47:30 +0000
4137@@ -180,7 +180,7 @@
4138 Table Create Table
4139 t1 CREATE TABLE `t1` (
4140 `da` DATE DEFAULT '1962-03-03',
4141- `dt` DATETIME DEFAULT '1962-03-03 00:00:00'
4142+ `dt` DATETIME DEFAULT '1962-03-03 00:00:00.000000'
4143 ) ENGINE=DEFAULT COLLATE = utf8_general_ci
4144 insert into t1 values ();
4145 insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
4146@@ -450,7 +450,7 @@
4147 Table Create Table
4148 t1 CREATE TABLE `t1` (
4149 `da` DATE DEFAULT '1962-03-03',
4150- `dt` DATETIME DEFAULT '1962-03-03 00:00:00'
4151+ `dt` DATETIME DEFAULT '1962-03-03 00:00:00.000000'
4152 ) ENGINE=DEFAULT COLLATE = utf8_general_ci
4153 insert into t1 values ();
4154 insert into t1 values ('2007-03-23 13:49:38','2007-03-23 13:49:38');
4155
4156=== modified file 'tests/r/type_timestamp.result'
4157--- tests/r/type_timestamp.result 2010-09-02 18:35:05 +0000
4158+++ tests/r/type_timestamp.result 2011-01-18 01:47:30 +0000
4159@@ -112,17 +112,17 @@
4160 drop table t1;
4161 create table t1 (ix timestamp);
4162 insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
4163-ERROR HY000: Received an invalid value '0' for a UNIX timestamp.
4164+ERROR HY000: Received an invalid timestamp value '0'.
4165 select ix+0 from t1;
4166 ix+0
4167 truncate table t1;
4168 insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
4169-ERROR HY000: Received an invalid value '00000000000000' for a UNIX timestamp.
4170+ERROR HY000: Received an invalid timestamp value '00000000000000'.
4171 select ix+0 from t1;
4172 ix+0
4173 truncate table t1;
4174 insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
4175-ERROR HY000: Received an invalid value '0000-00-00 00:00:00 some trailer' for a UNIX timestamp.
4176+ERROR HY000: Received an invalid timestamp value '0000-00-00 00:00:00 some trailer'.
4177 select ix+0 from t1;
4178 ix+0
4179 drop table t1;
4180
4181=== modified file 'tests/suite/microtime_type/r/basic.result'
4182--- tests/suite/microtime_type/r/basic.result 2011-01-07 21:56:29 +0000
4183+++ tests/suite/microtime_type/r/basic.result 2011-01-18 01:47:30 +0000
4184@@ -112,17 +112,17 @@
4185 drop table t1;
4186 create table t1 (ix TIMESTAMP(6));
4187 insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
4188-ERROR HY000: Received an invalid value '0' for a UNIX timestamp.
4189+ERROR HY000: Received an invalid timestamp value '0'.
4190 select ix+0 from t1;
4191 ix+0
4192 truncate table t1;
4193 insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
4194-ERROR HY000: Received an invalid value '00000000000000' for a UNIX timestamp.
4195+ERROR HY000: Received an invalid timestamp value '00000000000000'.
4196 select ix+0 from t1;
4197 ix+0
4198 truncate table t1;
4199 insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
4200-ERROR HY000: Received an invalid value '0000-00-00 00:00:00 some trailer' for a UNIX timestamp.
4201+ERROR HY000: Received an invalid timestamp value '0000-00-00 00:00:00 some trailer'.
4202 select ix+0 from t1;
4203 ix+0
4204 drop table t1;
4205
4206=== added file 'tests/suite/microtime_type/r/decimal.result'
4207--- tests/suite/microtime_type/r/decimal.result 1970-01-01 00:00:00 +0000
4208+++ tests/suite/microtime_type/r/decimal.result 2011-01-18 01:47:30 +0000
4209@@ -0,0 +1,19 @@
4210+CREATE TABLE t1 (
4211+_value decimal(20,6)
4212+);
4213+INSERT INTO t1 VALUES ("20030101000000.90000"), ("20030101000000.00000"), ("20030101000000.123456") ;
4214+SELECT _value FROM t1;
4215+_value
4216+20030101000000.000000
4217+20030101000000.123456
4218+20030101000000.900000
4219+CREATE TABLE t2 (
4220+_value TIMESTAMP(6)
4221+);
4222+INSERT INTO t2 SELECT _value from t1;
4223+SELECT _value FROM t2;
4224+_value
4225+2003-01-01 00:00:00.000000
4226+2003-01-01 00:00:00.125000
4227+2003-01-01 00:00:00.898437
4228+DROP TABLE t1,t2;
4229
4230=== added file 'tests/suite/microtime_type/r/max.result'
4231--- tests/suite/microtime_type/r/max.result 1970-01-01 00:00:00 +0000
4232+++ tests/suite/microtime_type/r/max.result 2011-01-18 01:47:30 +0000
4233@@ -0,0 +1,8 @@
4234+CREATE TABLE t2 (
4235+_value TIMESTAMP(6)
4236+);
4237+INSERT into t2 VALUES ("20660101000000.00000");
4238+SELECT _value FROM t2;
4239+_value
4240+2066-01-01 00:00:00.000000
4241+DROP TABLE t2;
4242
4243=== modified file 'tests/suite/microtime_type/t/basic.test'
4244--- tests/suite/microtime_type/t/basic.test 2011-01-06 19:13:50 +0000
4245+++ tests/suite/microtime_type/t/basic.test 2011-01-18 01:47:30 +0000
4246@@ -83,15 +83,15 @@
4247 # (for both strings and numbers)
4248 #
4249 create table t1 (ix TIMESTAMP(6));
4250---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix TIMESTAMP(6)
4251+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix TIMESTAMP(6)
4252 insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
4253 select ix+0 from t1;
4254 truncate table t1;
4255---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix TIMESTAMP(6)
4256+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix TIMESTAMP(6)
4257 insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
4258 select ix+0 from t1;
4259 truncate table t1;
4260---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix TIMESTAMP(6)
4261+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix TIMESTAMP(6)
4262 insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
4263 select ix+0 from t1;
4264 drop table t1;
4265
4266=== added file 'tests/suite/microtime_type/t/decimal.test'
4267--- tests/suite/microtime_type/t/decimal.test 1970-01-01 00:00:00 +0000
4268+++ tests/suite/microtime_type/t/decimal.test 2011-01-18 01:47:30 +0000
4269@@ -0,0 +1,17 @@
4270+CREATE TABLE t1 (
4271+ _value decimal(20,6)
4272+ );
4273+
4274+INSERT INTO t1 VALUES ("20030101000000.90000"), ("20030101000000.00000"), ("20030101000000.123456") ;
4275+--sorted_result
4276+SELECT _value FROM t1;
4277+
4278+CREATE TABLE t2 (
4279+ _value TIMESTAMP(6)
4280+);
4281+
4282+INSERT INTO t2 SELECT _value from t1;
4283+--sorted_result
4284+SELECT _value FROM t2;
4285+
4286+DROP TABLE t1,t2;
4287
4288=== added file 'tests/suite/microtime_type/t/max.test'
4289--- tests/suite/microtime_type/t/max.test 1970-01-01 00:00:00 +0000
4290+++ tests/suite/microtime_type/t/max.test 2011-01-18 01:47:30 +0000
4291@@ -0,0 +1,10 @@
4292+# Just a quick test to make sure we are not limited to the old max
4293+CREATE TABLE t2 (
4294+ _value TIMESTAMP(6)
4295+);
4296+
4297+INSERT into t2 VALUES ("20660101000000.00000");
4298+
4299+SELECT _value FROM t2;
4300+
4301+DROP TABLE t2;
4302
4303=== added file 'tests/suite/regression/r/592690.result'
4304--- tests/suite/regression/r/592690.result 1970-01-01 00:00:00 +0000
4305+++ tests/suite/regression/r/592690.result 2011-01-18 01:47:30 +0000
4306@@ -0,0 +1,3 @@
4307+select from_unixtime(1272945599.90000), from_unixtime(1272945599), from_unixtime("1272945599.90000");
4308+from_unixtime(1272945599.90000) from_unixtime(1272945599) from_unixtime("1272945599.90000")
4309+2010-05-04 03:59:59.900000 2010-05-04 03:59:59 2010-05-04 03:59:59.900000
4310
4311=== added file 'tests/suite/regression/t/592690.test'
4312--- tests/suite/regression/t/592690.test 1970-01-01 00:00:00 +0000
4313+++ tests/suite/regression/t/592690.test 2011-01-18 01:47:30 +0000
4314@@ -0,0 +1,2 @@
4315+# Decimal should be recorded properly from_unixtime();
4316+select from_unixtime(1272945599.90000), from_unixtime(1272945599), from_unixtime("1272945599.90000");
4317
4318=== modified file 'tests/suite/uuid_type/t/insert_null_no_key.test'
4319--- tests/suite/uuid_type/t/insert_null_no_key.test 2010-12-17 08:22:10 +0000
4320+++ tests/suite/uuid_type/t/insert_null_no_key.test 2011-01-18 01:47:30 +0000
4321@@ -19,7 +19,7 @@
4322 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883aaaa");
4323 SELECT a FROM t1 ORDER BY a;
4324
4325---error 1716
4326+--error ER_INVALID_UUID_VALUE
4327 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883");
4328 SELECT a FROM t1 ORDER BY a;
4329
4330
4331=== modified file 'tests/suite/uuid_type/t/primary_key.test'
4332--- tests/suite/uuid_type/t/primary_key.test 2010-12-17 08:22:10 +0000
4333+++ tests/suite/uuid_type/t/primary_key.test 2011-01-18 01:47:30 +0000
4334@@ -21,7 +21,7 @@
4335 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883aaaa");
4336 SELECT a FROM t1 ORDER BY a;
4337
4338---error 1716
4339+--error ER_INVALID_UUID_VALUE
4340 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883");
4341 SELECT a FROM t1 ORDER BY a;
4342
4343
4344=== modified file 'tests/t/func_time.test'
4345--- tests/t/func_time.test 2011-01-05 07:43:57 +0000
4346+++ tests/t/func_time.test 2011-01-18 01:47:30 +0000
4347@@ -242,19 +242,19 @@
4348
4349 # check for invalid dates
4350
4351-# bad year
4352---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
4353+# Legal, Drizzle has 64bit timestamp
4354 select unix_timestamp('2039-01-20 01:00:00');
4355+
4356 --error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
4357 select unix_timestamp('1968-01-20 01:00:00');
4358-# bad month
4359---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
4360+
4361 select unix_timestamp('2038-02-10 01:00:00');
4362+
4363 --error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
4364 select unix_timestamp('1969-11-20 01:00:00');
4365-# bad day
4366---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
4367+
4368 select unix_timestamp('2038-01-20 01:00:00');
4369+
4370 --error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
4371 select unix_timestamp('1969-12-30 01:00:00');
4372
4373
4374=== modified file 'tests/t/insert.test'
4375--- tests/t/insert.test 2010-08-26 21:56:15 +0000
4376+++ tests/t/insert.test 2011-01-18 01:47:30 +0000
4377@@ -33,7 +33,7 @@
4378 create table t1 (a int not null auto_increment, primary key (a), t timestamp null, c char(10) default "hello", i int);
4379 insert into t1 values (default,default,default,default);
4380 insert into t1 values (default,default,default,default);
4381---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
4382+--error ER_INVALID_TIMESTAMP_VALUE # Bad timestamp
4383 insert into t1 values (4,0,"a",5);
4384 insert into t1 values (default,default,default,default);
4385 select a,t is not null,c,i from t1;
4386
4387=== modified file 'tests/t/timezone.test'
4388--- tests/t/timezone.test 2010-08-26 21:56:15 +0000
4389+++ tests/t/timezone.test 2011-01-18 01:47:30 +0000
4390@@ -54,11 +54,11 @@
4391 #
4392 # Test for fix for Bug#2523 Check that boundary dates are processed
4393 # correctly.
4394+# -- scratch the above, Drizzle allows for longer dates.
4395 #
4396 select unix_timestamp('1970-01-01 00:00:00');
4397 select unix_timestamp('1970-01-01 00:00:01');
4398 select unix_timestamp('2038-01-19 03:14:07');
4399---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
4400 select unix_timestamp('2038-01-19 03:14:08');
4401
4402 # End of 4.1 tests
4403
4404=== modified file 'tests/t/type_timestamp.test'
4405--- tests/t/type_timestamp.test 2010-08-26 21:56:15 +0000
4406+++ tests/t/type_timestamp.test 2011-01-18 01:47:30 +0000
4407@@ -83,15 +83,15 @@
4408 # (for both strings and numbers)
4409 #
4410 create table t1 (ix timestamp);
4411---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix timestamp
4412+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix timestamp
4413 insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
4414 select ix+0 from t1;
4415 truncate table t1;
4416---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix timestamp
4417+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix timestamp
4418 insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
4419 select ix+0 from t1;
4420 truncate table t1;
4421---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix timestamp
4422+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix timestamp
4423 insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
4424 select ix+0 from t1;
4425 drop table t1;
4426
4427=== modified file 'unittests/calendar_test.cc'
4428--- unittests/calendar_test.cc 2010-06-05 21:39:51 +0000
4429+++ unittests/calendar_test.cc 2011-01-18 01:47:30 +0000
4430@@ -115,7 +115,7 @@
4431 {
4432 uint32_t year= 2038, month= 1, day= 19, hour= 3, minute= 14, second= 8;
4433
4434- ASSERT_FALSE(in_unix_epoch_range(year, month, day, hour, minute, second));
4435+ ASSERT_TRUE(in_unix_epoch_range(year, month, day, hour, minute, second));
4436 }
4437
4438 TEST(calendar_in_unix_epoch_range_test, InsideRange)
4439
4440=== modified file 'unittests/micro_timestamp_test.cc'
4441--- unittests/micro_timestamp_test.cc 2011-01-05 17:21:13 +0000
4442+++ unittests/micro_timestamp_test.cc 2011-01-18 01:47:30 +0000
4443@@ -71,7 +71,7 @@
4444
4445 result= micro_timestamp.is_valid();
4446
4447- ASSERT_FALSE(result);
4448+ ASSERT_TRUE(result);
4449 }
4450
4451 TEST_F(MicroTimestampTest, is_valid_InsideOfMicroTimestampRange_shouldReturn_True)
4452
4453=== modified file 'unittests/nano_timestamp_test.cc'
4454--- unittests/nano_timestamp_test.cc 2010-06-09 17:12:30 +0000
4455+++ unittests/nano_timestamp_test.cc 2011-01-18 01:47:30 +0000
4456@@ -71,7 +71,7 @@
4457
4458 result= nano_timestamp.is_valid();
4459
4460- ASSERT_FALSE(result);
4461+ ASSERT_TRUE(result);
4462 }
4463
4464 TEST_F(NanoTimestampTest, is_valid_InsideOfNanoTimestampRange_shouldReturn_True)
4465
4466=== modified file 'unittests/plugin/client_test.cc'
4467--- unittests/plugin/client_test.cc 2010-12-26 00:07:57 +0000
4468+++ unittests/plugin/client_test.cc 2011-01-18 01:47:30 +0000
4469@@ -46,7 +46,7 @@
4470 TEST_F(ClientTest, store_drizzle_time_datetime)
4471 {
4472 //TODO: is the sign intentionally ignored in the case of a datetime?
4473- type::Time dt= { 2010, 4, 5, 23, 45, 3, 777, true, DRIZZLE_TIMESTAMP_DATETIME};
4474+ type::Time dt(2010, 4, 5, 23, 45, 3, 777, type::DRIZZLE_TIMESTAMP_DATETIME);
4475 char expected[]= "2010-04-05 23:45:03.000777";
4476
4477 client.store(&dt);
4478@@ -57,7 +57,7 @@
4479 TEST_F(ClientTest, store_drizzle_time_date)
4480 {
4481 //TODO: is the sign intentionally ignored in the case of a date?
4482- type::Time dt= { 2010, 4, 5, 0, 0, 0, 0, true, DRIZZLE_TIMESTAMP_DATE};
4483+ type::Time dt(2010, 4, 5, 0, 0, 0, 0, type::DRIZZLE_TIMESTAMP_DATE);
4484 char expected[]= "2010-04-05";
4485
4486 client.store(&dt);
4487@@ -67,7 +67,7 @@
4488
4489 TEST_F(ClientTest, store_drizzle_time_time)
4490 {
4491- type::Time dt= { 2010, 4, 5, 23, 45, 3, 777, true, DRIZZLE_TIMESTAMP_TIME};
4492+ type::Time dt(23, 45, 3, 777, true);
4493 char expected[]= "-23:45:03.000777";
4494
4495 client.store(&dt);
4496
4497=== modified file 'unittests/timestamp_test.cc'
4498--- unittests/timestamp_test.cc 2010-12-21 20:27:48 +0000
4499+++ unittests/timestamp_test.cc 2011-01-18 01:47:30 +0000
4500@@ -225,7 +225,7 @@
4501
4502 result= timestamp.is_valid();
4503
4504- ASSERT_FALSE(result);
4505+ ASSERT_TRUE(result);
4506 }
4507
4508 TEST_F(TimestampTest, is_valid_InsideOfTimestampRange_shouldReturn_True)

Subscribers

People subscribed via source and target branches