MariaDB server is a community developed fork of MySQL server. Started by core members of the original MySQL team, MariaDB actively works with outside developers to deliver the most featureful, stable, and sanely licensed open SQL server in the industry.
Find a file
Praveenkumar Hulakund 9af695fb45 Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES IGNORED AND BREAKS REPLICATION
Analysis:
========================
sql_mode "NO_BACKSLASH_ESCAPES": When user want to use backslash as character input,
instead of escape character in a string literal then sql_mode can be set to 
"NO_BACKSLASH_ESCAPES". With this mode enabled, backslash becomes an ordinary 
character like any other. 

SQL_MODE set applies to the current client session. And while creating the stored 
procedure, MySQL stores the current sql_mode and always executes the stored 
procedure in sql_mode stored with the Procedure, regardless of the server SQL 
mode in effect when the routine is invoked.  

In the scenario (for which bug is reported), the routine is created with 
sql_mode=NO_BACKSLASH_ESCAPES. And routine is executed with the invoker sql_mode
is "" (NOT SET) by executing statement "call testp('Axel\'s')".
Since invoker sql_mode is "" (NOT_SET), the '\' in 'Axel\'s'(argument to function)
is considered as escape character and column "a" (of table "t1") values are 
updated with "Axel's". The binary log generated for above update operation is as below,

  set sql_mode=XXXXXX (for no_backslash_escapes)
  update test.t1 set a= NAME_CONST('var',_latin1'Axel\'s' COLLATE 'latin1_swedish_ci');

