summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjimw@mysql.com <>2004-12-03 00:39:55 +0100
committerjimw@mysql.com <>2004-12-03 00:39:55 +0100
commit4b8e96d5ca349209a4ab0889df6e18b66aa27097 (patch)
tree53ebea55676a1cbab3ffb260b9f465ae28508351
parenteb6c38fe9c129c238fbfc2defbcd832284c0d7b8 (diff)
parent13649d90ae90257620461cdd97bbf217bd1b1755 (diff)
downloadmariadb-git-4b8e96d5ca349209a4ab0889df6e18b66aa27097.tar.gz
Merge
-rw-r--r--BitKeeper/etc/logging_ok1
-rw-r--r--mysql-test/r/insert_select.result9
-rw-r--r--mysql-test/t/insert_select.test13
-rw-r--r--sql/sql_class.h10
-rw-r--r--sql/sql_insert.cc12
-rw-r--r--sql/sql_table.cc6
6 files changed, 45 insertions, 6 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index 00f4c86d319..b8043910a11 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -87,6 +87,7 @@ jcole@mugatu.jcole.us
jcole@mugatu.spaceapes.com
jcole@sarvik.tfr.cafe.ee
jcole@tetra.spaceapes.com
+jimw@mysql.com
joerg@mysql.com
joreland@mysql.com
jorge@linux.jorge.mysql.com
diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result
index 7c7ac152aa5..fcb4229fcdb 100644
--- a/mysql-test/r/insert_select.result
+++ b/mysql-test/r/insert_select.result
@@ -81,6 +81,15 @@ a
1
2
drop table t1, t2;
+create table t1(a int);
+insert into t1 values(1),(1);
+reset master;
+create table t2(unique(a)) select a from t1;
+Duplicate entry '1' for key 1
+show binlog events;
+Log_name Pos Event_type Server_id Orig_log_pos Info
+master-bin.001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
+drop table t1;
create table t1 (a int not null);
create table t2 (a int not null);
insert into t1 values (1);
diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test
index db5dc8d91da..e1459310bb9 100644
--- a/mysql-test/t/insert_select.test
+++ b/mysql-test/t/insert_select.test
@@ -89,6 +89,19 @@ show binlog events;
select * from t1;
drop table t1, t2;
+# Verify that a partly-completed CREATE TABLE .. SELECT does not
+# get into the binlog (Bug #6682)
+create table t1(a int);
+insert into t1 values(1),(1);
+reset master;
+--error 1062
+create table t2(unique(a)) select a from t1;
+# The above should produce an error, *and* not appear in the binlog
+let $VERSION=`select version()`;
+--replace_result $VERSION VERSION
+show binlog events;
+drop table t1;
+
#
# Test of insert ... select from same table
#
diff --git a/sql/sql_class.h b/sql/sql_class.h
index d0d9afc7746..4e695701310 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1092,6 +1092,15 @@ public:
void end_statement();
};
+# define tmp_disable_binlog(A) \
+ ulong save_options= (A)->options, save_master_access= (A)->master_access; \
+ (A)->options&= ~OPTION_BIN_LOG; \
+ (A)->master_access|= SUPER_ACL; /* unneeded in 4.1 */
+
+#define reenable_binlog(A) \
+ (A)->options= save_options; \
+ (A)->master_access= save_master_access;
+
/* Flags for the THD::system_thread (bitmap) variable */
#define SYSTEM_THREAD_DELAYED_INSERT 1
#define SYSTEM_THREAD_SLAVE_IO 2
@@ -1263,6 +1272,7 @@ public:
{}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &values);
+ void send_error(uint errcode,const char *err);
bool send_eof();
void abort();
};
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index d590d3b5093..d63bb29affa 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1667,6 +1667,18 @@ bool select_create::send_data(List<Item> &values)
}
+void select_create::send_error(uint errcode,const char *err)
+{
+ /*
+ Disable binlog, because we "roll back" partial inserts in ::abort
+ by removing the table, even for non-transactional tables.
+ */
+ tmp_disable_binlog(thd);
+ select_insert::send_error(errcode, err);
+ reenable_binlog(thd);
+}
+
+
bool select_create::send_eof()
{
bool tmp=select_insert::send_eof();
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 71ce9102fbb..abb840568c3 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -29,12 +29,6 @@
#include <io.h>
#endif
-#define tmp_disable_binlog(A) \
- ulong save_options= (A)->options; \
- (A)->options&= ~OPTION_BIN_LOG;
-
-#define reenable_binlog(A) (A)->options= save_options;
-
const char *primary_key_name="PRIMARY";
static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end);