Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
276b0c8e
Commit
276b0c8e
authored
May 02, 2017
by
Monty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed crash with SEQUENCE when using REPAIR
parent
c619fbea
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
7 deletions
+86
-7
mysql-test/suite/sql_sequence/other.result
mysql-test/suite/sql_sequence/other.result
+42
-0
mysql-test/suite/sql_sequence/other.test
mysql-test/suite/sql_sequence/other.test
+29
-0
sql/ha_sequence.cc
sql/ha_sequence.cc
+5
-1
sql/sql_sequence.cc
sql/sql_sequence.cc
+7
-5
sql/sql_sequence.h
sql/sql_sequence.h
+3
-1
No files found.
mysql-test/suite/sql_sequence/other.result
0 → 100644
View file @
276b0c8e
#
# Create and check
#
create sequence s1 engine=innodb;
check table s1;
Table Op Msg_type Msg_text
test.s1 check note The storage engine for the table doesn't support check
select next value for s1;
next value for s1
1
flush tables;
check table s1;
Table Op Msg_type Msg_text
test.s1 check note The storage engine for the table doesn't support check
select next value for s1;
next value for s1
1001
flush tables;
repair table s1;
Table Op Msg_type Msg_text
test.s1 repair note The storage engine for the table doesn't support repair
select next value for s1;
next value for s1
2001
drop sequence s1;
create or replace sequence s1 engine=innodb;
select next value for s1;
next value for s1
1
repair table s1;
Table Op Msg_type Msg_text
test.s1 repair note The storage engine for the table doesn't support repair
check table s1;
Table Op Msg_type Msg_text
test.s1 check note The storage engine for the table doesn't support check
select next value for s1;
next value for s1
1001
select * from s1;
next_value min_value max_value start increment cache cycle round
2001 1 9223372036854775806 1 1 1000 0 0
drop sequence s1;
mysql-test/suite/sql_sequence/other.test
0 → 100644
View file @
276b0c8e
--
source
include
/
have_sequence
.
inc
--
source
include
/
have_innodb
.
inc
#
# Test various combinations of operations on sequence
#
--
echo
#
--
echo
# Create and check
--
echo
#
create
sequence
s1
engine
=
innodb
;
check
table
s1
;
select
next
value
for
s1
;
flush
tables
;
check
table
s1
;
select
next
value
for
s1
;
flush
tables
;
repair
table
s1
;
select
next
value
for
s1
;
drop
sequence
s1
;
create
or
replace
sequence
s1
engine
=
innodb
;
select
next
value
for
s1
;
repair
table
s1
;
check
table
s1
;
select
next
value
for
s1
;
select
*
from
s1
;
drop
sequence
s1
;
sql/ha_sequence.cc
View file @
276b0c8e
...
...
@@ -110,6 +110,8 @@ int ha_sequence::open(const char *name, int mode, uint flags)
if
((
error
=
table
->
s
->
sequence
->
read_initial_values
(
table
)))
file
->
ha_close
();
}
else
table
->
m_needs_reopen
=
true
;
}
DBUG_RETURN
(
error
);
}
...
...
@@ -189,11 +191,13 @@ int ha_sequence::write_row(uchar *buf)
DBUG_ASSERT
(
table
->
record
[
0
]
==
buf
);
row_already_logged
=
0
;
if
(
!
sequence
->
initialized
)
if
(
unlikely
(
sequence
->
initialized
==
SEQUENCE
::
SEQ_IN_PREPARE
)
)
{
/* This calls is from ha_open() as part of create table */
DBUG_RETURN
(
file
->
write_row
(
buf
));
}
if
(
unlikely
(
sequence
->
initialized
!=
SEQUENCE
::
SEQ_READY_TO_USE
))
DBUG_RETURN
(
HA_ERR_WRONG_COMMAND
);
/*
User tries to write a row
...
...
sql/sql_sequence.cc
View file @
276b0c8e
...
...
@@ -327,7 +327,9 @@ bool sequence_insert(THD *thd, LEX *lex, TABLE_LIST *table_list)
tmp_disable_binlog
(
thd
);
save_write_set
=
table
->
write_set
;
table
->
write_set
=
&
table
->
s
->
all_set
;
table
->
s
->
sequence
->
initialized
=
SEQUENCE
::
SEQ_IN_PREPARE
;
error
=
table
->
file
->
ha_write_row
(
table
->
record
[
0
]);
table
->
s
->
sequence
->
initialized
=
SEQUENCE
::
SEQ_UNINTIALIZED
;
reenable_binlog
(
thd
);
table
->
write_set
=
save_write_set
;
...
...
@@ -339,7 +341,7 @@ bool sequence_insert(THD *thd, LEX *lex, TABLE_LIST *table_list)
Sequence structure is up to date and table has one row,
sequence is now usable
*/
table
->
s
->
sequence
->
initialized
=
1
;
table
->
s
->
sequence
->
initialized
=
SEQUENCE
::
SEQ_READY_TO_USE
;
}
trans_commit_stmt
(
thd
);
...
...
@@ -353,7 +355,7 @@ bool sequence_insert(THD *thd, LEX *lex, TABLE_LIST *table_list)
/* Create a SQUENCE object */
SEQUENCE
::
SEQUENCE
()
:
initialized
(
0
),
all_values_used
(
0
),
table
(
0
)
SEQUENCE
::
SEQUENCE
()
:
all_values_used
(
0
),
initialized
(
SEQ_UNINTIALIZED
),
table
(
0
)
{
mysql_mutex_init
(
key_LOCK_SEQUENCE
,
&
mutex
,
MY_MUTEX_INIT_SLOW
);
}
...
...
@@ -376,11 +378,11 @@ int SEQUENCE::read_initial_values(TABLE *table_arg)
MDL_request
mdl_request
;
// Empty constructor!
DBUG_ENTER
(
"SEQUENCE::read_initial_values"
);
if
(
likely
(
initialized
))
if
(
likely
(
initialized
!=
SEQ_UNINTIALIZED
))
DBUG_RETURN
(
0
);
table
=
table_arg
;
mysql_mutex_lock
(
&
mutex
);
if
(
unlikely
(
!
initialized
))
if
(
likely
(
initialized
==
SEQ_UNINTIALIZED
))
{
MYSQL_LOCK
*
lock
;
bool
mdl_lock_used
=
0
;
...
...
@@ -419,7 +421,7 @@ int SEQUENCE::read_initial_values(TABLE *table_arg)
DBUG_RETURN
(
HA_ERR_LOCK_WAIT_TIMEOUT
);
}
if
(
!
(
error
=
read_stored_values
()))
initialized
=
1
;
initialized
=
SEQ_READY_TO_USE
;
mysql_unlock_tables
(
thd
,
lock
,
0
);
if
(
mdl_lock_used
)
thd
->
mdl_context
.
release_lock
(
mdl_request
.
ticket
);
...
...
sql/sql_sequence.h
View file @
276b0c8e
...
...
@@ -66,6 +66,7 @@ class sequence_definition :public Sql_alloc
class
SEQUENCE
:
public
sequence_definition
{
public:
enum
seq_init
{
SEQ_UNINTIALIZED
,
SEQ_IN_PREPARE
,
SEQ_READY_TO_USE
};
SEQUENCE
();
~
SEQUENCE
();
int
read_initial_values
(
TABLE
*
table
);
...
...
@@ -87,8 +88,9 @@ class SEQUENCE :public sequence_definition
}
longlong
next_value
(
TABLE
*
table
,
bool
second_round
,
int
*
error
);
bool
initialized
;
// If row has been read
bool
all_values_used
;
seq_init
initialized
;
private:
TABLE
*
table
;
mysql_mutex_t
mutex
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment