summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/examples/ha_archive.cc30
-rw-r--r--sql/ha_innodb.cc19
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/log.cc5
-rw-r--r--sql/mysqld.cc6
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_delete.cc2
-rw-r--r--sql/sql_parse.cc47
8 files changed, 52 insertions, 60 deletions
diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc
index b33b5102e69..fb9a9d2281a 100644
--- a/sql/examples/ha_archive.cc
+++ b/sql/examples/ha_archive.cc
@@ -133,6 +133,23 @@ static HASH archive_open_tables;
#define DATA_BUFFER_SIZE 2 // Size of the data used in the data file
#define ARCHIVE_CHECK_HEADER 254 // The number we use to determine corruption
+/* dummy handlerton - only to have something to return from archive_db_init */
+static handlerton archive_hton = {
+ 0, /* slot */
+ 0, /* savepoint size. */
+ 0, /* close_connection */
+ 0, /* savepoint */
+ 0, /* rollback to savepoint */
+ 0, /* releas savepoint */
+ 0, /* commit */
+ 0, /* rollback */
+ 0, /* prepare */
+ 0, /* recover */
+ 0, /* commit_by_xid */
+ 0 /* rollback_by_xid */
+};
+
+
/*
Used for hash table that tracks open tables.
*/
@@ -152,18 +169,19 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length,
void
RETURN
- FALSE OK
- TRUE Error
+ &archive_hton OK
+ 0 Error
*/
-bool archive_db_init()
+handlerton *archive_db_init()
{
VOID(pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST));
- return (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0,
- (hash_get_key) archive_get_key, 0, 0));
+ if (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0,
+ (hash_get_key) archive_get_key, 0, 0))
+ return 0;
+ return &archive_hton;
}
-
/*
Release the archive handler.
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index ee9009ebf27..dafed2fd510 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -154,6 +154,7 @@ static int innobase_commit(THD* thd, bool all);
static int innobase_rollback(THD* thd, bool all);
static int innobase_rollback_to_savepoint(THD* thd, void *savepoint);
static int innobase_savepoint(THD* thd, void *savepoint);
+static int innobase_release_savepoint(THD* thd, void *savepoint);
static handlerton innobase_hton = {
0, /* slot */
@@ -161,7 +162,7 @@ static handlerton innobase_hton = {
innobase_close_connection,
innobase_savepoint,
innobase_rollback_to_savepoint,
- innobase_release_savepoint
+ innobase_release_savepoint,
innobase_commit, /* commit */
innobase_rollback, /* rollback */
innobase_xa_prepare, /* prepare */
@@ -1701,7 +1702,7 @@ innobase_rollback_to_savepoint(
/*********************************************************************
Release transaction savepoint name. */
-int
+static int
innobase_release_savepoint(
/*===========================*/
/* out: 0 if success, HA_ERR_NO_SAVEPOINT if
@@ -5575,12 +5576,16 @@ ha_innobase::transactional_table_lock(
/* MySQL is setting a new transactional table lock */
/* Set the MySQL flag to mark that there is an active transaction */
- thd->transaction.all.innodb_active_trans = 1;
+ if (trx->active_trans == 0) {
+
+ register_trans(thd);
+ trx->active_trans = 1;
+ }
if (thd->in_lock_tables && thd->variables.innodb_table_locks) {
ulint error = DB_SUCCESS;
- error = row_lock_table_for_mysql(prebuilt,NULL,
+ error = row_lock_table_for_mysql(prebuilt,NULL,
LOCK_TABLE_TRANSACTIONAL);
if (error != DB_SUCCESS) {
@@ -6299,9 +6304,9 @@ innobase_xa_prepare(
}
if (all || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
-
- /* We were instructed to prepare the whole transaction, or
- this is an SQL statement end and autocommit is on */
+
+ /* We were instructed to prepare the whole transaction, or
+ this is an SQL statement end and autocommit is on */
error = trx_prepare_for_mysql(trx);
} else {
diff --git a/sql/handler.cc b/sql/handler.cc
index c3144d16ec0..d1331243361 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1530,6 +1530,8 @@ int ha_enable_transaction(THD *thd, bool on)
DBUG_ENTER("ha_enable_transaction");
thd->transaction.on= on;
+ if (on)
+ ha_commit(thd);
DBUG_RETURN(error);
}
diff --git a/sql/log.cc b/sql/log.cc
index ca9cb6e3238..7d6f2abb022 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -64,14 +64,11 @@ static handlerton binlog_hton = {
this function is mostly a placeholder.
conceptually, binlog initialization (now mostly done in MYSQL_LOG::open)
should be moved here.
-
- for now, we fail if binlog is closed (mysql_bin_log.open() failed for some
- reason) - it'll make mysqld to shutdown.
*/
handlerton *binlog_init()
{
- return mysql_bin_log.is_open() : &binlog_hton : 0;
+ return &binlog_hton;
}
static int binlog_close_connection(THD *thd)
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 8b505ccb2fa..a30cc46677a 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2743,9 +2743,9 @@ server.");
unireg_abort(1);
}
- if (opt_bin_log)
- mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
- WRITE_CACHE, 0, max_binlog_size, 0);
+ if (opt_bin_log && mysql_bin_log.open(opt_bin_logname, LOG_BIN, 0,
+ WRITE_CACHE, 0, max_binlog_size, 0))
+ unireg_abort(1);
#ifdef HAVE_REPLICATION
if (opt_bin_log && expire_logs_days)
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 835e9dd2362..4ff9e7ecece 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1835,7 +1835,6 @@ class multi_update :public select_result_interceptor
uint table_count;
Copy_field *copy_field;
enum enum_duplicates handle_duplicates;
- bool do_update, trans_safe, transactional_tables;
bool do_update, trans_safe, transactional_tables, ignore;
public:
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 0033e419351..1737a277466 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -732,7 +732,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
If we return here we will not have logged the truncation to the bin log
and we will not send_ok() to the client.
*/
- goto end;
+ goto end;
}
(void) sprintf(path,"%s/%s/%s%s",mysql_data_home,table_list->db,
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 6f29e8b848d..8c1b786bd68 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -833,17 +833,6 @@ static int check_connection(THD *thd)
return(ER_OUT_OF_RESOURCES);
thd->client_capabilities=uint2korr(net->read_pos);
-#ifdef TO_BE_REMOVED_IN_4_1_RELEASE
- /*
- This is just a safety check against any client that would use the old
- CLIENT_CHANGE_USER flag
- */
- if ((thd->client_capabilities & CLIENT_PROTOCOL_41) &&
- !(thd->client_capabilities & (CLIENT_RESERVED |
- CLIENT_SECURE_CONNECTION |
- CLIENT_MULTI_RESULTS)))
- thd->client_capabilities&= ~CLIENT_PROTOCOL_41;
-#endif
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
{
thd->client_capabilities|= ((ulong) uint2korr(net->read_pos+2)) << 16;
@@ -1351,36 +1340,15 @@ int end_trans_and_send_ok(THD *thd, enum enum_mysql_completiontype completion)
case ROLLBACK:
case ROLLBACK_AND_CHAIN:
{
- bool warn= 0;
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
- if (!ha_rollback(thd))
- {
- /*
- If a non-transactional table was updated, warn; don't warn if this is a
- slave thread (because when a slave thread executes a ROLLBACK, it has
- been read from the binary log, so it's 100% sure and normal to produce
- error ER_WARNING_NOT_COMPLETE_ROLLBACK. If we sent the warning to the
- slave SQL thread, it would not stop the thread but just be printed in
- the error log; but we don't want users to wonder why they have this
- message in the error log, so we don't send it.
- */
- warn= (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) &&
- !thd->slave_thread;
- }
- else
+ if (ha_rollback(thd))
res= -1;
thd->options&= ~(ulong) (OPTION_BEGIN | OPTION_STATUS_NO_TRANS_UPDATE);
if (!res && (completion == ROLLBACK_AND_CHAIN))
res= begin_trans(thd);
if (!res)
- {
- if (warn)
- push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARNING_NOT_COMPLETE_ROLLBACK,
- ER(ER_WARNING_NOT_COMPLETE_ROLLBACK));
send_ok(thd);
- }
break;
}
default:
@@ -3886,16 +3854,16 @@ unsent_create_error:
break;
case SQLCOM_COMMIT:
if (end_trans_and_send_ok(thd, lex->tx_release ? COMMIT_RELEASE :
- lex->tx_chain ? COMMIT_AND_CHAIN : COMMIT, 0))
+ lex->tx_chain ? COMMIT_AND_CHAIN : COMMIT))
goto error;
break;
case SQLCOM_ROLLBACK:
if (end_trans_and_send_ok(thd, lex->tx_release ? ROLLBACK_RELEASE :
- lex->tx_chain ? ROLLBACK_AND_CHAIN : ROLLBACK,
- 0))
+ lex->tx_chain ? ROLLBACK_AND_CHAIN : ROLLBACK))
goto error;
break;
case SQLCOM_RELEASE_SAVEPOINT:
+ {
SAVEPOINT **sv;
for (sv=&thd->transaction.savepoints; *sv; sv=&(*sv)->prev)
{
@@ -3908,7 +3876,9 @@ unsent_create_error:
{
if (ha_release_savepoint(thd, *sv))
res= TRUE; // cannot happen
- *sv= 0;
+ else
+ send_ok(thd);
+ *sv=(*sv)->prev;
}
else
{
@@ -3918,6 +3888,7 @@ unsent_create_error:
break;
}
case SQLCOM_ROLLBACK_TO_SAVEPOINT:
+ {
SAVEPOINT **sv;
for (sv=&thd->transaction.savepoints; *sv; sv=&(*sv)->prev)
{
@@ -3939,7 +3910,7 @@ unsent_create_error:
ER(ER_WARNING_NOT_COMPLETE_ROLLBACK));
send_ok(thd);
}
- *sv= 0;
+ *sv=(*sv)->prev;
}
else
{