Commit graph

227 commits

Author SHA1 Message Date
Alexander Barkov
7ea9d1e692 MDEV-5458 RQG hits 'sql/tztime.cc:799: my_time_t sec_since_epoch(...):
Assertion `mon > 0 && mon < 13' failed.'
2014-01-27 13:15:40 +04:00
Alexander Barkov
d106dc0597 MDEV-5504 Server crashes in String::length on SELECT with MONTHNAME, GROUP BY, ROLLUP
The crash happened because Item_func_monthname was derived from
Item_func_month, so Item_func_monthname::is_null() did not work fine.
Backporting a change from 5.5: Item_func_monthname is now derived from
Item_str_func.
2014-01-24 16:50:39 +04:00
Alexander Barkov
b97b9536c7 MDEV-4857 Wrong result of HOUR('1 00:00:00')
modified:
  mysql-test/r/func_time.result
  mysql-test/t/func_time.test
  sql-common/my_time.c
  sql/item_func.h
  sql/item_timefunc.cc
  sql/mysql_priv.h
  sql/time.cc
2013-12-02 15:09:34 +04:00
Alexander Barkov
5464e904b6 MDEV-4861 TIME/DATETIME arithmetics does not preserve INTERVAL precision
Adding tests only.

The problem was earlier fixed by 
MDEV-4724 Some temporal functions do not preserve microseconds
2013-09-16 14:07:01 +04:00
Alexander Barkov
22c4a24961 MDEV-4870 Wrong values of CASE, COALESCE, IFNULL on a combination of different temporal types
Adding test cases from the bug report only.

The problem was earlier fixed by:
MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context

modified:
  mysql-test/r/func_time.result
  mysql-test/t/func_time.test
2013-09-16 13:52:13 +04:00
Alexander Barkov
6c9d983287 MDEV-4869 Wrong result of MAKETIME(0, 0, -0.1)
Adding a test case only.

The problem was fixed by:

  MDEV-4724 Some temporal functions do not preserve microseconds

modified:
  mysql-test/r/func_time.result
  mysql-test/t/func_time.test
2013-09-16 13:03:49 +04:00
Alexander Barkov
5d7b97b89e MDEV-4843 Wrong data type for TIMESTAMP('2001-01-01','10:10:10') 2013-09-16 10:14:41 +04:00
Alexander Barkov
cf9cc19e91 MDEV-4724 Some temporal functions do not preserve microseconds 2013-09-13 14:43:10 +04:00
Alexander Barkov
c2b38529a9 MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context 2013-09-09 15:32:25 +04:00
Alexander Barkov
4085836acf MDEV-4635 Crash in UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y'))
modified:
  mysql-test/r/func_time.result
  mysql-test/t/func_time.test
  sql/item_timefunc.cc
  sql/mysql_priv.h
2013-06-17 19:25:55 +04:00
Sergei Golubchik
1be4295617 MDEV-4293 Valgrind warnings (Conditional jump or move depends on uninitialised value) in remove_eq_conds on time functions with NULL argument
val_int() is expected to return 0 for NULL's
2013-03-20 16:13:00 +01:00
Sergei Golubchik
0536c506ff MDEV-437 Microseconds: In time functions precision is calculated modulo 256
store the precision in uint, not uint8
2012-08-30 09:05:27 +02:00
Sergei Golubchik
a3073ecd96 merge 2012-04-05 23:07:18 +02:00
Sergei Golubchik
dea3544b2d mysql-5.1.62 merge 2012-04-05 10:49:38 +02:00
Alexander Barkov
f8e924b467 BUG#13458237 - INCONSISTENT HANDLING OF INVALIDE DATES WITH ZERO DAY. SIMILAR TO '2009-10-00'
- Reverting the patch for Bug # 12584302
  The patch will be reverted in 5.1 and 5.5.
  The patch will not be reverted in 5.6, the change will
  be properly documented in 5.6.
- Backporting DBUG_ASSERT not to crash on '0000-01-00'
  (already fixed in mysql-trunk (5.6))
2012-01-24 13:00:13 +04:00
Michael Widenius
6d4224a31c Merge with 5.2.
no_error handling for select (used by INSERT ... SELECT) still needs to be fixed, but I will do that in a separate commit
2011-12-11 11:34:44 +02:00
Michael Widenius
a8d03ab235 Initail merge with MySQL 5.1 (XtraDB still needs to be merged)
Fixed up copyright messages.
2011-11-21 19:13:14 +02:00
Sergei Golubchik
11ebbabb08 sec_to_time() in the integer context was losing the sign of the result 2011-09-01 14:23:03 +04:00
Sergey Glukhov
3050742dd9 Bug#12584302 AFTER FIX FOR #12403504: ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0,
The problem is that TIME_FUZZY_DATE is explicitly used for get_arg0_date()
function in Item_date_typecast::get_date method. The fix is to use real
fuzzy_date value.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_timefunc.cc:
  use real fuzzy_date value
2011-07-27 12:34:25 +04:00
Sergei Golubchik
49874ff827 more buildbot fixes 2011-06-10 21:15:13 +02:00
Sergei Golubchik
c3f665dc66 bugfixes:
microsecond(TIME)
  alter table datetime<->datetime(6)
  max(TIME), mix(TIME) 

mysql-test/t/func_if.test:
  fix the test case of avoid overflow
sql/field.cc:
  don't use make_date() and make_time()
sql/field.h:
  correct eq_def() for temporal fields
sql/item.cc:
  move datetime caching from Item_cache_int
  to Item_cache_temporal
sql/item.h:
  move datetime caching from Item_cache_int
  to Item_cache_temporal
sql/item_func.cc:
  use existing helper methods, don't duplicate
sql/item_sum.cc:
  argument cache must use argument's cmp_type, not result_type.
sql/item_timefunc.cc:
  use existing methods, don't tuplicate.
  remove unused function.
  fix micorseconds() to support TIME argument
sql/mysql_priv.h:
  dead code
sql/time.cc:
  dead code
2011-06-09 17:23:39 +02:00
Sergei Golubchik
9b98cae4cc merge with 5.1-micro 2011-06-07 18:13:02 +02:00
Sergei Golubchik
4d128777dd revert a suggested "optimization" that introduced a bug
compilation error in mysys/my_getsystime.c fixed
some redundant code removed
sec_to_time, time_to_sec, from_unixtime, unix_timestamp, @@timestamp now
  use decimal, not double for numbers with a fractional part.
purge_master_logs_before_date() fixed
many bugs in corner cases fixed

mysys/my_getsystime.c:
  compilation failure fixed
sql/sql_parse.cc:
  don't cut corners. it backfires.
2011-06-06 20:28:15 +02:00
Michael Widenius
f197991f41 Merge with 5.1-microseconds
A lot of small fixes and new test cases.

client/mysqlbinlog.cc:
  Cast removed
client/mysqltest.cc:
  Added missing DBUG_RETURN
include/my_pthread.h:
  set_timespec_time_nsec() now only takes one argument
mysql-test/t/date_formats.test:
  Remove --disable_ps_protocl as now also ps supports microseconds
mysys/my_uuid.c:
  Changed to use my_interval_timer() instead of my_getsystime()
mysys/waiting_threads.c:
  Changed to use my_hrtime()
sql/field.h:
  Added bool special_const_compare() for fields that may convert values before compare (like year)
sql/field_conv.cc:
  Added test to get optimal copying of identical temporal values.
sql/item.cc:
  Return that item_int is equal if it's positive, even if unsigned flag is different.
  Fixed Item_cache_str::save_in_field() to have identical null check as other similar functions
  Added proper NULL check to Item_cache_int::save_in_field()
sql/item_cmpfunc.cc:
  Don't call convert_constant_item() if there is nothing that is worth converting.
  Simplified test when years should be converted
sql/item_sum.cc:
  Mark cache values in Item_sum_hybrid as not constants to ensure they are not replaced by other cache values in compare_datetime()
sql/item_timefunc.cc:
  Changed sec_to_time() to take a my_decimal argument to ensure we don't loose any sub seconds.
  Added Item_temporal_func::get_time() (This simplifies some things)
sql/mysql_priv.h:
  Added Lazy_string_decimal()
sql/mysqld.cc:
  Added my_decimal constants max_seconds_for_time_type, time_second_part_factor
sql/table.cc:
  Changed expr_arena to be of type CONVENTIONAL_EXECUTION to ensure that we don't loose any items that are created by fix_fields()
sql/tztime.cc:
  TIME_to_gmt_sec() now sets *in_dst_time_gap in case of errors
  This is needed to be able to detect if timestamp is 0
storage/maria/lockman.c:
  Changed from my_getsystime() to set_timespec_time_nsec()
storage/maria/ma_loghandler.c:
  Changed from my_getsystime() to my_hrtime()
storage/maria/ma_recovery.c:
  Changed from my_getsystime() to mmicrosecond_interval_timer()
storage/maria/unittest/trnman-t.c:
  Changed from my_getsystime() to mmicrosecond_interval_timer()
storage/xtradb/handler/ha_innodb.cc:
  Added support for new time,datetime and timestamp
unittest/mysys/thr_template.c:
  my_getsystime() -> my_interval_timer()
unittest/mysys/waiting_threads-t.c:
  my_getsystime() -> my_interval_timer()
2011-05-28 05:11:32 +03:00
Sergei Golubchik
f06cac336b post review changes 2
sql/event_parse_data.cc:
  don't use "not_used" variable
sql/item_timefunc.cc:
  Item_temporal_func::fix_length_and_dec()
  and other changes
sql/item_timefunc.h:
  introducing Item_timefunc::fix_length_and_dec()
sql/share/errmsg.txt:
  don't say "column X" in the error message that used not only for columns
2011-05-19 19:16:17 +02:00
Sergei Golubchik
8ddcd0cda8 post-review changes 1
include/my_time.h:
  remove duplicate defines.
  cast to ulonglong to avoid overflow
sql/field.cc:
  perform sign extension when reading packed TIME values
sql/item_cmpfunc.cc:
  when converting a string to a date for the purpose of comparing it with another date,
  we should ignore strict sql mode.
sql/item_timefunc.cc:
  better error message
sql/item_timefunc.h:
  limit decimals appropriately
sql/share/errmsg.txt:
  don't refer to an object as a "column" in error messages that are used not only for columns.
2011-05-19 19:01:46 +02:00
Sergey Glukhov
3201f92cb3 Bug#12403504 AFTER FIX FOR #11889186 : ASSERTION FAILED: DELSUM+(INT) Y/4-TEMP > 0
There are two problems:
1. There is a missing check for 'year' parameter(year can not be greater than 9999) in
   makedate function. fix: added check that year can not be greater than 9999.
2. There is a missing check for zero date in from_days() function.
   fix: added zero date check into Item_func_from_days::get_date()
   function.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_timefunc.cc:
  --added check that year can not be greater than 9999 for makedate() function
  --added zero date check into Item_func_from_days::get_date() function
2011-05-18 10:47:43 +04:00
Michael Widenius
e415ba0fb2 Merge with MySQL 5.1.57/58
Moved some BSD string functions from Unireg
2011-05-02 20:58:45 +03:00
Sergey Glukhov
a60c39a2ff Bug#11889186 60503: CRASH IN MAKE_DATE_TIME WITH DATE_FORMAT / STR_TO_DATE COMBINATION
calc_daynr() function returns negative result
if malformed date with zero year and month is used.
Attempt to calculate week day on negative value
leads to crash. The fix is return NULL for
'W', 'a', 'w' specifiers if zero year and month is used.
Additional fix for calc_daynr():
--added assertion that result can not be negative
--return 0 if zero year and month is used


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql-common/my_time.c:
  --added assertion that result can not be negative
  --return 0 if zero year and month is used
sql/item_timefunc.cc:
  eturn NULL for 'W', 'a', 'w' specifiers
  if zero year and month is used.
2011-04-27 11:35:57 +04:00
Sergey Glukhov
a7d383cbb8 Bug#11766124 59164: VALGRIND: UNINITIALIZED VALUE IN NUMBER_TO_DATETIME
Valgrind warning happens due to missing NULL value check in
Item::get_date. The fix is to add this check.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item.cc:
  added check for NULL value
2011-03-30 11:08:35 +04:00
Sergey Glukhov
3b7f044534 Bug#11766126 59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
Valgrind warning happens because null values check happens too late
in Item_func_month::val_str(after result string calculation).The fix
is to check null value before result string calculation.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_timefunc.h:
  check null value before result string calculation.
2011-03-30 11:00:41 +04:00
Sergey Glukhov
47885f552b Bug#11766087 59125: VALGRIND UNINITIALISED VALUE WARNING IN ULL2DEC, LONGLONG2DECIMAL
Valgrind warning happens due to missing NULL value check in
Item_func::val_decimal. The fix is to add this check.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_func.cc:
  added check for NULL value
2011-03-28 17:27:44 +04:00
Sergey Glukhov
d6125b27b3 Bug#11765216 58154: UNINITIALIZED VARIABLE FORMAT IN STR_TO_DATE FUNCTION
Valgrind warning happens due to uninitialized cached_format_type field
which is used later in Item_func_str_to_date::val_str method.
The fix is to init cached_format_type field.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_timefunc.cc:
  init cached_format_type field
2011-03-28 17:24:25 +04:00
Sergey Glukhov
d499851be0 Bug#11766112 59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...
Valgrind warining happens due to missing
'end of the string' check. The fix is to
check if we reached the end of the string.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_timefunc.cc:
  check if we reached the end of
  the string after leading spaces skipping.
2011-03-28 11:53:18 +04:00
Sergei Golubchik
e2d71ef3e6 ps-protocol fix 2011-03-19 15:49:36 +01:00
Sergei Golubchik
299b29b273 lp:738091 cast(timestamp() AS time returns NULL for 0000-00-00 00:00:00 in 5.1-micro 2011-03-19 15:19:05 +01:00
Sergei Golubchik
a67bf98f02 lp:738067 Crash in get_datetime_value() in 5.1-micro 2011-03-19 14:54:46 +01:00
Sergei Golubchik
c629477981 lp:737474 Wrong result with DAY(COALESCE(NULL)) in 5.1-micro
fix the return value of Item_func_coalesce::get_date()
2011-03-18 19:29:52 +01:00
Sergei Golubchik
5122e43a93 lp:737450 Second Assertion `item->null_value' failed in 5.1-micro
implement Item_func_min_max::get_date()
2011-03-18 19:23:32 +01:00
Sergei Golubchik
db9c46de40 number to time comparison 2011-03-18 13:50:39 +01:00
Sergei Golubchik
5ff5c4b8a3 lp:737111 Different behavior for TIMESTAMPADD with 0000-00-00 argument in 5.1-micro
respect fuzzydate flags in Item_*::get_date() methods
2011-03-18 13:43:33 +01:00
Sergei Golubchik
1a963822c8 lp:737104 Crash in DTCollation::set in 5.1-micro
and a different fix for lp:736370

