Below is the list of changes that have just been committed into a local
4.1 repository of kostja. When kostja does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2355 05/07/15 00:01:49 konstantin@stripped +5 -0
A fix and a test case for Bug#11299 "prepared statement makes wrong SQL
syntax in binlog which stops replication":
disallow the use of parameter markers which can lead to generation
of malformed binlog queries.
mysql-test/var
1.1 05/07/15 00:01:42 konstantin@stripped +0 -0
New BitKeeper file ``mysql-test/var''
mysql-test/var
1.0 05/07/15 00:01:42 konstantin@stripped +0 -0
BitKeeper file /opt/local/work/mysql-4.1-root/mysql-test/var
sql/sql_yacc.yy
1.389 05/07/15 00:01:41 konstantin@stripped +6 -13
The check for COM_PREPARE has been moved into the lexer.
sql/sql_lex.cc
1.146 05/07/15 00:01:41 konstantin@stripped +9 -0
Introduce a new parser token for a parameter marker. Make sure
that a parameter marker can not be used in a query which, when
transformed to a binlog query, becomes grammatically incorrect.
mysql-test/t/ps.test
1.39 05/07/15 00:01:41 konstantin@stripped +22 -0
A test case for Bug#11299
mysql-test/r/ps.result
1.40 05/07/15 00:01:41 konstantin@stripped +16 -0
Test results fixed: a test case for Bug#11299
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: konstantin
# Host: dragonfly.local
# Root: /opt/local/work/mysql-4.1-root
--- 1.145/sql/sql_lex.cc 2005-05-25 13:56:42 +04:00
+++ 1.146/sql/sql_lex.cc 2005-07-15 00:01:41 +04:00
@@ -554,6 +554,15 @@
lex->next_state= MY_LEX_START; // Allow signed numbers
if (c == ',')
lex->tok_start=lex->ptr; // Let tok_start point at next item
+ /*
+ Check for a placeholder: it should not precede a possible identifier
+ because of binlogging: when a placeholder is replaced with
+ its value in a query for the binlog, the query must stay
+ grammatically correct.
+ */
+ else if (c == '?' && ((THD*) yythd)->command == COM_PREPARE &&
+ !ident_map[cs, yyPeek()])
+ return(PARAM_MARKER);
return((int) c);
case MY_LEX_IDENT_OR_NCHAR:
--- 1.388/sql/sql_yacc.yy 2005-06-27 17:46:36 +04:00
+++ 1.389/sql/sql_yacc.yy 2005-07-15 00:01:41 +04:00
@@ -528,6 +528,7 @@
%token NOW_SYM
%token OLD_PASSWORD
%token PASSWORD
+%token PARAM_MARKER
%token POINTFROMTEXT
%token POINT_SYM
%token POLYFROMTEXT
@@ -4857,23 +4858,15 @@
;
param_marker:
- '?'
+ PARAM_MARKER
{
THD *thd=YYTHD;
LEX *lex= thd->lex;
- if (thd->command == COM_PREPARE)
+ Item_param *item= new Item_param((uint) (lex->tok_start -
+ (uchar *) thd->query));
+ if (!($$= item) || lex->param_list.push_back(item))
{
- Item_param *item= new Item_param((uint) (lex->tok_start -
- (uchar *) thd->query));
- if (!($$= item) || lex->param_list.push_back(item))
- {
- send_error(thd, ER_OUT_OF_RESOURCES);
- YYABORT;
- }
- }
- else
- {
- yyerror(ER(ER_SYNTAX_ERROR));
+ send_error(thd, ER_OUT_OF_RESOURCES);
YYABORT;
}
}
--- New file ---
+++ mysql-test/var 05/07/15 00:01:42
SYMLINK -> /dev/shm/var
--- 1.39/mysql-test/r/ps.result 2005-07-14 00:15:15 +04:00
+++ 1.40/mysql-test/r/ps.result 2005-07-15 00:01:41 +04:00
@@ -660,3 +660,19 @@
river
drop table t1;
deallocate prepare stmt;
+create table t1 (a int);
+prepare stmt from "select ??";
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '?' at line 1
+prepare stmt from "select ?FROM t1";
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '?FROM t1' at line 1
+prepare stmt from "select FROM t1 WHERE?=1";
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'FROM t1 WHERE?=1' at line 1
+prepare stmt from "update t1 set a=a+?WHERE 1";
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '?WHERE 1' at line 1
+select ?;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '?' at line 1
+select ??;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '??' at line 1
+select ? from t1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '? from t1' at line 1
+drop table t1;
--- 1.38/mysql-test/t/ps.test 2005-07-14 00:15:15 +04:00
+++ 1.39/mysql-test/t/ps.test 2005-07-15 00:01:41 +04:00
@@ -679,3 +679,25 @@
select utext from t1 where utext like '%%';
drop table t1;
deallocate prepare stmt;
+#
+# Bug#11299 "prepared statement makes wrong SQL syntax in binlog which stops
+# replication": check that errouneous queries with placeholders are not
+# allowed
+#
+create table t1 (a int);
+--error 1064
+prepare stmt from "select ??";
+--error 1064
+prepare stmt from "select ?FROM t1";
+--error 1064
+prepare stmt from "select FROM t1 WHERE?=1";
+--error 1064
+prepare stmt from "update t1 set a=a+?WHERE 1";
+--error 1064
+select ?;
+--error 1064
+select ??;
+--error 1064
+select ? from t1;
+drop table t1;
+#
| Thread |
|---|
| • bk commit into 4.1 tree (konstantin:1.2355) BUG#11299 | konstantin | 14 Jul |