diff options
author | unknown <lars@mysql.com> | 2005-10-10 18:34:35 +0200 |
---|---|---|
committer | unknown <lars@mysql.com> | 2005-10-10 18:34:35 +0200 |
commit | a90ab1e280965fe4a8a5c6fb281d82c86d972c5a (patch) | |
tree | 2fd12347450209731680f29d1c2e5d910c056166 /sql/sql_parse.cc | |
parent | 748b5ce3f086e88d0d7f0166628114d6379298f6 (diff) | |
parent | 37c98812b33595d404308cbd0e86e89b80f3631e (diff) | |
download | mariadb-git-a90ab1e280965fe4a8a5c6fb281d82c86d972c5a.tar.gz |
Merge mysql.com:/users/lthalmann/bkroot/mysql-5.0
into mysql.com:/users/lthalmann/bk/mysql-5.0
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 97 |
1 files changed, 17 insertions, 80 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 8951f6b6d2d..659a20325ff 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2317,8 +2317,6 @@ mysql_execute_command(THD *thd) LEX *lex= thd->lex; /* first SELECT_LEX (have special meaning for many of non-SELECTcommands) */ SELECT_LEX *select_lex= &lex->select_lex; - bool slave_fake_lock= 0; - MYSQL_LOCK *fake_prev_lock= 0; /* first table of first SELECT_LEX */ TABLE_LIST *first_table= (TABLE_LIST*) select_lex->table_list.first; /* list of all tables in query */ @@ -2367,34 +2365,21 @@ mysql_execute_command(THD *thd) #ifdef HAVE_REPLICATION if (thd->slave_thread) { - if (lex->sql_command == SQLCOM_UPDATE_MULTI) - { - DBUG_PRINT("info",("need faked locked tables")); - - if (check_multi_update_lock(thd)) - goto error; - - /* Fix for replication, the tables are opened and locked, - now we pretend that we have performed a LOCK TABLES action */ - - fake_prev_lock= thd->locked_tables; - if (thd->lock) - thd->locked_tables= thd->lock; - thd->lock= 0; - slave_fake_lock= 1; - } /* - Skip if we are in the slave thread, some table rules have been - given and the table list says the query should not be replicated. + Check if statment should be skipped because of slave filtering + rules Exceptions are: + - UPDATE MULTI: For this statement, we want to check the filtering + rules later in the code - SET: we always execute it (Not that many SET commands exists in the binary log anyway -- only 4.1 masters write SET statements, in 5.0 there are no SET statements in the binary log) - DROP TEMPORARY TABLE IF EXISTS: we always execute it (otherwise we have stale files on slave caused by exclusion of one tmp table). */ - if (!(lex->sql_command == SQLCOM_SET_OPTION) && + if (!(lex->sql_command == SQLCOM_UPDATE_MULTI) && + !(lex->sql_command == SQLCOM_SET_OPTION) && !(lex->sql_command == SQLCOM_DROP_TABLE && lex->drop_temporary && lex->drop_if_exists) && all_tables_not_ok(thd, all_tables)) @@ -3220,6 +3205,17 @@ end_with_restore_list: else res= 0; + if ((res= mysql_multi_update_prepare(thd))) + break; + + /* Check slave filtering rules */ + if (thd->slave_thread && all_tables_not_ok(thd,tables)) + { + /* we warn the slave SQL thread */ + my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); + break; + } + res= mysql_multi_update(thd, all_tables, &select_lex->item_list, &lex->value_list, @@ -4774,14 +4770,6 @@ error: res= 1; cleanup: - if (unlikely(slave_fake_lock)) - { - DBUG_PRINT("info",("undoing faked lock")); - thd->lock= thd->locked_tables; - thd->locked_tables= fake_prev_lock; - if (thd->lock == thd->locked_tables) - thd->lock= 0; - } DBUG_RETURN(res || thd->net.report_error); } @@ -6914,57 +6902,6 @@ bool check_simple_select() return 0; } -/* - Setup locking for multi-table updates. Used by the replication slave. - Replication slave SQL thread examines (all_tables_not_ok()) the - locking state of referenced tables to determine if the query has to - be executed or ignored. Since in multi-table update, the - 'default' lock is read-only, this lock is corrected early enough by - calling this function, before the slave decides to execute/ignore. - - SYNOPSIS - check_multi_update_lock() - thd Current thread - - RETURN VALUES - 0 ok - 1 error -*/ -static bool check_multi_update_lock(THD *thd) -{ - bool res= 1; - LEX *lex= thd->lex; - TABLE_LIST *table, *tables= lex->query_tables; - DBUG_ENTER("check_multi_update_lock"); - - if (check_db_used(thd, tables)) - goto error; - - /* - Ensure that we have UPDATE or SELECT privilege for each table - The exact privilege is checked in mysql_multi_update() - */ - for (table= tables ; table ; table= table->next_local) - { - TABLE_LIST *save= table->next_local; - table->next_local= 0; - if ((check_access(thd, UPDATE_ACL, table->db, - &table->grant.privilege,0,1, test(table->schema_table)) || - (grant_option && check_grant(thd, UPDATE_ACL, table,0,1,1))) && - check_one_table_access(thd, SELECT_ACL, table)) - goto error; - table->next_local= save; - } - - if (mysql_multi_update_prepare(thd)) - goto error; - - res= 0; - -error: - DBUG_RETURN(res); -} - Comp_creator *comp_eq_creator(bool invert) { |