summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/ps.result6
-rw-r--r--mysql-test/r/ps_1general.result6
-rw-r--r--mysql-test/t/ps.test6
-rw-r--r--mysql-test/t/ps_1general.test6
-rw-r--r--sql/sql_lex.cc8
-rw-r--r--sql/sql_lex.h10
-rw-r--r--sql/sql_prepare.cc5
-rw-r--r--sql/sql_yacc.yy15
8 files changed, 25 insertions, 37 deletions
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 15e1c8730f0..b811a27203c 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -26,11 +26,11 @@ ERROR HY000: Unknown prepared statement handler (no_such_statement) given to DEA
execute stmt1;
ERROR HY000: Incorrect arguments to EXECUTE
prepare stmt2 from 'prepare nested_stmt from "select 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 '"select 1"' at line 1
+ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt2 from 'execute stmt1';
-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 'stmt1' at line 1
+ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt2 from 'deallocate prepare z';
-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 'z' at line 1
+ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt3 from 'insert into t1 values (?,?)';
set @arg1=5, @arg2='five';
execute stmt3 using @arg1, @arg2;
diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result
index 391d22d232b..14ceac687a8 100644
--- a/mysql-test/r/ps_1general.result
+++ b/mysql-test/r/ps_1general.result
@@ -374,11 +374,11 @@ drop table t5 ;
deallocate prepare stmt_do ;
deallocate prepare stmt_set ;
prepare stmt1 from ' prepare stmt2 from '' select 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 '' select 1 '' at line 1
+ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt1 from ' execute stmt2 ' ;
-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 'stmt2' at line 1
+ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt1 from ' deallocate prepare never_prepared ' ;
-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 'never_prepared' at line 1
+ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt4 from ' use test ' ;
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt3 from ' create database mysqltest ';
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 44f9bf350b2..e21c3f793ad 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -34,13 +34,13 @@ deallocate prepare no_such_statement;
execute stmt1;
# Nesting ps commands is not allowed:
---error 1064
+--error ER_UNSUPPORTED_PS
prepare stmt2 from 'prepare nested_stmt from "select 1"';
---error 1064
+--error ER_UNSUPPORTED_PS
prepare stmt2 from 'execute stmt1';
---error 1064
+--error ER_UNSUPPORTED_PS
prepare stmt2 from 'deallocate prepare z';
# PS insert
diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test
index df3d1f0791c..0b2d7da4555 100644
--- a/mysql-test/t/ps_1general.test
+++ b/mysql-test/t/ps_1general.test
@@ -409,11 +409,11 @@ deallocate prepare stmt_do ;
deallocate prepare stmt_set ;
## nonsense like prepare of prepare,execute or deallocate
---error 1064
+--error ER_UNSUPPORTED_PS
prepare stmt1 from ' prepare stmt2 from '' select 1 '' ' ;
---error 1064
+--error ER_UNSUPPORTED_PS
prepare stmt1 from ' execute stmt2 ' ;
---error 1064
+--error ER_UNSUPPORTED_PS
prepare stmt1 from ' deallocate prepare never_prepared ' ;
## switch the database connection
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 1413ced8afe..4b03552854f 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -135,7 +135,8 @@ Lex_input_stream::Lex_input_stream(THD *thd,
buf(buffer),
next_state(MY_LEX_START),
found_semicolon(NULL),
- ignore_space(test(thd->variables.sql_mode & MODE_IGNORE_SPACE))
+ ignore_space(test(thd->variables.sql_mode & MODE_IGNORE_SPACE)),
+ stmt_prepare_mode(FALSE)
{
}
@@ -184,7 +185,6 @@ void lex_start(THD *thd)
lex->describe= 0;
lex->subqueries= FALSE;
lex->view_prepare_mode= FALSE;
- lex->stmt_prepare_mode= FALSE;
lex->derived_tables= 0;
lex->lock_option= TL_READ;
lex->safe_to_cache_query= 1;
@@ -623,7 +623,7 @@ int MYSQLlex(void *arg, void *yythd)
its value in a query for the binlog, the query must stay
grammatically correct.
*/
- else if (c == '?' && lex->stmt_prepare_mode && !ident_map[yyPeek()])
+ else if (c == '?' && lip->stmt_prepare_mode && !ident_map[yyPeek()])
return(PARAM_MARKER);
return((int) c);
@@ -1018,7 +1018,7 @@ int MYSQLlex(void *arg, void *yythd)
if (yyPeek())
{
if ((thd->client_capabilities & CLIENT_MULTI_STATEMENTS) &&
- !lex->stmt_prepare_mode)
+ !lip->stmt_prepare_mode)
{
lex->safe_to_cache_query= 0;
lip->found_semicolon= lip->ptr;
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 8d33b04f722..3f6218ad5da 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -1039,6 +1039,11 @@ public:
/** SQL_MODE = IGNORE_SPACE. */
bool ignore_space;
+ /*
+ TRUE if we're parsing a prepared statement: in this mode
+ we should allow placeholders and disallow multi-statements.
+ */
+ bool stmt_prepare_mode;
};
@@ -1184,11 +1189,6 @@ typedef struct st_lex : public Query_tables_list
to an .frm file. We need this definition to stay untouched.
*/
bool view_prepare_mode;
- /*
- TRUE if we're parsing a prepared statement: in this mode
- we should allow placeholders and disallow multistatements.
- */
- bool stmt_prepare_mode;
bool safe_to_cache_query;
bool subqueries, ignore;
st_parsing_options parsing_options;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index ca1b29ea57d..194f4a9dc1d 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1794,6 +1794,9 @@ static bool check_prepared_statement(Prepared_statement *stmt,
case SQLCOM_KILL:
break;
+ case SQLCOM_PREPARE:
+ case SQLCOM_EXECUTE:
+ case SQLCOM_DEALLOCATE_PREPARE:
default:
/*
Trivial check of all status commands. This is easier than having
@@ -2852,9 +2855,9 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
thd->stmt_arena= this;
Lex_input_stream lip(thd, thd->query, thd->query_length);
+ lip.stmt_prepare_mode= TRUE;
thd->m_lip= &lip;
lex_start(thd);
- lex->stmt_prepare_mode= TRUE;
int err= MYSQLparse((void *)thd);
error= err || thd->is_fatal_error ||
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index c02d8a85d9b..dbebbfc0e1b 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1364,11 +1364,6 @@ deallocate:
{
THD *thd= YYTHD;
LEX *lex= thd->lex;
- if (lex->stmt_prepare_mode)
- {
- my_parse_error(ER(ER_SYNTAX_ERROR));
- MYSQL_YYABORT;
- }
lex->sql_command= SQLCOM_DEALLOCATE_PREPARE;
lex->prepared_stmt_name= $3;
};
@@ -1384,11 +1379,6 @@ prepare:
{
THD *thd= YYTHD;
LEX *lex= thd->lex;
- if (lex->stmt_prepare_mode)
- {
- my_parse_error(ER(ER_SYNTAX_ERROR));
- MYSQL_YYABORT;
- }
lex->sql_command= SQLCOM_PREPARE;
lex->prepared_stmt_name= $2;
};
@@ -1414,11 +1404,6 @@ execute:
{
THD *thd= YYTHD;
LEX *lex= thd->lex;
- if (lex->stmt_prepare_mode)
- {
- my_parse_error(ER(ER_SYNTAX_ERROR));
- MYSQL_YYABORT;
- }
lex->sql_command= SQLCOM_EXECUTE;
lex->prepared_stmt_name= $2;
}