diff options
author | unknown <guilhem@mysql.com> | 2005-11-04 10:54:51 +0100 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2005-11-04 10:54:51 +0100 |
commit | 14cb1abbe0b16aebde9cef9a58ecf86826906ff6 (patch) | |
tree | 94d9b3d8b294f23b285c62c6cb937abcdeb8e7c7 /sql/sql_parse.cc | |
parent | 71898b3e2406897197df654f0ebf1b89e70b65b5 (diff) | |
parent | ff34d071bb32a0d1ca7ec2dff44e639c338f8e1c (diff) | |
download | mariadb-git-14cb1abbe0b16aebde9cef9a58ecf86826906ff6.tar.gz |
sql_parse.cc:
SCCS merged
sql/sql_parse.cc:
SCCS merged
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index aab4caec5d4..4bbca55f6ba 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -194,6 +194,18 @@ inline bool all_tables_not_ok(THD *thd, TABLE_LIST *tables) #endif +static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables) +{ + for (TABLE_LIST *table= tables; table; table= table->next_global) + { + DBUG_ASSERT(table->db && table->table_name); + if (table->updating && + !find_temporary_table(thd, table->db, table->table_name)) + return 1; + } + return 0; +} + static HASH hash_user_connections; static int get_or_create_user_conn(THD *thd, const char *user, @@ -2365,7 +2377,7 @@ mysql_execute_command(THD *thd) mysql_reset_errors(thd, 0); #ifdef HAVE_REPLICATION - if (thd->slave_thread) + if (unlikely(thd->slave_thread)) { /* Check if statment should be skipped because of slave filtering @@ -2404,16 +2416,20 @@ mysql_execute_command(THD *thd) } #endif } + else #endif /* HAVE_REPLICATION */ /* - When option readonly is set deny operations which change tables. - Except for the replication thread and the 'super' users. + When option readonly is set deny operations which change non-temporary + tables. Except for the replication thread and the 'super' users. */ if (opt_readonly && - !(thd->slave_thread || - (thd->security_ctx->master_access & SUPER_ACL)) && - uc_update_queries[lex->sql_command]) + !(thd->security_ctx->master_access & SUPER_ACL) && + uc_update_queries[lex->sql_command] && + !((lex->sql_command == SQLCOM_CREATE_TABLE) && + (lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)) && + ((lex->sql_command != SQLCOM_UPDATE_MULTI) && + some_non_temp_table_to_be_updated(thd, all_tables))) { my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only"); DBUG_RETURN(-1); @@ -3212,13 +3228,24 @@ end_with_restore_list: #ifdef HAVE_REPLICATION /* Check slave filtering rules */ - if (thd->slave_thread && all_tables_not_ok(thd, all_tables)) + if (unlikely(thd->slave_thread)) { - /* we warn the slave SQL thread */ - my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); - break; + if (all_tables_not_ok(thd, all_tables)) + { + /* we warn the slave SQL thread */ + my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); + break; + } } + else #endif /* HAVE_REPLICATION */ + if (opt_readonly && + !(thd->security_ctx->master_access & SUPER_ACL) && + some_non_temp_table_to_be_updated(thd, all_tables)) + { + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only"); + break; + } res= mysql_multi_update(thd, all_tables, &select_lex->item_list, |