summaryrefslogtreecommitdiff
path: root/sql/sql_time.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.3 into 10.4Marko Mäkelä2020-07-311-2/+2
|\
| * Merge 10.2 into 10.3Marko Mäkelä2020-07-311-4/+7
| |\
| | * MDEV-18042 Server crashes upon adding a non-null date column under ↵Nikita Malyavin2020-07-311-3/+6
| | | | | | | | | | | | | | | | | | NO_ZERO_DATE with ALGORITHM=INPLACE accept table_name and db_name instead of table_share in make_truncated_value_warning
* | | MDEV-20397 Support TIMESTAMP, DATETIME, TIME in ROUND() and TRUNCATE()Alexander Barkov2019-08-221-1/+1
| | |
* | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-1/+1
|\ \ \ | |/ /
| * | Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
| |\ \ | | |/
| | * Merge 10.1 into 10.2Marko Mäkelä2019-05-131-1/+1
| | |\
| | | * Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-111-1/+1
| | | |\
| | | | * Update FSF AddressVicențiu Ciorbaru2019-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | * Update wrong zip-code
| | | | * MDEV-10524 Assertion `arg1_int >= 0' failed in ↵Alexander Barkov2016-12-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Item_func_additive_op::result_precision() This change is a backport from 10.0 to 5.5 for: 1. The full patch for: MDEV-4841 Wrong character set of ADDTIME() and DATE_ADD() 9adb6e991ec87b65d04929f115d9d0c899e4ab19 2. A small fragment of: MDEV-5298 Illegal mix of collations on timestamp 03f6778d61a74bdd7d09103a16473a2a5624cf66 which overrides Item_temporal_hybrid_func::cmp_type(), and adds a new line into cache_temporal_4265.result.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2018-12-181-3/+4
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.2 into 10.3Marko Mäkelä2018-12-181-7/+8
| |\ \ \ \ | | |/ / /
| | * | | MDEV-14576 Include full name of object in message about incorrect value for ↵Alexey Botchkov2018-12-161-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | column. The error message modified. Then the TABLE_SHARE::error_table_name() implementation taken from 10.3, to be used as a name of the table in this message.
* | | | | MDEV-16991 Rounding vs truncation for TIME, DATETIME, TIMESTAMPbb-10.4-mdev16991Alexander Barkov2018-11-261-4/+11
| | | | |
* | | | | MDEV-17460 Move the code from Item_extract::val_int() to a new class ↵Alexander Barkov2018-10-161-1/+0
| | | | | | | | | | | | | | | | | | | | Extract_source
* | | | | MDEV-17216 Assertion `!dt->fraction_remainder(decimals())' failed in ↵Alexander Barkov2018-10-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Field_temporal_with_date::store_TIME_with_warning The problem happened because {{Field_xxx::store(longlong nr, bool unsigned_val)}} erroneously passed {{unsigned_flag}} to the {{usec}} parameter of this constructor: {code:cpp} Datetime(int *warn, longlong sec, ulong usec, date_conv_mode_t flags) {code} 1. Changing Time and Datetime constructors to accept data as Sec6 rather than as longlong/double/my_decimal, so it's not possible to do such mistakes in the future. Additional good effect of these changes: - This reduced some amount of similar code (minus ~35 lines). - The code now does not rely on the fact that "unsigned_flag" is not important inside Datetime(). The constructor always gets all three parts: sign, integer part, fractional part. The simple the better. 2. Fixing Field_xxx::store() to use the new Datetime constructor format. This change actually fixes the problem. 3. Adding "explicit" keyword to all Sec6 constructors, to avoid automatic hidden conversion from double/my_decimal to Sec6, as well as from longlong/ulonglong through double to Sec6. 4. Change#1 caused (as a dependency) changes in a few places with code like this: bool neg= nr < 0 && !unsigned_val; ulonglong value= m_neg ? (ulonglong) -nr : (ulonglong) nr; These fragments relied on a non-standard behavior with the operator "minus" applied to the lowest possible negative signed long long value. This can lead to different results depending on the platform and compilation flags. We have fixed such bugs a few times already. So instead of modifying the old wrong code to a new wrong code, replacing all such fragments to use Longlong_hybrid, which correctly handles this special case with -LONGLONG_MIN in its method abs(). This also reduced the amount of similar code (1 or 2 new lines instead 3 old lines in all 6 such fragments). 5. Removing ErrConvInteger(longlong nr, bool unsigned_flag= false) and adding ErrConvInteger(Longlong_hybrid) instead, to encourage use of safe Longlong_hybrid instead of unsafe pairs nr+neg. 6. Removing unused ErrConvInteger from Item_cache_temporal::get_date()
* | | | | A cleanup for MDEV-17317 Add THD* parameter into Item::get_date() and ↵Alexander Barkov2018-10-011-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | stricter data type control to "fuzzydate" Fixing C++ function check_date() to get the "fuzzydate" as date_mode_t rather than ulonglong, so conversion from date_time_t to ulonglong is now done inside C++ check_date(), and no conversion is needed in the callers' code. As an additional safety, modified the code not to pass TIME_FUZZY_DATE to the low level C functions: - check_date() - str_to_datetime() - str_to_time() - number_to_datetime() because TIME_FUZZY_DATE is known only on the C++ level, C functions do not know it. Soon we'll be adding more flags into the C++ level (i.e. to date_time_t), e.g. for rounding. It's a good idea to prevent passing C++ specific flags into pure C routines before this change. Asserts were added into the affected C functions to verify that the caller passed only known C level flags.
* | | | | MDEV-17317 Add THD* parameter into Item::get_date() and stricter data type ↵Alexander Barkov2018-09-281-13/+18
| | | | | | | | | | | | | | | | | | | | control to "fuzzydate"
* | | | | MDEV-17288 Replace Item_func::get_arg0_date() to Date/Datetime methodsAlexander Barkov2018-09-251-1/+1
| | | | |
* | | | | MDEV-17203 Move fractional second truncation from ↵Alexander Barkov2018-09-161-2/+0
| | | | | | | | | | | | | | | | | | | | Item_xxx_typecast::get_date() to Time and Datetime constructors
* | | | | MDEV-17175 Change Time/Datetime constructors to return warnings in ↵Alexander Barkov2018-09-121-9/+0
| | | | | | | | | | | | | | | | | | | | MYSQL_TIME_STATUS
* | | | | MDEV-16938 Move Item::get_time_with_conversion() to TimeAlexander Barkov2018-08-111-44/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The affected code is well covered by tests for MDEV-8766. Adding only the missing part: the old mode OLD_MODE_ZERO_DATE_TIME_CAST in combination with 0000-MM-00 and YYYY-00-00. The old mode in combination with 0000-00-DD was already covered, so was the new mode with all types of DATETIME values.
* | | | | MDEV-14032 SEC_TO_TIME executes side effect two timesAlexander Barkov2018-08-091-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Adding a helper class Sec6 to store (neg,seconds,microseconds) - Adding a helper class VSec6 (Sec6 with a flag for "IS NULL") - Wrapping related functions as methods of Sec6; * number_to_datetime() * number_to_time() * my_decimal2seconds() * Item::get_seconds() * A big piece of code in Item_func_sec_to_time::get_date() - Using the new classes in places where second-to-temporal conversion takes place: * Field_timestamp::store(double) * Field_timestamp::store(longlong) * Field_timestamp_with_dec::store_decimal(my_decimal) * Field_temporal_with_date::store(double) * Field_temporal_with_date::store(longlong) * Field_time::store(double) * Field_time::store(longlong) * Field_time::store_decimal(my_decimal) * Field_temporal_with_date::store_decimal(my_decimal) * get_interval_value() * Item_func_sec_to_time::get_date() * Item_func_from_unixtime::get_date() * Item_func_maketime::get_date() This change simplifies these methods and functions a lot. - Warnings are now sent at VSec6 initialization time, when the source data is available in its original data type representation. If Sec6::to_time() or Sec6::to_datetime() truncate data again during conversion to MYSQL_TIME, they send warnings, but only if no warnings were sent during VSec6 initialization. This helps prevents double warnings. The call for val_str() in Item_func_sec_to_time::get_date() is not needed any more, so it's removed. This change actually fixes the problem. As a good effect, FROM_UNIXTIME() and MAKETIME() now also send warnings in case if the seconds arguments is out of range. Previously these functions returned NULL silently. - Splitting the code in the global function make_truncated_value_warning() into a number of methods THD::raise_warning_xxxx(). This was needed to reuse the logic that chooses between: * ER_TRUNCATED_WRONG_VALUE * ER_WRONG_VALUE * ER_TRUNCATED_WRONG_VALUE_FOR_FIELD for non-temporal data types (Sec6). - Removing: * Item::get_seconds() * number_to_time_with_warn() as this code now resides inside methods of Sec6. - Cleanup (changes that are not directly related to the fix): * Removing calls for field_name_or_null() and passing NULL instead in Item_func_hybrid_field_type::get_date_from_{int|real}_op, because Item_func_hybrid_field_type::field_name_or_null() always returns NULL * Replacing a number of calls for make_truncated_value_warning() to calls for THD::raise_warning_xxx(). In these places we know that the execution went through a certain branch of make_truncated_value_warning(), (e.g. the exact error code is known, or field name is always NULL, or field name is always not-NULL). So calls for the entire make_truncated_value_warning() after splitting are not necessary.
* | | | | A cleanup for MDEV-16852Alexander Barkov2018-08-071-2/+2
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changing data types for: - seconds from longlong to ulonglong - microseconds from long to ulong in: - parameters of calc_time_diff() - parameters of calc_time_from_sec() - Members of Sec6_add This will help to reuse the code easier: all other functions use ulonglong+long for seconds/microsecond, e.g.: - number_to_time() - number_to_datetime() - number_to_datetime_with_warn() - Field_temporal_with_date::store_decimal() - my_decimal2seconds() - Item::get_seconds()
* | | | helper append_interval(String*)Sergei Golubchik2018-02-231-1/+3
| | | |
* | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2018-02-151-0/+4
|\ \ \ \
| * | | | MDEV-15310 Range optimizer does not work well for "WHERE temporal_column NOT ↵Alexander Barkov2018-02-141-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IN (const_list)" There were two problems related to the bug report: 1. Item_datetime::get_date() was not implemented. So execution went through val_int() followed by int-to-datetime or int-to-time conversion. This was the reason why the optimizer did not work well on data with fractional seconds. 2. Item_datetime::set() did not have a TIME specific code to mix months and days to hours after unpack_time(). This is why the optimizer did not work well with negative TIME values, as well as huge time values. Changes: 1. Overriding Item_datetime::get_date(), to return ltime. This fixes the problem N1. 2. Cleanup: Moving pack_time() and unpack_time() from sql-common/my_time.c and include/my_time.h to sql/sql_time.cc and sql/sql_time.h, as they are not needed on the client side. 3. Adding a new "enum_mysql_timestamp_type ts_type" parameter to unpack_time() and moving the TIME specific code to mix months and days with hours inside unpack_time(). Adding a new "ts_type" parameter to Item_datetime::set(), to pass it from the caller down to unpack_time(). So now the TIME specific code is automatically called from Item_datetime::set(). This fixes the problem N2. This change also helped to get rid of duplicate TIME specific code from other three places, where mixing month/days to hours was done immediately after unpack_time(). Moving the DATE specific code to zero hhmmssff from Item_func_min_max::get_date_native to inside unpack_time(), for symmetry. 4. Removing the virtual method in_vector::result_type(), adding in_vector::type_handler() instead. This helps to get result_type(), field_type(), mysql_timestamp_type() of an in_vector easier. Passing type_handler()->mysql_timestamp_type() as a new parameter to Item_datetime::set() inside in_temporal::value_to_item(). 5. Cleaup: Removing separate implementations of in_datetime::get_value() and in_time::get_value(). Adding a single implementation in_temporal::get_value() instead. Passing type_handler()->field_type() to get_value_internal().
* | | | | MDEV-15091 : Windows, 64bit: reenable and fix warning C4267 (conversion from ↵Vladislav Vaintroub2018-02-061-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'size_t' to 'type', possible loss of data) Handle string length as size_t, consistently (almost always:)) Change function prototypes to accept size_t, where in the past ulong or uint were used. change local/member variables to size_t when appropriate. This fix excludes rocksdb, spider,spider, sphinx and connect for now.
* | | | | System Versioning pre0.12Aleksey Midenkov2017-11-071-0/+1
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | Merge remote-tracking branch 'origin/archive/2017-10-17' into 10.3
| * | | | | IB: 0.2 part IVAleksey Midenkov2017-05-051-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * BEGIN_TS(), COMMIT_TS() SQL functions; * VTQ instead of packed stores secs + usecs like my_timestamp_to_binary() does; * versioned SELECT to IB is translated with COMMIT_TS(); * SQL fixes: - FOR_SYSTEM_TIME_UNSPECIFIED condition compares to TIMESTAMP_MAX_VALUE; - segfault fix #36: multiple execute of prepared stmt; - different tables to same stored procedure fix (#39) * Fixes of previous parts: ON DUPLICATE KEY, other misc fixes.
| * | | | | IB: 0.2 part IIAleksey Midenkov2017-05-051-0/+10
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * moved vers_notify_vtq() to commit phase; * low_level insert (load test passed); * rest of SYS_VTQ columns filled: COMMIT_TS, CONCURR_TRX; * savepoints support; * I_S.INNODB_SYS_VTQ adjustments: - limit to I_S_SYS_VTQ_LIMIT(10000) of most recent records; - CONCURR_TRX limit to I_S_MAX_CONCURR_TRX(100) with '...' truncation marker; - TIMESTAMP fields show fractions of seconds.
* | | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-10-041-1/+1
|\ \ \ \ \ | | |/ / / | |/| | |
| * | | | Merge remote-tracking branch 'origin/10.2' into bb-10.2-extAlexander Barkov2017-10-021-1/+1
| |\ \ \ \ | | | |/ / | | |/| |
| | * | | MDEV-13384 - misc Windows warnings fixedVladislav Vaintroub2017-09-281-1/+1
| | |/ /
* | | | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-09-251-1/+1
|\ \ \ \ | |/ / /
| * | | Fixing a few -Wconversion warningsAlexander Barkov2017-09-231-1/+1
| | | |
* | | | Enusure that my_global.h is included firstMichael Widenius2017-08-241-1/+0
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added sql/mariadb.h file that should be included first by files in sql directory, if sql_plugin.h is not used (sql_plugin.h adds SHOW variables that must be done before my_global.h is included) - Removed a lot of include my_global.h from include files - Removed include's of some files that my_global.h automatically includes - Removed duplicated include's of my_sys.h - Replaced include my_config.h with my_global.h
* | | Changing field::field_name and Item::name to LEX_CSTRINGMonty2017-04-231-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Benefits of this patch: - Removed a lot of calls to strlen(), especially for field_string - Strings generated by parser are now const strings, less chance of accidently changing a string - Removed a lot of calls with LEX_STRING as parameter (changed to pointer) - More uniform code - Item::name_length was not kept up to date. Now fixed - Several bugs found and fixed (Access to null pointers, access of freed memory, wrong arguments to printf like functions) - Removed a lot of casts from (const char*) to (char*) Changes: - This caused some ABI changes - lex_string_set now uses LEX_CSTRING - Some fucntions are now taking const char* instead of char* - Create_field::change and after changed to LEX_CSTRING - handler::connect_string, comment and engine_name() changed to LEX_CSTRING - Checked printf() related calls to find bugs. Found and fixed several errors in old code. - A lot of changes from LEX_STRING to LEX_CSTRING, especially related to parsing and events. - Some changes from LEX_STRING and LEX_STRING & to LEX_CSTRING* - Some changes for char* to const char* - Added printf argument checking for my_snprintf() - Introduced null_clex_str, star_clex_string, temp_lex_str to simplify code - Added item_empty_name and item_used_name to be able to distingush between items that was given an empty name and items that was not given a name This is used in sql_yacc.yy to know when to give an item a name. - select table_name."*' is not anymore same as table_name.* - removed not used function Item::rename() - Added comparision of item->name_length before some calls to my_strcasecmp() to speed up comparison - Moved Item_sp_variable::make_field() from item.h to item.cc - Some minimal code changes to avoid copying to const char * - Fixed wrong error message in wsrep_mysql_parse() - Fixed wrong code in find_field_in_natural_join() where real_item() was set when it shouldn't - ER_ERROR_ON_RENAME was used with extra arguments. - Removed some (wrong) ER_OUTOFMEMORY, as alloc_root will already give the error. TODO: - Check possible unsafe casts in plugin/auth_examples/qa_auth_interface.c - Change code to not modify LEX_CSTRING for database name (as part of lower_case_table_names)
* | Merge branch '10.0' into 10.1Sergei Golubchik2016-02-231-1/+2
|\ \
| * \ Merge branch '5.5' into 10.0Sergei Golubchik2016-02-151-1/+2
| |\ \ | | |/
| | * Merge branch 'mysql/5.5' into 5.5Sergei Golubchik2016-02-091-1/+2
| | |\ | | | | | | | | | | | | | | | | reverted about half of commits as either not applicable or outright wrong
| | | * Bug #21564557: INCONSISTENT OUTPUT FROM 5.5 AND 5.6Sreeharsha Ramanavarapu2015-12-311-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UNIX_TIMESTAMP(STR_TO_DATE('201506', "%Y%M" Issue: ----- When an invalid date is supplied to the UNIX_TIMESTAMP function from STR_TO_DATE, no check is performed before converting it to a timestamp value. SOLUTION: --------- Add the check_date function and only if it succeeds, proceed to the timestamp conversion. No warning will be returned for dates having zero in month/date, since partial dates are allowed. UNIX_TIMESTAMP will return only a zero for such values. The problem has been handled in 5.6+ with WL#946.
| | | * Updated/added copyright headersKent Boortz2011-06-301-1/+1
| | | |
| | | * WL#5030: Split and remove mysql_priv.hMats Kindahl2010-03-311-0/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch: - Moves all definitions from the mysql_priv.h file into header files for the component where the variable is defined - Creates header files if the component lacks one - Eliminates all include directives from mysql_priv.h - Eliminates all circular include cycles - Rename time.cc to sql_time.cc - Rename mysql_priv.h to sql_priv.h
* | | MDEV-8766 Wrong result for SELECT..WHERE LENGTH(time_column)=8 AND ↵Alexander Barkov2015-09-081-0/+61
| | | | | | | | | | | | time_column=TIMESTAMP'2001-01-01 10:20:31'
* | | MDEV-8336 The meaning of NO_ZERO_DATE is not clear for DATETIME.Alexander Barkov2015-07-081-2/+13
|/ / | | | | | | | | | | In some cases NO_ZERO_DATE did not allow datetime values with zero date part and non-zero time part (e.g. '0000-00-00 10:20:30.123456'). Allowing values of this kind in all known pieces of the code.
* | MDEV-6065 MySQL Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH ↵Sergei Golubchik2014-06-111-0/+1
| | | | | | | | | | | | TIME/DATETIME COMPARE" fix for ref like "indexed_time = datetime"
* | 5.5.38 mergeSergei Golubchik2014-06-061-1/+1
|\ \ | |/
| * Merge 5.3->5.5Alexander Barkov2014-06-041-1/+1
| |
* | 5.5 mergeSergei Golubchik2014-05-091-0/+3
|\ \ | |/