mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
Cleanup: now that we have Lex_input_stream, finish the transition
by moving yet another relevant flag to it from struct LEX. mysql-test/r/ps.result: Update result. mysql-test/r/ps_1general.result: Update result. mysql-test/t/ps.test: New error code. mysql-test/t/ps_1general.test: New error code. sql/sql_lex.cc: Move stmt_prepare_mode to Lex_input_stream. sql/sql_lex.h: Move stmt_prepare_mode to class Lex_input_stream sql/sql_prepare.cc: Move stmt_prepare_mode to Lex_input_stream sql/sql_yacc.yy: Remove dead code.
This commit is contained in:
@@ -26,11 +26,11 @@ ERROR HY000: Unknown prepared statement handler (no_such_statement) given to DEA
|
|||||||
execute stmt1;
|
execute stmt1;
|
||||||
ERROR HY000: Incorrect arguments to EXECUTE
|
ERROR HY000: Incorrect arguments to EXECUTE
|
||||||
prepare stmt2 from 'prepare nested_stmt from "select 1"';
|
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';
|
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';
|
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 (?,?)';
|
prepare stmt3 from 'insert into t1 values (?,?)';
|
||||||
set @arg1=5, @arg2='five';
|
set @arg1=5, @arg2='five';
|
||||||
execute stmt3 using @arg1, @arg2;
|
execute stmt3 using @arg1, @arg2;
|
||||||
|
@@ -391,11 +391,11 @@ drop table t5 ;
|
|||||||
deallocate prepare stmt_do ;
|
deallocate prepare stmt_do ;
|
||||||
deallocate prepare stmt_set ;
|
deallocate prepare stmt_set ;
|
||||||
prepare stmt1 from ' prepare stmt2 from '' select 1 '' ' ;
|
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 ' ;
|
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 ' ;
|
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 ' ;
|
prepare stmt4 from ' use test ' ;
|
||||||
ERROR HY000: This command is not supported in the prepared statement protocol yet
|
ERROR HY000: This command is not supported in the prepared statement protocol yet
|
||||||
prepare stmt3 from ' create database mysqltest ';
|
prepare stmt3 from ' create database mysqltest ';
|
||||||
|
@@ -33,13 +33,13 @@ deallocate prepare no_such_statement;
|
|||||||
execute stmt1;
|
execute stmt1;
|
||||||
|
|
||||||
# Nesting ps commands is not allowed:
|
# Nesting ps commands is not allowed:
|
||||||
--error 1064
|
--error ER_UNSUPPORTED_PS
|
||||||
prepare stmt2 from 'prepare nested_stmt from "select 1"';
|
prepare stmt2 from 'prepare nested_stmt from "select 1"';
|
||||||
|
|
||||||
--error 1064
|
--error ER_UNSUPPORTED_PS
|
||||||
prepare stmt2 from 'execute stmt1';
|
prepare stmt2 from 'execute stmt1';
|
||||||
|
|
||||||
--error 1064
|
--error ER_UNSUPPORTED_PS
|
||||||
prepare stmt2 from 'deallocate prepare z';
|
prepare stmt2 from 'deallocate prepare z';
|
||||||
|
|
||||||
# PS insert
|
# PS insert
|
||||||
|
@@ -416,11 +416,11 @@ deallocate prepare stmt_do ;
|
|||||||
deallocate prepare stmt_set ;
|
deallocate prepare stmt_set ;
|
||||||
|
|
||||||
## nonsense like prepare of prepare,execute or deallocate
|
## nonsense like prepare of prepare,execute or deallocate
|
||||||
--error 1064
|
--error ER_UNSUPPORTED_PS
|
||||||
prepare stmt1 from ' prepare stmt2 from '' select 1 '' ' ;
|
prepare stmt1 from ' prepare stmt2 from '' select 1 '' ' ;
|
||||||
--error 1064
|
--error ER_UNSUPPORTED_PS
|
||||||
prepare stmt1 from ' execute stmt2 ' ;
|
prepare stmt1 from ' execute stmt2 ' ;
|
||||||
--error 1064
|
--error ER_UNSUPPORTED_PS
|
||||||
prepare stmt1 from ' deallocate prepare never_prepared ' ;
|
prepare stmt1 from ' deallocate prepare never_prepared ' ;
|
||||||
|
|
||||||
## switch the database connection
|
## switch the database connection
|
||||||
|
@@ -123,7 +123,8 @@ Lex_input_stream::Lex_input_stream(THD *thd,
|
|||||||
buf(buffer),
|
buf(buffer),
|
||||||
next_state(MY_LEX_START),
|
next_state(MY_LEX_START),
|
||||||
found_semicolon(NULL),
|
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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +173,6 @@ void lex_start(THD *thd)
|
|||||||
lex->describe= 0;
|
lex->describe= 0;
|
||||||
lex->subqueries= FALSE;
|
lex->subqueries= FALSE;
|
||||||
lex->view_prepare_mode= FALSE;
|
lex->view_prepare_mode= FALSE;
|
||||||
lex->stmt_prepare_mode= FALSE;
|
|
||||||
lex->derived_tables= 0;
|
lex->derived_tables= 0;
|
||||||
lex->lock_option= TL_READ;
|
lex->lock_option= TL_READ;
|
||||||
lex->safe_to_cache_query= 1;
|
lex->safe_to_cache_query= 1;
|
||||||
@@ -586,7 +586,7 @@ int MYSQLlex(void *arg, void *yythd)
|
|||||||
its value in a query for the binlog, the query must stay
|
its value in a query for the binlog, the query must stay
|
||||||
grammatically correct.
|
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(PARAM_MARKER);
|
||||||
return((int) c);
|
return((int) c);
|
||||||
|
|
||||||
@@ -989,7 +989,7 @@ int MYSQLlex(void *arg, void *yythd)
|
|||||||
if (yyPeek())
|
if (yyPeek())
|
||||||
{
|
{
|
||||||
if ((thd->client_capabilities & CLIENT_MULTI_STATEMENTS) &&
|
if ((thd->client_capabilities & CLIENT_MULTI_STATEMENTS) &&
|
||||||
!lex->stmt_prepare_mode)
|
!lip->stmt_prepare_mode)
|
||||||
{
|
{
|
||||||
lex->safe_to_cache_query= 0;
|
lex->safe_to_cache_query= 0;
|
||||||
lip->found_semicolon= lip->ptr;
|
lip->found_semicolon= lip->ptr;
|
||||||
|
@@ -954,6 +954,11 @@ public:
|
|||||||
|
|
||||||
/** SQL_MODE = IGNORE_SPACE. */
|
/** SQL_MODE = IGNORE_SPACE. */
|
||||||
bool 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1082,11 +1087,6 @@ typedef struct st_lex : public Query_tables_list
|
|||||||
to an .frm file. We need this definition to stay untouched.
|
to an .frm file. We need this definition to stay untouched.
|
||||||
*/
|
*/
|
||||||
bool view_prepare_mode;
|
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 safe_to_cache_query;
|
||||||
bool subqueries, ignore;
|
bool subqueries, ignore;
|
||||||
st_parsing_options parsing_options;
|
st_parsing_options parsing_options;
|
||||||
|
@@ -1762,6 +1762,9 @@ static bool check_prepared_statement(Prepared_statement *stmt,
|
|||||||
case SQLCOM_OPTIMIZE:
|
case SQLCOM_OPTIMIZE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SQLCOM_PREPARE:
|
||||||
|
case SQLCOM_EXECUTE:
|
||||||
|
case SQLCOM_DEALLOCATE_PREPARE:
|
||||||
default:
|
default:
|
||||||
/* All other statements are not supported yet. */
|
/* All other statements are not supported yet. */
|
||||||
my_message(ER_UNSUPPORTED_PS, ER(ER_UNSUPPORTED_PS), MYF(0));
|
my_message(ER_UNSUPPORTED_PS, ER(ER_UNSUPPORTED_PS), MYF(0));
|
||||||
@@ -2801,10 +2804,10 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
|
|||||||
thd->stmt_arena= this;
|
thd->stmt_arena= this;
|
||||||
|
|
||||||
Lex_input_stream lip(thd, thd->query, thd->query_length);
|
Lex_input_stream lip(thd, thd->query, thd->query_length);
|
||||||
|
lip.stmt_prepare_mode= TRUE;
|
||||||
thd->m_lip= &lip;
|
thd->m_lip= &lip;
|
||||||
lex_start(thd);
|
lex_start(thd);
|
||||||
lex->safe_to_cache_query= FALSE;
|
lex->safe_to_cache_query= FALSE;
|
||||||
lex->stmt_prepare_mode= TRUE;
|
|
||||||
int err= MYSQLparse((void *)thd);
|
int err= MYSQLparse((void *)thd);
|
||||||
|
|
||||||
error= err || thd->is_fatal_error ||
|
error= err || thd->is_fatal_error ||
|
||||||
|
@@ -1276,11 +1276,6 @@ deallocate:
|
|||||||
{
|
{
|
||||||
THD *thd=YYTHD;
|
THD *thd=YYTHD;
|
||||||
LEX *lex= thd->lex;
|
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->sql_command= SQLCOM_DEALLOCATE_PREPARE;
|
||||||
lex->prepared_stmt_name= $3;
|
lex->prepared_stmt_name= $3;
|
||||||
};
|
};
|
||||||
@@ -1296,11 +1291,6 @@ prepare:
|
|||||||
{
|
{
|
||||||
THD *thd=YYTHD;
|
THD *thd=YYTHD;
|
||||||
LEX *lex= thd->lex;
|
LEX *lex= thd->lex;
|
||||||
if (lex->stmt_prepare_mode)
|
|
||||||
{
|
|
||||||
my_parse_error(ER(ER_SYNTAX_ERROR));
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
|
||||||
lex->sql_command= SQLCOM_PREPARE;
|
lex->sql_command= SQLCOM_PREPARE;
|
||||||
lex->prepared_stmt_name= $2;
|
lex->prepared_stmt_name= $2;
|
||||||
};
|
};
|
||||||
@@ -1326,11 +1316,6 @@ execute:
|
|||||||
{
|
{
|
||||||
THD *thd=YYTHD;
|
THD *thd=YYTHD;
|
||||||
LEX *lex= thd->lex;
|
LEX *lex= thd->lex;
|
||||||
if (lex->stmt_prepare_mode)
|
|
||||||
{
|
|
||||||
my_parse_error(ER(ER_SYNTAX_ERROR));
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
|
||||||
lex->sql_command= SQLCOM_EXECUTE;
|
lex->sql_command= SQLCOM_EXECUTE;
|
||||||
lex->prepared_stmt_name= $2;
|
lex->prepared_stmt_name= $2;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user