summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/session_tracker.cc3
-rw-r--r--sql/sql_base.cc9
-rw-r--r--sql/table.h3
3 files changed, 14 insertions, 1 deletions
diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc
index 1b21012f09e..65d600b9b5a 100644
--- a/sql/session_tracker.cc
+++ b/sql/session_tracker.cc
@@ -1226,7 +1226,7 @@ void Session_tracker::store(THD *thd, String *buf)
if ((size= net_length_size(length)) != 1)
{
- if (buf->reserve(size - 1, EXTRA_ALLOC))
+ if (buf->reserve(size - 1, 0))
{
buf->length(start); // it is safer to have 0-length block in case of error
return;
@@ -1236,6 +1236,7 @@ void Session_tracker::store(THD *thd, String *buf)
The 'buf->reserve()' can change the buf->ptr() so we cannot
calculate the 'data' earlier.
*/
+ buf->length(buf->length() + (size - 1));
data= (uchar *)(buf->ptr() + start);
memmove(data + (size - 1), data, length);
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 8efc731066b..57a44293e96 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -4685,10 +4685,19 @@ bool Lock_tables_prelocking_strategy::
handle_table(THD *thd, Query_tables_list *prelocking_ctx,
TABLE_LIST *table_list, bool *need_prelocking)
{
+ TABLE_LIST **last= prelocking_ctx->query_tables_last;
+
if (DML_prelocking_strategy::handle_table(thd, prelocking_ctx, table_list,
need_prelocking))
return TRUE;
+ /*
+ normally we don't need to open FK-prelocked tables for RESTRICT,
+ MDL is enough. But under LOCK TABLES we have to open everything
+ */
+ for (TABLE_LIST *tl= *last; tl; tl= tl->next_global)
+ tl->open_strategy= TABLE_LIST::OPEN_NORMAL;
+
/* We rely on a caller to check that table is going to be changed. */
DBUG_ASSERT(table_list->lock_type >= TL_WRITE_ALLOW_WRITE);
diff --git a/sql/table.h b/sql/table.h
index a1e7db36ced..35b0388afba 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -2026,6 +2026,9 @@ struct TABLE_LIST
OT_BASE_ONLY);
belong_to_view= belong_to_view_arg;
trg_event_map= trg_event_map_arg;
+ /* MDL is enough for read-only FK checks, we don't need the table */
+ if (prelocking_type == PRELOCK_FK && lock_type < TL_WRITE_ALLOW_WRITE)
+ open_strategy= OPEN_STUB;
**last_ptr= this;
prev_global= *last_ptr;