summaryrefslogtreecommitdiff
path: root/sql
Commit message (Collapse)AuthorAgeFilesLines
* A post-merge fix: loadxml failed on Windows (due to a wrong parameter to ↵Alexander Barkov2017-05-271-6/+6
| | | | | | my_error). Fixing to pass item->name.str rather than item->name to my_error().
* Merge tag 'mariadb-10.2.6' into bb-10.2-extAlexander Barkov2017-05-2625-178/+262
|\
| * MDEV-10332 support for OpenSSL 1.1 and LibreSSLSergei Golubchik2017-05-092-43/+25
| | | | | | | | | | | | | | | | | | | | | | | | post-review fixes: * move all ssl implementation related ifdefs/defines to one file (ssl_compat.h) * work around OpenSSL-1.1 desire to malloc every EVP context by run-time checking that context allocated on the stack is big enough (openssl.c) * use newer version of the AWS SDK for OpenSSL 1.1 * use get_dh2048() function as generated by openssl 1.1 (viosslfactories.c)
| * MDEV-10332 support for OpenSSL 1.1 and LibreSSLGeorg Richter2017-05-092-1/+26
| | | | | | | | | | | | | | | | | | | | | | Initial support tested against OpenSSL 1.0.1, 1.0.2, 1.1.0, Yassl and LibreSSL not working on Windows with native SChannel support, due to wrong cipher mapping: Latter one requires push of CONC-241 fixes. Please note that OpenSSL 0.9.8 and OpenSSL 1.1.0 will not work: Even if the build succeeds, test cases will fail with various errors, especially when using different tls libraries or versions for client and server.
| * MDEV-12019 FLASHBACK: Server crashes in bitmap_bits_set / pack_row / ...Sachin Setiya2017-05-091-0/+2
| | | | | | | | | | | | | | Reason for this crash is that table->rpl_write_set is NULL. In Rows_log_event::do_apply_event we set table->rpl_write_set equal to table->write_set. But we do not set table->rpl_write_set in Old_rows_log_event::do_apply_event.
| * Merge branch '10.1' into 10.2Sergei Golubchik2017-05-0915-102/+155
| |\ | | | | | | | | | | | | 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 columnSergei Golubchik2017-05-091-12/+29
| | | | | | | | | | | | extend the fix from 5.5 (in read_sep_field()) to apply to read_xml_field()
| | * Merge branch '10.0' into 10.1Sergei Golubchik2017-05-082-6/+10
| | |\
| | | * Merge branch '5.5' into 10.0Sergei Golubchik2017-05-081-5/+7
| | | |\
| | | | * Fixed the bug mdev-12673.Igor Babaev2017-05-041-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch corrects the fix for the bug mdev-10693. It is critical for the function get_best_combination() not to call create_ref_for_key() for constant tables. This bug could manifest itself only in multi-table subqueries where one of the tables is accessed by a constant primary key.
| | | * | restore dependencies, removed in f2dc04abeaSergei Golubchik2017-05-031-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | otherwise make didn't know it needs to regenerate lex_hash.h when gen_lex_hash (that is sql_yacc.h, that is sql_yacc.yy) changes.
| | * | | Remove compile warning - "this" canot be nullDaniel Black2017-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | /home/travis/build/MariaDB/server/sql/sql_class.cc:1941:15: warning: 'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion] if (this && WSREP(this) && wsrep_thd_is_BF(this, FALSE)) ^~~~ ~~
| | * | | Merge branch '10.0' 10.1Sergei Golubchik2017-04-2812-62/+107
| | |\ \ \ | | | |/ /
| | | * | Merge branch '5.5' into bb-10.0-merge-5.5bb-10.0-merge-5.5Oleksandr Byelkin2017-04-251-6/+15
| | | |\ \ | | | | |/
| | | | * Fixed the bug mdev-10693.Igor Babaev2017-04-241-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code that chooses between materialization of a non-correlated IN subquery and its transformation into an EXISTS correlated subquery assumes that the execution plan for the outer select has been already built. However it was not always so if subqueries occurred in the expressions used for ref access to tables of the outer select. A call of the function create_ref_for_key() in get_best_combination() could trigger a premature execution of the above mentioned code when the execution plan structures for the outer select were not fully built. This could cause a crash of the server. The fix postpones the calls of create_ref_for_key() until the structures for the execution plan is fully built.
| | | * | MDEV-12495 Conditional jump depends on uninitialised value for: SELECT NULL ↵Alexander Barkov2017-04-221-1/+4
| | | | | | | | | | | | | | | | | | | | UNION geom_expression
| | | * | Fixed bug mdev-10053.Igor Babaev2017-04-211-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation of the walk method for the class Item_in_subselect was missing. As a result the method never traversed the left operand of any IN subquery predicate. Item_exists_subselect::exists2in_processor() that performs the Exist-To-In transformation calls the walk method to collect info on outer references. As the walk method did not traverse the left operands of the IN subqueries the outer references there were not taken into account and some subqueries that were actually correlated were marked as uncorrelated. It could lead to an attempt of the materialization of such a subquery. Also added a cleanup for some test cases merged from 5.5.
| | | * | Merge branch '5.5' into 10.0Sergei Golubchik2017-04-2110-55/+81
| | | |\ \ | | | | |/
| | | | * MDEV-12230 include/my_sys.h:600:43: error: unknown type name ↵Sergei Golubchik2017-04-202-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ‘PSI_file_key’" when -DWITHOUT_SERVER=1 cherry-pick 2c2bd8c155 (MDEV-12261 build failure without P_S) from 10.0
| | | | * compiler warningSergei Golubchik2017-04-201-1/+1
| | | | | | | | | | | | | | | | | | | | way-too-smart compilers don't like the "confusing indentation"
| | | | * Merge remote-tracking branch 'mysql/5.5' into 5.5mariadb-5.5.55Sergei Golubchik2017-04-118-54/+80
| | | | |\
| | | | | * Bug#25514146: DB_NAME IS IGNORED WHEN CREATING TABLE WITH DATA DIRECTORYDyre Tjeldvoll2017-02-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: CREATE TABLE using a fully qualified name with INDEX DIR/DATA DIR option reports an error when the current database is not SET. check_access() was incorrectly called with NULL as the database argument in a situation where the database name was not needed for the particular privilege being checked. This will cause the current database to be used, or an error to be reported if there is no current database. Fix: Call check_access() with any_db as the database argument in this situation.
| | | | | * Bug#23195404 EXCESSIVE MEMORY CAN BE USED BY THE QUOTE()Ajo Robert2017-02-231-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | STRING FUNCTION Fix: ======= Added code in QUOTE string function to honor max_allowed_packet.
| | | | | * WL#10287 - Backport WL#7195 to MySQL - 5.5Thayumanavar S2017-01-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is backport of WL#7195 to MySQL-5.5. In 5.5, we offload connection authentication from the acceptor thread to tp worker threads. Connection authentication happens in the acceptor thread that accepts the connection for thread pool plugin. Connection authentication involves exchanging packets with client and disk I/O which is time consuming. This can cause other client connections to starve and wait in the queue possibly increasing the connect latency and decreasing throughput. In the worst case, some connections could be dropped. n addition, SSL handshakes are quite expensive and can stall connections in the accept queue. This patch offloads connection authentication when thread pool plugin is used for client connection. Each thread group shall have a queue of connection_context objects, which represents new connections that need to be processed by thread group threads. The connection context is composed of THD object & list pointers for intrusive queue implementation. Whenever a new connection arrives, connection context object is created and added to the queue. A new connect handler thread is created or woken up to handle the authentication task. The worker thread loop is modified to process connection events on connect handler threads in addition to checking for query processing events. The initial number of connect handler threads is one per thread group and it is restricted to a maximum of 4 threads per thread group.
| | | | | * Bug #24595937: INCORRECT BEHAVIOR WHEN LOADING DATA TO VIEWSreeharsha Ramanavarapu2016-12-131-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue: ------ While using the LOAD statement to insert data into an updateable view, the check to verify whether a column is actually updatable is missing. Solution for 5.5 and 5.6: ------------------------- For a view whose column-list in specified in the LOAD command, this check is not performed. This fix adds the check. This is a partial backport of Bug#21097485. Solution for 5.7 and trunk: --------------------------- For a view whose column-list is specified in the LOAD command, this check is already performed. This fix adds the same check when no column-list is specified.
| | | | | * Bug #25111907: XML TEST FAILS WITH UNDEFINED BEHAVIORGeorgi Kodinov2016-12-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The XML parser position stack for each level is with a fixed depth. So a bounds check was done to ensure that this depth is not exceeded. But it was off by one (i.e. the size of the array was a valid index). Fixed by decreasing the allowable depth by one to match the maximum number of elements in the position stack.
| | | | | * (no commit message)Arun Kuruvila2016-11-284-26/+618
| | | | | |
| | | | | * Bug#25092566: CREATE TABLE WITH DATA DIRECTORY CLAUSE DOES NOT REQUIRE SPECIALDyre Tjeldvoll2016-11-243-3/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PRIVILEGES Require FILE privilege when creating tables using external data directory or index directory.
| | | | | * BUG#24437124: POSSIBLE BUFFER OVERFLOW ON CREATE TABLEKarthik Kamath2016-11-101-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ANALYSIS: ========= 'CREATE TABLE' query with a large value for 'CONNECTION' string reports an incorrect error. The length of connection string is stored in .frm in two bytes (max value= 65535). When the string length exceeds the max value, the length is truncated to fit the two bytes limit. Further processing leads to reading only a part of the string as the length stored is incorrect. The remaining part of the string is treated as engine type and hence results in an error. FIX: ==== We are now restricting the connection string length to 1024. An appropriate error is reported if the length crosses this limit. NOTE: ===== The 'PASSWORD' table option is documented as unused and processed within a dead code. Hence it will not cause similar issue with large strings.
| | | | * | Fixed the bug mdev-12429 and its duplicates mdev-12145 and mdev-9886.Igor Babaev2017-04-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also fixed a wrong result for a test case for mdev-7691 (the alternative one). The test cases for all these bug have materialized semi-joins used inside dependent sub-queries. The patch actually reverts the change inroduced by Monty in 2003. It looks like this change is not valid anymore after the implementation of semi-joins. Adjusted output from EXPLAIN for many other test cases.
| * | | | | MDEV-12290 Wrong timestamps in binary log causes replication issuesSachin Setiya2017-05-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Binlog_background_thread does not make a call to set_time(), And when we call binlog_checkpoint_log_event->write() , we write the wrong timestamp. In this patch we correct this by calling thd->set_time().
| * | | | | MDEV-12580 Wrong query result in join when using an index (Version > "10.2.3")Sergei Golubchik2017-05-081-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | JOIN_TAB::remove_redundant_bnl_scan_conds() removes select_cond from a JOIN_TAB if join cache is enabled, and tab->cache_select->cond is the equal to tab->select_cond. But after 8d99166c69 the code to initialize join cache was moved to happen much later than JOIN_TAB::remove_redundant_bnl_scan_conds(), and that code might, under certain conditions, revert to *not* using join cache (set_join_cache_denial()). If JOIN_TAB::remove_redundant_bnl_scan_conds() removes the WHERE condition from the JOIN_TAB and later set_join_cache_denial() disables join cache, we end up with no WHERE condition at all. Fix: move JOIN_TAB::remove_redundant_bnl_scan_conds() to happen after all possible set_join_cache_denial() calls.
| * | | | | MDEV-12669 Circular foreign keys cause a loop and OOM upon LOCK TABLESergei Golubchik2017-05-081-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | table_already_fk_prelocked() was looking for a table in the wrong list (not the complete list of prelocked tables, but only in its tail, starting from the current table - which is always empty for the last added table), so for circular FKs it kept adding same tables to the list indefinitely.
| * | | | | MDEV-10541: Faking the version string only works with MariaDB-ClientsVicențiu Ciorbaru2017-05-063-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our RPL_VERSION_HACK prefix caused MySQL clients to always report 5.5 major and minor versions, even if a specific fake version is passed via my.cnf or command line parameters. When a specific version is requested, don't employ the RPL_VERSION_HACK prefix within the server handshake packet.
| * | | | | Merge 10.1 into 10.2Marko Mäkelä2017-05-068-54/+63
| |\ \ \ \ \ | | |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | Also, include fixes by Vladislav Vaintroub to the aws_key_management plugin. The AWS C++ SDK specifically depends on OPENSSL_LIBRARIES, not generic SSL_LIBRARIES (such as YaSSL).
| | * | | | MDEV-9566 Server code changes in preparation for mariabackupVladislav Vaintroub2017-04-272-14/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Backup will load encryption plugins outside of mysqld. Thus, do not force loading MyISAM plugin in plugin_load. - init_signals() will be used in backup, make it global, not static.
| | * | | | MDEV-11663 Create services for functionality used by pluginsVladislav Vaintroub2017-04-273-5/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added service for - encryption (AES) - error reporting, e.g my_printf_error()
| | * | | | cleanup: don't include *.h files into SQL_SOURCESSergei Golubchik2017-04-271-14/+14
| | | | | |
| | * | | | bugfix: federated/replication did not increment bytes_received status variableSergei Golubchik2017-04-273-29/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | because mysql->net.thd was reset to NULL in mysql_real_connect() and thd_increment_bytes_received() didn't do anything. Fix: * set mysql->net.thd to current_thd instread. * remove the test for non-null THD from a very often used function thd_increment_bytes_received().
* | | | | | A cleanup for MDEV-11514, MDEV-11497, MDEV-11554, MDEV-11555 - IN and CASE ↵Alexander Barkov2017-05-252-32/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | type aggregation problems Removing cmp_item::get_comparator() and calling instead Type_handler::make_cmp_item(), which was earlier introduced by this patch: 74891ed257c431e5e8b4bc9479ca6456563d592f
* | | | | | Fixing a few data type related problems: MDEV-12875, MDEV-12886, MDEV-12916Alexander Barkov2017-05-255-39/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a joint patch fixing the following problems: MDEV-12875 Wrong VIEW column data type for COALESCE(int_column) MDEV-12886 Different default for INT and BIGINT column in a VIEW for a SELECT with ROLLUP MDEV-12916 Wrong column data type for an INT field of a cursor-anchored ROW variable All above problem happened because the global function ::create_tmp_field() called the top-level Item::create_tmp_field(), which made some tranformation for INT-result data types. For example, INT(11) became BIGINT(11), because 11 is a corner case and it's not known if it fits or does not fit into INT range, so Item::create_tmp_field() converted it to BIGINT(11) for safety. The main idea of this patch is to avoid such tranformations. 1. Fixing Item::create_tmp_field() not to have a special case for INT_RESULT. Item::create_tmp_field() is changed not to have a special case for INT_RESULT (which earlier made a decision based on Item's max_length). It now calls tmp_table_field_from_field_type() for INT_RESULT, therefore preserves the original data type (e.g. INT, YEAR) without conversion to BIGINT. This change is valid, because a number of recent fixes (e.g. in Item_func_int, Item_hybrid_func, Item_int, Item_splocal) guarantee that item->type_handler() now properly returns type_handler_long vs type_handler_longlong. So no adjustment by length is needed any more for Items returning INT_RESULT. After this change, Item::create_tmp_field() calls tmp_table_field_from_field_type() for all XXX_RESULT, except REAL_RESULT. 2. Fixing Item::create_tmp_field() not to have a special case for REAL_RESULT. Note, the reason for a special case for REAL_RESULT is to have a special constructor for Field_double(), forcing Field_real::not_fixed to be set to true. Taking into account that only Item_sum descendants actually need a special constructor call Field_double(not_fixed=true), not too loose precision when mixing individual rows to the aggregate result: - renaming Item::create_tmp_field() to Item_sum::create_tmp_field(). - changing Item::create_tmp_field() just to call tmp_table_field_from_field_type() for all XXX_RESULT types. A special case for REAL_RESULT in Item::create_tmp_field() is now gone. Item::create_tmp_field() is now symmetric for all XXX_RESULT types, and now just calls tmp_table_field_from_field_type(). 3. Fixing Item_func::create_field_for_create_select() not to have a special case for STRING_RESULT. After changes #1 and #2, the code in Item_func::create_field_for_create_select(), testing result_type(), becomes useless, because: now Item::create_tmp_field() and tmp_table_field_from_field_type() do exactly the same thing for all XXX_RESULT types for Item_func descendants: a. It calls tmp_table_field_from_field_type for STRING_RESULT directly. b. For other XXX_RESULT, it goes through Item::create_tmp_field(), which calls the global function ::create_tmp_field(), which calls item->create_tmp_field() for FUNC_ITEM, which calls tmp_table_field_from_field_type() again. So removing the virtual implementation of Item_func::create_field_for_create_select(). The inherited Item::create_field_for_create_select() now perfectly does the job, as it also calls tmp_table_field_from_field_type() for FUNC_ITEM, independently from XXX_RESULT type. 4. Taking into account #1 and #2, as well as some recent changes, removing virtual implementations: - Item_hybrid_func::create_tmp_field() - Item_hybrid_func::create_field_for_create_select() - Item_int_func::create_tmp_field() - Item_int_func::create_field_for_create_select() - Item_temporal_func::create_field_for_create_select() The derived versions from Item now perfectly work. 5. Moving a piece of code from create_tmp_field_from_item() to a new function create_tmp_field_from_item_finalize(), to reuse it in two places (see #6). 6. Changing the code responsible for BIT->INT/BIGIN tranformation (which is called for the cases when the created table, e.g. HEAP, does not fully support BIT) not to call create_tmp_field_from_item(), because the latter now calls tmp_table_field_from_field_type() instead of create_tmp_field() and thefore cannot do BIT transformation. So rewriting this code using a sequence of these calls: - item->type_handler_long_or_longlong() - handler->make_and_init_table_field() - create_tmp_field_from_item_finalize() 7. Miscelaneous changes: - Moving type_handler_long_or_longlong() from "protected" to "public", as it's now needed in the global function create_tmp_field(). 8. The above changes fixed MDEV-12875, MDEV-12886, MDEV-12916. So adding tests for these bugs.
* | | | | | More tests for SEQUENCE'sMonty2017-05-241-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Test with LOCK TABLES - Test mysqldump - Don't update rows for sequence tables if values doesn't change. This is needed as InnoDB gives an error for updates where values doesn't change.
* | | | | | MDEV-12546 Wrong metadata or data type for string user variablesAlexander Barkov2017-05-243-13/+32
| | | | | |
* | | | | | MDEV-12876 Wrong data type for CREATE..SELECT sp_varAlexander Barkov2017-05-232-18/+15
| | | | | |
* | | | | | A cleanup for the patch for MDEV-12852, MDEV-12853, MDEV-12869Alexander Barkov2017-05-233-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch broke expressions like CAST(1.0e+300 AS SIGNED INT) in binary protocol, e.g.: mtr --ps cast Short real numbers like 1.0e+300 can return huge values, so using args[0]->max_length is not reliable to choose properly the result type for Item_func_signed and Item_func_unsigned (between INT and BIGINT). Setting Item_[un]signed_typecast::max_length to MAX_BIGINT_WIDTH when doing CAST from FLOAT/DOUBLE, to force type_handler() return &type_handler_longlong rather than &type_handler_long.
* | | | | | Make SEQUENCE working with replicationMonty2017-05-2314-99/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Old sequence code forced row based replication for any statements that refered to a sequence table. What is new is that row based replication is now sequence aware: - NEXT VALUE is now generating a short row based event with only next_value and round being replicated. - Short row based events are now on the slave updated as trough SET_VALUE(sequence_name) - Full row based events are on the slave updated with a full insert, which is practically same as ALTER SEQUENCE. - INSERT on a SEQUENCE table does now a EXCLUSIVE LOCK to ensure that it is logged in binary log before any following NEXT VALUE calls. - Enable all sequence tests and fixed found bugs - ALTER SEQUENCE doesn't anymore allow changes that makes the next_value outside of allowed range - SEQUENCE changes are done with TL_WRITE_ALLOW_WRITE. Because of this one can generate a statement for MyISAM with both TL_WRITE_CONCURRENT_INSERT and TL_WRITE_ALLOW_WRITE. To fix a warning I had to add an extra test in thr_lock.c for this. - Removed UPDATE of SEQUENCE (no need to support this as we have ALTER SEQUENCE, which takes the EXCLUSIVE lock properly. - Removed DBUG_ASSERT() in MDL_context::upgrade_shared_lock. This was removed upstream in MySQL 5.6 in 72f823de453. - Simplified test in decided_logging_format() by using sql_command_flags() - Fix that we log DROP SEQUENCE correctly. - Fixed that Aria works with SEQUENCE
* | | | | | Fixing a few problems with data type and metadata for INT result functions ↵Alexander Barkov2017-05-236-36/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (MDEV-12852, MDEV-12853, MDEV-12869) This is a joint patch for: MDEV-12852 Out-of-range errors when CAST(1-2 AS UNSIGNED MDEV-12853 Out-of-range errors when CAST('-1' AS UNSIGNED MDEV-12869 Wrong metadata for integer additive and multiplicative operators 1. Fixing all Item_func_numhybrid descendants to set the precise data type handler (type_handler_long or type_handler_longlong) at fix_fields() time. This fixes MDEV-12869. 2. Fixing Item_func_unsigned_typecast to set the precise data type handler at fix_fields() time. This fixes MDEV-12852 and MDEV-12853. This is done by: - fixing Type_handler::Item_func_unsigned_fix_length_and_dec() and Type_handler_string_result::Item_func_unsigned_fix_length_and_dec() to properly detect situations when a negative epxression is converted to UNSIGNED. In this case, length of the result is now always set to MAX_BIGINT_WIDTH without trying to use args[0]->max_length, as very short arguments can produce very long result in such conversion: CAST(-1 AS UNSIGNED) -> 18446744073709551614 - adding a new virtual method "longlong Item::val_int_max() const", to preserve the old behavior for expressions like this: CAST(1 AS UNSIGNED) to stay under the INT data type (instead of BIGINT) for small positive integer literals. Using Item::unsigned_flag would not help, because Item_int does not set unsigned_flag to "true" for positive numbers. 3. Adding helper methods: * Item::type_handler_long_or_longlong() * Type_handler::type_handler_long_or_longlong() and reusing them in a few places, to reduce code duplication. 4. Making reorganation in create_tmp_field() and create_field_for_create_select() for Item_hybrid_func and descendants, to reduce duplicate code. They all now have a similar behavior in respect of creating fields. Only Item_func_user_var descendants have a different behavior. So moving the default behvior to Item_hybrid_func, and overriding behavior on Item_func_user_var level.
* | | | | | MDEV-12866 Out-of-range error with CREATE..SELECT..TO_SECONDS(NOW())Alexander Barkov2017-05-221-3/+3
| | | | | |
* | | | | | MDEV-12858 + MDEV+12859 + MDEV-12862 - a join patch fixing a few data type ↵Alexander Barkov2017-05-225-37/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | problems with CREATE..SELECT MDEV-12858 Out-of-range error for CREATE..SELECT unsigned_int_column+1 MDEV-12859 Out-of-range error for CREATE..SELECT @a:=EXTRACT(MINUTE_MICROSECOND FROM..) MDEV-12862 Data type of @a:=1e0 depends on the session character set 1. Moving a part of Item::create_tmp_field() into a new helper method Item::create_tmp_field_int() and reusing it in Item::create_tmp_field() and Item_func_signed::create_tmp_field(). Fixing the code in Item::create_tmp_field_int() to call Type_handler::make_table_field() instead of doing "new Field_long[long]" directly. This change revealed a problem reported in MDEV-12862. 2. Changing the "long vs longlong" cut-off length for - Item_func::create_tmp_field() - Item_sum::create_tmp_field() - Item_func_get_user_var::create_tmp_field() from MY_INT32_NUM_DECIMAL_DIGITS to (MY_INT32_NUM_DECIMAL_DIGITS - 2). This fixes MDEV-12858. After this change, the "convert_int_length" parameter to Item::create_tmp_field() is not needed any more, because (MY_INT32_NUM_DECIMAL_DIGITS - 2) is always passed. So removing the "convert_int_length" parameter. 3. Fixing Item::create_tmp_field() to pass max_char_length() instead of max_length to the constructor of Field_double(). This fixes MDEV-12862. 4. Additionally, fixing - Type_handler_{tiny|short|int24|long|longlong}::make_table_field() - Type_handler_{float|double}::make_table_field() to pass max_char_length() instead of max_length to Field contructors. This is needed by the change (1). 5. Adding new tests, and recording new correct results in the old tests in: - mysql-test/r/type_ranges.result - storage/tokudb/mysql-test/tokudb/r/type_ranges.result
* | | | | | MDEV-12860 Out-of-range error on CREATE..SELECT with a view using MAX and ↵Alexander Barkov2017-05-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | EXTRACT(MINUTE_MICROSECOND..)