summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorjimw@mysql.com <>2004-12-03 00:05:11 +0100
committerjimw@mysql.com <>2004-12-03 00:05:11 +0100
commit13649d90ae90257620461cdd97bbf217bd1b1755 (patch)
treec6630df438ab32a1664bb54903e60729d5755629 /sql
parent7ed2753300a9fe874149ba9f3d8255726c60414e (diff)
downloadmariadb-git-13649d90ae90257620461cdd97bbf217bd1b1755.tar.gz
Prevent adding 'CREATE TABLE .. SELECT' query to the binary log when the
insertion of new records partially failed. It would get logged because of the logic to log a partially-failed 'INSERT ... SELECT' (which can't be rolled back in non-transactional tables), but 'CREATE TABLE ... SELECT' is always rolled back on failure, even for non-transactional tables. (Bug #6682) (Original fix reimplemented after review by Serg and Guilhem.)
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_class.h10
-rw-r--r--sql/sql_insert.cc13
-rw-r--r--sql/sql_table.cc8
3 files changed, 23 insertions, 8 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 4250ebdd568..17d371d3dc0 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -637,6 +637,15 @@ public:
#endif
};
+# 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
@@ -781,6 +790,7 @@ public:
{}
int prepare(List<Item> &list);
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 8912c1faf2a..0c62a9af7ba 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1505,6 +1505,19 @@ bool select_create::send_data(List<Item> &values)
return 0;
}
+
+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);
+}
+
+
extern HASH open_cache;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 1e5237b1428..33bdd992efb 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -31,14 +31,6 @@
#endif
#include "sql_acl.h" // for SUPER_ACL
-# 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;
extern HASH open_cache;
static const char *primary_key_name="PRIMARY";