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
b118f92b
Commit
b118f92b
authored
Feb 09, 2021
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views.
Enable the FLUSH TABLES for views. It works now.
parent
be8e51c4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
120 additions
and
16 deletions
+120
-16
mysql-test/main/flush-innodb.result
mysql-test/main/flush-innodb.result
+1
-1
mysql-test/main/flush-innodb.test
mysql-test/main/flush-innodb.test
+1
-1
mysql-test/main/flush.result
mysql-test/main/flush.result
+55
-5
mysql-test/main/flush.test
mysql-test/main/flush.test
+59
-5
sql/sql_reload.cc
sql/sql_reload.cc
+4
-2
sql/sql_yacc.yy
sql/sql_yacc.yy
+0
-2
No files found.
mysql-test/main/flush-innodb.result
View file @
b118f92b
...
...
@@ -60,7 +60,7 @@ DROP TABLE export;
CREATE VIEW v1 AS SELECT 1;
CREATE TEMPORARY TABLE t1 (a INT);
FLUSH TABLES v1 FOR EXPORT;
ERROR HY000: 'test.v1' is not of type 'BASE TABLE'
UNLOCK TABLES;
FLUSH TABLES t1 FOR EXPORT;
ERROR 42S02: Table 'test.t1' doesn't exist
FLUSH TABLES non_existent FOR EXPORT;
...
...
mysql-test/main/flush-innodb.test
View file @
b118f92b
...
...
@@ -93,8 +93,8 @@ DROP TABLE export;
CREATE
VIEW
v1
AS
SELECT
1
;
CREATE
TEMPORARY
TABLE
t1
(
a
INT
);
--
error
ER_WRONG_OBJECT
FLUSH
TABLES
v1
FOR
EXPORT
;
UNLOCK
TABLES
;
--
error
ER_NO_SUCH_TABLE
FLUSH
TABLES
t1
FOR
EXPORT
;
--
error
ER_NO_SUCH_TABLE
...
...
mysql-test/main/flush.result
View file @
b118f92b
...
...
@@ -295,16 +295,16 @@ create view v1 as select 1;
create view v2 as select * from t1;
create view v3 as select * from v2;
flush table v1, v2, v3 with read lock;
ERROR HY000: 'test.v1' is not of type 'BASE TABLE'
unlock tables;
flush table v1 with read lock;
ERROR HY000: 'test.v1' is not of type 'BASE TABLE'
unlock tables;
flush table v2 with read lock;
ERROR HY000: 'test.v2' is not of type 'BASE TABLE'
unlock tables;
flush table v3 with read lock;
ERROR HY000: 'test.v3' is not of type 'BASE TABLE'
unlock tables;
create temporary table v1 (a int);
flush table v1 with read lock;
ERROR HY000: 'test.v1' is not of type 'BASE TABLE'
unlock tables;
drop view v1;
create table v1 (a int);
flush table v1 with read lock;
...
...
@@ -556,6 +556,56 @@ UNLOCK TABLES;
DROP VIEW v1;
DROP TABLE t1;
#
# MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views.
#
create table t1 (a int);
insert into t1 values (1), (2), (3);
create view v1 as select * from t1;
create view v2 as select * from v1;
flush table v1 with read lock;
connect con1, localhost, root;
insert into v1 values (4);
connection default;
# Wait until INSERT starts to wait for FTWRL to go away.
select * from t1;
a
1
2
3
unlock tables;
connection con1;
connection default;
select * from t1;
a
1
2
3
4
flush table v2 with read lock;
connection con1;
insert into t1 values (5);
connection default;
# Wait until INSERT starts to wait for FTWRL to go away.
select * from t1;
a
1
2
3
4
unlock tables;
connection con1;
connection default;
select * from t1;
a
1
2
3
4
5
drop view v1, v2;
drop table t1;
disconnect con1;
#
# Test FLUSH THREADS
#
flush threads;
...
...
mysql-test/main/flush.test
View file @
b118f92b
...
...
@@ -377,17 +377,17 @@ create view v1 as select 1;
create
view
v2
as
select
*
from
t1
;
create
view
v3
as
select
*
from
v2
;
--
error
ER_WRONG_OBJECT
flush
table
v1
,
v2
,
v3
with
read
lock
;
--
error
ER_WRONG_OBJECT
unlock
tables
;
flush
table
v1
with
read
lock
;
--
error
ER_WRONG_OBJECT
unlock
tables
;
flush
table
v2
with
read
lock
;
--
error
ER_WRONG_OBJECT
unlock
tables
;
flush
table
v3
with
read
lock
;
unlock
tables
;
create
temporary
table
v1
(
a
int
);
--
error
ER_WRONG_OBJECT
flush
table
v1
with
read
lock
;
unlock
tables
;
drop
view
v1
;
create
table
v1
(
a
int
);
flush
table
v1
with
read
lock
;
...
...
@@ -669,6 +669,60 @@ UNLOCK TABLES;
DROP
VIEW
v1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views.
--
echo
#
create
table
t1
(
a
int
);
insert
into
t1
values
(
1
),
(
2
),
(
3
);
create
view
v1
as
select
*
from
t1
;
create
view
v2
as
select
*
from
v1
;
flush
table
v1
with
read
lock
;
connect
(
con1
,
localhost
,
root
);
--
send
insert
into
v1
values
(
4
)
--
sleep
1
connection
default
;
--
echo
# Wait until INSERT starts to wait for FTWRL to go away.
let
$wait_condition
=
select
count
(
*
)
=
1
from
information_schema
.
processlist
where
state
=
"Waiting for table metadata lock"
and
info
=
"insert into v1 values (4)"
;
--
source
include
/
wait_condition
.
inc
select
*
from
t1
;
unlock
tables
;
connection
con1
;
reap
;
connection
default
;
select
*
from
t1
;
flush
table
v2
with
read
lock
;
connection
con1
;
--
send
insert
into
t1
values
(
5
)
--
sleep
1
connection
default
;
--
echo
# Wait until INSERT starts to wait for FTWRL to go away.
let
$wait_condition
=
select
count
(
*
)
=
1
from
information_schema
.
processlist
where
state
=
"Waiting for table metadata lock"
and
info
=
"insert into t1 values (5)"
;
--
source
include
/
wait_condition
.
inc
select
*
from
t1
;
unlock
tables
;
connection
con1
;
reap
;
connection
default
;
select
*
from
t1
;
drop
view
v1
,
v2
;
drop
table
t1
;
disconnect
con1
;
--
echo
#
--
echo
# Test FLUSH THREADS
--
echo
#
...
...
sql/sql_reload.cc
View file @
b118f92b
...
...
@@ -592,7 +592,8 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
for
(
TABLE_LIST
*
table_list
=
all_tables
;
table_list
;
table_list
=
table_list
->
next_global
)
{
if
(
!
(
table_list
->
table
->
file
->
ha_table_flags
()
&
HA_CAN_EXPORT
))
if
(
!
(
table_list
->
is_view
()
||
table_list
->
table
->
file
->
ha_table_flags
()
&
HA_CAN_EXPORT
))
{
my_error
(
ER_ILLEGAL_HA
,
MYF
(
0
),
table_list
->
table
->
file
->
table_type
(),
table_list
->
db
.
str
,
table_list
->
table_name
.
str
);
...
...
@@ -606,7 +607,8 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
for
(
auto
table_list
=
all_tables
;
table_list
;
table_list
=
table_list
->
next_global
)
{
if
(
table_list
->
table
->
file
->
extra
(
HA_EXTRA_FLUSH
))
if
(
!
table_list
->
is_view
()
&&
table_list
->
table
->
file
->
extra
(
HA_EXTRA_FLUSH
))
goto
error_reset_bits
;
}
}
...
...
sql/sql_yacc.yy
View file @
b118f92b
...
...
@@ -14426,8 +14426,6 @@ opt_flush_lock:
for (; tables; tables= tables->next_global)
{
tables->mdl_request.set_type(MDL_SHARED_NO_WRITE);
/* Don't try to flush views. */
tables->required_type= TABLE_TYPE_NORMAL;
/* Ignore temporary tables. */
tables->open_type= OT_BASE_ONLY;
}
...
...
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