Commit e57c8007 authored by unknown's avatar unknown

Manual merge from 5.0

parent 0fdd64ba
......@@ -644,7 +644,7 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
ok:
if (dbchanged)
(void) mysql_change_db(thd, old_db.str, 1);
(void) mysql_change_db(thd, &old_db, 1);
/*
This statement may cause a spooky valgrind warning at startup
inside init_key_cache on my system (ahristov, 2006/08/10)
......@@ -654,7 +654,7 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
err:
if (dbchanged)
(void) mysql_change_db(thd, old_db.str, 1);
(void) mysql_change_db(thd, &old_db, 1);
if (table)
close_thread_tables(thd);
DBUG_RETURN(TRUE);
......
......@@ -3083,9 +3083,7 @@ static bool set_option_autocommit(THD *thd, set_var *var)
if ((org_options & OPTION_NOT_AUTOCOMMIT))
{
/* We changed to auto_commit mode */
thd->options&= ~(ulonglong) (OPTION_BEGIN |
OPTION_STATUS_NO_TRANS_UPDATE |
OPTION_KEEP_LOG);
thd->options&= ~(ulonglong) (OPTION_BEGIN | OPTION_KEEP_LOG);
thd->no_trans_update.all= FALSE;
thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
if (ha_commit(thd))
......@@ -3094,7 +3092,6 @@ static bool set_option_autocommit(THD *thd, set_var *var)
else
{
thd->no_trans_update.all= FALSE;
thd->options&= ~(ulonglong) (OPTION_STATUS_NO_TRANS_UPDATE);
thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT;
}
}
......
......@@ -315,6 +315,7 @@ int check_user(THD *thd, enum enum_server_command command,
bool check_count)
{
DBUG_ENTER("check_user");
LEX_STRING db_str= { (char *) db, db ? strlen(db) : 0 };
#ifdef NO_EMBEDDED_ACCESS_CHECKS
thd->main_security_ctx.master_access= GLOBAL_ACLS; // Full rights
......@@ -326,7 +327,7 @@ int check_user(THD *thd, enum enum_server_command command,
function returns 0
*/
thd->reset_db(NULL, 0);
if (mysql_change_db(thd, db, FALSE))
if (mysql_change_db(thd, &db_str, FALSE))
{
/* Send the error to the client */
net_send_error(thd);
......@@ -472,7 +473,7 @@ int check_user(THD *thd, enum enum_server_command command,
/* Change database if necessary */
if (db && db[0])
{
if (mysql_change_db(thd, db, FALSE))
if (mysql_change_db(thd, &db_str, FALSE))
{
/* Send error to the client */
net_send_error(thd);
......
......@@ -22,6 +22,7 @@
#include "events.h"
#include <my_dir.h>
#include <m_ctype.h>
#include "log.h"
#ifdef __WIN__
#include <direct.h>
#endif
......@@ -1420,7 +1421,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
to be sure.
*/
if (check_db_name(new_db_file_name.str))
if (check_db_name(&new_db_file_name))
{
my_error(ER_WRONG_DB_NAME, MYF(0), new_db_file_name.str);
my_free(new_db_file_name.str, MYF(0));
......@@ -1454,8 +1455,9 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
sctx->priv_user,
sctx->priv_host,
new_db_file_name.str);
mysql_log.write(thd, COM_INIT_DB, ER(ER_DBACCESS_DENIED_ERROR),
sctx->priv_user, sctx->priv_host, new_db_file_name.str);
general_log_print(thd, COM_INIT_DB, ER(ER_DBACCESS_DENIED_ERROR),
sctx->priv_user, sctx->priv_host,
new_db_file_name.str);
my_free(new_db_file_name.str, MYF(0));
DBUG_RETURN(TRUE);
}
......@@ -1801,7 +1803,7 @@ bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db)
/* Step9: Let's do "use newdb" if we renamed the current database */
if (change_to_newdb)
error|= mysql_change_db(thd, new_db->str, 0);
error|= mysql_change_db(thd, new_db, 0);
exit:
pthread_mutex_lock(&LOCK_lock_db);
......
......@@ -712,7 +712,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
}
}
if (!transactional_table)
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
thd->no_trans_update.all= TRUE;
}
}
if (transactional_table)
......@@ -1322,7 +1322,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
goto err;
info->deleted++;
if (!table->file->has_transactions())
thd->no_trans_update= 1;
thd->no_trans_update.stmt= TRUE;
if (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
TRG_ACTION_AFTER, TRUE))
......@@ -2638,7 +2638,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
if (info.handle_duplicates == DUP_REPLACE &&
(!table->triggers || !table->triggers->has_delete_triggers()))
table->file->extra(HA_EXTRA_WRITE_CAN_REPLACE);
thd->no_trans_update= 0;
thd->no_trans_update.stmt= FALSE;
thd->abort_on_warning= (!info.ignore &&
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
......
......@@ -720,7 +720,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
&LOCK_status);
thd->convert_string(&tmp, system_charset_info,
packet, packet_length-1, thd->charset());
if (!mysql_change_db(thd, tmp.str, FALSE))
if (!mysql_change_db(thd, &tmp, FALSE))
{
general_log_print(thd, command, "%s",thd->db);
send_ok(thd);
......@@ -4208,8 +4208,8 @@ mysql_execute_command(THD *thd)
xa_state_names[thd->transaction.xid_state.xa_state]);
break;
}
thd->options&= ~(OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE |
OPTION_KEEP_LOG);
thd->options&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
thd->no_trans_update.all= FALSE;
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
xid_cache_delete(&thd->transaction.xid_state);
thd->transaction.xid_state.xa_state=XA_NOTR;
......@@ -5023,8 +5023,10 @@ void mysql_reset_thd_for_next_command(THD *thd)
in ha_rollback_trans() about some tables couldn't be rolled back.
*/
if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
thd->options&= ~(OPTION_STATUS_NO_TRANS_UPDATE | OPTION_KEEP_LOG);
{
thd->options&= ~OPTION_KEEP_LOG;
thd->no_trans_update.all= FALSE;
}
DBUG_ASSERT(thd->security_ctx== &thd->main_security_ctx);
thd->tmp_table_used= 0;
if (!thd->in_sub_stmt)
......
......@@ -535,7 +535,7 @@ int mysql_update(THD *thd,
if (!error)
{
updated++;
thd->no_trans_update= !transactional_table;
thd->no_trans_update.stmt= !transactional_table;
if (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment