mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
Manual merge and some fixes.
mysql-test/include/varchar.inc: Manual merge between 5.1 and maria. Added a comment. mysql-test/r/maria.result: Temporary fix. mysql-test/suite/binlog/r/binlog_unsafe.result: Manual merge. mysql-test/suite/binlog/t/binlog_unsafe.test: Manual merge. sql/handler.h: Manual merge + fix. sql/item.h: Manual merge + fix. sql/log.cc: Manual merge + fix. sql/sql_insert.cc: Manual merge + fix. A commit was done when using create table ... select from for transactional tables other than maria, when an error occurred and transaction should have been aborted.
This commit is contained in:
parent
663f971b8d
commit
e771ee75e7
8 changed files with 34 additions and 19 deletions
|
@ -11,6 +11,11 @@ enable_query_log;
|
|||
# Simple basic test that endspace is saved
|
||||
#
|
||||
|
||||
#
|
||||
# Remember to check that one doesn't get a warning or a note
|
||||
# from a char field when end spaces get removed. SQL standard!
|
||||
#
|
||||
|
||||
create table t1 (v varchar(10), c char(10), t text);
|
||||
insert into t1 values('+ ', '+ ', '+ ');
|
||||
set @a=repeat(' ',20);
|
||||
|
|
|
@ -983,6 +983,7 @@ set @a=repeat(' ',20);
|
|||
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'v' at row 1
|
||||
Note 1265 Data truncated for column 'c' at row 1
|
||||
select concat('*',v,'*',c,'*',t,'*') from t1;
|
||||
concat('*',v,'*',c,'*',t,'*')
|
||||
*+ *+*+ *
|
||||
|
|
|
@ -11,7 +11,6 @@ INSERT DELAYED INTO t1 VALUES (5);
|
|||
INSERT INTO t1 VALUES (@@global.sync_binlog);
|
||||
Warnings:
|
||||
Warning 1592 Statement is not safe to log in statement format.
|
||||
DROP VIEW v1;
|
||||
INSERT INTO t1 VALUES (@@session.insert_id);
|
||||
Warnings:
|
||||
Warning 1592 Statement is not safe to log in statement format.
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
source include/have_log_bin.inc;
|
||||
source include/have_binlog_format_statement.inc;
|
||||
|
||||
DROP VIEW v1;
|
||||
--echo ==== Setup tables ====
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
|
|
|
@ -767,6 +767,7 @@ struct THD_TRANS
|
|||
bool modified_non_trans_table;
|
||||
|
||||
void reset() { no_2pc= FALSE; modified_non_trans_table= FALSE; }
|
||||
THD_TRANS() {} /* Remove gcc warning */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1028,6 +1028,7 @@ public:
|
|||
if (orig_name)
|
||||
name= orig_name;
|
||||
}
|
||||
Item_basic_constant() {} /* Remove gcc warning */
|
||||
};
|
||||
|
||||
|
||||
|
|
25
sql/log.cc
25
sql/log.cc
|
@ -1535,16 +1535,23 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all)
|
|||
YESNO(in_transaction),
|
||||
YESNO(thd->transaction.all.modified_non_trans_table),
|
||||
YESNO(thd->transaction.stmt.modified_non_trans_table)));
|
||||
if (in_transaction &&
|
||||
(all ||
|
||||
(!trx_data->at_least_one_stmt &&
|
||||
thd->transaction.stmt.modified_non_trans_table)) ||
|
||||
!in_transaction && !all)
|
||||
if (thd->options & OPTION_BIN_LOG)
|
||||
{
|
||||
Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE);
|
||||
qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE)
|
||||
int error= binlog_end_trans(thd, trx_data, &qev, all);
|
||||
DBUG_RETURN(error);
|
||||
if (in_transaction &&
|
||||
(all ||
|
||||
(!trx_data->at_least_one_stmt &&
|
||||
thd->transaction.stmt.modified_non_trans_table)) ||
|
||||
!in_transaction && !all)
|
||||
{
|
||||
Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE);
|
||||
qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE)
|
||||
int error= binlog_end_trans(thd, trx_data, &qev, all);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
trx_data->reset();
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
|
|
@ -3533,15 +3533,17 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
|
|||
engines to do logging of insertions (optimization). We don't do it for
|
||||
temporary tables (yet) as re-enabling causes an undesirable commit.
|
||||
*/
|
||||
if (((thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) == 0) &&
|
||||
ha_enable_transaction(thd, FALSE))
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
if (!(table= create_table_from_items(thd, create_info, create_table,
|
||||
alter_info, &values,
|
||||
&extra_lock, hook_ptr)))
|
||||
DBUG_RETURN(-1); // abort() deletes table
|
||||
|
||||
if (((thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) == 0) &&
|
||||
!create_info->table_existed &&
|
||||
ha_enable_transaction(thd, FALSE))
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
if (extra_lock)
|
||||
{
|
||||
DBUG_ASSERT(m_plock == NULL);
|
||||
|
@ -3682,7 +3684,8 @@ bool select_create::send_eof()
|
|||
abort();
|
||||
else
|
||||
{
|
||||
if ((thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) == 0)
|
||||
if ((thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) == 0 &&
|
||||
!create_info->table_existed)
|
||||
ha_enable_transaction(thd, TRUE);
|
||||
/*
|
||||
Do an implicit commit at end of statement for non-temporary
|
||||
|
@ -3712,9 +3715,6 @@ void select_create::abort()
|
|||
{
|
||||
DBUG_ENTER("select_create::abort");
|
||||
|
||||
if ((thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) == 0)
|
||||
ha_enable_transaction(thd, TRUE);
|
||||
|
||||
/*
|
||||
In select_insert::abort() we roll back the statement, including
|
||||
truncating the transaction cache of the binary log. To do this, we
|
||||
|
@ -3731,11 +3731,13 @@ void select_create::abort()
|
|||
log state.
|
||||
*/
|
||||
tmp_disable_binlog(thd);
|
||||
if ((thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) == 0 &&
|
||||
!create_info->table_existed)
|
||||
ha_enable_transaction(thd, TRUE);
|
||||
select_insert::abort();
|
||||
thd->transaction.stmt.modified_non_trans_table= FALSE;
|
||||
reenable_binlog(thd);
|
||||
|
||||
|
||||
if (m_plock)
|
||||
{
|
||||
mysql_unlock_tables(thd, *m_plock);
|
||||
|
|
Loading…
Add table
Reference in a new issue