Skip to content
Permalink
Browse files
MDEV-12846 sql_mode=ORACLE: using Oracle-style placeholders in direct…
… query execution makes the server crash
  • Loading branch information
abarkov committed Nov 15, 2017
1 parent 765452d commit b8f906d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
@@ -247,3 +247,18 @@ DROP PROCEDURE p1;
#
# End of MDEV-10866 Extend PREPARE and EXECUTE IMMEDIATE to understand expressions
#
#
# MDEV-12846 sql_mode=ORACLE: using Oracle-style placeholders in direct query execution makes the server crash
#
SELECT ? FROM DUAL;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '? FROM DUAL' at line 1
SELECT :a FROM DUAL;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':a FROM DUAL' at line 1
SELECT :1 FROM DUAL;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':1 FROM DUAL' at line 1
SELECT 1+? FROM DUAL;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '? FROM DUAL' at line 1
SELECT 1+:a FROM DUAL;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':a FROM DUAL' at line 1
SELECT 1+:1 FROM DUAL;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':1 FROM DUAL' at line 1
@@ -264,3 +264,22 @@ DROP PROCEDURE p1;
--echo #
--echo # End of MDEV-10866 Extend PREPARE and EXECUTE IMMEDIATE to understand expressions
--echo #


--echo #
--echo # MDEV-12846 sql_mode=ORACLE: using Oracle-style placeholders in direct query execution makes the server crash
--echo #

--error ER_PARSE_ERROR
SELECT ? FROM DUAL;
--error ER_PARSE_ERROR
SELECT :a FROM DUAL;
--error ER_PARSE_ERROR
SELECT :1 FROM DUAL;

--error ER_PARSE_ERROR
SELECT 1+? FROM DUAL;
--error ER_PARSE_ERROR
SELECT 1+:a FROM DUAL;
--error ER_PARSE_ERROR
SELECT 1+:1 FROM DUAL;
@@ -6438,6 +6438,11 @@ Item *LEX::create_and_link_Item_trigger_field(THD *thd,
Item_param *LEX::add_placeholder(THD *thd, const LEX_CSTRING *name,
const char *start, const char *end)
{
if (!thd->m_parser_state->m_lip.stmt_prepare_mode)
{
thd->parse_error(ER_SYNTAX_ERROR, start);
return NULL;
}
if (!parsing_options.allows_variable)
{
my_error(ER_VIEW_SELECT_VARIABLE, MYF(0));

0 comments on commit b8f906d

Please sign in to comment.