summaryrefslogtreecommitdiff
path: root/sql-common
Commit message (Collapse)AuthorAgeFilesLines
* MDEV-16991 Rounding vs truncation for TIME, DATETIME, TIMESTAMPbb-10.4-mdev16991Alexander Barkov2018-11-261-0/+8
|
* MDEV-17776 CAST(x AS INTERVAL DAY_SECOND(N))Alexander Barkov2018-11-201-33/+42
|
* MDEV-17740 Extend EXTRACT(x AS DAY*) to understand long time intervalsAlexander Barkov2018-11-171-87/+255
|
* A cleanup for "MDEV-17477 Wrong result for TIME('-2001-01-01 10:20:30')"Alexander Barkov2018-11-161-25/+13
| | | | | | | | | | | | modified: ../sql-common/my_time.c Moving the logic that mixes warnings of two kinds: - those came from truncating garbage before the actual parsing of date/time - those came during the actual parsing from outside to inside of str_to_datetime_or_date_body(). This makes the caller code easier and removes some code duplication. We'll be adding more parsing functions for time intervals soon, so this change helps to avoid more duplicate code in the coming functions.
* MDEV-17712 Remove C_TIME_FUZZY_DATES, C_TIME_DATETIME_ONLY, C_TIME_TIME_ONLYAlexander Barkov2018-11-141-35/+69
|
* MDEV-17563 Different results using table or view when comparing values of ↵Alexander Barkov2018-11-081-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | time type MDEV-17625 Different warnings when comparing a garbage to DATETIME vs TIME - Splitting processes of data type conversion (to TIME/DATE,DATETIME) and warning generation. Warning are now only get collected during conversion (in an "int" variable), and are pushed in the very end of conversion (not in parallel). Warnings generated by the low level routines str_to_xxx() and number_to_xxx() can now be changed at the end, when TIME_FUZZY_DATES is applied, from "Invalid value" to "Truncated invalid value". Now "Illegal value" is issued only when the low level routine returned an error and TIME_FUZZY_DATES was not set. Otherwise, if the low level routine returned "false" (success), or if NULL was converted to a zero datetime by TIME_FUZZY_DATES, then "Truncated illegal value" is issued. This gives better warnings. - Methods Type_handler::Item_get_date() and Type_handler::Item_func_hybrid_field_type_get_date() now only convert and collect warning information, but do not push warnings. - Changing the return data type for Type_handler::Item_get_date() and Type_handler::Item_func_hybrid_field_type_get_date() from "bool" to "void". The conversion result (success vs error) can be checked by testing ltime->time_type. MYSQL_TIME_{NONE|ERROR} mean mean error, other values mean success. - Adding new wrapper methods Type_handler::Item_get_date_with_warn() and Type_handler::Item_func_hybrid_field_type_get_date_with_warn() to do conversion followed by raising warnings, and changing the code to call new Type_handler::***_with_warn() methods. - Adding a helper class Temporal::Status, a wrapper for MYSQL_TIME_STATUS with automatic initialization. - Adding a helper class Temporal::Warn, to collect warnings but without actually raising them. Moving a part of ErrConv into a separate class ErrBuff, and deriving both Temporal::Warn and ErrConv from ErrBuff. The ErrBuff part of Temporal::Warn is used to collect textual representation of the input data. - Adding a helper class Temporal::Warn_push. It's used to collect warning information during conversion, and automatically pushes warnings to the diagnostics area on its destructor time (in case of non-zero warning). - Moving more code from various functions inside class Temporal. - Adding more Temporal_hybrid constructors and protected Temporal methods make_from_xxx(), which convert and only collect warning information, but do not actually raise warnings. - Now the low level functions str_to_datetime() and str_to_time() always set status->warning if the return value is "true" (error). - Now the low level functions number_to_time() and number_to_datetime() set the "*was_cut" argument if the return value is "true" (error). - Adding a few DBUG_ASSERTs to make sure that str_to_xxx() and number_to_xxx() always set warnings on error. - Adding new warning flags MYSQL_TIME_WARN_EDOM and MYSQL_TIME_WARN_ZERO_DATE for the code symmetry. Before this change there was a special code path for (rc==true && was_cut==0) which was treated by Field_temporal::store_invalid_with_warning as "zero date violation". Now was_cut==0 always means that there are no any error/warnings/notes to be raised, not matter what rc is. - Using new Temporal_hybrid constructors in combination with Temporal::Warn_push inside str_to_datetime_with_warn(), double_to_datetime_with_warn(), int_to_datetime_with_warn(), Field::get_date(), Item::get_date_from_string(), and a few other places. - Removing methods Dec_ptr::to_datetime_with_warn(), Year::to_time_with_warn(), my_decimal::to_datetime_with_warn(), Dec_ptr::to_datetime_with_warn(). Fixing Sec6::to_time() and Sec6::to_datetime() to convert and only collect warnings, without raising warnings. Now warning raising functionality resides in Temporal::Warn_push. - Adding classes Longlong_hybrid_null and Double_null, to return both value and the "IS NULL" flag. Adding methods Item::to_double_null(), to_longlong_hybrid_null(), Item_func_hybrid_field_type::to_longlong_hybrid_null_op(), Item_func_hybrid_field_type::to_double_null_op(). Removing separate classes VInt and VInt_op, as they have been replaced by a single class Longlong_hybrid_null. - Adding a helper method Temporal::type_name_by_timestamp_type(), moving a part of make_truncated_value_warning() into it, and reusing in Temporal::Warn::push_conversion_warnings(). - Removing Item::make_zero_date() and Item_func_hybrid_field_type::make_zero_mysql_time(). They provided duplicate functionality. Now this code resides in Temporal::make_fuzzy_date(). The latter is now called for all Item types when data type conversion (to DATE/TIME/DATETIME) is involved, including Item_field and Item_direct_view_ref. This fixes MDEV-17563: Item_direct_view_ref now correctly converts NULL to a zero date when TIME_FUZZY_DATES says so.
* MDEV-17477 Wrong result for TIME('-2001-01-01 10:20:30') and numerous other ↵Alexander Barkov2018-10-201-100/+203
| | | | | | str-to-time conversion problems MDEV-17478 Wrong result for TIME('+100:20:30')
* MDEV-17417 TIME(99991231235959) returns 838:59:59 instead of 23:59:58Alexander Barkov2018-10-141-1/+1
|
* MDEV-17400 The result of TIME('42949672965959-01') depends on architectureAlexander Barkov2018-10-091-0/+7
| | | | | | | | - Fixing portabibily problems in sql-common/my_time.c (and additionally in sql/sql_time.cc) - Re-enabling func_time.test Now all new chunks added in MDEV-17351 work fine on all platforms.
* MDEV-17351 Wrong results for GREATEST,TIMESTAMP,ADDTIME with an out-of-range ↵Alexander Barkov2018-10-081-22/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TIME-alike argument Problems: Functions LEAST() and GREATEST() in TIME context, as well as functions TIMESTAMP(a,b) and ADDTIME(a,b), returned confusing results when the input TIME-alike value in a number or in a string was out of the TIME supported range. In case of TIMESTAMP(a,b) and ADDTIME(a,b), the second argument value could get extra unexpected digits. For example, in: ADDTIME('2001-01-01 00:00:00', 10000000) or ADDTIME('2001-01-01 00:00:00', '1000:00:00') the second argument was converted to '838:59:59.999999' with six fractional digits, which contradicted "decimals" previously set to 0 in fix_length_and_dec(). These unexpected fractional digits led to confusing function results. Changes: 1. GREATEST(), LEAST() - fixing Item_func_min_max::get_time_native() to respect "decimals" set by fix_length_and_dec(). If a value of some numeric or string time-alike argument goes outside of the TIME range and gets limited to '838:59:59.999999', it's now right-truncated to the correct fractional precision. - fixing, Type_handler_temporal_result::Item_func_min_max_fix_attributes() to take into account arguments' time_precision() or datetime_precision(), rather than rely on "decimals" calculated by the generic implementation in Type_handler::Item_func_min_max_fix_attributes(). This makes GREATEST() and LEAST() return better data types, with the same fractional precision with what TIMESTAMP(a,b) and ADDTIME(a,b) return for the same arguments, and with DATE(a) and TIMESTAMP(a). 2. Item_func_add_time and Item_func_timestamp It was semantically wrong to apply the limit of the TIME data type to the argument "b", which plays the role of "INTERVAL DAY TO SECOND" here. Changing the code to fetch the argument "b" as INTERVAL rather than as TIME. The low level routine calc_time_diff() now gets the interval value without limiting to '838:59:59.999999', so in these examples: ADDTIME('2001-01-01 00:00:00', 10000000) ADDTIME('2001-01-01 00:00:00', '1000:00:00') calc_time_diff() gets '1000:00:00' as is. The SQL function result now gets limited to the supported result data type range (datetime or time) inside calc_time_diff(), which now calculates the return value using the real fractional digits that came directly from the arguments (without the effect of limiting to the TIME range), so the result does not have any unexpected fractional digits any more. Detailed changes in TIMESTAMP() and ADDTIME(): - Adding a new class Interval_DDhhmmssff. It's similar to Time, but: * does not try to parse datetime format, as it's not needed for functions TIMESTAMP() and ADDTIME(). * does not cut values to '838:59:59.999999' The maximum supported Interval_DDhhmmssff's hard limit is 'UINT_MAX32:59:59.999999'. The maximum used soft limit is: - '87649415:59:59.999999' (in 'hh:mm:ss.ff' format) - '3652058 23:59:59.999999' (in 'DD hh:mm:ss.ff' format) which is a difference between: - TIMESTAMP'0001-01-01 00:00:00' and - TIMESTAMP'9999-12-31 23:59:59.999999' (the minimum datetime that supports arithmetic, and the maximum possible datetime value). - Fixing get_date() methods in the classes related to functions ADDTIME(a,b) and TIMESTAMP(a,b) to use the new class Interval_DDhhmmssff for fetching data from the second argument, instead of get_date(). - Fixing fix_length_and_dec() methods in the classes related to functions ADDTIME(a,b) and TIMESTAMP(a,b) to use Interval_DDhhmmssff::fsp(item) instead of item->time_precision() to get the fractional precision of the second argument correctly. - Splitting the low level function str_to_time() into smaller pieces to reuse the code. Adding a new function str_to_DDhhmmssff(), to parse "INTERVAL DAY TO SECOND" values. After these changes, functions TIMESTAMP() and ADDTIME() return much more predictable results, in terms of fractional digits, and in terms of the overall result. The full ranges of DATETIME and TIME values are now covered by TIMESTAMP() and ADDTIME(), so the following can now be calculated: SELECT ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59.999999'); -> '9999-12-31 23:59:59.999999' SELECT TIMESTAMP(DATE'0001-01-01', '87649415:59:59.999999') -> '9999-12-31 23:59:59.999999' SELECT ADDTIME(TIME'-838:59:59.999999', '1677:59:59.999998'); -> '838:59:59.999999'
* A cleanup for MDEV-17317 Add THD* parameter into Item::get_date() and ↵Alexander Barkov2018-10-011-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | 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-9/+8
| | | | control to "fuzzydate"
* MDEV-16536 Remove shared memory transportVladislav Vaintroub2018-08-201-312/+3
|
* Merge 10.2 into 10.3Marko Mäkelä2018-08-031-0/+4
|\
| * Merge 10.1 into 10.2Marko Mäkelä2018-08-021-0/+4
| |\
| | * Merge branch '10.0' into 10.1Oleksandr Byelkin2018-07-311-0/+4
| | |\
| | | * Merge 5.5 into 10.0Marko Mäkelä2018-07-301-0/+4
| | | |\
| | | | * Merge remote-tracking branch 'mysql/5.5' into 5.5Oleksandr Byelkin2018-07-291-0/+4
| | | | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We do not accept: 1. We did not have this problem (fixed earlier and better) d982e717aba67227ec40761a21a4211db91aa0e2 Bug#27510150: MYSQLDUMP FAILS FOR SPECIFIC --WHERE CLAUSES 2. We do not have such options (an DBUG_ASSERT put just in case) bbc2e37fe4e0ca3a7cfa1437a763dc43829e98e2 Bug#27759871: BACKRONYM ISSUE IS STILL IN MYSQL 5.7 3. Serg fixed it in other way in this release: e48d775c6f066add457fa8cfb2ebc4d5ff0c7613 Bug#27980823: HEAP OVERFLOW VULNERABILITIES IN MYSQL CLIENT LIBRARY
| | | | | * Bug#27980823: HEAP OVERFLOW VULNERABILITIES IN MYSQL CLIENT LIBRARYmysql-5.5.61Ivo Roylev2018-06-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | (cherry picked from commit b5b986b2cbd9a7848dc3f48e5c42b6d4e1e5fb22)
| | | | | * Bug#27759871: BACKRONYM ISSUE IS STILL IN MYSQL 5.7Arun Kuruvila2018-05-141-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Description:- Client applications establishes connection to server, which does not support SSL, via TCP even when SSL is enforced via MYSQL_OPT_SSL_MODE or MYSQL_OPT_SSL_ENFORCE or MYSQL_OPT_SSL_VERIFY_SERVER_CERT. Analysis:- There exist no error handling for catching client applications which enforces SSL connection to connect to a server which does not support SSL. Fix:- Error handling is done to catch above mentioned scenarios.
| | | | | * Bug#25471090: MYSQL USE AFTER FREEArun Kuruvila2018-02-122-9/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Description:- Mysql client crashes when trying to connect to a fake server which is sending incorrect packets. Analysis:- Mysql client crashes when it tries to read server version details. Fix:- A check is added in "red_one_row()".
| | | | | * Bug#26585560 - MYSQL DAEMON SHOULD CREATE ITS PID FILE ASShishir Jaiswal2017-12-021-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ROOT DESCRIPTION =========== If the .pid file is created at a world-writable location, it can be compromised by replacing the server's pid with another running server's (or some other non-mysql process) PID causing abnormal behaviour. ANALYSIS ======== In such a case, user should be warned that .pid file is being created at a world-writable location. FIX === A new function is_file_or_dir_world_writable() is defined and it is called in create_pid_file() before .pid file creation. If the location is world-writable, a relevant warning is thrown. NOTE ==== 1. PID file is always created with permission bit 0664, so for outside world its read-only. 2. Ignoring the case when permission is denied to get the dir stats since the .pid file creation would fail anyway in such a case.
| | | | | * BUG#25575605: SETTING --SSL-MODE=REQUIRED SENDS CREDENTIALS BEFORE VERIFYING ↵Ramil Kalimullin2017-03-101-2/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SSL CONNECTION MYSQL_OPT_SSL_MODE option introduced. It is set in case of --ssl-mode=REQUIRED and permits only SSL connection.
| | | | | * (no commit message)Nisha Gopalakrishnan2017-02-161-4/+7
| | | | | |
* | | | | | MDEV-16812 Semisync slave io thread segfaults at STOP-SLAVE handlingAndrei Elkin2018-07-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the semisync slave is being stopped with STOP SLAVE just after the master was shut down it attempts to reconnect with the master anyway per a semisync routine. Instead of an expected error the io-thread segfauls in mysql_real_connect() execution at !mysql->options.extension->async_context check trying to reach the extension's member while mysql->options.extension is actually and correctly NULL. Apparently not-NULL check for mysql->options.extension was missed and it's deployed by the patch to fix this issue. As a bonus it also tackles an assert Thread 0x7f16c72148c0 (LWP 24639) 0x00007f16c53b3bf2 in __GI___assert_fail (assertion=0x55a686117558 "global_status_var.global_memory_used == 0", file=0x55a6861171e8 "/home/andrei/MDB/WTs/10.3-clean/sql/mysqld.cc", line=2201, function=0x55a68611fa80 <mysqld_exit(int)::__PRETTY_FUNCTION__> "void mysqld_exit(int)") at assert.c:101 in a new test of the patch. The reason of the assert was insufficient cleanup in Repl_semi_sync_slave::kill_connection() which has a branch where a MYSQL instance was left out unfred.
* | | | | | Merge branch '10.2' into 10.3Sergei Golubchik2018-06-301-0/+4
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge branch '10.1' into 10.2Sergei Golubchik2018-06-211-0/+4
| |\ \ \ \ \ | | |/ / / /
| | * | | | Merge branch '10.0' into 10.1Vicențiu Ciorbaru2018-06-121-0/+4
| | |\ \ \ \ | | | |/ / /
| | | * | | Merge branch '5.5' into 10.0Vicențiu Ciorbaru2018-06-101-0/+4
| | | |\ \ \ | | | | |/ /
| | | | * | MDEV-10246 ssl-* config file options have no effect without mysql_ssl_set()Vladislav Vaintroub2018-06-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Partially revert 4ef74979969ac9339d0d42c11a6f26632e6776f1 that caused regression. Any ssl- option must imply use_ssl=1, even if mysql_set_ssl() was not used.
* | | | | | client.c: set connect attributes as late as possibleSergei Golubchik2018-06-031-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | just before they're sent to the client. Because mysql->host value is known only after the connection is established, and it's needed for the "_sever_host" attribute. This fixes ASAN use-after-free warning in rpl tests followup for ee8dfc688e8
* | | | | | User _server_host per discussion.twocode2018-05-111-2/+2
| | | | | |
* | | | | | Add host name to session attributes.Xiangyu Hu2018-05-111-0/+3
| | | | | |
* | | | | | Merge branch '10.2' into 10.3Sergei Golubchik2018-05-111-11/+19
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge branch '10.1' into 10.2Sergei Golubchik2018-05-101-11/+19
| |\ \ \ \ \ | | |/ / / /
| | * | | | Merge branch '10.0' into 10.1Sergei Golubchik2018-05-051-11/+19
| | |\ \ \ \ | | | |/ / /
| | | * | | Merge branch '5.5' into 10.0Sergei Golubchik2018-05-041-7/+15
| | | |\ \ \ | | | | |/ /
| | | | * | protocol: verify that number of rows is correctSergei Golubchik2018-05-041-7/+15
| | | | | |
| | | * | | Merge branch '5.5' into 10.0mariadb-10.0.35Sergei Golubchik2018-05-011-4/+4
| | | |\ \ \ | | | | |/ /
| | | | * | Use after free in authenticationSergei Golubchik2018-05-011-2/+2
| | | | | |
| | | | * | Bug#25471090: MYSQL USE AFTER FREESergei Golubchik2018-04-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | a better fix
| | | * | | Merge branch '5.5' into 10.0Sergei Golubchik2018-04-291-1/+1
| | | |\ \ \ | | | | |/ /
| | | | * | Bug#25471090: MYSQL USE AFTER FREESergei Golubchik2018-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fix another similar line followup for 7828ba0df488
* | | | | | Removed even more warning that was found with -WunusedMonty2018-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Removed test if HA_FT_WTYPE == HA_KEYTYPE_FLOAT as this never worked (HA_KEYTYPE_FLOAT is an enum) - Define HA_FT_MAXLEN to 126 (was tested before but never defined)
* | | | | | Merge 10.2 into 10.3Marko Mäkelä2018-04-241-1/+1
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge 10.1 into 10.2Marko Mäkelä2018-04-241-1/+1
| |\ \ \ \ \ | | |/ / / /
| | * | | | Merge 10.0 into 10.1Marko Mäkelä2018-04-241-1/+1
| | |\ \ \ \ | | | |/ / /
| | | * | | Merge branch '5.5' into 10.0Sergei Golubchik2018-04-201-1/+1
| | | |\ \ \ | | | | |/ /
| | | | * | Bug#25471090: MYSQL USE AFTER FREESergei Golubchik2018-04-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | in a specially crafted invalid packet, one can get end_pos < pos here
* | | | | | Merge remote-tracking branch '10.2' into 10.3Vicențiu Ciorbaru2018-04-121-3/+4
|\ \ \ \ \ \ | |/ / / / /