149
static bool some_non_temp_table_to_be_updated(Session *session, TableList *tables)
151
for (TableList *table= tables; table; table= table->next_global)
153
assert(table->db && table->table_name);
154
if (table->updating &&
155
!find_temporary_table(session, table->db, table->table_name))
163
149
Mark all commands that somehow changes a table.
435
Determine if an attempt to update a non-temporary table while the
436
read-only option was enabled has been made.
438
This is a helper function to mysql_execute_command.
440
@note SQLCOM_MULTI_UPDATE is an exception and dealt with elsewhere.
442
@see mysql_execute_command
445
@retval true The statement should be denied.
446
@retval false The statement isn't updating any relevant tables.
449
static bool deny_updates_if_read_only_option(Session *session,
450
TableList *all_tables)
455
LEX *lex= session->lex;
457
if (!(sql_command_flags[lex->sql_command].test(CF_BIT_CHANGES_DATA)))
460
/* Multi update is an exception and is dealt with later. */
461
if (lex->sql_command == SQLCOM_UPDATE_MULTI)
464
const bool create_temp_tables=
465
(lex->sql_command == SQLCOM_CREATE_TABLE) &&
466
(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE);
468
const bool drop_temp_tables=
469
(lex->sql_command == SQLCOM_DROP_TABLE) &&
472
const bool update_real_tables=
473
some_non_temp_table_to_be_updated(session, all_tables) &&
474
!(create_temp_tables || drop_temp_tables);
477
const bool create_or_drop_databases=
478
(lex->sql_command == SQLCOM_CREATE_DB) ||
479
(lex->sql_command == SQLCOM_DROP_DB);
481
if (update_real_tables || create_or_drop_databases)
484
An attempt was made to modify one or more non-temporary tables.
490
/* Assuming that only temporary tables are modified. */
495
421
Perform one connection-level (COM_XXXX) command.
497
423
@param command type of command to perform
1147
When option readonly is set deny operations which change non-temporary
1148
tables. Except for the replication thread and the 'super' users.
1150
if (deny_updates_if_read_only_option(session, all_tables))
1152
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
1155
} /* endif unlikely slave */
1156
1071
status_var_increment(session->status_var.com_stat[lex->sql_command]);
1158
1073
assert(session->transaction.stmt.modified_non_trans_table == false);
1697
some_non_temp_table_to_be_updated(session, all_tables))
1699
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
1702
1612
} /* unlikely */
1704
1614
res= mysql_multi_update(session, all_tables,