From de85a60049af7af2cfdaa6f642e4ea7b7189afbe Mon Sep 17 00:00:00 2001 From: Rohit Kalhans Date: Wed, 8 Feb 2012 00:33:08 +0530 Subject: BUG#11758263 50440: MARK UNORDERED UPDATE WITH AUTOINC UNSAFE Problem: Statements that write to tables with auto_increment columns based on the selection from another table, may lead to master and slave going out of sync, as the order in which the rows are retrived from the table may differ on master and slave. Solution: We mark writing to a table with auto_increment table as unsafe. This will cause the execution of such statements to throw a warning and forces the statement to be logged in ROW if the logging format is mixed. Changes: 1. All the statements that writes to a table with auto_increment column(s) based on the rows fetched from another table, will now be unsafe. 2. CREATE TABLE with SELECT will now be unsafe. sql/share/errmsg-utf8.txt: Added new Warning messages sql/sql_base.cc: created a new function that checks for select + write on a autoinc table made all such statements to be unsafe. sql/sql_parse.cc: made create autoincremnet tabble + select unsafe --- sql/sql_parse.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a5d23858a8d..f26deb9a01a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2414,9 +2414,12 @@ case SQLCOM_PREPARE: select_result *result; /* - CREATE TABLE...IGNORE/REPLACE SELECT... can be unsafe, unless - ORDER BY PRIMARY KEY clause is used in SELECT statement. We therefore - use row based logging if mixed or row based logging is available. + - CREATE TABLE...IGNORE + - REPLACE SELECT... + - CREATE TABLE [with auto inc. column]...SELECT + can be unsafe, unless ORDER BY PRIMARY KEY clause is used in SELECT + statement. We therefore use row based logging if mixed or row based + logging is available. TODO: Check if the order of the output of the select statement is deterministic. Waiting for BUG#42415 */ @@ -2426,6 +2429,9 @@ case SQLCOM_PREPARE: if(lex->duplicates == DUP_REPLACE) lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT); + if (lex->type & AUTO_INCREMENT_FLAG) + lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC); + /* If: a) we inside an SP and there was NAME_CONST substitution, -- cgit v1.2.1 From b7430d73e4be2f5933e147ba7a44e3b054cb79b7 Mon Sep 17 00:00:00 2001 From: Rohit Kalhans Date: Wed, 8 Feb 2012 12:10:55 +0530 Subject: Backout the patch for bug#11758263. --- sql/sql_parse.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f26deb9a01a..a5d23858a8d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2414,12 +2414,9 @@ case SQLCOM_PREPARE: select_result *result; /* - - CREATE TABLE...IGNORE - - REPLACE SELECT... - - CREATE TABLE [with auto inc. column]...SELECT - can be unsafe, unless ORDER BY PRIMARY KEY clause is used in SELECT - statement. We therefore use row based logging if mixed or row based - logging is available. + CREATE TABLE...IGNORE/REPLACE SELECT... can be unsafe, unless + ORDER BY PRIMARY KEY clause is used in SELECT statement. We therefore + use row based logging if mixed or row based logging is available. TODO: Check if the order of the output of the select statement is deterministic. Waiting for BUG#42415 */ @@ -2429,9 +2426,6 @@ case SQLCOM_PREPARE: if(lex->duplicates == DUP_REPLACE) lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT); - if (lex->type & AUTO_INCREMENT_FLAG) - lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC); - /* If: a) we inside an SP and there was NAME_CONST substitution, -- cgit v1.2.1