summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2010-07-29 14:18:13 +0400
committerKonstantin Osipov <kostja@sun.com>2010-07-29 14:18:13 +0400
commitd85c6281802c8f6ef7187518f9f4357d96134b3e (patch)
tree9baa8f27a086b903e03b7e74a85ac8346895fbaf /sql
parentdd135df6a8ef67e0c9615a5732ce89737f144e68 (diff)
parent279896c29fedf400cb16d90182185a9a2c6c5064 (diff)
downloadmariadb-git-d85c6281802c8f6ef7187518f9f4357d96134b3e.tar.gz
Merge trunk-bugfixing -> trunk-runtime.
Diffstat (limited to 'sql')
-rw-r--r--sql/log_event.cc7
-rw-r--r--sql/sql_base.cc32
-rw-r--r--sql/sql_base.h2
-rw-r--r--sql/sql_select.cc2
4 files changed, 31 insertions, 12 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 8f70282ce79..ea7f4b4b245 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -3714,6 +3714,7 @@ bool Start_log_event_v3::write(IO_CACHE* file)
int Start_log_event_v3::do_apply_event(Relay_log_info const *rli)
{
DBUG_ENTER("Start_log_event_v3::do_apply_event");
+ int error= 0;
switch (binlog_version)
{
case 3:
@@ -3726,7 +3727,7 @@ int Start_log_event_v3::do_apply_event(Relay_log_info const *rli)
*/
if (created)
{
- close_temporary_tables(thd);
+ error= close_temporary_tables(thd);
cleanup_load_tmpdir();
}
else
@@ -3754,7 +3755,7 @@ int Start_log_event_v3::do_apply_event(Relay_log_info const *rli)
Can distinguish, based on the value of 'created': this event was
generated at master startup.
*/
- close_temporary_tables(thd);
+ error= close_temporary_tables(thd);
}
/*
Otherwise, can't distinguish a Start_log_event generated at
@@ -3766,7 +3767,7 @@ int Start_log_event_v3::do_apply_event(Relay_log_info const *rli)
/* this case is impossible */
DBUG_RETURN(1);
}
- DBUG_RETURN(0);
+ DBUG_RETURN(error);
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 7a59fefdddd..3dd5a7bfcc5 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1582,7 +1582,7 @@ static inline uint tmpkeyval(THD *thd, TABLE *table)
creates one DROP TEMPORARY TABLE binlog event for each pseudo-thread
*/
-void close_temporary_tables(THD *thd)
+bool close_temporary_tables(THD *thd)
{
DBUG_ENTER("close_temporary_tables");
TABLE *table;
@@ -1590,9 +1590,10 @@ void close_temporary_tables(THD *thd)
TABLE *prev_table;
/* Assume thd->variables.option_bits has OPTION_QUOTE_SHOW_CREATE */
bool was_quote_show= TRUE;
+ bool error= 0;
if (!thd->temporary_tables)
- DBUG_VOID_RETURN;
+ DBUG_RETURN(FALSE);
if (!mysql_bin_log.is_open())
{
@@ -1603,7 +1604,7 @@ void close_temporary_tables(THD *thd)
close_temporary(table, 1, 1);
}
thd->temporary_tables= 0;
- DBUG_VOID_RETURN;
+ DBUG_RETURN(FALSE);
}
/* Better add "if exists", in case a RESET MASTER has been done */
@@ -1702,11 +1703,27 @@ void close_temporary_tables(THD *thd)
qinfo.db= db.ptr();
qinfo.db_len= db.length();
thd->variables.character_set_client= cs_save;
- if (mysql_bin_log.write(&qinfo))
+
+ thd->stmt_da->can_overwrite_status= TRUE;
+ if ((error= (mysql_bin_log.write(&qinfo) || error)))
{
- push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, MYF(0),
- "Failed to write the DROP statement for temporary tables to binary log");
+ /*
+ If we're here following THD::cleanup, thence the connection
+ has been closed already. So lets print a message to the
+ error log instead of pushing yet another error into the
+ stmt_da.
+
+ Also, we keep the error flag so that we propagate the error
+ up in the stack. This way, if we're the SQL thread we notice
+ that close_temporary_tables failed. (Actually, the SQL
+ thread only calls close_temporary_tables while applying old
+ Start_log_event_v3 events.)
+ */
+ sql_print_error("Failed to write the DROP statement for "
+ "temporary tables to binary log");
}
+ thd->stmt_da->can_overwrite_status= FALSE;
+
thd->variables.pseudo_thread_id= save_pseudo_thread_id;
thd->thread_specific_used= save_thread_specific_used;
}
@@ -1719,7 +1736,8 @@ void close_temporary_tables(THD *thd)
if (!was_quote_show)
thd->variables.option_bits&= ~OPTION_QUOTE_SHOW_CREATE; /* restore option */
thd->temporary_tables=0;
- DBUG_VOID_RETURN;
+
+ DBUG_RETURN(error);
}
/*
diff --git a/sql/sql_base.h b/sql/sql_base.h
index b912f80d44f..45f1408e2f5 100644
--- a/sql/sql_base.h
+++ b/sql/sql_base.h
@@ -223,7 +223,7 @@ int decide_logging_format(THD *thd, TABLE_LIST *tables);
void free_io_cache(TABLE *entry);
void intern_close_table(TABLE *entry);
bool close_thread_table(THD *thd, TABLE **table_ptr);
-void close_temporary_tables(THD *thd);
+bool close_temporary_tables(THD *thd);
TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list,
bool check_alias);
int drop_temporary_table(THD *thd, TABLE_LIST *table_list);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 60354d15091..93c3e76c047 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -13197,7 +13197,7 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
DBUG_RETURN(0);
}
- if (key_part->field != field)
+ if (key_part->field != field || !field->part_of_sortkey.is_set(idx))
DBUG_RETURN(0);
/* set flag to 1 if we can use read-next on key, else to -1 */