summaryrefslogtreecommitdiff
path: root/sql/sql_sequence.cc
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* Fixed sequences based on comments from Peter Gulutzan and Andrii NikitinMonty2017-06-031-11/+15
| | | | | | | - Changed names of SEQUENCE table columns to be more close to ANSI - Fixed error message for SHOW SEQUENCE non_existing_sequence - Allow syntax CACHE +1 - Fixed ALTER TABLE for TEMPORARY sequences.
* MDEV-12930 Testing SEQUENCE objectMonty2017-05-301-2/+6
| | | | | | | | | Fixed the following things from the above MDEV: - Ensure the user has INSERT privilege when generating new sequence values with NEXT VALUE FOR or SETVAL() - Fixed bug in InnoDB when generating several sequence values in one statement - Ensure that read_set is up to date before calling ha_sequence::ha_write_row() - This is only a potential bug with storage engines that trusts the column maps completely
* Add locks for sequence's to ensure that there is only one writer or many readersMonty2017-05-291-14/+45
| | | | | | This is needed for MyISAM and other storage engines which normally relies on THR_LOCK's to ensure that one is not writing the same block one could be reading from.
* Make SEQUENCE working with replicationMonty2017-05-231-25/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* MDEV-10139 Support for SEQUENCE objectsMonty2017-05-081-68/+252
| | | | | | | | | | - SETVAL(sequence_name, next_value, is_used, round) - ALTER SEQUENCE, including RESTART WITH Other things: - Added handler::extra() option HA_EXTRA_PREPARE_FOR_ALTER_TABLE to signal ha_sequence() that it should allow write_row statments. - ALTER ONLINE TABLE now works with SEQUENCE:s
* Fixed crash with SEQUENCE when using REPAIRMonty2017-05-081-5/+7
|
* MDEV-12695 Add Column_definition::type_handler()Alexander Barkov2017-05-051-12/+12
|
* Changing field::field_name and Item::name to LEX_CSTRINGMonty2017-04-231-12/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Benefits of this patch: - Removed a lot of calls to strlen(), especially for field_string - Strings generated by parser are now const strings, less chance of accidently changing a string - Removed a lot of calls with LEX_STRING as parameter (changed to pointer) - More uniform code - Item::name_length was not kept up to date. Now fixed - Several bugs found and fixed (Access to null pointers, access of freed memory, wrong arguments to printf like functions) - Removed a lot of casts from (const char*) to (char*) Changes: - This caused some ABI changes - lex_string_set now uses LEX_CSTRING - Some fucntions are now taking const char* instead of char* - Create_field::change and after changed to LEX_CSTRING - handler::connect_string, comment and engine_name() changed to LEX_CSTRING - Checked printf() related calls to find bugs. Found and fixed several errors in old code. - A lot of changes from LEX_STRING to LEX_CSTRING, especially related to parsing and events. - Some changes from LEX_STRING and LEX_STRING & to LEX_CSTRING* - Some changes for char* to const char* - Added printf argument checking for my_snprintf() - Introduced null_clex_str, star_clex_string, temp_lex_str to simplify code - Added item_empty_name and item_used_name to be able to distingush between items that was given an empty name and items that was not given a name This is used in sql_yacc.yy to know when to give an item a name. - select table_name."*' is not anymore same as table_name.* - removed not used function Item::rename() - Added comparision of item->name_length before some calls to my_strcasecmp() to speed up comparison - Moved Item_sp_variable::make_field() from item.h to item.cc - Some minimal code changes to avoid copying to const char * - Fixed wrong error message in wsrep_mysql_parse() - Fixed wrong code in find_field_in_natural_join() where real_item() was set when it shouldn't - ER_ERROR_ON_RENAME was used with extra arguments. - Removed some (wrong) ER_OUTOFMEMORY, as alloc_root will already give the error. TODO: - Check possible unsafe casts in plugin/auth_examples/qa_auth_interface.c - Change code to not modify LEX_CSTRING for database name (as part of lower_case_table_names)
* Fixed failure in mtr --ps sql_sequence.create sql_sequence.read_onlyMichael Widenius2017-04-091-0/+8
| | | | | | | | Problem was that we got an error in sequence_insert while opening the newly created sequence table in an prepared statement as the table id didn't match. Fixed by temporarly removing the reprepare observer during sequence_insert as there can never be a table missmatch in this case.
* MDEV-10139 Support for SEQUENCE objectsMonty2017-04-071-0/+670
Working features: CREATE OR REPLACE [TEMPORARY] SEQUENCE [IF NOT EXISTS] name [ INCREMENT [ BY | = ] increment ] [ MINVALUE [=] minvalue | NO MINVALUE ] [ MAXVALUE [=] maxvalue | NO MAXVALUE ] [ START [ WITH | = ] start ] [ CACHE [=] cache ] [ [ NO ] CYCLE ] ENGINE=xxx COMMENT=".." SELECT NEXT VALUE FOR sequence_name; SELECT NEXTVAL(sequence_name); SELECT PREVIOUS VALUE FOR sequence_name; SELECT LASTVAL(sequence_name); SHOW CREATE SEQUENCE sequence_name; SHOW CREATE TABLE sequence_name; CREATE TABLE sequence-structure ... SEQUENCE=1 ALTER TABLE sequence RENAME TO sequence2; RENAME TABLE sequence TO sequence2; DROP [TEMPORARY] SEQUENCE [IF EXISTS] sequence_names Missing features - SETVAL(value,sequence_name), to be used with replication. - Check replication, including checking that sequence tables are marked not transactional. - Check that a commit happens for NEXT VALUE that changes table data (may already work) - ALTER SEQUENCE. ANSI SQL version of setval. - Share identical sequence entries to not add things twice to table list. - testing insert/delete/update/truncate/load data - Run and fix Alibaba sequence tests (part of mysql-test/suite/sql_sequence) - Write documentation for NEXT VALUE / PREVIOUS_VALUE - NEXTVAL in DEFAULT - Ensure that NEXTVAL in DEFAULT uses database from base table - Two NEXTVAL for same row should give same answer. - Oracle syntax sequence_table.nextval, without any FOR or FROM. - Sequence tables are treated as 'not read constant tables' by SELECT; Would be better if we would have a separate list for sequence tables so that select doesn't know about them, except if refereed to with FROM. Other things done: - Improved output for safemalloc backtrack - frm_type_enum changed to Table_type - Removed lex->is_view and replaced with lex->table_type. This allows use to more easy check if item is view, sequence or table. - Added table flag HA_CAN_TABLES_WITHOUT_ROLLBACK, needed for handlers that want's to support sequences - Added handler calls: - engine_name(), to simplify getting engine name for partition and sequences - update_first_row(), to be able to do efficient sequence implementations. - Made binlog_log_row() global to be able to call it from ha_sequence.cc - Added handler variable: row_already_logged, to be able to flag that the changed row is already logging to replication log. - Added CF_DB_CHANGE and CF_SCHEMA_CHANGE flags to simplify deny_updates_if_read_only_option() - Added sp_add_cfetch() to avoid new conflicts in sql_yacc.yy - Moved code for add_table_options() out from sql_show.cc::show_create_table() - Added String::append_longlong() and used it in sql_show.cc to simplify code. - Added extra option to dd_frm_type() and ha_table_exists to indicate if the table is a sequence. Needed by DROP SQUENCE to not drop a table.