cache temporal expression in Item_cache_int, not in Item_string.
invoke get_datetime_value() to create a correct Item_cache_int.
Implement Item_cache_int::clone, as it's a proper constant
2011-03-17 22:38:34 +01:00
Sergei Golubchik
684405e741 lp:737092 Assertion `item->null_value' failed in get_datetime_value in 5.1-micro
Implement Item_func_coalesce::get_date()
2011-03-17 22:04:45 +01:00
Sergei Golubchik
256185c50d lp:736370 Datetime functions in subquery context cause wrong result and bogus warnings in mysql-5.1-micro
Don't cache temporal value in an Item_string, it is compared differently.
2011-03-17 18:19:47 +01:00
Sergei Golubchik
d72f05fc5b lp:736791 Crash in make_truncated_value_warningwith LEAST()/GREATEST/COALESCE
and a test case for lp:736370 Datetime functions in subquery context cause wrong result
2011-03-17 15:57:04 +01:00
Sergei Golubchik
3c6ff364ca lp:731815 Crash/valgrind warning Item::send with 5.1-micro
Two problems:
* Item_func_convert_tz() did not tell args[0] that it needs
  TIME_NO_ZERO_IN_DATE result
* Item_func_timediff did not respect fuzzy_date limitations,
  truncated seconds when casting to signed long, resulting in
  invalid time value (hours, seconds = (uint)-1).
2011-03-09 11:59:47 +01:00
Sergei Golubchik
2c80662d23 lp:731103 Assertion `maybe_null && item->null_value' failed with ORDER BY LAST_DAY()
Item_func_last_day did not set mayby_null=1
2011-03-08 10:14:43 +01:00
Sergei Golubchik
b27b5793a0 followup for lp:730637
mysql-test/t/func_time.test:
  fixed wrong test case
sql-common/my_time.c:
  negative datetime is invalid.
  fix check_date() to reflect that.
2011-03-07 23:19:26 +01:00
Sergei Golubchik
30e5b4d719 lp:730637 - Valgrind warnings in 5.1-micro
sql/field.cc:
  initialize ltime completely
sql/filesort.cc:
  don't pack MYSQL_TIME if it's not initialized
  (safe here, but valgrind complains)
sql/item_cmpfunc.cc:
  don't pack MYSQL_TIME if it's not initialized
  (safe here, but valgrind complains)
sql/item_timefunc.cc:
  don't check MYSQL_TIME members if it's uninitialized
  (safe here, but valgrind complains)
sql/time.cc:
  use c_ptr_safe() instead of c_ptr()
  (make valgrind happy)
2011-03-07 21:57:17 +01:00
Sergei Golubchik
19a3c29d64 lp:730627 TIME_to_ulonglong: Assertion `0' failed in 5.1-micro on wrong argument to MAKETIME
correct the return value of Item_func_maketime::get_date()
2011-03-07 16:27:49 +01:00