summaryrefslogtreecommitdiff
path: root/sql/sql_handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_handler.cc')
-rw-r--r--sql/sql_handler.cc36
1 files changed, 20 insertions, 16 deletions
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 01a75316671..b2c41ac81a3 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -52,9 +52,9 @@
cursor points at the first record).
*/
+#include <my_global.h>
#include "sql_priv.h"
#include "sql_handler.h"
-#include "unireg.h" // REQUIRED: for other includes
#include "sql_base.h" // close_thread_tables
#include "lock.h" // mysql_unlock_tables
#include "key.h" // key_copy
@@ -155,10 +155,11 @@ static void mysql_ha_close_table(SQL_HANDLER *handler)
{
THD *thd= handler->thd;
TABLE *table= handler->table;
+ DBUG_ENTER("mysql_ha_close_table");
/* check if table was already closed */
if (!table)
- return;
+ DBUG_VOID_RETURN;
if (!table->s->tmp_table)
{
@@ -171,7 +172,7 @@ static void mysql_ha_close_table(SQL_HANDLER *handler)
table->file->ha_index_or_rnd_end();
table->open_by_handler= 0;
- (void) close_thread_table(thd, &table);
+ close_thread_table(thd, &table);
thd->mdl_context.release_lock(handler->mdl_request.ticket);
}
else
@@ -184,6 +185,7 @@ static void mysql_ha_close_table(SQL_HANDLER *handler)
}
my_free(handler->lock);
handler->init();
+ DBUG_VOID_RETURN;
}
/*
@@ -294,7 +296,8 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
open_ltable() or open_table() because we would like to be able
to open a temporary table.
*/
- error= open_tables(thd, &tables, &counter, 0);
+ error= (open_temporary_tables(thd, tables) ||
+ open_tables(thd, &tables, &counter, 0));
if (error)
goto err;
@@ -304,7 +307,8 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
/* There can be only one table in '*tables'. */
if (! (table->file->ha_table_flags() & HA_CAN_SQL_HANDLER))
{
- my_error(ER_ILLEGAL_HA, MYF(0), tables->alias);
+ my_error(ER_ILLEGAL_HA, MYF(0), table->file->table_type(),
+ table->s->db.str, table->s->table_name.str);
goto err;
}
@@ -323,7 +327,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen)
/* copy data to sql_handler */
if (!(sql_handler= new SQL_HANDLER(thd)))
goto err;
- init_alloc_root(&sql_handler->mem_root, 1024, 0);
+ init_alloc_root(&sql_handler->mem_root, 1024, 0, MYF(MY_THREAD_SPECIFIC));
sql_handler->db.length= strlen(tables->db);
sql_handler->table_name.length= strlen(tables->table_name);
@@ -501,9 +505,9 @@ public:
bool handle_condition(THD *thd,
uint sql_errno,
const char *sqlstate,
- MYSQL_ERROR::enum_warning_level level,
+ Sql_condition::enum_warning_level level,
const char* msg,
- MYSQL_ERROR **cond_hdl);
+ Sql_condition **cond_hdl);
bool need_reopen() const { return m_need_reopen; };
void init() { m_need_reopen= FALSE; };
@@ -522,9 +526,9 @@ Sql_handler_lock_error_handler::
handle_condition(THD *thd,
uint sql_errno,
const char *sqlstate,
- MYSQL_ERROR::enum_warning_level level,
+ Sql_condition::enum_warning_level level,
const char* msg,
- MYSQL_ERROR **cond_hdl)
+ Sql_condition **cond_hdl)
{
*cond_hdl= NULL;
if (sql_errno == ER_LOCK_ABORTED)
@@ -639,9 +643,10 @@ mysql_ha_fix_cond_and_key(SQL_HANDLER *handler,
key_part_map keypart_map;
uint key_len;
- if (key_expr->elements > keyinfo->key_parts)
+ if (key_expr->elements > keyinfo->user_defined_key_parts)
{
- my_error(ER_TOO_MANY_KEY_PARTS, MYF(0), keyinfo->key_parts);
+ my_error(ER_TOO_MANY_KEY_PARTS, MYF(0),
+ keyinfo->user_defined_key_parts);
return 1;
}
for (keypart_map= key_len=0 ; (item=it_ke++) ; key_part++)
@@ -904,7 +909,8 @@ retry:
break;
}
default:
- my_message(ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), MYF(0));
+ my_error(ER_ILLEGAL_HA, MYF(0), table->file->table_type(),
+ table->s->db.str, table->s->table_name.str);
goto err;
}
@@ -1112,8 +1118,6 @@ void mysql_ha_flush(THD *thd)
SQL_HANDLER *hash_tables;
DBUG_ENTER("mysql_ha_flush");
- mysql_mutex_assert_not_owner(&LOCK_open);
-
/*
Don't try to flush open HANDLERs when we're working with
system tables. The main MDL context is backed up and we can't
@@ -1132,7 +1136,7 @@ void mysql_ha_flush(THD *thd)
((hash_tables->table->mdl_ticket &&
hash_tables->table->mdl_ticket->has_pending_conflicting_lock()) ||
(!hash_tables->table->s->tmp_table &&
- hash_tables->table->s->has_old_version())))
+ hash_tables->table->s->tdc.flushed)))
mysql_ha_close_table(hash_tables);
}