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

Proposed by Brian Aker
Status: Superseded
Proposed branch: lp:~brianaker/drizzle/bug-592690
Merge into: lp:drizzle/7.0
Diff against target: 1921 lines (+496/-325)
53 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/date.cc (+5/-3)
drizzled/field/epoch.cc (+26/-12)
drizzled/field/epoch.h (+7/-4)
drizzled/field/microtime.cc (+53/-19)
drizzled/field/microtime.h (+3/-1)
drizzled/function/cast/time.cc (+2/-1)
drizzled/function/time/date_add_interval.cc (+2/-2)
drizzled/function/time/from_unixtime.cc (+25/-4)
drizzled/function/time/makedate.cc (+3/-1)
drizzled/function/time/now.cc (+3/-2)
drizzled/function/time/sysdate_local.cc (+1/-1)
drizzled/function/time/typecast.cc (+6/-2)
drizzled/session.h (+1/-1)
drizzled/time_functions.cc (+5/-26)
drizzled/time_functions.h (+0/-6)
drizzled/type/decimal.cc (+6/-0)
drizzled/type/decimal.h (+88/-83)
drizzled/type/time.cc (+67/-25)
drizzled/type/time.h (+23/-12)
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/func_time.result (+6/-3)
tests/r/insert.result (+1/-1)
tests/r/timezone.result (+2/-1)
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/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+46085@code.launchpad.net

This proposal has been superseded by a proposal from 2011-01-14.

To post a comment you must log in.
lp:~brianaker/drizzle/bug-592690 updated
2078. By Brian Aker <brian@gir-3>

Merge in all of the fixes for definition to instance.

2079. By Brian Aker <brian@gir-3>

