Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix for MDEV-14831
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.
- Loading branch information
Showing
6 changed files
with
104 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| drop table if exists s1, t1, t2; | ||
| CREATE SEQUENCE s1; | ||
| create table t1 (a int); | ||
| create table t2 (a int); | ||
| LOCK TABLE s1 WRITE, t1 write; | ||
| create or replace sequence s1; | ||
| select * from s1; | ||
| next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count | ||
| 1 1 9223372036854775806 1 1 1000 0 0 | ||
| select * from t1; | ||
| a | ||
| select * from t2; | ||
| ERROR HY000: Table 't2' was not locked with LOCK TABLES | ||
| unlock tables; | ||
| select * from t1; | ||
| a | ||
| select * from t2; | ||
| a | ||
| drop tables s1, t1, t2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --source include/have_sequence.inc | ||
| --source include/have_innodb.inc | ||
|
|
||
| --disable_warnings | ||
| drop table if exists s1, t1, t2; | ||
| --enable_warnings | ||
|
|
||
| # | ||
| # MDEV-14831 CREATE OR REPLACE SEQUENCE under LOCK TABLE corrupts the | ||
| # sequence, causes ER_KEY_NOT_FOUND | ||
| # | ||
| CREATE SEQUENCE s1; | ||
| create table t1 (a int); | ||
| create table t2 (a int); | ||
| LOCK TABLE s1 WRITE, t1 write; | ||
| create or replace sequence s1; | ||
| select * from s1; | ||
| select * from t1; | ||
| --error ER_TABLE_NOT_LOCKED | ||
| select * from t2; | ||
| unlock tables; | ||
| select * from t1; | ||
| select * from t2; | ||
| drop tables s1, t1, t2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters