summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.1 into 10.2Marko Mäkelä2017-05-261-1/+1
|\
| * MDEV-12844 numerous issues in MASTER_GTID_WAIT()Sergei Golubchik2017-05-241-1/+1
| |
* | Merge 10.1 into 10.2Marko Mäkelä2017-05-221-1/+2
|\ \ | |/
| * Silence bogus GCC 7 warnings -Wimplicit-fallthroughMarko Mäkelä2017-05-171-1/+2
| | | | | | | | | | | | | | | | Do not silence uncertain cases, or fix any bugs. The only functional change should be that ha_federated::extra() is not calling DBUG_PRINT to report an unhandled case for HA_EXTRA_PREPARE_FOR_DROP.
* | Merge branch '10.1' into 10.2Sergei Golubchik2017-05-091-5/+4
|\ \ | |/ | | | | | | Revert commit db0917f68f, because the fix for MDEV-12696 is coming from 5.5 and 10.1 in this merge.
* | MDEV-12696 Crash with LOAD XML and non-updatable VIEW columnAlexander Barkov2017-05-051-4/+5
| |
* | Fixed the bug mdev-12373.Igor Babaev2017-04-241-0/+3
| | | | | | | | | | Condition pushdown into derived tables / views with side effects is not allowed.
* | Merge branch '10.1' into 10.2Sergei Golubchik2017-03-301-6/+2
|\ \ | |/
| * Merge 10.0 into 10.1Marko Mäkelä2017-03-031-6/+2
| |\
| | * MDEV-9573 'Stop slave' hangs on replication slaveMonty2017-02-281-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reason for this is that stop slave takes LOCK_active_mi over the whole operation while some slave operations will also need LOCK_active_mi which causes deadlocks. Fixed by introducing object counting for Master_info and not taking LOCK_active_mi over stop slave or even stop_all_slaves() Another benefit of this approach is that it allows: - Multiple threads can run SHOW SLAVE STATUS at the same time - START/STOP/RESET/SLAVE STATUS on a slave will not block other slaves - Simpler interface for handling get_master_info() - Added some missing unlock of 'log_lock' in error condtions - Moved rpl_parallel_inactivate_pool(&global_rpl_thread_pool) to end of stop_slave() to not have to use LOCK_active_mi inside terminate_slave_threads() - Changed argument for remove_master_info() to Master_info, as we always have this available - Fixed core dump when doing FLUSH TABLES WITH READ LOCK and parallel replication. Problem was that waiting for pause_for_ftwrl was not done when deleting rpt->current_owner after a force_abort.
* | | Merge branch '10.1' into 10.2Sergei Golubchik2017-02-101-4/+1
|\ \ \ | |/ /
| * | Merge branch '10.0' into 10.1mariadb-10.1.21Sergei Golubchik2017-01-171-4/+1
| |\ \ | | |/
| | * Merge branch '5.5' into 10.0Sergei Golubchik2017-01-171-5/+2
| | |\
| | | * bugfix: Item_func_min_max stored thd internallySergei Golubchik2017-01-151-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was used for get_datetime_value() and for thd->is_error(). But in fact, get_datetime_value() never used thd argument, because the cache ptr argument was NULL. And thd->is_error() check was not needed at that place at all.
* | | | MDEV-11597 Assertion when doing select from virtual column with impossible valueMonty2017-01-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Changed error handlers interface so that they can change error level in the handler - Give warnings and errors when calculating virtual columns - On insert/update error is fatal in strict mode. - SELECT and DELETE will only give a warning if a virtual field generates an error - Added VCOL_UPDATE_FOR_DELETE and VCOL_UPDATE_INDEX_FOR_REPLACE to be able to easily detect in update_virtual_fields() if we should use an error handler to mask errors or not.
* | | | New simpler bugfix for UPDATE and virtual BLOBsMonty2017-01-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When updating a table with virtual BLOB columns, the following might happen: - an old record is read from the table, it has no virtual blob values - update_virtual_fields() is run, vcol blob gets its value into the record. But only a pointer to the value is in the table->record[0], the value is in Field_blob::value String (but it doesn't have to be! it can be in the record, if the column is just a copy of another columns: ... b VARCHAR, c BLOB AS (b) ...) - store_record(table,record[1]), old record now is in record[1] - fill_record() prepares new values in record[0], vcol blob is updated, new value replaces the old one in the Field_blob::value - now both record[1] and record[0] have a pointer that points to the *new* vcol blob value. Or record[1] has a pointer to nowhere if Field_blob::value had to realloc. To fix this I have introduced a new String object 'read_value' in Field_blob. When updating virtual columns when a row has been read, the allocated value is stored in 'read_value' instead of 'value'. The allocated blobs for the new row is stored in 'value' as before. I also made, as a safety precaution, the insert delayed handling of blobs more general by using value to store strings instead of the record. This ensures that virtual functions on delayed insert should work in as in the case of normal insert. Triggers are now properly updating the read, write and vcol maps for used fields. This means that we don't need VCOL_UPDATE_FOR_READ_WRITE anymore and there is no need for any other special handling of triggers in update_virtual_fields(). To be able to test how many times virtual fields are invoked, I also relaxed rules that one can use local (@) variables in DEFAULT and non persistent virtual field expressions.
* | | | Removed usage of my_hash_search() with uninitialized HASH.Monty2017-01-111-1/+2
| | | | | | | | | | | | | | | | | | | | - Not documented on intened usage - Extra checking takes time for all HASH usage
* | | | Merge branch '10.1' into 10.2Sergei Golubchik2016-12-291-1/+2
|\ \ \ \ | |/ / /
| * | | Merge branch '10.0' into 10.1Sergei Golubchik2016-12-111-1/+2
| |\ \ \ | | |/ /
| | * | Merge branch '5.5' into 10.0Sergei Golubchik2016-12-091-1/+2
| | |\ \ | | | |/
| | | * MDEV-10713: signal 11 error on multi-table update - crash in ↵Sergei Golubchik2016-12-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | handler::increment_statistics or in make_select or assertion failure pfs_thread == ((PFS_thread*) pthread_getspecific((THR_PFS))) Different fix. Don't allow Item_func_sp to be evaluated unless all tables are prelocked. Extend the test case to make sure Item_func_sp::val_str is called (the table must have at least one row for that).
| | | * MDEV-10467 Assertion `nr >= 0.0' failed in Item_sum_std::val_real()Alexander Barkov2016-08-031-0/+3
| | | | | | | | | | | | | | | | Backporting MDEV-5781 from 10.0.
* | | | Item::print(): remove redundant parenthesesSergei Golubchik2016-12-121-11/+6
| | | | | | | | | | | | | | | | | | | | by introducing new Item::precedence() method and using it to decide whether parentheses are required
* | | | rename Virtual_column_info::expr_itemSergei Golubchik2016-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | now, when expr_str is gone, expr_item can be unambiguously renamed to expr.
* | | | bugfix: Item_func_get_system_var::print()Sergei Golubchik2016-12-121-1/+16
| | | |
* | | | Merge branch '10.1' into 10.2Sergei Golubchik2016-09-091-12/+4
|\ \ \ \ | |/ / /
| * | | Merge branch '10.0' into 10.1Sergei Golubchik2016-08-251-3/+4
| |\ \ \ | | |/ /
| | * | MDEV-10563 Crash during shutdown in Master_info_index::any_slave_sql_runningVicențiu Ciorbaru2016-08-231-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In well defined C code, the "this" pointer is never NULL. Currently, we were potentially dereferencing a NULL pointer (master_info_index). GCC v6 removes any "if (!this)" conditions as it assumes this is always a non-null pointer. In order to prevent undefined behaviour, check the pointer before dereferencing and remove the check within member functions.
| | * | Merge branch '5.5' into bb-10.0Sergei Golubchik2016-06-211-2/+3
| | |\ \ | | | |/
| | | * MDEV-9972 Least function retuns date in date time formatAlexander Barkov2016-06-081-2/+3
| | | |
| * | | Removing class Item_func_integer. It's not used since MySQL-5.0.Alexander Barkov2016-07-051-9/+0
| | | |
| * | | Partial backporting of 7b50447aa6d051b8d14bb01ef14802cb8ffee223Alexander Barkov2016-07-031-49/+2
| | | | | | | | | | | | | | | | | | | | | | | | (MDEV-9407, MDEV-9408) from 10.1 Needed to fix MDEV-10317 easier.
* | | | Merge branch '10.2-mdev9197-cons' of github.com:shagalla/serverIgor Babaev2016-08-311-0/+3
|\ \ \ \ | | | | | | | | | | | | | | | into branch 10.2-mdev9197.
| * | | | The consolidated patch for mdev-9197.Galina Shalygina2016-08-231-0/+3
| | | | |
* | | | | session-state dependent functions in DEFAULT/CHECK/vcolsSergei Golubchik2016-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * revert part of the db7edfe that moved calculations from fix_fields to val_str for Item_func_sysconst and descendants * mark session state dependent functions in check_vcol_func_processor() * re-run fix_fields for all such functions for every statement * fix CURRENT_USER/CURRENT_ROLE not to use Name_resolution_context (that is allocated on the stack in unpack_vcol_info_from_frm()) Note that NOW(), CURDATE(), etc use lazy initialization and do *not* force fix_fields to be re-run. The rule is: * lazy initialization is *not* allowed, if it changes metadata (so, e.g. DAYNAME() cannot use it) * lazy initialization is *preferrable* if it has side effects (e.g. NOW() sets thd->time_zone_used=1, so it's better to do it when the value of NOW is actually needed, not when NOW is simply prepared)
* | | | | Merge branch '10.1' into 10.2Sergei Golubchik2016-06-301-0/+2
|\ \ \ \ \ | | |/ / / | |/| | |
| * | | | Merge branch '10.0' into 10.1Sergei Golubchik2016-05-041-0/+2
| |\ \ \ \ | | | |/ / | | |/| |
| | * | | Merge branch '5.5' into 10.0Sergei Golubchik2016-04-261-11/+13
| | |\ \ \ | | | | |/ | | | |/|
| | | * | MDEV-9986 Full-text search of the utf8mb4 column causes crashSergei Golubchik2016-04-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | take into account that agg_arg_charsets_for_comparison() can replace Item_field's with Item_func_conv_charset
| | | * | MDEV-9745 Crash with CASE WHEN TRUE THEN COALESCE(CAST(NULL AS UNSIGNED)) ↵Alexander Barkov2016-04-201-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ELSE 4 END This is a backport of the patch for MDEV-9653 (fixed earlier in 10.1.13). The code in Item_func_case::fix_length_and_dec() did not calculate max_length and decimals properly. In case of any numeric result (DECIMAL, REAL, INT) a generic method Item_func_case::agg_num_lengths() was called, which could erroneously result into a DECIMAL item with max_length==0 and decimals==0, so the constructor of Field_new_decimals tried to create a field of DECIMAL(0,0) type, which caused a crash. Unlike Item_func_case, the code responsible for merging attributes in Item_func_coalesce::fix_length_and_dec() works fine: it has specific execution branches for all distinct numeric types and correctly creates a DECIMAL(1,0) column instead of DECIMAL(0,0) for the same set of arguments. The fix does the following: - Moves the attribute merging code from Item_func_coalesce::fix_length_and_dec() to a new method Item_func_hybrid_result_type::fix_attributes() - Removes the wrong code from Item_func_case::fix_length_and_dec() and reuses fix_attributes() in both Item_func_coalesce::fix_length_and_dec() and Item_func_case::fix_length_and_dec() - Fixes count_real_length() and count_decimal_length() to get an array of Items as an argument, instead of using Item::args directly. This is needed for Item_func_case::fix_length_and_dec(). - Moves methods Item_func::count_xxx_length() from "public" to "protected". - Removes Item_func_case::agg_num_length(), as it's not used any more. - Additionally removes Item_func_case::agg_str_length(), as it also was not used (dead code).
* | | | | better ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWEDSergei Golubchik2016-06-301-0/+13
| | | | |
* | | | | cleanup: change Item::walk() to take void* not uchar*Sergei Golubchik2016-06-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | and remove all related casts to uchar* also remove a couple of unused methods
* | | | | Preparing the CAST(..AS [UN]SIGNED) related code to fix a numberAlexander Barkov2016-06-291-65/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of bugs easier (MDEV-8919, MDEV-10304, MDEV-10305, MDEV-10307) - Adding Item::push_note_converted_to_negative_complement() and Item::push_note_converted_to_positive_complement() - Adding virtual methods Item::val_int_signed_typecast() and Item::val_int_unsigned_typecast() - Moving COLUMN_GET() related code from Item_func_signed::val_int() and Item_func_unsigned::val_int() to Item_dyncol_get::val_int_signed_typecast() and Item_dyncol_get::val_int_unsigned_typecast() - Moving Item_func_signed::val_int_from_str() to Item::val_int_from_str() and changing it to get the value from "this" instead of args[0]. The patch does not change behaviour. It's only to simplify fixing of the mentioned bugs. It will also simplify switching the CAST related code to use the type handler infrastructure easier (soon).
* | | | | MDEV-10138 Support for decimals up to 38 digitsMonty2016-06-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Decimals with float, double and decimal now works the following way: - DECIMAL_NOT_SPECIFIED is used when declaring DECIMALS without a firm number of decimals. It's only used in asserts and my_decimal_int_part. - FLOATING_POINT_DECIMALS (31) is used to mark that a FLOAT or DOUBLE was defined without decimals. This is regarded as a floating point value. - Max decimals allowed for FLOAT and DOUBLE is FLOATING_POINT_DECIMALS-1 - Clients assumes that float and double with decimals >= NOT_FIXED_DEC are floating point values (no decimals) - In the .frm decimals=FLOATING_POINT_DECIMALS are used to define floating point for float and double (31, like before) To ensure compatibility with old clients we do: - When storing float and double, we change NOT_FIXED_DEC to FLOATING_POINT_DECIMALS. - When creating fields from .frm we change for float and double FLOATING_POINT_DEC to NOT_FIXED_DEC - When sending definition for a float/decimal field without decimals to the client as part of a result set we convert NOT_FIXED_DEC to FLOATING_POINT_DECIMALS. - variance() and std() has changed to limit the decimals to FLOATING_POINT_DECIMALS -1 to not get the double converted floating point. (This was to preserve compatiblity) - FLOAT and DOUBLE still have 30 as max number of decimals. Bugs fixed: variance() printed more decimals than we support for double values. New behaviour: - Strings now have 38 decimals instead of 30 when converted to decimal - CREATE ... SELECT with a decimal with > 30 decimals will create a column with a smaller range than before as we are trying to preserve the number of decimals. Other changes - We are now using the obsolete bit FIELDFLAG_LEFT_FULLSCREEN to specify decimals > 31 - NOT_FIXED_DEC is now declared in one place - For clients, NOT_FIXED_DEC is always 31 (to ensure compatibility). On the server NOT_FIXED_DEC is DECIMAL_NOT_SPECIFIED (39) - AUTO_SEC_PART_DIGITS is taken from DECIMAL_NOT_SPECIFIED - DOUBLE conversion functions are now using DECIMAL_NOT_SPECIFIED instead of NOT_FIXED_DEC
* | | | | General spell fixing in comments and stringsOtto Kekäläinen2016-06-081-1/+1
| |_|_|/ |/| | |
* | | | Merge branch '10.2' into bb-10.2-mdev9543Sergei Petrunia2016-03-281-18/+20
|\ \ \ \
| * \ \ \ Merge branch '10.1' into 10.2Sergei Golubchik2016-03-231-18/+20
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.0' into 10.1Sergei Golubchik2016-03-211-2/+2
| | |\ \ \ | | | |/ /
| | | * | Fix spelling: occurred, execute, which etcOtto Kekäläinen2016-03-041-2/+2
| | | | |
| | * | | MDEV-9653 Assertion `length || !scale' failed in uint ↵Alexander Barkov2016-03-181-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | my_decimal_length_to_precision(uint, uint, bool) MDEV-9752 Wrong data type for COALEASCE(?,1) in prepared statements