Merge in fix around API (we should be able to move to seeing errors directly
from SE interface (which solves the wishlist issue, and convoluted issues
around issuing errors).

2080. By Brian Aker <brian@gir-3>

Rollup of catalog patch.

2081. By Brian Aker <brian@gir-3>

Cleanup around alter table (mostly harmless stuff, though some lock move).

2082. By Brian Aker <brian@gir-3>

Rollup changes for trunk.

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

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
2083. By Lee Bieber

Merge Stewart - fix bug 582486: valgrind warning in drizzled::mysql_load

2084. By Lee Bieber

Merge Lee - fix rabbitmq test to use $TOP_SRCDIR instead of $TOP_BUILDDIR

2085. By Lee Bieber

Merge Stewart - track what is being called in the Storage Engine in storage_engine_api_tester

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

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.

2099. By Brian Aker

Remove dead code.

2100. By Brian Aker

Merge in uint to int fixes in time type.

Unmerged revisions

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-14 20:07:36 +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-14 20:07:36 +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-14 20:07:36 +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-14 20:07:36 +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/date.cc'
128--- drizzled/field/date.cc 2010-12-25 04:38:28 +0000
129+++ drizzled/field/date.cc 2011-01-14 20:07:36 +0000
130@@ -132,6 +132,7 @@
131 time_type == DRIZZLE_TIMESTAMP_DATETIME)
132 {
133 tmp= ltime->year*10000 + ltime->month*100 + ltime->day;
134+
135 if (check_date(ltime, tmp != 0,
136 (TIME_FUZZY_DATE |
137 (current_session->variables.sql_mode &
138@@ -139,16 +140,17 @@
139 {
140 char buff[MAX_DATE_STRING_REP_LENGTH];
141 String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
142- make_date(ltime, &str);
143+ ltime->convert(str, DRIZZLE_TIMESTAMP_DATE);
144 set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED,
145 str.ptr(), str.length(), DRIZZLE_TIMESTAMP_DATE, 1);
146 }
147- if (!error && ltime->time_type != DRIZZLE_TIMESTAMP_DATE &&
148+
149+ if (not error && ltime->time_type != DRIZZLE_TIMESTAMP_DATE &&
150 (ltime->hour || ltime->minute || ltime->second || ltime->second_part))
151 {
152 char buff[MAX_DATE_STRING_REP_LENGTH];
153 String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
154- make_datetime(ltime, &str);
155+ ltime->convert(str);
156 set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_NOTE,
157 ER_WARN_DATA_TRUNCATED,
158 str.ptr(), str.length(), DRIZZLE_TIMESTAMP_DATE, 1);
159
160=== modified file 'drizzled/field/epoch.cc'
161--- drizzled/field/epoch.cc 2011-01-06 18:00:47 +0000
162+++ drizzled/field/epoch.cc 2011-01-14 20:07:36 +0000
163@@ -162,7 +162,7 @@
164
165 if (not temporal.from_string(from, (size_t) len))
166 {
167- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), from);
168+ my_error(ER_INVALID_TIMESTAMP_VALUE, MYF(ME_FATALERROR), from);
169 return 1;
170 }
171
172@@ -178,19 +178,33 @@
173 {
174 ASSERT_COLUMN_MARKED_FOR_WRITE;
175
176- if (from < 0 || from > 99991231235959.0)
177+ uint64_t from_tmp= (uint64_t)from;
178+
179+ Timestamp temporal;
180+ if (not temporal.from_int64_t(from_tmp))
181 {
182- /* Convert the double to a string using stringstream */
183- std::stringstream ss;
184- std::string tmp;
185- ss.precision(18); /* 18 places should be fine for error display of double input. */
186- ss << from;
187- ss >> tmp;
188+ /* Convert the integer to a string using boost::lexical_cast */
189+ std::string tmp(boost::lexical_cast<std::string>(from));
190
191- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
192+ my_error(ER_INVALID_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
193 return 2;
194 }
195- return Epoch::store((int64_t) rint(from), false);
196+
197+ time_t tmp;
198+ temporal.to_time_t(tmp);
199+
200+ uint64_t tmp_micro= tmp;
201+ pack_num(tmp_micro);
202+
203+ return 0;
204+}
205+
206+int Epoch::store_decimal(const type::Decimal *value)
207+{
208+ double tmp;
209+ value->convert(tmp);
210+
211+ return store(tmp);
212 }
213
214 int Epoch::store(int64_t from, bool)
215@@ -202,12 +216,12 @@
216 * if unable to create a valid DateTime.
217 */
218 Timestamp temporal;
219- if (! temporal.from_int64_t(from))
220+ if (not temporal.from_int64_t(from))
221 {
222 /* Convert the integer to a string using boost::lexical_cast */
223 std::string tmp(boost::lexical_cast<std::string>(from));
224
225- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
226+ my_error(ER_INVALID_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
227 return 2;
228 }
229
230
231=== modified file 'drizzled/field/epoch.h'
232--- drizzled/field/epoch.h 2011-01-06 18:00:47 +0000
233+++ drizzled/field/epoch.h 2011-01-14 20:07:36 +0000
234@@ -50,10 +50,13 @@
235 enum_field_types type() const { return DRIZZLE_TYPE_TIMESTAMP;}
236 enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
237 enum Item_result cmp_type () const { return INT_RESULT; }
238- int store(const char *to,uint32_t length,
239- const CHARSET_INFO * const charset);
240- int store(double nr);
241- int store(int64_t nr, bool unsigned_val);
242+
243+ int store(const char *to,uint32_t length,
244+ const CHARSET_INFO * const charset);
245+ int store(double nr);
246+ int store(int64_t nr, bool unsigned_val);
247+ int store_decimal(const type::Decimal *value);
248+
249 int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; return 0; }
250 double val_real(void);
251 int64_t val_int(void);
252
253=== modified file 'drizzled/field/microtime.cc'
254--- drizzled/field/microtime.cc 2011-01-11 00:57:46 +0000
255+++ drizzled/field/microtime.cc 2011-01-14 20:07:36 +0000
256@@ -54,8 +54,8 @@
257 unireg_check_arg,
258 field_name_arg,
259 share)
260- {
261- }
262+{
263+}
264
265 Microtime::Microtime(bool maybe_null_arg,
266 const char *field_name_arg) :
267@@ -74,7 +74,7 @@
268
269 if (not temporal.from_string(from, (size_t) len))
270 {
271- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), from);
272+ my_error(ER_INVALID_TIMESTAMP_VALUE, MYF(ME_FATALERROR), from);
273 return 1;
274 }
275
276@@ -109,19 +109,27 @@
277 {
278 ASSERT_COLUMN_MARKED_FOR_WRITE;
279
280- if (from < 0 || from > 99991231235959.0)
281+ uint64_t from_tmp= (uint64_t)from;
282+ type::Time::usec_t fractional_seconds= (type::Time::usec_t)((from - from_tmp) * type::Time::FRACTIONAL_DIGITS) % type::Time::FRACTIONAL_DIGITS;
283+
284+ MicroTimestamp temporal;
285+ if (not temporal.from_int64_t(from_tmp))
286 {
287- /* Convert the double to a string using stringstream */
288- std::stringstream ss;
289- std::string tmp;
290- ss.precision(18); /* 18 places should be fine for error display of double input. */
291- ss << from;
292- ss >> tmp;
293+ /* Convert the integer to a string using boost::lexical_cast */
294+ std::string tmp(boost::lexical_cast<std::string>(from));
295
296- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
297+ my_error(ER_INVALID_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
298 return 2;
299 }
300- return Microtime::store((int64_t) rint(from), false);
301+
302+ time_t tmp;
303+ temporal.to_time_t(tmp);
304+
305+ uint64_t tmp_micro= tmp;
306+ pack_num(tmp_micro);
307+ pack_num(fractional_seconds, ptr +8);
308+
309+ return 0;
310 }
311
312 int Microtime::store(int64_t from, bool)
313@@ -134,7 +142,7 @@
314 /* Convert the integer to a string using boost::lexical_cast */
315 std::string tmp(boost::lexical_cast<std::string>(from));
316
317- my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
318+ my_error(ER_INVALID_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
319 return 2;
320 }
321
322@@ -150,7 +158,33 @@
323
324 double Microtime::val_real(void)
325 {
326- return (double) Microtime::val_int();
327+ uint64_t temp;
328+ type::Time::usec_t micro_temp;
329+
330+ ASSERT_COLUMN_MARKED_FOR_READ;
331+
332+ unpack_num(temp);
333+ unpack_num(micro_temp, ptr +8);
334+
335+ Timestamp temporal;
336+ (void) temporal.from_time_t((time_t) temp);
337+
338+ /* We must convert into a "timestamp-formatted integer" ... */
339+ int64_t result;
340+ temporal.to_int64_t(&result);
341+
342+ result+= micro_temp % type::Time::FRACTIONAL_DIGITS;
343+
344+ return result;
345+}
346+
347+type::Decimal *Microtime::val_decimal(type::Decimal *decimal_value)
348+{
349+ type::Time ltime;
350+
351+ get_date(&ltime, 0);
352+
353+ return date2_class_decimal(&ltime, decimal_value);
354 }
355
356 int64_t Microtime::val_int(void)
357@@ -174,7 +208,7 @@
358 String *Microtime::val_str(String *val_buffer, String *)
359 {
360 uint64_t temp= 0;
361- uint32_t micro_temp= 0;
362+ type::Time::usec_t micro_temp= 0;
363 char *to;
364 int to_len= field_length + 1 + 8;
365
366@@ -209,7 +243,7 @@
367 unpack_num(temp);
368 unpack_num(micro_temp, ptr +8);
369
370- memset(ltime, 0, sizeof(*ltime));
371+ ltime->reset();
372
373 Timestamp temporal;
374 (void) temporal.from_time_t((time_t) temp);
375@@ -225,12 +259,12 @@
376 ltime->second= temporal.seconds();
377 ltime->second_part= temporal.useconds();
378
379- return 0;
380+ return false;
381 }
382
383 bool Microtime::get_time(type::Time *ltime)
384 {
385- return Microtime::get_date(ltime,0);
386+ return Microtime::get_date(ltime, 0);
387 }
388
389 int Microtime::cmp(const unsigned char *a_ptr, const unsigned char *b_ptr)
390@@ -275,7 +309,7 @@
391 {
392 Session *session= getTable() ? getTable()->in_use : current_session;
393
394- uint32_t fractional_seconds= 0;
395+ type::Time::usec_t fractional_seconds= 0;
396 uint64_t epoch_seconds= session->getCurrentTimestampEpoch(fractional_seconds);
397
398 set_notnull();
399
400=== modified file 'drizzled/field/microtime.h'
401--- drizzled/field/microtime.h 2011-01-11 00:57:46 +0000
402+++ drizzled/field/microtime.h 2011-01-14 20:07:36 +0000
403@@ -56,9 +56,11 @@
404 int store(int64_t nr, bool unsigned_val);
405 int store_time(type::Time *ltime, enum enum_drizzle_timestamp_type t_type);
406
407+ String *val_str(String*,String *);
408 double val_real(void);
409 int64_t val_int(void);
410- String *val_str(String*,String *);
411+ type::Decimal *val_decimal(type::Decimal *decimal_value);
412+
413 int cmp(const unsigned char *,const unsigned char *);
414 void sort_string(unsigned char *buff,uint32_t length);
415 uint32_t pack_length() const { return 12; }
416
417=== modified file 'drizzled/function/cast/time.cc'
418--- drizzled/function/cast/time.cc 2010-12-25 04:38:28 +0000
419+++ drizzled/function/cast/time.cc 2011-01-14 20:07:36 +0000
420@@ -47,7 +47,8 @@
421 if (not get_arg0_time(&ltime))
422 {
423 null_value= 0;
424- make_time(&ltime, str);
425+ ltime.convert(*str, DRIZZLE_TIMESTAMP_TIME);
426+
427 return str;
428 }
429
430
431=== modified file 'drizzled/function/time/date_add_interval.cc'
432--- drizzled/function/time/date_add_interval.cc 2011-01-06 23:23:07 +0000
433+++ drizzled/function/time/date_add_interval.cc 2011-01-14 20:07:36 +0000
434@@ -115,7 +115,7 @@
435
436 if (ltime.time_type == DRIZZLE_TIMESTAMP_DATE)
437 {
438- make_date(&ltime, str);
439+ ltime.convert(*str, DRIZZLE_TIMESTAMP_DATE);
440 }
441 else if (ltime.second_part)
442 {
443@@ -135,7 +135,7 @@
444 }
445 else
446 {
447- make_datetime(&ltime, str);
448+ ltime.convert(*str);
449 }
450
451 return str;
452
453=== modified file 'drizzled/function/time/from_unixtime.cc'
454--- drizzled/function/time/from_unixtime.cc 2010-12-25 04:38:28 +0000
455+++ drizzled/function/time/from_unixtime.cc 2011-01-14 20:07:36 +0000
456@@ -54,7 +54,7 @@
457 return 0;
458 }
459
460- make_datetime(&time_tmp, str);
461+ time_tmp.convert(*str);
462
463 return str;
464 }
465@@ -73,7 +73,27 @@
466
467 bool Item_func_from_unixtime::get_date(type::Time *ltime, uint32_t)
468 {
469- uint64_t tmp= (uint64_t)(args[0]->val_int());
470+ uint64_t tmp= 0;
471+ type::Time::usec_t fractional_tmp= 0;
472+
473+ switch (args[0]->result_type()) {
474+ case REAL_RESULT:
475+ case ROW_RESULT:
476+ case DECIMAL_RESULT:
477+ case STRING_RESULT:
478+ {
479+ double double_tmp= args[0]->val_real();
480+
481+ tmp= (uint64_t)(double_tmp);
482+ fractional_tmp= (type::Time::usec_t)((double_tmp - tmp) * 1000000);
483+
484+ break;
485+ }
486+ case INT_RESULT:
487+ tmp= (uint64_t)(args[0]->val_int());
488+ break;
489+ }
490+
491 /*
492 "tmp > TIMESTAMP_MAX_VALUE" check also covers case of negative
493 from_unixtime() argument since tmp is unsigned.
494@@ -82,7 +102,7 @@
495 return 1;
496
497 Timestamp temporal;
498- if (! temporal.from_time_t((time_t) tmp))
499+ if (not temporal.from_time_t((time_t) tmp))
500 {
501 null_value= true;
502 std::string tmp_string(boost::lexical_cast<std::string>(tmp));
503@@ -90,7 +110,7 @@
504 return 0;
505 }
506
507- memset(ltime, 0, sizeof(*ltime));
508+ ltime->reset();
509
510 ltime->year= temporal.years();
511 ltime->month= temporal.months();
512@@ -98,6 +118,7 @@
513 ltime->hour= temporal.hours();
514 ltime->minute= temporal.minutes();
515 ltime->second= temporal.seconds();
516+ ltime->second_part= fractional_tmp;
517 ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME;
518
519 return 0;
520
521=== modified file 'drizzled/function/time/makedate.cc'
522--- drizzled/function/time/makedate.cc 2010-12-25 04:38:28 +0000
523+++ drizzled/function/time/makedate.cc 2011-01-14 20:07:36 +0000
524@@ -58,7 +58,9 @@
525 get_date_from_daynr(days,&l_time.year,&l_time.month,&l_time.day);
526 if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
527 goto err;
528- make_date(&l_time, str);
529+
530+ l_time.convert(*str, DRIZZLE_TIMESTAMP_DATE);
531+
532 return str;
533 }
534
535
536=== modified file 'drizzled/function/time/now.cc'
537--- drizzled/function/time/now.cc 2011-01-06 23:02:43 +0000
538+++ drizzled/function/time/now.cc 2011-01-14 20:07:36 +0000
539@@ -31,6 +31,7 @@
540 {
541 assert(fixed == 1);
542 str_value.set(buff, buff_length, &my_charset_bin);
543+
544 return &str_value;
545 }
546
547@@ -40,14 +41,14 @@
548 decimals= DATETIME_DEC;
549 collation.set(&my_charset_bin);
550
551- memset(&ltime, 0, sizeof(type::Time));
552+ ltime.reset();
553
554 ltime.time_type= DRIZZLE_TIMESTAMP_DATETIME;
555
556 store_now_in_TIME(&ltime);
557 value= (int64_t) TIME_to_uint64_t_datetime(&ltime);
558
559- buff_length= (uint) my_datetime_to_str(&ltime, buff);
560+ buff_length= (uint) my_TIME_to_str(&ltime, buff);
561 max_length= buff_length;
562 }
563
564
565=== modified file 'drizzled/function/time/sysdate_local.cc'
566--- drizzled/function/time/sysdate_local.cc 2010-12-25 04:38:28 +0000
567+++ drizzled/function/time/sysdate_local.cc 2011-01-14 20:07:36 +0000
568@@ -41,7 +41,7 @@
569 {
570 assert(fixed == 1);
571 store_now_in_TIME(&ltime);
572- buff_length= (uint) my_datetime_to_str(&ltime, buff);
573+ buff_length= (uint) my_TIME_to_str(&ltime, buff);
574 str_value.set(buff, buff_length, &my_charset_bin);
575 return &str_value;
576 }
577
578=== modified file 'drizzled/function/time/typecast.cc'
579--- drizzled/function/time/typecast.cc 2010-12-25 04:38:28 +0000
580+++ drizzled/function/time/typecast.cc 2011-01-14 20:07:36 +0000
581@@ -214,7 +214,10 @@
582 str->set_charset(&my_charset_bin);
583 }
584 else
585- make_datetime(&ltime, str);
586+ {
587+ ltime.convert(*str);
588+ }
589+
590 return str;
591 }
592
593@@ -261,7 +264,8 @@
594 if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) &&
595 !str->alloc(MAX_DATE_STRING_REP_LENGTH))
596 {
597- make_date(&ltime, str);
598+ ltime.convert(*str, DRIZZLE_TIMESTAMP_DATE);
599+
600 return str;
601 }
602
603
604=== modified file 'drizzled/session.h'
605--- drizzled/session.h 2011-01-13 01:27:33 +0000
606+++ drizzled/session.h 2011-01-14 20:07:36 +0000
607@@ -1332,7 +1332,7 @@
608 return (_start_timer - _epoch).total_seconds();
609 }
610
611- time_t getCurrentTimestampEpoch(uint32_t &fraction_arg) const
612+ time_t getCurrentTimestampEpoch(type::Time::usec_t &fraction_arg) const
613 {
614 if (not _user_time.is_not_a_date_time())
615 {
616
617=== modified file 'drizzled/time_functions.cc'
618--- drizzled/time_functions.cc 2010-12-25 04:38:28 +0000
619+++ drizzled/time_functions.cc 2011-01-14 20:07:36 +0000
620@@ -170,32 +170,6 @@
621 to->second= (int) from->tm_sec;
622 }
623
624-void make_time(const type::Time *l_time, String *str)
625-{
626- str->alloc(MAX_DATE_STRING_REP_LENGTH);
627- uint32_t length= (uint32_t) my_time_to_str(l_time, str->c_ptr());
628- str->length(length);
629- str->set_charset(&my_charset_bin);
630-}
631-
632-void make_date(const type::Time *l_time, String *str)
633-{
634- str->alloc(MAX_DATE_STRING_REP_LENGTH);
635- uint32_t length= (uint32_t) my_date_to_str(l_time, str->c_ptr());
636- str->length(length);
637- str->set_charset(&my_charset_bin);
638-}
639-
640-
641-void make_datetime(const type::Time *l_time, String *str)
642-{
643- str->alloc(MAX_DATE_STRING_REP_LENGTH);
644- uint32_t length= (uint32_t) my_datetime_to_str(l_time, str->c_ptr());
645- str->length(length);
646- str->set_charset(&my_charset_bin);
647-}
648-
649-
650 void make_truncated_value_warning(Session *session,
651 DRIZZLE_ERROR::enum_warning_level level,
652 const char *str_val,
653@@ -223,6 +197,7 @@
654 type_str= "datetime";
655 break;
656 }
657+
658 if (field_name)
659 {
660 cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
661@@ -233,12 +208,16 @@
662 else
663 {
664 if (time_type > DRIZZLE_TIMESTAMP_ERROR)
665+ {
666 cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
667 ER(ER_TRUNCATED_WRONG_VALUE),
668 type_str, str.c_ptr());
669+ }
670 else
671+ {
672 cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),
673 ER(ER_WRONG_VALUE), type_str, str.c_ptr());
674+ }
675 }
676 push_warning(session, level,
677 ER_TRUNCATED_WRONG_VALUE, warn_buff);
678
679=== modified file 'drizzled/time_functions.h'
680--- drizzled/time_functions.h 2010-12-26 00:07:57 +0000
681+++ drizzled/time_functions.h 2011-01-14 20:07:36 +0000
682@@ -92,12 +92,6 @@
683 */
684 void localtime_to_TIME(type::Time *to, struct tm *from);
685
686-void make_time(const type::Time *l_time, String *str);
687-
688-void make_date(const type::Time *l_time, String *str);
689-
690-void make_datetime(const type::Time *l_time, String *str);
691-
692 void make_truncated_value_warning(Session *session,
693 DRIZZLE_ERROR::enum_warning_level level,
694 const char *str_val,
695
696=== modified file 'drizzled/type/decimal.cc'
697--- drizzled/type/decimal.cc 2010-12-27 19:16:17 +0000
698+++ drizzled/type/decimal.cc 2011-01-14 20:07:36 +0000
699@@ -313,6 +313,10 @@
700 return err;
701 }
702
703+void type::Decimal::convert(double &result) const
704+{
705+ decimal2double(static_cast<const decimal_t*>(this), &result);
706+}
707
708 type::Decimal *date2_class_decimal(type::Time *ltime, type::Decimal *dec)
709 {
710@@ -320,8 +324,10 @@
711 date = (ltime->year*100L + ltime->month)*100L + ltime->day;
712 if (ltime->time_type > DRIZZLE_TIMESTAMP_DATE)
713 date= ((date*100L + ltime->hour)*100L+ ltime->minute)*100L + ltime->second;
714+
715 if (int2_class_decimal(E_DEC_FATAL_ERROR, date, false, dec))
716 return dec;
717+
718 if (ltime->second_part)
719 {
720 dec->buf[(dec->intg-1) / 9 + 1]= ltime->second_part * 1000;
721
722=== modified file 'drizzled/type/decimal.h'
723--- drizzled/type/decimal.h 2010-12-27 19:16:17 +0000
724+++ drizzled/type/decimal.h 2011-01-14 20:07:36 +0000
725@@ -23,8 +23,13 @@
726 {
727
728 typedef enum
729-{TRUNCATE=0, HALF_EVEN, HALF_UP, CEILING, FLOOR}
730- decimal_round_mode;
731+{
732+ TRUNCATE= 0,
733+ HALF_EVEN,
734+ HALF_UP,
735+ CEILING,
736+ FLOOR
737+} decimal_round_mode;
738 typedef int32_t decimal_digit_t;
739
740 typedef struct st_decimal_t {
741@@ -179,96 +184,96 @@
742
743 namespace type {
744 /**
745- type::Decimal class limits 'decimal_t' type to what we need in MySQL.
746+ type Decimal class limits 'decimal_t' type to what we need in MySQL.
747
748 It contains internally all necessary space needed by the instance so
749 no extra memory is needed. One should call fix_buffer_pointer() function
750 when he moves type::Decimal objects in memory.
751 */
752
753-class Decimal :public decimal_t
754+class Decimal : public decimal_t
755+{
756+ decimal_digit_t buffer[DECIMAL_BUFF_LENGTH];
757+
758+public:
759+
760+ void init()
761 {
762- decimal_digit_t buffer[DECIMAL_BUFF_LENGTH];
763-
764- public:
765-
766- void init()
767- {
768- len= DECIMAL_BUFF_LENGTH;
769- buf= buffer;
770+ len= DECIMAL_BUFF_LENGTH;
771+ buf= buffer;
772 #if !defined (HAVE_VALGRIND)
773- /* Set buffer to 'random' value to find wrong buffer usage */
774- for (uint32_t i= 0; i < DECIMAL_BUFF_LENGTH; i++)
775- buffer[i]= i;
776+ /* Set buffer to 'random' value to find wrong buffer usage */
777+ for (uint32_t i= 0; i < DECIMAL_BUFF_LENGTH; i++)
778+ buffer[i]= i;
779 #endif
780- }
781-
782- Decimal()
783- {
784- init();
785- }
786- void fix_buffer_pointer() { buf= buffer; }
787- bool sign() const { return decimal_t::sign; }
788- void sign(bool s) { decimal_t::sign= s; }
789- uint32_t precision() const { return intg + frac; }
790-
791- int val_int32(uint32_t mask, bool unsigned_flag, int64_t *l) const
792- {
793- type::Decimal rounded;
794- /* decimal_round can return only E_DEC_TRUNCATED */
795- decimal_round(static_cast<const decimal_t*>(this), &rounded, 0, HALF_UP);
796- return check_result(mask, (unsigned_flag ?
797- decimal2uint64_t(&rounded, reinterpret_cast<uint64_t *>(l)) :
798- decimal2int64_t(&rounded, l)));
799- }
800-
801- int string_length() const
802- {
803- return decimal_string_size(this);
804- }
805-
806- int val_binary(uint32_t mask, unsigned char *bin, int prec, int scale) const;
807-
808-
809- int set_zero()
810- {
811- decimal_make_zero(static_cast<decimal_t*> (this));
812- return 0;
813- }
814-
815-
816- bool is_zero() const
817- {
818- return decimal_is_zero(static_cast<const decimal_t*>(this));
819- }
820-
821-
822- int store(uint32_t mask, const char *from, uint32_t length, const CHARSET_INFO * charset);
823-
824- int store(uint32_t mask, char *str, char **end)
825- {
826- return check_result_and_overflow(mask, string2decimal(str, static_cast<decimal_t*>(this), end));
827- }
828-
829- int store(uint32_t mask, const String *str)
830- {
831- return store(mask, str->ptr(), str->length(), str->charset());
832- }
833-
834- int check_result_and_overflow(uint32_t mask, int result)
835- {
836- if (check_result(mask, result) & E_DEC_OVERFLOW)
837- {
838- bool _sign= sign();
839- fix_buffer_pointer();
840- max_internal_decimal(this);
841- sign(_sign);
842- }
843- return result;
844-}
845-
846-
847- };
848+ }
849+
850+ Decimal()
851+ {
852+ init();
853+ }
854+ void fix_buffer_pointer() { buf= buffer; }
855+ bool sign() const { return decimal_t::sign; }
856+ void sign(bool s) { decimal_t::sign= s; }
857+ uint32_t precision() const { return intg + frac; }
858+
859+ int val_int32(uint32_t mask, bool unsigned_flag, int64_t *l) const
860+ {
861+ type::Decimal rounded;
862+ /* decimal_round can return only E_DEC_TRUNCATED */
863+ decimal_round(static_cast<const decimal_t*>(this), &rounded, 0, HALF_UP);
864+ return check_result(mask, (unsigned_flag ?
865+ decimal2uint64_t(&rounded, reinterpret_cast<uint64_t *>(l)) :
866+ decimal2int64_t(&rounded, l)));
867+ }
868+
869+ int string_length() const
870+ {
871+ return decimal_string_size(this);
872+ }
873+
874+ int val_binary(uint32_t mask, unsigned char *bin, int prec, int scale) const;
875+
876+
877+ int set_zero()
878+ {
879+ decimal_make_zero(static_cast<decimal_t*> (this));
880+ return 0;
881+ }
882+
883+
884+ bool is_zero() const
885+ {
886+ return decimal_is_zero(static_cast<const decimal_t*>(this));
887+ }
888+
889+
890+ int store(uint32_t mask, const char *from, uint32_t length, const CHARSET_INFO * charset);
891+
892+ int store(uint32_t mask, char *str, char **end)
893+ {
894+ return check_result_and_overflow(mask, string2decimal(str, static_cast<decimal_t*>(this), end));
895+ }
896+
897+ int store(uint32_t mask, const String *str)
898+ {
899+ return store(mask, str->ptr(), str->length(), str->charset());
900+ }
901+
902+ int check_result_and_overflow(uint32_t mask, int result)
903+ {
904+ if (check_result(mask, result) & E_DEC_OVERFLOW)
905+ {
906+ bool _sign= sign();
907+ fix_buffer_pointer();
908+ max_internal_decimal(this);
909+ sign(_sign);
910+ }
911+ return result;
912+ }
913+
914+ void convert(double &value) const;
915+};
916
917 } // type
918
919
920=== modified file 'drizzled/type/time.cc'
921--- drizzled/type/time.cc 2011-01-11 00:57:46 +0000
922+++ drizzled/type/time.cc 2011-01-14 20:07:36 +0000
923@@ -21,6 +21,7 @@
924 #include "drizzled/charset_info.h"
925 #include <drizzled/util/test.h>
926 #include "drizzled/definitions.h"
927+#include <drizzled/sql_string.h>
928
929 #include <cstdio>
930 #include <algorithm>
931@@ -453,7 +454,9 @@
932 DRIZZLE_TIMESTAMP_DATETIME));
933
934 err:
935- memset(l_time, 0, sizeof(*l_time));
936+
937+ l_time->reset();
938+
939 return(DRIZZLE_TIMESTAMP_ERROR);
940 }
941
942@@ -883,18 +886,7 @@
943 We are safe with shifts close to MAX_INT32, as there are no known
944 time switches on Jan 2038 yet :)
945 */
946- if ((t->year == TIMESTAMP_MAX_YEAR) && (t->month == 1) && (t->day > 4))
947- {
948- /*
949- Below we will pass (uint32_t) (t->day - shift) to calc_daynr.
950- As we don't want to get an overflow here, we will shift
951- only safe dates. That's why we have (t->day > 4) above.
952- */
953- t->day-= 2;
954- shift= 2;
955- }
956 #ifdef TIME_T_UNSIGNED
957- else
958 {
959 /*
960 We can get 0 in time_t representaion only on 1969, 31 of Dec or on
961@@ -1039,7 +1031,7 @@
962 number of characters written to 'to'
963 */
964
965-int my_time_to_str(const type::Time *l_time, char *to)
966+static int my_time_to_str(const type::Time *l_time, char *to)
967 {
968 uint32_t extra_hours= 0;
969 return sprintf(to, "%s%02u:%02u:%02u",
970@@ -1049,7 +1041,7 @@
971 l_time->second);
972 }
973
974-int my_date_to_str(const type::Time *l_time, char *to)
975+static int my_date_to_str(const type::Time *l_time, char *to)
976 {
977 return sprintf(to, "%04u-%02u-%02u",
978 l_time->year,
979@@ -1057,7 +1049,7 @@
980 l_time->day);
981 }
982
983-int my_datetime_to_str(const type::Time *l_time, char *to)
984+static int my_datetime_to_str(const type::Time *l_time, char *to)
985 {
986 return sprintf(to, "%04u-%02u-%02u %02u:%02u:%02u",
987 l_time->year,
988@@ -1092,13 +1084,63 @@
989 case DRIZZLE_TIMESTAMP_NONE:
990 case DRIZZLE_TIMESTAMP_ERROR:
991 to[0]='\0';
992- return 0;
993- default:
994+ }
995+
996+ return 0;
997+}
998+
999+namespace type {
1000+
1001+static void make_time(const type::Time *l_time, String *str)
1002+{
1003+ str->alloc(MAX_DATE_STRING_REP_LENGTH);
1004+ uint32_t length= (uint32_t) my_time_to_str(l_time, str->c_ptr());
1005+ str->length(length);
1006+ str->set_charset(&my_charset_bin);
1007+}
1008+
1009+static void make_date(const type::Time *l_time, String *str)
1010+{
1011+ str->alloc(MAX_DATE_STRING_REP_LENGTH);
1012+ uint32_t length= (uint32_t) my_date_to_str(l_time, str->c_ptr());
1013+ str->length(length);
1014+ str->set_charset(&my_charset_bin);
1015+}
1016+
1017+
1018+static void make_datetime(const type::Time *l_time, String *str)
1019+{
1020+ str->alloc(MAX_DATE_STRING_REP_LENGTH);
1021+ uint32_t length= (uint32_t) my_datetime_to_str(l_time, str->c_ptr());
1022+ str->length(length);
1023+ str->set_charset(&my_charset_bin);
1024+}
1025+
1026+
1027+
1028+void Time::convert(String &str, const enum_drizzle_timestamp_type arg)
1029+{
1030+ switch (arg) {
1031+ case DRIZZLE_TIMESTAMP_DATETIME:
1032+ make_datetime(this, &str);
1033+ break;
1034+
1035+ case DRIZZLE_TIMESTAMP_DATE:
1036+ make_date(this, &str);
1037+ break;
1038+
1039+ case DRIZZLE_TIMESTAMP_TIME:
1040+ make_time(this, &str);
1041+ break;
1042+
1043+ case DRIZZLE_TIMESTAMP_NONE:
1044+ case DRIZZLE_TIMESTAMP_ERROR:
1045 assert(0);
1046- return 0;
1047+ break;
1048 }
1049 }
1050
1051+}
1052
1053 /*
1054 Convert datetime value specified as number to broken-down TIME
1055@@ -1132,7 +1174,7 @@
1056 long part1,part2;
1057
1058 *was_cut= 0;
1059- memset(time_res, 0, sizeof(*time_res));
1060+ time_res->reset();
1061 time_res->time_type=DRIZZLE_TIMESTAMP_DATE;
1062
1063 if (nr == 0LL || nr >= 10000101000000LL)
1064@@ -1219,8 +1261,9 @@
1065
1066 static uint64_t TIME_to_uint64_t_date(const type::Time *my_time)
1067 {
1068- return (uint64_t) (my_time->year * 10000UL + my_time->month * 100UL +
1069- my_time->day);
1070+ return (uint64_t) (my_time->year * 10000UL +
1071+ my_time->month * 100UL +
1072+ my_time->day);
1073 }
1074
1075
1076@@ -1233,8 +1276,8 @@
1077 static uint64_t TIME_to_uint64_t_time(const type::Time *my_time)
1078 {
1079 return (uint64_t) (my_time->hour * 10000UL +
1080- my_time->minute * 100UL +
1081- my_time->second);
1082+ my_time->minute * 100UL +
1083+ my_time->second);
1084 }
1085
1086
1087@@ -1270,9 +1313,8 @@
1088 case DRIZZLE_TIMESTAMP_NONE:
1089 case DRIZZLE_TIMESTAMP_ERROR:
1090 return 0ULL;
1091- default:
1092- assert(0);
1093 }
1094+
1095 return 0;
1096 }
1097
1098
1099=== modified file 'drizzled/type/time.h'
1100--- drizzled/type/time.h 2011-01-11 00:57:46 +0000
1101+++ drizzled/type/time.h 2011-01-14 20:07:36 +0000
1102@@ -32,6 +32,8 @@
1103 # endif
1104 #endif
1105
1106+#include <drizzled/sql_string.h>
1107+
1108 namespace drizzled
1109 {
1110
1111@@ -39,7 +41,6 @@
1112 extern unsigned char days_in_month[];
1113
1114 /* Time handling defaults */
1115-#define TIMESTAMP_MAX_YEAR 2038
1116 #define TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1)
1117 #define TIMESTAMP_MAX_VALUE INT32_MAX
1118 #define TIMESTAMP_MIN_VALUE 1
1119@@ -88,17 +89,31 @@
1120 bigger values.
1121 */
1122 namespace type {
1123+
1124 class Time
1125 {
1126 public:
1127+ typedef uint32_t usec_t;
1128+
1129 unsigned int year, month, day, hour, minute, second;
1130- unsigned int second_part;
1131- bool neg;
1132+ usec_t second_part;
1133+ bool neg;
1134 enum enum_drizzle_timestamp_type time_type;
1135+
1136+ void reset()
1137+ {
1138+ year= month= day= hour= minute= second= second_part= 0;
1139+ neg= false;
1140+ time_type= DRIZZLE_TIMESTAMP_DATE;
1141+ }
1142+
1143+ void convert(drizzled::String &str, const enum_drizzle_timestamp_type arg= DRIZZLE_TIMESTAMP_DATETIME);
1144+
1145+ static const uint32_t FRACTIONAL_DIGITS= 1000000;
1146 };
1147+
1148 }
1149
1150-
1151 bool check_date(const type::Time *ltime, bool not_zero_date,
1152 uint32_t flags, int *was_cut);
1153 enum enum_drizzle_timestamp_type
1154@@ -110,8 +125,7 @@
1155 uint64_t TIME_to_uint64_t(const type::Time *);
1156
1157
1158-bool str_to_time(const char *str,uint32_t length, type::Time *l_time,
1159- int *warning);
1160+bool str_to_time(const char *str,uint32_t length, type::Time *l_time, int *warning);
1161
1162 long calc_daynr(uint32_t year,uint32_t month,uint32_t day);
1163 uint32_t calc_days_in_year(uint32_t year);
1164@@ -135,10 +149,10 @@
1165
1166 static inline bool validate_timestamp_range(const type::Time *t)
1167 {
1168- if ((t->year > TIMESTAMP_MAX_YEAR || t->year < TIMESTAMP_MIN_YEAR) ||
1169- (t->year == TIMESTAMP_MAX_YEAR && (t->month > 1 || t->day > 19)) ||
1170- (t->year == TIMESTAMP_MIN_YEAR && (t->month < 12 || t->day < 31)))
1171+ if ((t->year < TIMESTAMP_MIN_YEAR) or (t->year == TIMESTAMP_MIN_YEAR && (t->month < 12 || t->day < 31)))
1172+ {
1173 return false;
1174+ }
1175
1176 return true;
1177 }
1178@@ -159,9 +173,6 @@
1179 */
1180 #define MAX_DATE_STRING_REP_LENGTH 30
1181
1182-int my_time_to_str(const type::Time *l_time, char *to);
1183-int my_date_to_str(const type::Time *l_time, char *to);
1184-int my_datetime_to_str(const type::Time *l_time, char *to);
1185 int my_TIME_to_str(const type::Time *l_time, char *to);
1186
1187 /*
1188
1189=== modified file 'plugin/csv/tests/t/uuid_type.test'
1190--- plugin/csv/tests/t/uuid_type.test 2010-12-17 22:39:43 +0000
1191+++ plugin/csv/tests/t/uuid_type.test 2011-01-14 20:07:36 +0000
1192@@ -19,7 +19,7 @@
1193 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883aaaa");
1194 SELECT a FROM t1 ORDER BY a;
1195
1196---error 1716
1197+--error ER_INVALID_UUID_VALUE
1198 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883");
1199 SELECT a FROM t1 ORDER BY a;
1200
1201
1202=== modified file 'plugin/haildb/tests/r/type_timestamp.result'
1203--- plugin/haildb/tests/r/type_timestamp.result 2010-12-10 05:45:44 +0000
1204+++ plugin/haildb/tests/r/type_timestamp.result 2011-01-14 20:07:36 +0000
1205@@ -112,17 +112,17 @@
1206 drop table t1;
1207 create table t1 (ix timestamp);
1208 insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
1209-ERROR HY000: Received an invalid value '0' for a UNIX timestamp.
1210+ERROR HY000: Received an invalid timestamp value '0'.
1211 select ix+0 from t1;
1212 ix+0
1213 truncate table t1;
1214 insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
1215-ERROR HY000: Received an invalid value '00000000000000' for a UNIX timestamp.
1216+ERROR HY000: Received an invalid timestamp value '00000000000000'.
1217 select ix+0 from t1;
1218 ix+0
1219 truncate table t1;
1220 insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
1221-ERROR HY000: Received an invalid value '0000-00-00 00:00:00 some trailer' for a UNIX timestamp.
1222+ERROR HY000: Received an invalid timestamp value '0000-00-00 00:00:00 some trailer'.
1223 select ix+0 from t1;
1224 ix+0
1225 drop table t1;
1226
1227=== modified file 'plugin/haildb/tests/t/type_timestamp.test'
1228--- plugin/haildb/tests/t/type_timestamp.test 2010-12-10 05:45:44 +0000
1229+++ plugin/haildb/tests/t/type_timestamp.test 2011-01-14 20:07:36 +0000
1230@@ -83,15 +83,15 @@
1231 # (for both strings and numbers)
1232 #
1233 create table t1 (ix timestamp);
1234---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix timestamp
1235+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix timestamp
1236 insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
1237 select ix+0 from t1;
1238 truncate table t1;
1239---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix timestamp
1240+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix timestamp
1241 insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
1242 select ix+0 from t1;
1243 truncate table t1;
1244---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix timestamp
1245+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix timestamp
1246 insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
1247 select ix+0 from t1;
1248 drop table t1;
1249
1250=== modified file 'plugin/memory/tests/t/primary_key.test'
1251--- plugin/memory/tests/t/primary_key.test 2010-12-17 22:39:43 +0000
1252+++ plugin/memory/tests/t/primary_key.test 2011-01-14 20:07:36 +0000
1253@@ -21,7 +21,7 @@
1254 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883aaaa");
1255 SELECT a FROM t1 ORDER BY a;
1256
1257---error 1716
1258+--error ER_INVALID_UUID_VALUE
1259 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883");
1260 SELECT a FROM t1 ORDER BY a;
1261
1262
1263=== modified file 'plugin/myisam/tests/r/mix2_myisam.result'
1264--- plugin/myisam/tests/r/mix2_myisam.result 2010-12-07 09:12:12 +0000
1265+++ plugin/myisam/tests/r/mix2_myisam.result 2011-01-14 20:07:36 +0000
1266@@ -873,10 +873,12 @@
1267 create TEMPORARY table t2 (col1 int,stamp TIMESTAMP,INDEX stamp_idx
1268 (stamp))ENGINE=MyISAM;
1269 insert into t1 values (1),(2),(3);
1270-insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
1271-ERROR HY000: Received an invalid value '20020204310000' for a UNIX timestamp.
1272-SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
1273-'20020204120000' GROUP BY col1;
1274+insert into t2 values (1, 20020204130000);
1275+insert into t2 values (2, 20020204130000);
1276+insert into t2 values (4, 20020204310000);
1277+ERROR HY000: Received an invalid timestamp value '20020204310000'.
1278+insert into t2 values (5, 20020204230000);
1279+SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp < '20020204120000' GROUP BY col1;
1280 col1
1281 1
1282 2
1283
1284=== modified file 'plugin/transaction_log/tests/r/transaction_log_data_type.result'
1285--- plugin/transaction_log/tests/r/transaction_log_data_type.result 2011-01-11 14:22:54 +0000
1286+++ plugin/transaction_log/tests/r/transaction_log_data_type.result 2011-01-14 20:07:36 +0000
1287@@ -3405,7 +3405,7 @@
1288
1289 Testing MIN-1 TIMESTAMP
1290 INSERT INTO t1 (b) VALUES('1969-12-31 23:59:59');
1291-ERROR HY000: Received an invalid value '1969-12-31 23:59:59' for a UNIX timestamp.
1292+ERROR HY000: Received an invalid timestamp value '1969-12-31 23:59:59'.
1293 Check transaction_log_entries
1294 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
1295 COUNT(*)
1296@@ -3460,16 +3460,15 @@
1297
1298 Testing MAX+1 TIMESTAMP
1299 INSERT INTO t1 (b) VALUES('2038-01-19 03:14:08');
1300-ERROR HY000: Received an invalid value '2038-01-19 03:14:08' for a UNIX timestamp.
1301 Check transaction_log_entries
1302 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
1303 COUNT(*)
1304-3
1305+4
1306
1307 Check transaction_log_transactions
1308 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
1309 COUNT(*)
1310-3
1311+4
1312 Check transaction log contents
1313 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
1314 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
1315@@ -3501,8 +3500,8 @@
1316 segment_id: 1
1317 end_segment: true
1318 record {
1319- insert_value: "2"
1320- insert_value: "2038-01-19 03:14:07"
1321+ insert_value: "3"
1322+ insert_value: "2038-01-19 03:14:08"
1323 is_null: false
1324 is_null: false
1325 }
1326@@ -3518,12 +3517,12 @@
1327 Check transaction_log_entries
1328 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
1329 COUNT(*)
1330-4
1331+5
1332
1333 Check transaction_log_transactions
1334 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
1335 COUNT(*)
1336-4
1337+5
1338 Check transaction log contents
1339 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
1340 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
1341@@ -3555,7 +3554,7 @@
1342 segment_id: 1
1343 end_segment: true
1344 record {
1345- insert_value: "3"
1346+ insert_value: "4"
1347 insert_value: "2000-01-01 12:15:59"
1348 is_null: false
1349 is_null: false
1350@@ -3572,12 +3571,12 @@
1351 Check transaction_log_entries
1352 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
1353 COUNT(*)
1354-5
1355+6
1356
1357 Check transaction_log_transactions
1358 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
1359 COUNT(*)
1360-5
1361+6
1362 Check transaction log contents
1363 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
1364 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
1365@@ -3609,7 +3608,7 @@
1366 segment_id: 1
1367 end_segment: true
1368 record {
1369- insert_value: "4"
1370+ insert_value: "5"
1371 insert_value: "1999-06-01 12:15:47"
1372 is_null: false
1373 is_null: false
1374@@ -3626,12 +3625,12 @@
1375 Check transaction_log_entries
1376 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
1377 COUNT(*)
1378-6
1379+7
1380
1381 Check transaction_log_transactions
1382 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
1383 COUNT(*)
1384-6
1385+7
1386 Check transaction log contents
1387 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
1388 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
1389@@ -3663,7 +3662,7 @@
1390 segment_id: 1
1391 end_segment: true
1392 record {
1393- insert_value: "5"
1394+ insert_value: "6"
1395 insert_value: ""
1396 is_null: false
1397 is_null: true
1398@@ -3677,16 +3676,16 @@
1399
1400 Testing BAD INPUT TIMESTAMP1
1401 INSERT INTO t1 (b) VALUES('2000-01-01 25:00:00');
1402-ERROR HY000: Received an invalid value '2000-01-01 25:00:00' for a UNIX timestamp.
1403+ERROR HY000: Received an invalid timestamp value '2000-01-01 25:00:00'.
1404 Check transaction_log_entries
1405 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
1406 COUNT(*)
1407-6
1408+7
1409
1410 Check transaction_log_transactions
1411 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
1412 COUNT(*)
1413-6
1414+7
1415 Check transaction log contents
1416 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
1417 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
1418@@ -3718,7 +3717,7 @@
1419 segment_id: 1
1420 end_segment: true
1421 record {
1422- insert_value: "5"
1423+ insert_value: "6"
1424 insert_value: ""
1425 is_null: false
1426 is_null: true
1427@@ -3732,16 +3731,16 @@
1428
1429 Testing BAD INPUT TIMESTAMP2
1430 INSERT INTO t1 (b) VALUES('2000-01-01 12:60:00');
1431-ERROR HY000: Received an invalid value '2000-01-01 12:60:00' for a UNIX timestamp.
1432+ERROR HY000: Received an invalid timestamp value '2000-01-01 12:60:00'.
1433 Check transaction_log_entries
1434 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
1435 COUNT(*)
1436-6
1437+7
1438
1439 Check transaction_log_transactions
1440 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
1441 COUNT(*)
1442-6
1443+7
1444 Check transaction log contents
1445 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
1446 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
1447@@ -3773,7 +3772,7 @@
1448 segment_id: 1
1449 end_segment: true
1450 record {
1451- insert_value: "5"
1452+ insert_value: "6"
1453 insert_value: ""
1454 is_null: false
1455 is_null: true
1456@@ -3787,16 +3786,16 @@
1457
1458 Testing BAD INPUT TIMESTAMP3
1459 INSERT INTO t1 (b) VALUES('2000-01-01 12:00:65');
1460-ERROR HY000: Received an invalid value '2000-01-01 12:00:65' for a UNIX timestamp.
1461+ERROR HY000: Received an invalid timestamp value '2000-01-01 12:00:65'.
1462 Check transaction_log_entries
1463 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_ENTRIES;
1464 COUNT(*)
1465-6
1466+7
1467
1468 Check transaction_log_transactions
1469 SELECT COUNT(*) FROM DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS;
1470 COUNT(*)
1471-6
1472+7
1473 Check transaction log contents
1474 SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS));
1475 PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
1476@@ -3828,7 +3827,7 @@
1477 segment_id: 1
1478 end_segment: true
1479 record {
1480- insert_value: "5"
1481+ insert_value: "6"
1482 insert_value: ""
1483 is_null: false
1484 is_null: true
1485
1486=== modified file 'plugin/transaction_log/tests/t/transaction_log_data_type.test'
1487--- plugin/transaction_log/tests/t/transaction_log_data_type.test 2010-12-20 19:20:57 +0000
1488+++ plugin/transaction_log/tests/t/transaction_log_data_type.test 2011-01-14 20:07:36 +0000
1489@@ -470,13 +470,12 @@
1490 --echo
1491
1492 --echo Testing MIN-1 TIMESTAMP
1493---ERROR 1685
1494+--ERROR ER_INVALID_TIMESTAMP_VALUE
1495 INSERT INTO t1 (b) VALUES('1969-12-31 23:59:59');
1496 --source ../plugin/transaction_log/tests/t/check_transaction_log.inc
1497 --echo
1498
1499 --echo Testing MAX+1 TIMESTAMP
1500---ERROR 1685
1501 INSERT INTO t1 (b) VALUES('2038-01-19 03:14:08');
1502 --source ../plugin/transaction_log/tests/t/check_transaction_log.inc
1503 --echo
1504@@ -497,19 +496,19 @@
1505 --echo
1506
1507 --echo Testing BAD INPUT TIMESTAMP1
1508---ERROR 1685
1509+--ERROR ER_INVALID_TIMESTAMP_VALUE
1510 INSERT INTO t1 (b) VALUES('2000-01-01 25:00:00');
1511 --source ../plugin/transaction_log/tests/t/check_transaction_log.inc
1512 --echo
1513
1514 --echo Testing BAD INPUT TIMESTAMP2
1515---ERROR 1685
1516+--ERROR ER_INVALID_TIMESTAMP_VALUE
1517 INSERT INTO t1 (b) VALUES('2000-01-01 12:60:00');
1518 --source ../plugin/transaction_log/tests/t/check_transaction_log.inc
1519 --echo
1520
1521 --echo Testing BAD INPUT TIMESTAMP3
1522---ERROR 1685
1523+--ERROR ER_INVALID_TIMESTAMP_VALUE
1524 INSERT INTO t1 (b) VALUES('2000-01-01 12:00:65');
1525 --source ../plugin/transaction_log/tests/t/check_transaction_log.inc
1526 --echo
1527
1528=== modified file 'tests/include/mix2.inc'
1529--- tests/include/mix2.inc 2010-12-07 09:12:12 +0000
1530+++ tests/include/mix2.inc 2011-01-14 20:07:36 +0000
1531@@ -929,11 +929,12 @@
1532 eval create $temp table t2 (col1 int,stamp TIMESTAMP,INDEX stamp_idx
1533 (stamp))ENGINE=$engine_type;
1534 insert into t1 values (1),(2),(3);
1535-# Note that timestamp 3 is wrong
1536---error 1685 # Bad timestamp
1537-insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
1538-SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
1539-'20020204120000' GROUP BY col1;
1540+insert into t2 values (1, 20020204130000);
1541+insert into t2 values (2, 20020204130000);
1542+--error ER_INVALID_TIMESTAMP_VALUE # Bad timestamp
1543+insert into t2 values (4, 20020204310000);
1544+insert into t2 values (5, 20020204230000);
1545+SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp < '20020204120000' GROUP BY col1;
1546 drop table t1,t2;
1547
1548 #
1549
1550=== modified file 'tests/r/func_time.result'
1551--- tests/r/func_time.result 2011-01-08 10:35:13 +0000
1552+++ tests/r/func_time.result 2011-01-14 20:07:36 +0000
1553@@ -408,15 +408,18 @@
1554 unix_timestamp(from_unixtime(2147483648))
1555 NULL
1556 select unix_timestamp('2039-01-20 01:00:00');
1557-ERROR HY000: Received an invalid value '2039-01-20 01:00:00' for a UNIX timestamp.
1558+unix_timestamp('2039-01-20 01:00:00')
1559+2179098000
1560 select unix_timestamp('1968-01-20 01:00:00');
1561 ERROR HY000: Received an invalid value '1968-01-20 01:00:00' for a UNIX timestamp.
1562 select unix_timestamp('2038-02-10 01:00:00');
1563-ERROR HY000: Received an invalid value '2038-02-10 01:00:00' for a UNIX timestamp.
1564+unix_timestamp('2038-02-10 01:00:00')
1565+2149376400
1566 select unix_timestamp('1969-11-20 01:00:00');
1567 ERROR HY000: Received an invalid value '1969-11-20 01:00:00' for a UNIX timestamp.
1568 select unix_timestamp('2038-01-20 01:00:00');
1569-ERROR HY000: Received an invalid value '2038-01-20 01:00:00' for a UNIX timestamp.
1570+unix_timestamp('2038-01-20 01:00:00')
1571+2147562000
1572 select unix_timestamp('1969-12-30 01:00:00');
1573 ERROR HY000: Received an invalid value '1969-12-30 01:00:00' for a UNIX timestamp.
1574 select unix_timestamp('2038-01-17 12:00:00');
1575
1576=== modified file 'tests/r/insert.result'
1577--- tests/r/insert.result 2010-04-20 18:23:07 +0000
1578+++ tests/r/insert.result 2011-01-14 20:07:36 +0000
1579@@ -24,7 +24,7 @@
1580 insert into t1 values (default,default,default,default);
1581 insert into t1 values (default,default,default,default);
1582 insert into t1 values (4,0,"a",5);
1583-ERROR HY000: Received an invalid value '0' for a UNIX timestamp.
1584+ERROR HY000: Received an invalid timestamp value '0'.
1585 insert into t1 values (default,default,default,default);
1586 select a,t is not null,c,i from t1;
1587 a t is not null c i
1588
1589=== modified file 'tests/r/timezone.result'
1590--- tests/r/timezone.result 2009-02-28 20:43:31 +0000
1591+++ tests/r/timezone.result 2011-01-14 20:07:36 +0000
1592@@ -45,4 +45,5 @@
1593 unix_timestamp('2038-01-19 03:14:07')
1594 2147483647
1595 select unix_timestamp('2038-01-19 03:14:08');
1596-ERROR HY000: Received an invalid value '2038-01-19 03:14:08' for a UNIX timestamp.
1597+unix_timestamp('2038-01-19 03:14:08')
1598+2147483648
1599
1600=== modified file 'tests/r/type_timestamp.result'
1601--- tests/r/type_timestamp.result 2010-09-02 18:35:05 +0000
1602+++ tests/r/type_timestamp.result 2011-01-14 20:07:36 +0000
1603@@ -112,17 +112,17 @@
1604 drop table t1;
1605 create table t1 (ix timestamp);
1606 insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
1607-ERROR HY000: Received an invalid value '0' for a UNIX timestamp.
1608+ERROR HY000: Received an invalid timestamp value '0'.
1609 select ix+0 from t1;
1610 ix+0
1611 truncate table t1;
1612 insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
1613-ERROR HY000: Received an invalid value '00000000000000' for a UNIX timestamp.
1614+ERROR HY000: Received an invalid timestamp value '00000000000000'.
1615 select ix+0 from t1;
1616 ix+0
1617 truncate table t1;
1618 insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
1619-ERROR HY000: Received an invalid value '0000-00-00 00:00:00 some trailer' for a UNIX timestamp.
1620+ERROR HY000: Received an invalid timestamp value '0000-00-00 00:00:00 some trailer'.
1621 select ix+0 from t1;
1622 ix+0
1623 drop table t1;
1624
1625=== modified file 'tests/suite/microtime_type/r/basic.result'
1626--- tests/suite/microtime_type/r/basic.result 2011-01-07 21:56:29 +0000
1627+++ tests/suite/microtime_type/r/basic.result 2011-01-14 20:07:36 +0000
1628@@ -112,17 +112,17 @@
1629 drop table t1;
1630 create table t1 (ix TIMESTAMP(6));
1631 insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
1632-ERROR HY000: Received an invalid value '0' for a UNIX timestamp.
1633+ERROR HY000: Received an invalid timestamp value '0'.
1634 select ix+0 from t1;
1635 ix+0
1636 truncate table t1;
1637 insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
1638-ERROR HY000: Received an invalid value '00000000000000' for a UNIX timestamp.
1639+ERROR HY000: Received an invalid timestamp value '00000000000000'.
1640 select ix+0 from t1;
1641 ix+0
1642 truncate table t1;
1643 insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
1644-ERROR HY000: Received an invalid value '0000-00-00 00:00:00 some trailer' for a UNIX timestamp.
1645+ERROR HY000: Received an invalid timestamp value '0000-00-00 00:00:00 some trailer'.
1646 select ix+0 from t1;
1647 ix+0
1648 drop table t1;
1649
1650=== added file 'tests/suite/microtime_type/r/decimal.result'
1651--- tests/suite/microtime_type/r/decimal.result 1970-01-01 00:00:00 +0000
1652+++ tests/suite/microtime_type/r/decimal.result 2011-01-14 20:07:36 +0000
1653@@ -0,0 +1,19 @@
1654+CREATE TABLE t1 (
1655+_value decimal(20,6)
1656+);
1657+INSERT INTO t1 VALUES ("20030101000000.90000"), ("20030101000000.00000"), ("20030101000000.123456") ;
1658+SELECT _value FROM t1;
1659+_value
1660+20030101000000.000000
1661+20030101000000.123456
1662+20030101000000.900000
1663+CREATE TABLE t2 (
1664+_value TIMESTAMP(6)
1665+);
1666+INSERT INTO t2 SELECT _value from t1;
1667+SELECT _value FROM t2;
1668+_value
1669+2003-01-01 00:00:00.000000
1670+2003-01-01 00:00:00.125000
1671+2003-01-01 00:00:00.898437
1672+DROP TABLE t1,t2;
1673
1674=== added file 'tests/suite/microtime_type/r/max.result'
1675--- tests/suite/microtime_type/r/max.result 1970-01-01 00:00:00 +0000
1676+++ tests/suite/microtime_type/r/max.result 2011-01-14 20:07:36 +0000
1677@@ -0,0 +1,8 @@
1678+CREATE TABLE t2 (
1679+_value TIMESTAMP(6)
1680+);
1681+INSERT into t2 VALUES ("20660101000000.00000");
1682+SELECT _value FROM t2;
1683+_value
1684+2066-01-01 00:00:00.000000
1685+DROP TABLE t2;
1686
1687=== modified file 'tests/suite/microtime_type/t/basic.test'
1688--- tests/suite/microtime_type/t/basic.test 2011-01-06 19:13:50 +0000
1689+++ tests/suite/microtime_type/t/basic.test 2011-01-14 20:07:36 +0000
1690@@ -83,15 +83,15 @@
1691 # (for both strings and numbers)
1692 #
1693 create table t1 (ix TIMESTAMP(6));
1694---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix TIMESTAMP(6)
1695+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix TIMESTAMP(6)
1696 insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
1697 select ix+0 from t1;
1698 truncate table t1;
1699---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix TIMESTAMP(6)
1700+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix TIMESTAMP(6)
1701 insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
1702 select ix+0 from t1;
1703 truncate table t1;
1704---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix TIMESTAMP(6)
1705+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix TIMESTAMP(6)
1706 insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
1707 select ix+0 from t1;
1708 drop table t1;
1709
1710=== added file 'tests/suite/microtime_type/t/decimal.test'
1711--- tests/suite/microtime_type/t/decimal.test 1970-01-01 00:00:00 +0000
1712+++ tests/suite/microtime_type/t/decimal.test 2011-01-14 20:07:36 +0000
1713@@ -0,0 +1,17 @@
1714+CREATE TABLE t1 (
1715+ _value decimal(20,6)
1716+ );
1717+
1718+INSERT INTO t1 VALUES ("20030101000000.90000"), ("20030101000000.00000"), ("20030101000000.123456") ;
1719+--sorted_result
1720+SELECT _value FROM t1;
1721+
1722+CREATE TABLE t2 (
1723+ _value TIMESTAMP(6)
1724+);
1725+
1726+INSERT INTO t2 SELECT _value from t1;
1727+--sorted_result
1728+SELECT _value FROM t2;
1729+
1730+DROP TABLE t1,t2;
1731
1732=== added file 'tests/suite/microtime_type/t/max.test'
1733--- tests/suite/microtime_type/t/max.test 1970-01-01 00:00:00 +0000
1734+++ tests/suite/microtime_type/t/max.test 2011-01-14 20:07:36 +0000
1735@@ -0,0 +1,10 @@
1736+# Just a quick test to make sure we are not limited to the old max
1737+CREATE TABLE t2 (
1738+ _value TIMESTAMP(6)
1739+);
1740+
1741+INSERT into t2 VALUES ("20660101000000.00000");
1742+
1743+SELECT _value FROM t2;
1744+
1745+DROP TABLE t2;
1746
1747=== added file 'tests/suite/regression/r/592690.result'
1748--- tests/suite/regression/r/592690.result 1970-01-01 00:00:00 +0000
1749+++ tests/suite/regression/r/592690.result 2011-01-14 20:07:36 +0000
1750@@ -0,0 +1,3 @@
1751+select from_unixtime(1272945599.90000), from_unixtime(1272945599), from_unixtime("1272945599.90000");
1752+from_unixtime(1272945599.90000) from_unixtime(1272945599) from_unixtime("1272945599.90000")
1753+2010-05-04 03:59:59.900000 2010-05-04 03:59:59 2010-05-04 03:59:59.900000
1754
1755=== added file 'tests/suite/regression/t/592690.test'
1756--- tests/suite/regression/t/592690.test 1970-01-01 00:00:00 +0000
1757+++ tests/suite/regression/t/592690.test 2011-01-14 20:07:36 +0000
1758@@ -0,0 +1,2 @@
1759+# Decimal should be recorded properly from_unixtime();
1760+select from_unixtime(1272945599.90000), from_unixtime(1272945599), from_unixtime("1272945599.90000");
1761
1762=== modified file 'tests/suite/uuid_type/t/insert_null_no_key.test'
1763--- tests/suite/uuid_type/t/insert_null_no_key.test 2010-12-17 08:22:10 +0000
1764+++ tests/suite/uuid_type/t/insert_null_no_key.test 2011-01-14 20:07:36 +0000
1765@@ -19,7 +19,7 @@
1766 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883aaaa");
1767 SELECT a FROM t1 ORDER BY a;
1768
1769---error 1716
1770+--error ER_INVALID_UUID_VALUE
1771 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883");
1772 SELECT a FROM t1 ORDER BY a;
1773
1774
1775=== modified file 'tests/suite/uuid_type/t/primary_key.test'
1776--- tests/suite/uuid_type/t/primary_key.test 2010-12-17 08:22:10 +0000
1777+++ tests/suite/uuid_type/t/primary_key.test 2011-01-14 20:07:36 +0000
1778@@ -21,7 +21,7 @@
1779 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883aaaa");
1780 SELECT a FROM t1 ORDER BY a;
1781
1782---error 1716
1783+--error ER_INVALID_UUID_VALUE
1784 INSERT INTO t1 VALUES ("d9163f3c-6228-4f62-9c21-0af56883");
1785 SELECT a FROM t1 ORDER BY a;
1786
1787
1788=== modified file 'tests/t/func_time.test'
1789--- tests/t/func_time.test 2011-01-05 07:43:57 +0000
1790+++ tests/t/func_time.test 2011-01-14 20:07:36 +0000
1791@@ -242,19 +242,19 @@
1792
1793 # check for invalid dates
1794
1795-# bad year
1796---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
1797+# Legal, Drizzle has 64bit timestamp
1798 select unix_timestamp('2039-01-20 01:00:00');
1799+
1800 --error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
1801 select unix_timestamp('1968-01-20 01:00:00');
1802-# bad month
1803---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
1804+
1805 select unix_timestamp('2038-02-10 01:00:00');
1806+
1807 --error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
1808 select unix_timestamp('1969-11-20 01:00:00');
1809-# bad day
1810---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
1811+
1812 select unix_timestamp('2038-01-20 01:00:00');
1813+
1814 --error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
1815 select unix_timestamp('1969-12-30 01:00:00');
1816
1817
1818=== modified file 'tests/t/insert.test'
1819--- tests/t/insert.test 2010-08-26 21:56:15 +0000
1820+++ tests/t/insert.test 2011-01-14 20:07:36 +0000
1821@@ -33,7 +33,7 @@
1822 create table t1 (a int not null auto_increment, primary key (a), t timestamp null, c char(10) default "hello", i int);
1823 insert into t1 values (default,default,default,default);
1824 insert into t1 values (default,default,default,default);
1825---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
1826+--error ER_INVALID_TIMESTAMP_VALUE # Bad timestamp
1827 insert into t1 values (4,0,"a",5);
1828 insert into t1 values (default,default,default,default);
1829 select a,t is not null,c,i from t1;
1830
1831=== modified file 'tests/t/timezone.test'
1832--- tests/t/timezone.test 2010-08-26 21:56:15 +0000
1833+++ tests/t/timezone.test 2011-01-14 20:07:36 +0000
1834@@ -54,11 +54,11 @@
1835 #
1836 # Test for fix for Bug#2523 Check that boundary dates are processed
1837 # correctly.
1838+# -- scratch the above, Drizzle allows for longer dates.
1839 #
1840 select unix_timestamp('1970-01-01 00:00:00');
1841 select unix_timestamp('1970-01-01 00:00:01');
1842 select unix_timestamp('2038-01-19 03:14:07');
1843---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad timestamp
1844 select unix_timestamp('2038-01-19 03:14:08');
1845
1846 # End of 4.1 tests
1847
1848=== modified file 'tests/t/type_timestamp.test'
1849--- tests/t/type_timestamp.test 2010-08-26 21:56:15 +0000
1850+++ tests/t/type_timestamp.test 2011-01-14 20:07:36 +0000
1851@@ -83,15 +83,15 @@
1852 # (for both strings and numbers)
1853 #
1854 create table t1 (ix timestamp);
1855---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix timestamp
1856+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix timestamp
1857 insert into t1 values (0),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101),(20031200000000),(20030000000000);
1858 select ix+0 from t1;
1859 truncate table t1;
1860---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix timestamp
1861+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix timestamp
1862 insert into t1 values ("00000000000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"),("20031200000000"),("20030000000000");
1863 select ix+0 from t1;
1864 truncate table t1;
1865---error ER_INVALID_UNIX_TIMESTAMP_VALUE # Bad unix timestamp
1866+--error ER_INVALID_TIMESTAMP_VALUE # Bad unix timestamp
1867 insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
1868 select ix+0 from t1;
1869 drop table t1;
1870
1871=== modified file 'unittests/calendar_test.cc'
1872--- unittests/calendar_test.cc 2010-06-05 21:39:51 +0000
1873+++ unittests/calendar_test.cc 2011-01-14 20:07:36 +0000
1874@@ -115,7 +115,7 @@
1875 {
1876 uint32_t year= 2038, month= 1, day= 19, hour= 3, minute= 14, second= 8;
1877
1878- ASSERT_FALSE(in_unix_epoch_range(year, month, day, hour, minute, second));
1879+ ASSERT_TRUE(in_unix_epoch_range(year, month, day, hour, minute, second));
1880 }
1881
1882 TEST(calendar_in_unix_epoch_range_test, InsideRange)
1883
1884=== modified file 'unittests/micro_timestamp_test.cc'
1885--- unittests/micro_timestamp_test.cc 2011-01-05 17:21:13 +0000
1886+++ unittests/micro_timestamp_test.cc 2011-01-14 20:07:36 +0000
1887@@ -71,7 +71,7 @@
1888
1889 result= micro_timestamp.is_valid();
1890
1891- ASSERT_FALSE(result);
1892+ ASSERT_TRUE(result);
1893 }
1894
1895 TEST_F(MicroTimestampTest, is_valid_InsideOfMicroTimestampRange_shouldReturn_True)
1896
1897=== modified file 'unittests/nano_timestamp_test.cc'
1898--- unittests/nano_timestamp_test.cc 2010-06-09 17:12:30 +0000
1899+++ unittests/nano_timestamp_test.cc 2011-01-14 20:07:36 +0000
1900@@ -71,7 +71,7 @@
1901
1902 result= nano_timestamp.is_valid();
1903
1904- ASSERT_FALSE(result);
1905+ ASSERT_TRUE(result);
1906 }
1907
1908 TEST_F(NanoTimestampTest, is_valid_InsideOfNanoTimestampRange_shouldReturn_True)
1909
1910=== modified file 'unittests/timestamp_test.cc'
1911--- unittests/timestamp_test.cc 2010-12-21 20:27:48 +0000
1912+++ unittests/timestamp_test.cc 2011-01-14 20:07:36 +0000
1913@@ -225,7 +225,7 @@
1914
1915 result= timestamp.is_valid();
1916
1917- ASSERT_FALSE(result);
1918+ ASSERT_TRUE(result);
1919 }
1920
1921 TEST_F(TimestampTest, is_valid_InsideOfTimestampRange_shouldReturn_True)

Subscribers

People subscribed via source and target branches