summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2009-04-03 16:46:00 -0300
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2009-04-03 16:46:00 -0300
commit54bf80b63345647492a7ec0007e016ae2fd52ad5 (patch)
tree043456df5b0aad4de66f579a537690947263e592 /sql/sql_parse.cc
parent102de8f5c35d63453c2e240473ccb5fce8d2918a (diff)
parent72e978828edb6b6cc045e6c728747dafd46b8732 (diff)
downloadmariadb-git-54bf80b63345647492a7ec0007e016ae2fd52ad5.tar.gz
Merge Bug#43230 into mysql-5.1-bugteam
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc33
1 files changed, 30 insertions, 3 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 2974dff9ea9..6dbe4a4fd8d 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2200,8 +2200,15 @@ mysql_execute_command(THD *thd)
res= check_access(thd,
lex->exchange ? SELECT_ACL | FILE_ACL : SELECT_ACL,
any_db, 0, 0, 0, 0);
- if (!res)
- res= execute_sqlcom_select(thd, all_tables);
+
+ if (res)
+ break;
+
+ if (!thd->locked_tables && lex->protect_against_global_read_lock &&
+ !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ break;
+
+ res= execute_sqlcom_select(thd, all_tables);
break;
case SQLCOM_PREPARE:
{
@@ -3006,6 +3013,9 @@ end_with_restore_list:
DBUG_ASSERT(first_table == all_tables && first_table != 0);
if (update_precheck(thd, all_tables))
break;
+ if (!thd->locked_tables &&
+ !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ goto error;
DBUG_ASSERT(select_lex->offset_limit == 0);
unit->set_limit(select_lex);
res= (up_result= mysql_update(thd, all_tables,
@@ -3032,6 +3042,15 @@ end_with_restore_list:
else
res= 0;
+ /*
+ Protection might have already been risen if its a fall through
+ from the SQLCOM_UPDATE case above.
+ */
+ if (!thd->locked_tables &&
+ lex->sql_command == SQLCOM_UPDATE_MULTI &&
+ !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ goto error;
+
res= mysql_multi_update_prepare(thd);
#ifdef HAVE_REPLICATION
@@ -3229,7 +3248,8 @@ end_with_restore_list:
ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
goto error;
}
-
+ if (!(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ goto error;
res= mysql_truncate(thd, first_table, 0);
break;
case SQLCOM_DELETE:
@@ -3402,6 +3422,10 @@ end_with_restore_list:
if (check_one_table_access(thd, privilege, all_tables))
goto error;
+ if (!thd->locked_tables &&
+ !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ goto error;
+
res= mysql_load(thd, lex->exchange, first_table, lex->field_list,
lex->update_list, lex->value_list, lex->duplicates,
lex->ignore, (bool) lex->local_file);
@@ -3472,6 +3496,9 @@ end_with_restore_list:
if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables,
UINT_MAX, FALSE))
goto error;
+ if (lex->protect_against_global_read_lock &&
+ !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ goto error;
thd->in_lock_tables=1;
thd->options|= OPTION_TABLE_LOCK;