summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index f91a5e14835..af08d20baaf 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1088,6 +1088,11 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
/* find a unused table in the open table cache */
if (refresh)
*refresh=0;
+
+ /* an open table operation needs a lot of the stack space */
+ if (check_stack_overrun(thd, 8 * STACK_MIN_SIZE, (char *)&alias))
+ return 0;
+
if (thd->killed)
DBUG_RETURN(0);
key_length= (uint) (strmov(strmov(key, table_list->db)+1,
@@ -1200,17 +1205,16 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
(void) unpack_filename(path, path);
if (mysql_frm_type(thd, path, &not_used) == FRMTYPE_VIEW)
{
- TABLE tab;// will not be used (because it's VIEW) but have to be passed
+ /*
+ Will not be used (because it's VIEW) but has to be passed.
+ Also we will not free it (because it is a stack variable).
+ */
+ TABLE tab;
table= &tab;
VOID(pthread_mutex_lock(&LOCK_open));
- if (open_unireg_entry(thd, table, table_list->db,
- table_list->table_name,
- alias, table_list, mem_root))
- {
- table->next=table->prev=table;
- free_cache_entry(table);
- }
- else
+ if (!open_unireg_entry(thd, table, table_list->db,
+ table_list->table_name,
+ alias, table_list, mem_root))
{
DBUG_ASSERT(table_list->view != 0);
VOID(pthread_mutex_unlock(&LOCK_open));