summaryrefslogtreecommitdiff
path: root/sql/sql_sequence.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.4 into 10.5Marko Mäkelä2020-07-211-0/+5
|\
| * Merge 10.3 into 10.4Marko Mäkelä2020-07-211-0/+4
| |\
| | * MDEV-16929 Assertion ... in close_thread_tables upon killing connectionMonty2020-07-211-0/+4
| | | | | | | | | | | | | | | Problem was that the code didn't handle a transaction created in innodb as part of a failed mysql_lock_tables()
* | | MDEV-19745 BACKUP STAGE BLOCK_DDL hangs on flush sequence tableMonty2020-06-141-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem was that FLUSH TABLES where trying to read latest sequence state which conflicted with a running ALTER SEQUENCE. Removed the reading of the state, when opening a table for FLUSH, as it's not needed in this case. Other thing: - Fixed a potential issue with concurrently running ALTER SEQUENCE where the later ALTER could potentially read old data
* | | Merge 10.4 into 10.5Marko Mäkelä2020-06-081-1/+12
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2020-06-081-1/+12
| |\ \ | | |/
| | * Don't allow ALTER TABLE ... ORDER BY on SEQUENCE objectsMonty2020-06-071-0/+5
| | | | | | | | | | | | | | | MDEV-19320 Sequence gets corrupted and produces ER_KEY_NOT_FOUND (Can't find record) after ALTER .. ORDER BY
| | * Don't allow illegal create options for SEQUENCEMonty2020-06-071-1/+7
| | | | | | | | | | | | | | | MDEV-19977 Assertion `(0xFUL & mode) == LOCK_S || (0xFUL & mode) == LOCK_X' failed in lock_rec_lock
* | | Merge 10.4 into 10.5Marko Mäkelä2020-05-311-2/+4
|\ \ \ | |/ /
| * | Merge 10.3 into 10.4Marko Mäkelä2020-05-261-2/+4
| |\ \ | | |/
| | * Don't crash if creating sequence under XAMonty2020-05-221-2/+4
| | | | | | | | | | | | | | | MDEV-22002 Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon CREATE TEMPORARY SEQUENCE under XA
* | | Aria will now register it's transactionsMonty2020-05-231-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-22531 Remove maria::implicit_commit() MDEV-22607 Assertion `ha_info->ht() != binlog_hton' failed in MYSQL_BIN_LOG::unlog_xa_prepare From the handler point of view, Aria now looks like a transactional engine. One effect of this is that we don't need to call maria::implicit_commit() anymore. This change also forces the server to call trans_commit_stmt() after doing any read or writes to system tables. This work will also make it easier to later allow users to have system tables in other engines than Aria. To handle the case that Aria doesn't support rollback, a new handlerton flag, HTON_NO_ROLLBACK, was added to engines that has transactions without rollback (for the moment only binlog and Aria). Other things - Moved freeing of MARIA_SHARE to a separate function as the MARIA_SHARE can be still part of a transaction even if the table has closed. - Changed Aria checkpoint to use the new MARIA_SHARE free function. This fixes a possible memory leak when using S3 tables - Changed testing of binlog_hton to instead test for HTON_NO_ROLLBACK - Removed checking of has_transaction_manager() in handler.cc as we can assume that as the transaction was started by the engine, it does support transactions. - Added new class 'start_new_trans' that can be used to start indepdendent sub transactions, for example while reading mysql.proc, using help or status tables etc. - open_system_tables...() and open_proc_table_for_Read() doesn't anymore take a Open_tables_backup list. This is now handled by 'start_new_trans'. - Split thd::has_transactions() to thd::has_transactions() and thd::has_transactions_and_rollback() - Added handlerton code to free cached transactions objects. Needed by InnoDB. squash! 2ed35999f2a2d84f1c786a21ade5db716b6f1bbc
* | | Change THD->transaction to a pointer to enable multiple transactionsMonty2020-05-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | All changes (except one) is of type thd->transaction. -> thd->transaction-> thd->transaction points by default to 'thd->default_transaction' This allows us to 'easily' have multiple active transactions for a THD object, like when reading data from the mysql.proc table
* | | Clean up and speed up interfaces for binary row loggingMonty2020-03-241-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MDEV-21605 Clean up and speed up interfaces for binary row logging MDEV-21617 Bug fix for previous version of this code The intention is to have as few 'if' as possible in ha_write() and related functions. This is done by pre-calculating once per statement the row_logging state for all tables. Benefits are simpler and faster code both when binary logging is disabled and when it's enabled. Changes: - Added handler->row_logging to make it easy to check it table should be row logged. This also made it easier to disabling row logging for system, internal and temporary tables. - The tables row_logging capabilities are checked once per "statements that updates tables" in THD::binlog_prepare_for_row_logging() which is called when needed from THD::decide_logging_format(). - Removed most usage of tmp_disable_binlog(), reenable_binlog() and temporary saving and setting of thd->variables.option_bits. - Moved checks that can't change during a statement from check_table_binlog_row_based() to check_table_binlog_row_based_internal() - Removed flag row_already_logged (used by sequence engine) - Moved binlog_log_row() to a handler:: - Moved write_locked_table_maps() to THD::binlog_write_table_maps() as most other related binlog functions are in THD. - Removed binlog_write_table_map() and binlog_log_row_internal() as they are now obsolete as 'has_transactions()' is pre-calculated in prepare_for_row_logging(). - Remove 'is_transactional' argument from binlog_write_table_map() as this can now be read from handler. - Changed order of 'if's in handler::external_lock() and wsrep_mysqld.h to first evaluate fast and likely cases before more complex ones. - Added error checking in ha_write_row() and related functions if binlog_log_row() failed. - Don't clear check_table_binlog_row_based_result in clear_cached_table_binlog_row_based_flag() as it's not needed. - THD::clear_binlog_table_maps() has been replaced with THD::reset_binlog_for_next_statement() - Added 'MYSQL_OPEN_IGNORE_LOGGING_FORMAT' flag to open_and_lock_tables() to avoid calculating of binary log format for internal opens. This flag is also used to avoid reading statistics tables for internal tables. - Added OPTION_BINLOG_LOG_OFF as a simple way to turn of binlog temporary for create (instead of using THD::sql_log_bin_off. - Removed flag THD::sql_log_bin_off (not needed anymore) - Speed up THD::decide_logging_format() by remembering if blackhole engine is used and avoid a loop over all tables if it's not used (the common case). - THD::decide_logging_format() is not called anymore if no tables are used for the statement. This will speed up pure stored procedure code with about 5%+ according to some simple tests. - We now get annotated events on slave if a CREATE ... SELECT statement is transformed on the slave from statement to row logging. - In the original code, the master could come into a state where row logging is enforced for all future events if statement could be used. This is now partly fixed. Other changes: - Ensure that all tables used by a statement has query_id set. - Had to restore the row_logging flag for not used tables in THD::binlog_write_table_maps (not normal scenario) - Removed injector::transaction::use_table(server_id_type sid, table tbl) as it's not used. - Cleaned up set_slave_thread_options() - Some more DBUG_ENTER/DBUG_RETURN, code comments and minor indentation changes. - Ensure we only call THD::decide_logging_format_low() once in mysql_insert() (inefficiency). - Don't annotate INSERT DELAYED - Removed zeroing pos_in_table_list in THD::open_temporary_table() as it's already 0
* | | perfschema mdl related instrumentation changesSergei Golubchik2020-03-101-4/+3
| | |
* | | Merge 10.4 into 10.5Marko Mäkelä2019-12-161-2/+5
|\ \ \ | |/ /
| * | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-12-091-2/+5
| |\ \ | | |/
| | * MDEV-15977 Assertion !thd->in_sub_stmt failed in trans_commit_stmtRobert Bindar2019-12-021-2/+5
| | |
* | | MDEV-20353 Add separate type handlers for unsigned integer data typesAlexander Barkov2019-08-151-9/+9
| | |
* | | Revert "MDEV-20342 Turn Field::flags from a member to a method"Alexander Barkov2019-08-141-2/+2
| | | | | | | | | | | | | | | | | | | | | This reverts commit e86010f909fb6b8c4ffd9d6df92991ac079e67e7. Reverting on Monty's request, as this change makes merging things from 10.5 to 10.2 much harder.
* | | MDEV-20342 Turn Field::flags from a member to a methodAlexander Barkov2019-08-141-2/+2
|/ /
* | Merge 10.3 into 10.4Marko Mäkelä2019-07-251-1/+1
|\ \ | |/
| * Fix typo and example in comment/KB for `setval()`Anel Husakovic2019-07-221-1/+1
| |
* | Merge 10.3 into 10.4Marko Mäkelä2019-04-171-2/+2
|\ \ | |/
| * Typo fix in sql_sequence.ccwayne2019-04-151-2/+2
| |
* | Merge 10.3 into 10.4Marko Mäkelä2018-09-111-2/+3
|\ \ | |/
| * Sequences with negative numbers and auto_increment_increment crashesMonty2018-08-301-2/+3
| | | | | | | | | | | | | | This also fixes MDEV-16313 Assertion `next_free_value % real_increment == offset' fails upon CREATE SEQUENCE in galera cluster Fixed by adding llabs() to assert. Also adjusted auto_increment_offset to mod auto_increment_increment.
* | MDEV-11953: support of brackets in UNION/EXCEPT/INTERSECT operationsOleksandr Byelkin2018-07-041-2/+2
|/
* Added missing write_unlock() in case of errorsMichael Widenius2018-05-141-0/+4
|
* Add likely/unlikely to speed up executionMonty2018-05-071-10/+10
| | | | | | | | | Added to: - if (error) - Lex - sql_yacc.yy and sql_yacc_ora.yy - In header files to alloc() calls - Added thd argument to thd_net_is_killed()
* MDEV-15732: Assertion `next_free_value % real_increment == offset && ↵Oleksandr Byelkin2018-04-261-2/+1
| | | | | | | next_free_value >= reserved_until' failed in sequence_definition::adjust_values upon SETVAL for sequence with INCREMENT 0 there was a problem with "next_free_value >= reserved_until" condition: SEQUENCE::set_value handle next_free_value & reserved_until after adjust_values() call, so it is incorect to put assert on it in adjust_values()
* Fix for MDEV-14831Monty2018-04-021-28/+58
| | | | | | | | | | | | | | | | MDEV-14831 CREATE OR REPLACE SEQUENCE under LOCK TABLE corrupts the sequence, causes ER_KEY_NOT_FOUND The problem was that sequence_insert didn't properly handle the case where there where there was a LOCK TABLE while creating the sequence. Fixed by opening the sequence table, for inserting the first record, in a new environment without any other open tables. Found also a bug in Locked_tables_list::reopen_tables() where the lock structure for the new tables was allocated in THD::mem_root, which causes crashes. This could cause problems with other create tables done under LOCK TABLES.
* MDEV-15149 Assert upon concurrent creating / querying sequencesMonty2018-03-291-0/+3
| | | | | | Problem was that sequence_insert closed and reopened the like table without proper locking. Fixed by ensuring that the like table is not reopened in sequence_insert
* Make possible to use clang on Windows (clang-cl)Vladislav Vaintroub2018-02-201-3/+3
| | | | | | -DWITH_ASAN can be used as well now, on x64 Fix many clang-cl warnings.
* Merge bb-10.2-ext into 10.3Marko Mäkelä2018-02-191-1/+1
|\
| * Fix for MDEV-15105 (memory loss with LOCK sequence)Monty2018-02-191-1/+1
| | | | | | | | | | MDEV 15105 "Bytes lost and Assertion `global_status_var.global_memory_used == 0' fails on shutdown after attempts to LOCK/RENAME sequence"
| * Fix warningsVladislav Vaintroub2018-01-051-1/+1
| |
* | Change C_STRING_WITH_LEN to STRING_WITH_LENMonty2018-01-301-1/+1
| | | | | | | | | | | | | | | | | | This preserves const str for constant strings Other things - A few variables where changed from LEX_STRING to LEX_CSTRING - Incident_log_event::Incident_log_event and record_incident where changed to take LEX_CSTRING* as an argument instead of LEX_STRING
* | Changed database, tablename and alias to be LEX_CSTRINGMonty2018-01-301-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was done in, among other things: - thd->db and thd->db_length - TABLE_LIST tablename, db, alias and schema_name - Audit plugin database name - lex->db - All db and table names in Alter_table_ctx - st_select_lex db Other things: - Changed a lot of functions to take const LEX_CSTRING* as argument for db, table_name and alias. See init_one_table() as an example. - Changed some function arguments from LEX_CSTRING to const LEX_CSTRING - Changed some lists from LEX_STRING to LEX_CSTRING - threads_mysql.result changed because process list_db wasn't always correctly updated - New append_identifier() function that takes LEX_CSTRING* as arguments - Added new element tmp_buff to Alter_table_ctx to separate temp name handling from temporary space - Ensure we store the length after my_casedn_str() of table/db names - Removed not used version of rename_table_in_stat_tables() - Changed Natural_join_column::table_name and db_name() to never return NULL (used for print) - thd->get_db() now returns db as a printable string (thd->db.str or "")
* | Merge bb-10.2-ext into 10.3Marko Mäkelä2017-11-301-2/+2
|\ \ | |/
| * MDEV-14404 Don't use LEX::check_exists in ALTER SEQUENCEAlexander Barkov2017-11-151-2/+2
| |
* | Fix warningsVladislav Vaintroub2017-11-271-1/+1
| |
* | Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3Alexander Barkov2017-10-301-15/+15
|\ \ | |/ | | | | TODO: enable MDEV-13049 optimization for 10.3
| * Reset table->record[1] early for sequences to fix comparision of innodb rowMonty2017-10-221-6/+0
| | | | | | | | Added also suppression of openssl warnings from valgrind
| * MDEV-13711 Assertion failure on CREATE TABLE .. LIKE <sequence>Aleksey Midenkov2017-10-221-1/+0
| | | | | | | | | | | | | | | | | | | | Fixes two issues: - Update assert in open_and_process_tables to handle sequences - Removed not needed and conflicting mdl_context.release_transactional_locks in sql_sequence.cc. The MDL lock is released at end of mysql_execute_command(). Signed-off-by: Monty <monty@mariadb.org>
| * MDEV-14092 NEXTVAL fails on slaveMichael Widenius2017-10-191-8/+15
| | | | | | | | | | | | The problem was that the code in replication didn't distinguish between a setval() failing because the stored sequence number was bigger than the current (should have been ignored) and a failure from the storage engine.
* | MDEV-13732 User with SELECT privilege can ALTER sequenceMonty2017-09-081-1/+1
| | | | | | | | Bug in privilege checking of sequences. Test case added.
* | Enusure that my_global.h is included firstMichael Widenius2017-08-241-0/+1
|/ | | | | | | | | | - 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
* Get rid of valgrind warning for sql_sequence tests.Monty2017-08-071-0/+6
| | | | | | | Added extra memcpy to get rid of valgrind warning for sequence tables with InnoDB. When reading a row from InnoDB, some of the bytes in the row are marked as not initialized. Needs to be investigated later, but this is a safe patch for now.
* MDEV-13393 SEQUENCE related crash when running concurrent I_S.TABLES and ↵Monty2017-08-071-7/+7
| | | | | | | FLUSH queries Problem was that SEQUENCE::table was shared among threads, which caused several threads to use the same object at the same time.