Commit e771ee75 authored by unknown's avatar unknown

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.
parent 663f971b
...@@ -11,6 +11,11 @@ enable_query_log; ...@@ -11,6 +11,11 @@ enable_query_log;
# Simple basic test that endspace is saved # 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); create table t1 (v varchar(10), c char(10), t text);
insert into t1 values('+ ', '+ ', '+ '); insert into t1 values('+ ', '+ ', '+ ');
set @a=repeat(' ',20); set @a=repeat(' ',20);
......
...@@ -983,6 +983,7 @@ set @a=repeat(' ',20); ...@@ -983,6 +983,7 @@ set @a=repeat(' ',20);
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a)); insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
Warnings: Warnings:
Note 1265 Data truncated for column 'v' at row 1 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; select concat('*',v,'*',c,'*',t,'*') from t1;
concat('*',v,'*',c,'*',t,'*') concat('*',v,'*',c,'*',t,'*')
*+ *+*+ * *+ *+*+ *
......
...@@ -11,7 +11,6 @@ INSERT DELAYED INTO t1 VALUES (5); ...@@ -11,7 +11,6 @@ INSERT DELAYED INTO t1 VALUES (5);
INSERT INTO t1 VALUES (@@global.sync_binlog); INSERT INTO t1 VALUES (@@global.sync_binlog);
Warnings: Warnings:
Warning 1592 Statement is not safe to log in statement format. Warning 1592 Statement is not safe to log in statement format.
DROP VIEW v1;
INSERT INTO t1 VALUES (@@session.insert_id); INSERT INTO t1 VALUES (@@session.insert_id);
Warnings: Warnings:
Warning 1592 Statement is not safe to log in statement format. Warning 1592 Statement is not safe to log in statement format.
......
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
source include/have_log_bin.inc; source include/have_log_bin.inc;
source include/have_binlog_format_statement.inc; source include/have_binlog_format_statement.inc;
DROP VIEW v1;
--echo ==== Setup tables ==== --echo ==== Setup tables ====
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
......
...@@ -767,6 +767,7 @@ struct THD_TRANS ...@@ -767,6 +767,7 @@ struct THD_TRANS
bool modified_non_trans_table; bool modified_non_trans_table;
void reset() { no_2pc= FALSE; modified_non_trans_table= FALSE; } void reset() { no_2pc= FALSE; modified_non_trans_table= FALSE; }
THD_TRANS() {} /* Remove gcc warning */
}; };
......
...@@ -1028,6 +1028,7 @@ class Item_basic_constant :public Item ...@@ -1028,6 +1028,7 @@ class Item_basic_constant :public Item
if (orig_name) if (orig_name)
name= orig_name; name= orig_name;
} }
Item_basic_constant() {} /* Remove gcc warning */
}; };
......
...@@ -1535,16 +1535,23 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) ...@@ -1535,16 +1535,23 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all)
YESNO(in_transaction), YESNO(in_transaction),
YESNO(thd->transaction.all.modified_non_trans_table), YESNO(thd->transaction.all.modified_non_trans_table),
YESNO(thd->transaction.stmt.modified_non_trans_table))); YESNO(thd->transaction.stmt.modified_non_trans_table)));
if (in_transaction && if (thd->options & OPTION_BIN_LOG)
(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); if (in_transaction &&
qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE) (all ||
int error= binlog_end_trans(thd, trx_data, &qev, all); (!trx_data->at_least_one_stmt &&
DBUG_RETURN(error); 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); DBUG_RETURN(0);
} }
......
...@@ -3533,15 +3533,17 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u) ...@@ -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 engines to do logging of insertions (optimization). We don't do it for
temporary tables (yet) as re-enabling causes an undesirable commit. 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, if (!(table= create_table_from_items(thd, create_info, create_table,
alter_info, &values, alter_info, &values,
&extra_lock, hook_ptr))) &extra_lock, hook_ptr)))
DBUG_RETURN(-1); // abort() deletes table 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) if (extra_lock)
{ {
DBUG_ASSERT(m_plock == NULL); DBUG_ASSERT(m_plock == NULL);
...@@ -3682,7 +3684,8 @@ bool select_create::send_eof() ...@@ -3682,7 +3684,8 @@ bool select_create::send_eof()
abort(); abort();
else 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); ha_enable_transaction(thd, TRUE);
/* /*
Do an implicit commit at end of statement for non-temporary Do an implicit commit at end of statement for non-temporary
...@@ -3712,9 +3715,6 @@ void select_create::abort() ...@@ -3712,9 +3715,6 @@ void select_create::abort()
{ {
DBUG_ENTER("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 In select_insert::abort() we roll back the statement, including
truncating the transaction cache of the binary log. To do this, we truncating the transaction cache of the binary log. To do this, we
...@@ -3731,11 +3731,13 @@ void select_create::abort() ...@@ -3731,11 +3731,13 @@ void select_create::abort()
log state. log state.
*/ */
tmp_disable_binlog(thd); 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(); select_insert::abort();
thd->transaction.stmt.modified_non_trans_table= FALSE; thd->transaction.stmt.modified_non_trans_table= FALSE;
reenable_binlog(thd); reenable_binlog(thd);
if (m_plock) if (m_plock)
{ {
mysql_unlock_tables(thd, *m_plock); mysql_unlock_tables(thd, *m_plock);
......
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