Skip to content

Commit efd5018

Browse files
author
Omar Sharieff
committed
Bug#33866103 : MYSQLPUMP [ERROR] (1356) WITH VIEW CONTAINING FROM
SUBQUERY - REGRESSION Description: Mysqlpump may not work in cases where derived tables are generated. This is due to privileges not being set for those tables. Fix: Backport. Derived tables handled separately and privileges set. Gerrit#16933 Change-Id: Ia31d479ed2d7aba47993d2e646efb84651ee784a
1 parent 9f37498 commit efd5018

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

mysql-test/r/mysqlpump_bugs.result

+9
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,13 @@ CREATE VIEW B32067013.t123 AS SELECT * FROM B32067013.t1;
1919
DROP TABLE B32067013.t1;
2020
# Test criteria: shouldn't crash
2121
DROP DATABASE B32067013;
22+
#
23+
# Bug#33866103 : MYSQLPUMP [ERROR] (1356) WITH VIEW CONTAINING FROM SUBQUERY - REGRESSION
24+
#
25+
CREATE DATABASE db1;
26+
CREATE TABLE db1.t1 (c1 int);
27+
CREATE TABLE db1.t2 (c1 int);
28+
USE db1;
29+
CREATE VIEW db1.v12 AS (SELECT * FROM (SELECT * FROM db1.t1 UNION SELECT * FROM db1.t2) AS t12);
30+
DROP DATABASE db1;
2231
# End of 5.7 tests

mysql-test/t/mysqlpump_bugs.test

+20
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,24 @@ DROP DATABASE B32067013;
4646
--remove_file $MYSQLTEST_VARDIR/tmp/bug32067013.dump
4747

4848

49+
--echo #
50+
--echo # Bug#33866103 : MYSQLPUMP [ERROR] (1356) WITH VIEW CONTAINING FROM SUBQUERY - REGRESSION
51+
--echo #
52+
53+
CREATE DATABASE db1;
54+
55+
CREATE TABLE db1.t1 (c1 int);
56+
CREATE TABLE db1.t2 (c1 int);
57+
58+
USE db1;
59+
60+
CREATE VIEW db1.v12 AS (SELECT * FROM (SELECT * FROM db1.t1 UNION SELECT * FROM db1.t2) AS t12);
61+
62+
--exec $MYSQL_PUMP -u root --result-file=$MYSQLTEST_VARDIR/tmp/bug33866103.sql
63+
64+
--remove_file $MYSQLTEST_VARDIR/tmp/bug33866103.sql
65+
66+
DROP DATABASE db1;
67+
68+
4969
--echo # End of 5.7 tests

sql/auth/sql_authorization.cc

+5
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,11 @@ bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *all_tables)
608608
bool check_single_table_access(THD *thd, ulong privilege,
609609
TABLE_LIST *all_tables, bool no_errors)
610610
{
611+
if (all_tables->is_derived()) {
612+
all_tables->set_privileges(privilege);
613+
return false;
614+
}
615+
611616
Security_context *backup_ctx= thd->security_context();
612617

613618
/* we need to switch to the saved context (if any) */

0 commit comments

Comments
 (0)