Commit 8454773a authored by Marc Alff's avatar Marc Alff
Browse files

Manual merge of bug#26030 in mysql-5.1-bugteam

parents 0a638f6b f3ff1aeb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*! AND 2=2;";
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 bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*! AND 2=2;*";
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
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 bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!98765' AND b = 'bar';";
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 '/*!98765' AND b = 'bar'' at line 1
prepare bar from "DELETE FROM table_28779 WHERE a = 7 OR 1=1/*!98765' AND b = 'bar';*";
+68 −0
Original line number Diff line number Diff line
@@ -284,6 +284,74 @@ Field Type Null Key Default Extra
DROP TABLE table_25930_a;
DROP TABLE table_25930_b;
SET @@sql_mode=@save_sql_mode;
DROP PROCEDURE IF EXISTS p26030;
select "non terminated"$$
non terminated
non terminated
select "terminated";$$
terminated
terminated
select "non terminated, space"      $$
non terminated, space
non terminated, space
select "terminated, space";      $$
terminated, space
terminated, space
select "non terminated, comment" /* comment */$$
non terminated, comment
non terminated, comment
select "terminated, comment"; /* comment */$$
terminated, comment
terminated, comment
select "stmt 1";select "stmt 2 non terminated"$$
stmt 1
stmt 1
stmt 2 non terminated
stmt 2 non terminated
select "stmt 1";select "stmt 2 terminated";$$
stmt 1
stmt 1
stmt 2 terminated
stmt 2 terminated
select "stmt 1";select "stmt 2 non terminated, space"      $$
stmt 1
stmt 1
stmt 2 non terminated, space
stmt 2 non terminated, space
select "stmt 1";select "stmt 2 terminated, space";      $$
stmt 1
stmt 1
stmt 2 terminated, space
stmt 2 terminated, space
select "stmt 1";select "stmt 2 non terminated, comment" /* comment */$$
stmt 1
stmt 1
stmt 2 non terminated, comment
stmt 2 non terminated, comment
select "stmt 1";select "stmt 2 terminated, comment"; /* comment */$$
stmt 1
stmt 1
stmt 2 terminated, comment
stmt 2 terminated, comment
select "stmt 1";             select "space, stmt 2"$$
stmt 1
stmt 1
space, stmt 2
space, stmt 2
select "stmt 1";/* comment */select "comment, stmt 2"$$
stmt 1
stmt 1
comment, stmt 2
comment, stmt 2
DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() BEGIN SELECT 1; END; CALL p26030()
$$
1
1
DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() SELECT 1; CALL p26030()
$$
1
1
DROP PROCEDURE p26030;
select pi(3.14);
ERROR 42000: Incorrect parameter count in the call to native function 'pi'
select tan();
+2 −2
Original line number Diff line number Diff line
@@ -85,9 +85,9 @@ NULL
NULL
NULL
prepare stmt6 from 'select 1; select2';
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 '; select2' at line 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 'select2' at line 1
prepare stmt6 from 'insert into t1 values (5,"five"); select2';
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 '; select2' at line 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 'select2' at line 1
explain prepare stmt6 from 'insert into t1 values (5,"five"); select2';
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 'insert into t1 values (5,"five"); select2'' at line 1
create table t2
+47 −0
Original line number Diff line number Diff line
@@ -6,6 +6,11 @@
# LEXICAL PARSER (lex)
#=============================================================================

#
# Maintainer: these tests are for the lexical parser, so every character,
# even whitespace or comments, is significant here.
#

SET @save_sql_mode=@@sql_mode;

#
@@ -387,6 +392,48 @@ DROP TABLE table_25930_b;

SET @@sql_mode=@save_sql_mode;

#
# Bug#26030 (Parsing fails for stored routine w/multi-statement execution
# enabled)
#

--disable_warnings
DROP PROCEDURE IF EXISTS p26030;
--enable_warnings

delimiter $$;

select "non terminated"$$
select "terminated";$$
select "non terminated, space"      $$
select "terminated, space";      $$
select "non terminated, comment" /* comment */$$
select "terminated, comment"; /* comment */$$

# Multi queries can not be used in --ps-protocol test mode
--disable_ps_protocol

select "stmt 1";select "stmt 2 non terminated"$$
select "stmt 1";select "stmt 2 terminated";$$
select "stmt 1";select "stmt 2 non terminated, space"      $$
select "stmt 1";select "stmt 2 terminated, space";      $$
select "stmt 1";select "stmt 2 non terminated, comment" /* comment */$$
select "stmt 1";select "stmt 2 terminated, comment"; /* comment */$$

select "stmt 1";             select "space, stmt 2"$$
select "stmt 1";/* comment */select "comment, stmt 2"$$

DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() BEGIN SELECT 1; END; CALL p26030()
$$

DROP PROCEDURE IF EXISTS p26030; CREATE PROCEDURE p26030() SELECT 1; CALL p26030()
$$

--enable_ps_protocol

delimiter ;$$
DROP PROCEDURE p26030;

#=============================================================================
# SYNTACTIC PARSER (bison)
#=============================================================================
+3 −18
Original line number Diff line number Diff line
@@ -1317,23 +1317,8 @@ int MYSQLlex(void *arg, void *yythd)
      lip->yySkip();
      return (SET_VAR);
    case MY_LEX_SEMICOLON:			// optional line terminator
      if (lip->yyPeek())
      {
        if ((thd->client_capabilities & CLIENT_MULTI_STATEMENTS) && 
            !lip->stmt_prepare_mode)
        {
	  lex->safe_to_cache_query= 0;
          lip->found_semicolon= lip->get_ptr();
          thd->server_status|= SERVER_MORE_RESULTS_EXISTS;
          lip->next_state= MY_LEX_END;
          lip->set_echo(TRUE);
          return (END_OF_INPUT);
        }
      state= MY_LEX_CHAR;               // Return ';'
      break;
      }
      lip->next_state=MY_LEX_END;       // Mark for next loop
      return(END_OF_INPUT);
    case MY_LEX_EOL:
      if (lip->eof())
      {
Loading