mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
Merge branch '5.5-galera' into 10.0-galera
This commit is contained in:
commit
8a18bb9694
9 changed files with 247 additions and 45 deletions
38
mysql-test/suite/galera/r/rename.result
Normal file
38
mysql-test/suite/galera/r/rename.result
Normal file
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# MDEV-8598 : Failed MySQL DDL commands and Galera replication
|
||||
#
|
||||
# On node 1
|
||||
USE test;
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
CREATE TABLE t1(i INT) ENGINE=INNODB;
|
||||
INSERT INTO t1 VALUE(1);
|
||||
SELECT * FROM t1;
|
||||
i
|
||||
1
|
||||
# Create a new user 'foo' with limited privileges
|
||||
GRANT SELECT on test.* TO foo@localhost;
|
||||
# Open connection to the 1st node using 'test_user1' user.
|
||||
SELECT * FROM t1;
|
||||
i
|
||||
1
|
||||
# Following RENAME should not replicate to other node.
|
||||
RENAME TABLE t1 TO t2;
|
||||
ERROR 42000: DROP, ALTER command denied to user 'foo'@'localhost' for table 't1'
|
||||
# On node 2
|
||||
USE test;
|
||||
SELECT * FROM t1;
|
||||
i
|
||||
1
|
||||
# On node_1
|
||||
RENAME TABLE t1 TO t2;
|
||||
SHOW TABLES;
|
||||
Tables_in_test
|
||||
t2
|
||||
# On node 2
|
||||
USE test;
|
||||
SELECT * FROM t2;
|
||||
i
|
||||
1
|
||||
DROP USER foo@localhost;
|
||||
DROP TABLE t2;
|
||||
# End of tests
|
|
@ -4,4 +4,49 @@
|
|||
USE test;
|
||||
CREATE DEFINER=CURRENT_USER VIEW v1 AS SELECT 1;
|
||||
DROP VIEW v1;
|
||||
#
|
||||
# MDEV-8464 : ALTER VIEW not replicated in some cases
|
||||
#
|
||||
# On node_1
|
||||
USE test;
|
||||
CREATE TABLE t1(i INT) ENGINE=INNODB;
|
||||
CREATE DEFINER=CURRENT_USER VIEW v1 AS SELECT * FROM t1;
|
||||
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t1;
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t1;
|
||||
CREATE ALGORITHM=UNDEFINED DEFINER=CURRENT_USER VIEW v4 AS SELECT * FROM t1;
|
||||
# On node_2
|
||||
USE test;
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
SHOW CREATE VIEW v2;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
SHOW CREATE VIEW v3;
|
||||
View Create View character_set_client collation_connection
|
||||
v3 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
SHOW CREATE VIEW v4;
|
||||
View Create View character_set_client collation_connection
|
||||
v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
# On node_1
|
||||
ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
|
||||
ALTER ALGORITHM=UNDEFINED VIEW v2 AS SELECT * FROM t1;
|
||||
ALTER DEFINER=CURRENT_USER VIEW v3 AS SELECT * FROM t1;
|
||||
ALTER ALGORITHM=TEMPTABLE DEFINER=CURRENT_USER VIEW v4 AS SELECT * FROM t1;
|
||||
# On node_2
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
SHOW CREATE VIEW v2;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
SHOW CREATE VIEW v3;
|
||||
View Create View character_set_client collation_connection
|
||||
v3 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
SHOW CREATE VIEW v4;
|
||||
View Create View character_set_client collation_connection
|
||||
v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci
|
||||
# Cleanup
|
||||
DROP VIEW v1, v2, v3, v4;
|
||||
DROP TABLE t1;
|
||||
# End of tests
|
||||
|
|
52
mysql-test/suite/galera/t/rename.test
Normal file
52
mysql-test/suite/galera/t/rename.test
Normal file
|
@ -0,0 +1,52 @@
|
|||
--source include/galera_cluster.inc
|
||||
--source include/have_innodb.inc
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-8598 : Failed MySQL DDL commands and Galera replication
|
||||
--echo #
|
||||
--echo # On node 1
|
||||
--connection node_1
|
||||
USE test;
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE t1(i INT) ENGINE=INNODB;
|
||||
INSERT INTO t1 VALUE(1);
|
||||
SELECT * FROM t1;
|
||||
|
||||
--echo # Create a new user 'foo' with limited privileges
|
||||
GRANT SELECT on test.* TO foo@localhost;
|
||||
|
||||
--echo # Open connection to the 1st node using 'test_user1' user.
|
||||
--let $port_1= \$NODE_MYPORT_1
|
||||
--connect(foo_node_1,localhost,foo,,test,$port_1,)
|
||||
|
||||
--connection foo_node_1
|
||||
SELECT * FROM t1;
|
||||
--echo # Following RENAME should not replicate to other node.
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
RENAME TABLE t1 TO t2;
|
||||
|
||||
--echo # On node 2
|
||||
--connection node_2
|
||||
USE test;
|
||||
SELECT * FROM t1;
|
||||
|
||||
--echo # On node_1
|
||||
--connection node_1
|
||||
RENAME TABLE t1 TO t2;
|
||||
SHOW TABLES;
|
||||
|
||||
--echo # On node 2
|
||||
--connection node_2
|
||||
USE test;
|
||||
SELECT * FROM t2;
|
||||
|
||||
# Cleanup
|
||||
--connection node_1
|
||||
DROP USER foo@localhost;
|
||||
DROP TABLE t2;
|
||||
|
||||
--echo # End of tests
|
||||
|
|
@ -8,4 +8,43 @@ USE test;
|
|||
CREATE DEFINER=CURRENT_USER VIEW v1 AS SELECT 1;
|
||||
DROP VIEW v1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-8464 : ALTER VIEW not replicated in some cases
|
||||
--echo #
|
||||
--echo # On node_1
|
||||
--connection node_1
|
||||
USE test;
|
||||
CREATE TABLE t1(i INT) ENGINE=INNODB;
|
||||
CREATE DEFINER=CURRENT_USER VIEW v1 AS SELECT * FROM t1;
|
||||
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM t1;
|
||||
CREATE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t1;
|
||||
CREATE ALGORITHM=UNDEFINED DEFINER=CURRENT_USER VIEW v4 AS SELECT * FROM t1;
|
||||
|
||||
--echo # On node_2
|
||||
--connection node_2
|
||||
USE test;
|
||||
SHOW CREATE VIEW v1;
|
||||
SHOW CREATE VIEW v2;
|
||||
SHOW CREATE VIEW v3;
|
||||
SHOW CREATE VIEW v4;
|
||||
|
||||
--echo # On node_1
|
||||
--connection node_1
|
||||
ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1;
|
||||
ALTER ALGORITHM=UNDEFINED VIEW v2 AS SELECT * FROM t1;
|
||||
ALTER DEFINER=CURRENT_USER VIEW v3 AS SELECT * FROM t1;
|
||||
ALTER ALGORITHM=TEMPTABLE DEFINER=CURRENT_USER VIEW v4 AS SELECT * FROM t1;
|
||||
|
||||
--echo # On node_2
|
||||
--connection node_2
|
||||
SHOW CREATE VIEW v1;
|
||||
SHOW CREATE VIEW v2;
|
||||
SHOW CREATE VIEW v3;
|
||||
SHOW CREATE VIEW v4;
|
||||
|
||||
--echo # Cleanup
|
||||
DROP VIEW v1, v2, v3, v4;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo # End of tests
|
||||
|
||||
|
|
|
@ -4718,20 +4718,22 @@ restart:
|
|||
}
|
||||
}
|
||||
#ifdef WITH_WSREP
|
||||
if ((thd->lex->sql_command== SQLCOM_INSERT ||
|
||||
thd->lex->sql_command== SQLCOM_INSERT_SELECT ||
|
||||
thd->lex->sql_command== SQLCOM_REPLACE ||
|
||||
thd->lex->sql_command== SQLCOM_REPLACE_SELECT ||
|
||||
thd->lex->sql_command== SQLCOM_UPDATE ||
|
||||
thd->lex->sql_command== SQLCOM_UPDATE_MULTI ||
|
||||
thd->lex->sql_command== SQLCOM_LOAD ||
|
||||
thd->lex->sql_command== SQLCOM_DELETE) &&
|
||||
wsrep_replicate_myisam &&
|
||||
(*start) &&
|
||||
(*start)->table && (*start)->table->file->ht->db_type == DB_TYPE_MYISAM)
|
||||
{
|
||||
WSREP_TO_ISOLATION_BEGIN(NULL, NULL, (*start));
|
||||
}
|
||||
if (wsrep_replicate_myisam &&
|
||||
(*start) &&
|
||||
(*start)->table &&
|
||||
(*start)->table->file->ht->db_type == DB_TYPE_MYISAM &&
|
||||
thd->get_command() != COM_STMT_PREPARE &&
|
||||
((thd->lex->sql_command == SQLCOM_INSERT ||
|
||||
thd->lex->sql_command == SQLCOM_INSERT_SELECT ||
|
||||
thd->lex->sql_command == SQLCOM_REPLACE ||
|
||||
thd->lex->sql_command == SQLCOM_REPLACE_SELECT ||
|
||||
thd->lex->sql_command == SQLCOM_UPDATE ||
|
||||
thd->lex->sql_command == SQLCOM_UPDATE_MULTI ||
|
||||
thd->lex->sql_command == SQLCOM_LOAD ||
|
||||
thd->lex->sql_command == SQLCOM_DELETE)))
|
||||
{
|
||||
WSREP_TO_ISOLATION_BEGIN(NULL, NULL, (*start));
|
||||
}
|
||||
error:
|
||||
#endif
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
#include "sql_connect.h" // decrease_user_connections,
|
||||
// check_mqh,
|
||||
// reset_mqh
|
||||
#include "sql_rename.h" // mysql_rename_table
|
||||
#include "sql_rename.h" // mysql_rename_tables
|
||||
#include "sql_tablespace.h" // mysql_alter_tablespace
|
||||
#include "hostname.h" // hostname_cache_refresh
|
||||
#include "sql_acl.h" // *_ACL, check_grant, is_acl_user,
|
||||
|
@ -132,7 +132,7 @@ static void sql_kill(THD *thd, longlong id, killed_state state, killed_type type
|
|||
static void sql_kill_user(THD *thd, LEX_USER *user, killed_state state);
|
||||
static bool lock_tables_precheck(THD *thd, TABLE_LIST *tables);
|
||||
static bool execute_show_status(THD *, TABLE_LIST *);
|
||||
static bool execute_rename_table(THD *, TABLE_LIST *, TABLE_LIST *);
|
||||
static bool check_rename_table(THD *, TABLE_LIST *, TABLE_LIST *);
|
||||
|
||||
const char *any_db="*any*"; // Special symbol for check_access
|
||||
|
||||
|
@ -1064,6 +1064,11 @@ bool do_command(THD *thd)
|
|||
command != COM_SLEEP &&
|
||||
command != COM_STATISTICS &&
|
||||
command != COM_TIME &&
|
||||
command != COM_STMT_PREPARE &&
|
||||
command != COM_STMT_SEND_LONG_DATA &&
|
||||
command != COM_STMT_EXECUTE &&
|
||||
command != COM_STMT_RESET &&
|
||||
command != COM_STMT_CLOSE &&
|
||||
command != COM_END
|
||||
) {
|
||||
my_message(ER_UNKNOWN_COM_ERROR,
|
||||
|
@ -3503,8 +3508,12 @@ end_with_restore_list:
|
|||
#endif /* HAVE_REPLICATION */
|
||||
case SQLCOM_RENAME_TABLE:
|
||||
{
|
||||
if (check_rename_table(thd, first_table, all_tables))
|
||||
goto error;
|
||||
|
||||
WSREP_TO_ISOLATION_BEGIN(0, 0, first_table)
|
||||
if (execute_rename_table(thd, first_table, all_tables))
|
||||
|
||||
if (mysql_rename_tables(thd, first_table, 0))
|
||||
goto error;
|
||||
break;
|
||||
}
|
||||
|
@ -5805,8 +5814,8 @@ static bool execute_show_status(THD *thd, TABLE_LIST *all_tables)
|
|||
}
|
||||
|
||||
|
||||
static bool execute_rename_table(THD *thd, TABLE_LIST *first_table,
|
||||
TABLE_LIST *all_tables)
|
||||
static bool check_rename_table(THD *thd, TABLE_LIST *first_table,
|
||||
TABLE_LIST *all_tables)
|
||||
{
|
||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||
TABLE_LIST *table;
|
||||
|
@ -5820,7 +5829,7 @@ static bool execute_rename_table(THD *thd, TABLE_LIST *first_table,
|
|||
&table->next_local->grant.privilege,
|
||||
&table->next_local->grant.m_internal,
|
||||
0, 0))
|
||||
return 1;
|
||||
return true;
|
||||
TABLE_LIST old_list, new_list;
|
||||
/*
|
||||
we do not need initialize old_list and new_list because we will
|
||||
|
@ -5833,10 +5842,10 @@ static bool execute_rename_table(THD *thd, TABLE_LIST *first_table,
|
|||
INSERT_ACL | CREATE_ACL) &&
|
||||
check_grant(thd, INSERT_ACL | CREATE_ACL, &new_list, FALSE, 1,
|
||||
FALSE)))
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return mysql_rename_tables(thd, first_table, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -122,8 +122,6 @@ static void get_cs_converted_string_value(THD *thd,
|
|||
|
||||
static int show_create_view(THD *thd, TABLE_LIST *table, String *buff);
|
||||
|
||||
static void append_algorithm(TABLE_LIST *table, String *buff);
|
||||
|
||||
static COND * make_cond_for_info_schema(COND *cond, TABLE_LIST *table);
|
||||
|
||||
/**
|
||||
|
@ -2082,32 +2080,30 @@ static void store_key_options(THD *thd, String *packet, TABLE *table,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
view_store_options(THD *thd, TABLE_LIST *table, String *buff)
|
||||
{
|
||||
append_algorithm(table, buff);
|
||||
append_definer(thd, buff, &table->definer.user, &table->definer.host);
|
||||
if (table->view_suid)
|
||||
buff->append(STRING_WITH_LEN("SQL SECURITY DEFINER "));
|
||||
else
|
||||
buff->append(STRING_WITH_LEN("SQL SECURITY INVOKER "));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Append DEFINER clause to the given buffer.
|
||||
Append ALGORITHM clause to the given buffer.
|
||||
|
||||
SYNOPSIS
|
||||
append_definer()
|
||||
thd [in] thread handle
|
||||
buffer [inout] buffer to hold DEFINER clause
|
||||
definer_user [in] user name part of definer
|
||||
definer_host [in] host name part of definer
|
||||
append_algorithm()
|
||||
table [in] table list
|
||||
buff [inout] buffer to hold the ALGORITHM clause
|
||||
check_inherit [in] if true, do nothing if algorithm is INHERIT
|
||||
*/
|
||||
|
||||
static void append_algorithm(TABLE_LIST *table, String *buff)
|
||||
static void append_algorithm(TABLE_LIST *table, String *buff,
|
||||
bool check_inherit)
|
||||
{
|
||||
int16 algorithm= (int16) table->algorithm;
|
||||
|
||||
DBUG_ENTER("append_algorithm");
|
||||
|
||||
/*
|
||||
Handle a special case when ALGORITHM is not specified, in which case we
|
||||
simply return.
|
||||
*/
|
||||
if (check_inherit && (algorithm == VIEW_ALGORITHM_INHERIT))
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
buff->append(STRING_WITH_LEN("ALGORITHM="));
|
||||
switch ((int16)table->algorithm) {
|
||||
case VIEW_ALGORITHM_UNDEFINED:
|
||||
|
@ -2122,6 +2118,8 @@ static void append_algorithm(TABLE_LIST *table, String *buff)
|
|||
default:
|
||||
DBUG_ASSERT(0); // never should happen
|
||||
}
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2148,6 +2146,23 @@ void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user,
|
|||
buffer->append(' ');
|
||||
}
|
||||
|
||||
void
|
||||
view_store_options4(THD *thd, TABLE_LIST *table, String *buff,
|
||||
bool check_inherit)
|
||||
{
|
||||
append_algorithm(table, buff, check_inherit);
|
||||
append_definer(thd, buff, &table->definer.user, &table->definer.host);
|
||||
if (table->view_suid)
|
||||
buff->append(STRING_WITH_LEN("SQL SECURITY DEFINER "));
|
||||
else
|
||||
buff->append(STRING_WITH_LEN("SQL SECURITY INVOKER "));
|
||||
}
|
||||
|
||||
void
|
||||
view_store_options(THD *thd, TABLE_LIST *table, String *buff)
|
||||
{
|
||||
view_store_options4(thd, table, buff, false);
|
||||
}
|
||||
|
||||
static int show_create_view(THD *thd, TABLE_LIST *table, String *buff)
|
||||
{
|
||||
|
|
|
@ -108,6 +108,8 @@ void free_status_vars();
|
|||
void reset_status_vars();
|
||||
bool show_create_trigger(THD *thd, const sp_name *trg_name);
|
||||
void view_store_options(THD *thd, TABLE_LIST *table, String *buff);
|
||||
void view_store_options4(THD *thd, TABLE_LIST *table, String *buff,
|
||||
bool check_inherit);
|
||||
|
||||
void init_fill_schema_files_row(TABLE* table);
|
||||
bool schema_table_store_record(THD *thd, TABLE *table);
|
||||
|
|
|
@ -1151,7 +1151,7 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len)
|
|||
views->view_suid = lex->create_view_suid;
|
||||
views->with_check = lex->create_view_check;
|
||||
|
||||
view_store_options(thd, views, &buff);
|
||||
view_store_options4(thd, views, &buff, true);
|
||||
buff.append(STRING_WITH_LEN("VIEW "));
|
||||
/* Test if user supplied a db (ie: we did not use thd->db) */
|
||||
if (views->db && views->db[0] &&
|
||||
|
|
Loading…
Reference in a new issue