While logging stored procedure statements, the local variables (params) used in
statements are replaced with the NAME_CONST(var_name, var_value) (Internal function) 
(http://dev.mysql.com/doc/refman/5.6/en/miscellaneous-functions.html#function_name-const)

On slave, these logs are applied. NAME_CONST is parsed to get the variable and its
value. Since, stored procedure is created with sql_mode="NO_BACKSLASH_ESCAPES", the sql_mode
is also logged in. So that at slave this sql_mode is set before executing the statements
of routine.  So at slave, sql_mode is set to "NO_BACKSLASH_ESCAPES" and then while
parsing NAME_CONST of string variable, '\' is considered as NON ESCAPE character
and parsing reported error for "'" (as we have only one "'" no backslash). 

At slave, parsing was proper with sql_mode "NO_BACKSLASH_ESCAPES".
But above error reported while writing bin log, "'" (of Axel's) is escaped with
"\" character. Actually, all special characters (n, r, ', ", \, 0...) are escaped
while writing NAME_CONST for string variable(param, local variable) in bin log 
Airrespective of "NO_BACKSLASH_ESCAPES" sql_mode. So, basically, the problem is 
that logging string parameter does not take into account sql_mode value.

Fix:
========================
So when sql_mode is set to "NO_BACKSLASH_ESCAPES", escaping  characters as 
(n, r, ', ", \, 0...) should be avoided. To do so, added a check to not to
escape such characters while writing NAME_CONST for string variables in bin 
log. 
And when sql_mode is set to NO_BACKSLASH_ESCAPES, quote character "'" is
represented as ''.
http://dev.mysql.com/doc/refman/5.6/en/string-literals.html (There are several 
ways to include quote characters within a string: )
2012-02-29 12:23:15 +05:30
.bzr-mysql merge mysql-5.0-security->mysql-5.1-security 2011-08-17 13:25:33 +03:00
BitKeeper Merge trift2.:/MySQL/M51/mysql-5.1 2008-01-28 15:16:40 +01:00
BUILD Updated/added copyright headers 2011-06-30 17:37:13 +02:00
client Updated/added copyright headers 2012-02-15 17:21:38 +01:00
cmd-line-utils Fixes required to build on AIX 2012-01-11 18:40:29 +01:00
config/ac-macros Bug#57991: Compiler flag change build error : adler32.c 2010-12-07 13:06:20 -02:00
dbug Merge 2010-12-29 00:47:05 +01:00
Docs Makefile.am: 2008-04-08 11:44:18 +02:00
extra 2nd fix for Bug #55713 innochecksum is NOT built with large file support enabled 2011-08-17 00:34:11 +02:00
include Updated/added copyright headers 2012-02-15 17:21:38 +01:00
libmysql Updated/added copyright headers 2011-07-03 17:47:37 +02:00
libmysql_r Merge from mysql-5.0-bugteam. 2010-11-24 13:07:37 +03:00
libmysqld Updated/added copyright headers 2012-02-15 17:21:38 +01:00
man Updated/added copyright headers 2011-06-30 17:37:13 +02:00
mysql-test Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES IGNORED AND BREAKS REPLICATION 2012-02-29 12:23:15 +05:30
mysys Updated/added copyright headers 2012-02-15 17:21:38 +01:00
netware Bug #45058 init_available_charsets uses double checked locking 2009-12-12 19:11:25 +01:00
plugin Updated/added copyright headers 2011-07-03 17:47:37 +02:00
regex Updated/added copyright headers 2011-06-30 17:37:13 +02:00
scripts Updated/added copyright headers 2012-02-15 17:21:38 +01:00
server-tools Updated/added copyright headers 2011-06-30 17:37:13 +02:00
sql Bug#12601974 - STORED PROCEDURE SQL_MODE=NO_BACKSLASH_ESCAPES IGNORED AND BREAKS REPLICATION 2012-02-29 12:23:15 +05:30
sql-bench Updated/added copyright headers 2011-06-30 17:37:13 +02:00
sql-common Updated/added copyright headers 2012-02-15 17:21:38 +01:00
storage Bug#13721257 RACE CONDITION IN UPDATES OR INSERTS OF WIDE RECORDS 2012-02-17 11:42:04 +02:00
strings Updated/added copyright headers 2012-02-15 17:21:38 +01:00
support-files Fix bug#11886309: RPM UPGRADE OF MYSQL ADVANCED GPL TO MYSQL SERVER ADVANCED DOES NOT WORK 2011-10-04 15:58:19 +02:00
tests Fix Windows-build failure: use my_snprintf() instead of snprintf(). 2011-10-20 18:06:41 +04:00
unittest Updated/added copyright headers 2012-02-15 17:21:38 +01:00
vio Updated/added copyright headers 2011-07-03 17:47:37 +02:00
win Updated/added copyright headers 2011-07-03 17:47:37 +02:00
zlib The header "config.h" needs to be included "early" to control other headers. 2008-10-13 14:23:39 +02:00
.bzrignore merge 2011-04-20 18:00:50 +02:00
.cvsignore Import changeset 2000-07-31 21:29:14 +02:00
CMakeLists.txt Updated/added copyright headers 2011-07-03 17:47:37 +02:00
configure.in merged and updated the version in mysql-5.1 2012-02-21 14:14:52 +02:00
COPYING Use a new version of "COPYING", the GPL text. 2010-03-04 14:26:27 +01:00
INSTALL-SOURCE ReadMe.txt, INSTALL-WIN-SOURCE, INSTALL-BINARY, INSTALL-SOURCE: 2007-11-23 10:15:55 +01:00
INSTALL-WIN-SOURCE ReadMe.txt, INSTALL-WIN-SOURCE, INSTALL-BINARY, INSTALL-SOURCE: 2007-11-23 10:15:55 +01:00
Makefile.am Merge 2010-12-29 00:47:05 +01:00
README Removed the "Third-Party Component Notices" part from README 2011-03-16 23:07:05 +01:00

MySQL Server 5.1

This is a release of MySQL, a dual-license SQL database server.
For the avoidance of doubt, this particular copy of the software 
is released under the version 2 of the GNU General Public License. 
MySQL is brought to you by Oracle.

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

License information can be found in the COPYING file.

MySQL FOSS License Exception
We want free and open source software applications under certain
licenses to be able to use specified GPL-licensed MySQL client
libraries despite the fact that not all such FOSS licenses are
compatible with version 2 of the GNU General Public License.  
Therefore there are special exceptions to the terms and conditions 
of the GPLv2 as applied to these client libraries, which are 
identified and described in more detail in the FOSS License 
Exception at 
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.

This distribution may include materials developed by third
parties. For license and attribution notices for these
materials, please refer to the documentation that accompanies
this distribution (see the "Licenses for Third-Party Components"
appendix) or view the online documentation at 
<http://dev.mysql.com/doc/>.

GPLv2 Disclaimer
For the avoidance of doubt, except that if any license choice
other than GPL or LGPL is available it will apply instead, 
Oracle elects to use only the General Public License version 2 
(GPLv2) at this time for any software where a choice of GPL 
license versions is made available with the language indicating 
that GPLv2 or any later version may be used, or where a choice 
of which version of the GPL is applied is otherwise unspecified.

For further information about MySQL or additional documentation, 
see:
- The latest information about MySQL: http://www.mysql.com
- The current MySQL documentation: http://dev.mysql.com/doc

Some Reference Manual sections of special interest:
- If you are migrating from an older version of MySQL, please 
  read the "Upgrading from..." section.
- To see what MySQL can do, take a look at the features section.
- For installation instructions, see the Installing and Upgrading
  chapter.
- For the new features/bugfix history, see the MySQL Change History 
  appendix.

You can browse the MySQL Reference Manual online or download it 
in any of several formats at the URL given earlier in this file.
Source distributions include a local copy of the manual in the
Docs directory.