summaryrefslogtreecommitdiff
path: root/sql/handler.h
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | MDEV-16144 Default TIMESTAMP clause for SELECT from versionedAleksey Midenkov2019-09-301-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Removed TIMESTAMP/TRANSACTION unit auto-detection in favor of default TIMESTAMP. Reasons: 1.1. rare practical use and doubtful advantage of such auto-detection; 1.2. it conflicts with MDEV-16226 (TRX_ID-based versioned tables performance improvement). Needless check_unit membership removed. 2. SQL: versioning type handling refactoring Vers_type_handler hierarchy stores versioning properties of type. virtual Type_handler::vers() accesses specialization of Vers_type_handler for specific type. virtual Vers_type_handler::kind() returns versioning kind (timestamp/trx_id). Removed Type_handler::Vers_history_point_check_unit() in favor of Type_handler::vers(). Renames: require_timestamp() -> require_timestamp_error() require_trx_id() -> require_trx_id_error() EDIT by Alexander Barkov (@abarkov): check_sys_fields() moved to Vers_type_handler::check_sys_fields()
* | | | Merge 10.4 into 10.5Marko Mäkelä2019-09-121-6/+10
|\ \ \ \ | |/ / /
| * | | Merge 10.3 into 10.4Marko Mäkelä2019-09-121-6/+10
| |\ \ \ | | |/ /
| | * | MDEV-16490: It's possible to make a system versioned table without any ↵Nikita Malyavin2019-09-091-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | versioning field * do not allow versioned table to be without versioned (non-system) fields * prohibit changing field versioning, when removing table versioning * handle CREATE...SELECT as well
* | | | Merge 10.4 into 10.5Marko Mäkelä2019-09-061-2/+2
|\ \ \ \ | |/ / /
| * | | Merge branch '10.3' into 10.4Sergei Golubchik2019-09-061-2/+2
| |\ \ \ | | |/ /
| | * | Merge 10.2 into 10.3Marko Mäkelä2019-09-041-2/+2
| | |\ \ | | | |/
| | | * MDEV-15326: InnoDB: Failing assertion: !other_lockMarko Mäkelä2019-09-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MySQL 5.7.9 (and MariaDB 10.2.2) introduced a race condition between InnoDB transaction commit and the conversion of implicit locks into explicit ones. The assertion failure can be triggered with a test that runs 3 concurrent single-statement transactions in a loop on a simple table: CREATE TABLE t (a INT PRIMARY KEY) ENGINE=InnoDB; thread1: INSERT INTO t SET a=1; thread2: DELETE FROM t; thread3: SELECT * FROM t FOR UPDATE; -- or DELETE FROM t; The failure scenarios are like the following: (1) The INSERT statement is being committed, waiting for lock_sys->mutex. (2) At the time of the failure, both the DELETE and SELECT transactions are active but have not logged any changes yet. (3) The transaction where the !other_lock assertion fails started lock_rec_convert_impl_to_expl(). (4) After this point, the commit of the INSERT removed the transaction from trx_sys->rw_trx_set, in trx_erase_lists(). (5) The other transaction consulted trx_sys->rw_trx_set and determined that there is no implicit lock. Hence, it grabbed the lock. (6) The !other_lock assertion fails in lock_rec_add_to_queue() for the lock_rec_convert_impl_to_expl(), because the lock was 'stolen'. This assertion failure looks genuine, because the INSERT transaction is still active (trx->state=TRX_STATE_ACTIVE). The problematic step (4) was introduced in mysql/mysql-server@e27e0e0bb75b4d35e87059816f1cc370c09890ad which fixed something related to MVCC (covered by the test innodb.innodb-read-view). Basically, it reintroduced an error that had been mentioned in an earlier commit mysql/mysql-server@a17be6963fc0d9210fa0642d3985b7219cdaf0c5: "The active transaction was removed from trx_sys->rw_trx_set prematurely." Our fix goes along the following lines: (a) Implicit locks will released by assigning trx->state=TRX_STATE_COMMITTED_IN_MEMORY as the first step. This transition will no longer be protected by lock_sys_t::mutex, only by trx->mutex. This idea is by Sergey Vojtovich. (b) We detach the transaction from trx_sys before starting to release explicit locks. (c) All callers of trx_rw_is_active() and trx_rw_is_active_low() must recheck trx->state after acquiring trx->mutex. (d) Before releasing any explicit locks, we will ensure that any activity by other threads to convert implicit locks into explicit will have ceased, by checking !trx_is_referenced(trx). There was a glitch in this check when it was part of lock_trx_release_locks(); at the end we would release trx->mutex and acquire lock_sys->mutex and trx->mutex, and fail to recheck (trx_is_referenced() is protected by trx_t::mutex). (e) Explicit locks can be released in batches (LOCK_RELEASE_INTERVAL=1000) just like we did before. trx_t::state: Document that the transition to COMMITTED is only protected by trx_t::mutex, no longer by lock_sys_t::mutex. trx_rw_is_active_low(), trx_rw_is_active(): Document that the transaction state should be rechecked after acquiring trx_t::mutex. trx_t::commit_state(): New function to change a transaction to committed state, to release implicit locks. trx_t::release_locks(): New function to release the explicit locks after commit_state(). lock_trx_release_locks(): Move much of the logic to the caller (which must invoke trx_t::commit_state() and trx_t::release_locks() as needed), and assert that the transaction will have locks. trx_get_trx_by_xid(): Make the parameter a pointer to const. lock_rec_other_trx_holds_expl(): Recheck trx->state after acquiring trx->mutex, and avoid a redundant lookup of the transaction. lock_rec_queue_validate(): Recheck impl_trx->state while holding impl_trx->mutex. row_vers_impl_x_locked(), row_vers_impl_x_locked_low(): Document that the transaction state must be rechecked after trx_mutex_enter(). trx_free_prepared(): Adjust for the changes to lock_trx_release_locks().
* | | | Don't copy uninitialized bytes when copying varstringsMonty2019-08-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using field_conv(), which is called in case of field1=field2 copy in fill_records(), full varstring's was copied, including unitialized bytes. This caused valgrind to compilain about usage of unitialized bytes when using Aria static length records. Fixed by not using memcpy when copying varstrings but instead just copy the real bytes.
* | | | Merge 10.4 into 10.5Marko Mäkelä2019-08-131-3/+4
|\ \ \ \ | |/ / /
| * | | MDEV-18266 Changing an index comment unnecessarily rebuilds indexbb-10.4-MDEV-18266-index-commentEugene Kosov2019-07-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | ALTER_CHANGE_INDEX_COMMENT: new handler flag added Compare_keys::EqualButComment: new outcome of compare_keys_but_name()
| * | | MDEV-19955 make argument of handler::ha_write_row() constEugene Kosov2019-07-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-19486 and one more similar bug appeared because handler::write_row() interface welcomes to modify buffer by storage engine. But callers are not ready for that thus bugs are possible in future. handler::write_row(): handler::ha_write_row(): make argument const
* | | | MDEV-20004 Move Field_geom from field.cc to sql_type_geom.ccAlexander Barkov2019-07-091-6/+0
| | | |
* | | | MDEV-19991 Turn I_S tables GEOMETRY_COLUMNS and SPATIAL_REF_SYS into a pluginAlexander Barkov2019-07-091-5/+1
| | | |
* | | | Merge remote-tracking branch 'origin/10.4' into 10.5Monty2019-06-271-11/+34
|\ \ \ \ | |/ / /
| * | | NFC: refactor Field::is_equal() and related stuffEugene Kosov2019-06-221-11/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make Field::is_equal() const and return bool as it's a naturally fitting type for it. Also it's agrument was narrowed to Column_definition. InnoDB can change type of some columns by itself. InnoDB-specific code used to reside in Field_xxx:is_equal() methods. Now engine-specific stuff was moved to a virtual methods of handler::can_convert{string,varstring,blob,geom}. These methods are called by Field::can_be_converted_by_engine() which is a double dispatch pattern. Some InnoDB-specific code still resides in compare_keys_but_name(). It should be moved from here someday to handler::compare_key_parts(...) or similar. IS_EQUAL_WITH_REINTERPRET_COMPATIBLE_CHARSET IS_EQUAL_WITH_REINTERPRET_COMPATIBLE_CHARSET_BUT_COLLATE: both was removed IS_EQUAL_NO, IS_EQUAL_YES are not needed now and should be removed along with deprecated handler::check_if_incompatible_data(). HA_EXTENDED_TYPES_CONVERSION: was removed as such logic is not needed now by server code. ALTER_COLUMN_EQUAL_PACK_LENGTH: was renamed to a more generic ALTER_COLUMN_TYPE_CHANGE_BY_ENGINE
* | | | Merge 10.4 into 10.5Marko Mäkelä2019-06-131-2/+5
|\ \ \ \ | |/ / /
| * | | Merge 10.3 into 10.4Marko Mäkelä2019-06-121-1/+1
| |\ \ \ | | |/ /
| | * | Merge 10.2 into 10.3Marko Mäkelä2019-06-111-1/+1
| | |\ \ | | | |/
| | | * Fix plugin linking on WindowsVladislav Vaintroub2019-06-031-1/+1
| | | |
| * | | MDEV-16249 CHECKSUM TABLE for a spider table is not parallel and saves all ↵Kentoku SHIBA2019-06-111-1/+4
| | | | | | | | | | | | | | | | | | | | data in memory in the spider head by default (#1328) add checksum_null for setting null value of checksum
* | | | MDEV-17709 Remove handlerton::stateRobert Bindar2019-06-061-8/+2
| | | |
* | | | Merge 10.4 into 10.5Marko Mäkelä2019-05-231-7/+13
|\ \ \ \ | |/ / /
| * | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-7/+13
| |\ \ \ | | |/ /
| | * | make method constEugene Kosov2019-05-171-2/+2
| | | | | | | | | | | | | | | | Closes #677
| | * | MDEV-15408 Confusing error message upon ER_VERS_FIELD_WRONG_TYPE while ↵Eugene Kosov2019-05-171-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | omitting UNSIGNED in BIGINT Improve diagnostics. Try to guess what type user tried to type.
| | * | Merge 10.2 into 10.3Marko Mäkelä2019-05-141-0/+6
| | |\ \ | | | |/
| | | * MDEV-19158: MariaDB 10.2.22 is writing duplicate entries into binary logSujatha2019-05-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: ======== We have a Master/Master Setup on two servers, but are only writing to one of those servers (so it is essentially Master/Slave) We upgraded from 10.1.* to 10.2.22 last week and starting with the upgrade, we are getting duplicate key errors on the slave. BINLOG=mixed. Analysis: ========= This issue happens with LOCK TABLES and binlog_format=MIXED combination. When an UNSAFE statement is encountered in 'MIXED' mode, it is logged in the form of 'ROW' format. For all the tables that are part of LOCK TABLES list their table maps are written into the binary log. For each table in the list a check is done to see if 'check_table_binlog_row_based_done' flag is set or not. If it is not set a check process is initiated to see if table qualifies for row based binary logging or not and 'check_table_binlog_row_based_done' is set. This flag will be cleared at the time of closing thread tables. But there can be special cases where the LOCK TABLES contains more number of tables but the unsafe query is actually using subset of tables from LOCK TABLES list. For example: LOCK TABLES locks t1,t2,t3 but the unsafe statement makes use of only two tables t1,t3. In this case the 'check_table_binlog_row_based_done' flag is enabled for table 't2' while writing table map, but 'close_thread_tables' function call will not reset this flag. Since the flag is not cleared for table 't2' even a safe statement which used t2 will be logged in the form of row based format. This leads to an assert on debug builds and causes duplicate entries in release builds. In release builds a statement is logged in the form of both ROW and STATEMENT format. This causes the slave to fail with duplicate key error. Fix: === During 'close_thread_tables' when LOCK TABLE modes are active "ha_reset" is done for all the tables which were part of current statement. As mentioned in the example 'ha_reset' is called for tables 't1' and 't3'. This will clear the 'check_table_binlog_row_based_done' flag. At this point add a check for the rest of the tables to see if 'check_table_binlog_row_based_done' is enabled or not. If enabled clear the flag.
| | * | 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
| | * | | | Merge branch '10.2' into 10.3Oleksandr Byelkin2019-05-121-2/+3
| | |\ \ \ \ | | | |/ / /
| | | * | | Merge branch '10.1' into 10.2Oleksandr Byelkin2019-05-041-2/+3
| | | |\ \ \ | | | | |/ /
| | | | * | Bug#28573894 ALTER PARTITIONED TABLE ADD AUTO_INCREMENT DIFF RESULT ↵Marko Mäkelä2019-04-251-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DEPENDING ON ALGORITHM For partitioned table, ensure that the AUTO_INCREMENT values will be assigned from the same sequence. This is based on the following change in MySQL 5.6.44: commit aaba359c13d9200747a609730dafafc3b63cd4d6 Author: Rahul Malik <rahul.m.malik@oracle.com> Date: Mon Feb 4 13:31:41 2019 +0530 Bug#28573894 ALTER PARTITIONED TABLE ADD AUTO_INCREMENT DIFF RESULT DEPENDING ON ALGORITHM Problem: When a partition table is in-place altered to add an auto-increment column, then its values are starting over for each partition. Analysis: In the case of in-place alter, InnoDB is creating a new sequence object for each partition. It is default initialized. So auto-increment columns start over for each partition. Fix: Assign old sequence of the partition to the sequence of next partition so it won't start over. RB#21148 Reviewed by Bin Su <bin.x.su@oracle.com>
| | * | | | cleanup: move checksum code to handler classSergei Golubchik2019-05-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | make live checksum to be returned in handler::info(), and slow table-scan checksum to be calculated in handler::checksum(). part of MDEV-16249 CHECKSUM TABLE for a spider table is not parallel and saves all data in memory in the spider head by default
* | | | | | Avoid not needed renames in ALTER TABLEMonty2019-05-231-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removed not needed table renames when doing ALTER TABLE when engine changes and both of the following is true: - Either new or old engine does not store the table in files - Neither old or new engine uses files from another engine We also skip renames when ALTER TABLE does an explicit rename This improves performance, especially for engines where rename is a slow operation (like the upcoming S3 engine)
* | | | | | Replace ha_notify_table_changed() with notify_tabledef_changed()Monty2019-05-231-19/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reason for the change was that ha_notify_table_changed() was done after table open when .frm had been replaced, which caused failure in engines that checks on open if .frm matches the engines table definition. Other changes: - Remove not needed open/close call at end of inline alter table. Some test that depended on the table beeing in the table cache after ALTER TABLE had to be updated.
* | | | | | Fixed FederatedX to follow THD ha_data protocolSergey Vojtovich2019-05-211-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use thd_get_ha_data()/thd_set_ha_data() which protect against plugin removal until it has THD ha_data. Do not reset THD ha_data in ha_federatedx::disconnect(), cleaner approach is to let ha_close_connection() do it. Part of MDEV-19515 - Improve connect speed
* | | | | | MDEV-307 review minor edits, add yacc_ora supportRobert Bindar2019-05-211-1/+2
| | | | | |
* | | | | | MDEV-307 Add functionality for database commentsGagan Goel2019-05-211-1/+2
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a new feature to the server to add comments at the database level. 1024 bytes is the maximum comment length allowed. If the comment length exceeds this limit, a new error/warning code 4144 is thrown, based on whether thd->is_strict_mode() is true/false. The database comment is also added to the db.opt file, as well as to the information_schema.schemata table.
* | | | | Just move, no code changes otherwise.Sergey Vojtovich2019-04-251-10/+0
| | | | | | | | | | | | | | | | | | | | Part of MDEV-7974 - backport fix for mysql bug#12161 (XA and binlog)
* | | | | MDEV-13301 Optimize DROP INDEX, ADD INDEX into RENAME INDEXEugene Kosov2019-04-031-17/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Just rename index in data dictionary and in InnoDB cache when it's possible. Introduce ALTER_INDEX_RENAME for that purpose so that engines can optimize such operation. Unused code between macro MYSQL_RENAME_INDEX was removed. compare_keys_but_name(): compare index definitions except for index names Alter_inplace_info::rename_keys: ha_innobase_inplace_ctx::rename_keys: vector of rename indexes fill_alter_inplace_info():: fills Alter_inplace_info::rename_keys
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-04-021-3/+5
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-15951 system versioning by trx id doesn't work with partitioningNikita Malyavin2019-03-291-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix partitioning for trx_id-versioned tables. `partition by hash`, `range` and others now work. `partition by system_time` is forbidden. Currently we cannot use row_start and row_end in `partition by`, because insertion of versioned field is done by engine's handler, as well as row_start/row_end's value set up, which is a transaction id -- so it's also forbidden. The drawback is that it's now impossible to use `partition by key()` without parameters for such tables, because it references row_start and row_end implicitly. * add handler::vers_can_native() * drop Table_scope_and_contents_source_st::vers_native() * drop partition_element::find_engine_flag as unused * forbid versioning partitioning for trx_id as not supported * adopt vers tests for trx_id partitioning * forbid any row_end referencing in `partition by` clauses,   including implicit `by key()`
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-03-251-1/+0
|\ \ \ \ \ | |/ / / /
| * | | | remove unused methodEugene Kosov2019-03-221-1/+0
| | | | |
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-03-201-3/+1
|\ \ \ \ \ | |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MDEV-17262 commit 26432e49d37a37d09b862bb49a021e44bdf4789c was skipped. In Galera 4, the implementation would seem to require changes to the streaming replication. In the tests archive.rnd_pos main.profiling, disable_ps_protocol for SHOW STATUS and SHOW PROFILE commands until MDEV-18974 has been fixed.
| * | | | Merge branch '10.2' into 10.3Sergei Golubchik2019-03-171-3/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.1' into 10.2Sergei Golubchik2019-03-151-1/+1
| | |\ \ \ | | | |/ /