[Commits] 684bd68: MDEV-8615: Assertion `m_cpp_buf <= begin_ptr && begin_ptr <= m_cpp_buf + m_buf_length' failed in Lex_input_stream::body_utf8_start

OleksandrByelkin sanja at mariadb.com
Fri Dec 25 19:40:58 EET 2015


revision-id: 684bd68c33284f6106551188d9567f35b18593ed (mariadb-10.1.9-21-g684bd68)
parent(s): 59fcd7ff2315d007045eb987da5f21abbea6f6f1
committer: Oleksandr Byelkin
timestamp: 2015-12-25 18:39:43 +0100
message:

MDEV-8615: Assertion `m_cpp_buf <= begin_ptr && begin_ptr <= m_cpp_buf + m_buf_length' failed in Lex_input_stream::body_utf8_start

Nothing should be done before any keyword recognised.

---
 mysql-test/r/compound.result                       |   7 ++
 mysql-test/r/mysql.result                          |   2 +-
 mysql-test/r/mysqltest.result                      |  60 +++++------
 mysql-test/r/ps_1general.result                    |   4 +-
 mysql-test/suite/funcs_1/r/innodb_views.result     |   4 +-
 mysql-test/suite/funcs_1/r/memory_views.result     |   4 +-
 mysql-test/suite/funcs_1/r/storedproc.result       |   7 +-
 mysql-test/suite/funcs_1/t/storedproc.test         |   4 +-
 mysql-test/suite/plugins/r/server_audit.result     |   2 +-
 mysql-test/suite/plugins/r/sql_error_log.result    |   4 +-
 .../plugins/r/thread_pool_server_audit.result      |   2 +-
 mysql-test/t/compound.test                         |   7 ++
 sql/sql_yacc.yy                                    | 116 +++++++++++++--------
 .../mysql-test/sql_discovery/simple.result         |   2 +-
 14 files changed, 135 insertions(+), 90 deletions(-)

diff --git a/mysql-test/r/compound.result b/mysql-test/r/compound.result
index 92d3226..1d412e6 100644
--- a/mysql-test/r/compound.result
+++ b/mysql-test/r/compound.result
@@ -162,3 +162,10 @@ a
 begin not atomic select a from t1 having a > 1; end|
 a
 drop table t1|
+#
+# MDEV-8615: Assertion `m_cpp_buf <= begin_ptr &&
+# begin_ptr <= m_cpp_buf + m_buf_length' failed in
+# Lex_input_stream::body_utf8_start
+#
+b'|
+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 'b'' at line 1
diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result
index ca19d2e..da5d03d 100644
--- a/mysql-test/r/mysql.result
+++ b/mysql-test/r/mysql.result
@@ -166,7 +166,7 @@ count(*)
 drop table t17583;
 Test connect without db- or host-name => reconnect
 Test connect with dbname only => new dbname, old hostname
-ERROR 1064 (42000) at line 1: 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 'connecttest' at line 1
+ERROR 1064 (42000) at line 1: 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 '' at line 1
 Test connect with _invalid_ dbname only => new invalid dbname, old hostname
 ERROR 1049 (42000) at line 1: Unknown database 'invalid'
 ERROR 1049 (42000) at line 1: Unknown database 'invalid'
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index e258b1d..a9980a7 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -29,40 +29,40 @@ select 0 as "after_successful_stmt_errno" ;
 after_successful_stmt_errno
 0
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 ER_PARSE_ERROR
 select 1064 as "after_wrong_syntax_errno" ;
 after_wrong_syntax_errno
 1064
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 ER_PARSE_ERROR
 select 1064 as "after_let_var_equal_value" ;
 after_let_var_equal_value
 1064
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 set @my_var= 'abc' ;
 
 select 0 as "after_set_var_equal_value" ;
 after_set_var_equal_value
 0
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 ER_PARSE_ERROR
 select 1064 as "after_disable_warnings_command" ;
 after_disable_warnings_command
 1064
 drop table if exists t1 ;
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 drop table if exists t1 ;
 
 select 0 as "after_disable_warnings" ;
 after_disable_warnings
 0
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 select 3 from t1 ;
 ERROR 42S02: Table 'test.t1' doesn't exist
 ER_NO_SUCH_TABLE
@@ -70,7 +70,7 @@ select 1146 as "after_minus_masked" ;
 after_minus_masked
 1146
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 select 3 from t1 ;
 ERROR 42S02: Table 'test.t1' doesn't exist
 ER_NO_SUCH_TABLE
@@ -78,12 +78,12 @@ select 1146 as "after_!_masked" ;
 after_!_masked
 1146
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 select -1 as "after_let_errno_equal_value" ;
 after_let_errno_equal_value
 -1
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 prepare stmt from "select 3 from t1" ;
 ERROR 42S02: Table 'test.t1' doesn't exist
 ER_NO_SUCH_TABLE
@@ -92,14 +92,14 @@ after_failing_prepare
 1146
 create table t1 ( f1 char(10));
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 prepare stmt from "select 3 from t1" ;
 
 select 0 as "after_successful_prepare" ;
 after_successful_prepare
 0
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 execute stmt;
 3
 
@@ -108,7 +108,7 @@ after_successful_execute
 0
 drop table t1;
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 execute stmt;
 ERROR 42S02: Table 'test.t1' doesn't exist
 ER_NO_SUCH_TABLE
@@ -116,7 +116,7 @@ select 1146 as "after_failing_execute" ;
 after_failing_execute
 1146
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 execute __stmt_;
 ERROR HY000: Unknown prepared statement handler (__stmt_) given to EXECUTE
 ER_UNKNOWN_STMT_HANDLER
@@ -124,14 +124,14 @@ select 1243 as "after_failing_execute" ;
 after_failing_execute
 1243
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 deallocate prepare stmt;
 
 select 0 as "after_successful_deallocate" ;
 after_successful_deallocate
 0
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 deallocate prepare __stmt_;
 ERROR HY000: Unknown prepared statement handler (__stmt_) given to DEALLOCATE PREPARE
 ER_UNKNOWN_STMT_HANDLER
@@ -139,7 +139,7 @@ select 1243 as "after_failing_deallocate" ;
 after_failing_deallocate
 1243
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 ER_PARSE_ERROR
 select 1064 as "after_--disable_abort_on_error" ;
 after_--disable_abort_on_error
@@ -156,12 +156,12 @@ after_!errno_masked_error
 1146
 select 3 from t1;
 mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1000...
-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 'garbage' at line 1
+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 '' at line 1
  is empty
-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 'nonsense' at line 1
+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 '' at line 1
  is empty
 garbage ;
-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 'garbage' at line 1
+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 '' at line 1
 ER_PARSE_ERROR
 select 1064 as "after_--enable_abort_on_error" ;
 after_--enable_abort_on_error
@@ -171,7 +171,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist
 select 3 from t1;
 mysqltest: At line 1: query 'select 3 from t1' failed with wrong errno 1146: 'Table 'test.t1' doesn't exist', instead of 1064...
 garbage;
-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 'garbage' at line 1
+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 '' at line 1
 select 2;
 select 3;
 3
@@ -364,7 +364,7 @@ insert into t1 values ('$dollar');
 $dollar
 `select 42`
 drop table t1;
-mysqltest: At line 1: query 'let $var2= `failing query`' failed: 1064: 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 'failing query' at line 1
+mysqltest: At line 1: query 'let $var2= `failing query`' failed: 1064: 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 'query' at line 1
 mysqltest: At line 1: Missing required argument 'filename' to command 'source'
 mysqltest: At line 1: Could not open 'non_existingFile' for reading, errno: 2
 mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": 
@@ -387,7 +387,7 @@ At line 1: Source directives are nesting too deep
 garbage ;
 mysqltest: In included file "MYSQLTEST_VARDIR/tmp/error.sql": 
 included from <stdin> at line 1:
-At line 1: query 'garbage ' failed: 1064: 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 'garbage' at line 1
+At line 1: query 'garbage ' failed: 1064: 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 '' at line 1
 
 2 = outer loop variable after while
 here is the sourced script
@@ -586,9 +586,9 @@ Output from mysqltest-x.inc
 Output from mysqltest-x.inc
 mysqltest: Could not open './non_existing_file.inc' for reading, errno: 2
 failing_statement;
-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 'failing_statement' at line 1
+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 '' at line 1
 failing_statement;
-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 'failing_statement' at line 1
+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 '' at line 1
 SELECT 1 as a;
 a
 1
@@ -625,12 +625,12 @@ insertz 'error query'||||
 mysqltest: At line 3: query 'create table t1 (a int primary key);
 insert into t1 values (1);
 select 'select-me';
-insertz 'error query'' failed: 1064: 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 'insertz 'error query'' at line 1
+insertz 'error query'' failed: 1064: 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 ''error query'' at line 1
 drop table t1;
 mysqltest: At line 3: query 'create table t1 (a int primary key);
 insert into t1 values (1);
 select 'select-me';
-insertz 'error query'' failed: 1064: 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 'insertz 'error query'' at line 1
+insertz 'error query'' failed: 1064: 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 ''error query'' at line 1
 drop table t1;
 Multi statement using expected error
 create table t1 (a int primary key);
@@ -639,13 +639,13 @@ select 'select-me';
 insertz error query||||
 select-me
 select-me
-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 'insertz error query' at line 1
+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 'error query' at line 1
 drop table t1;
 drop table t1;
 sleep;
-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 'sleep' at line 1
+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 '' at line 1
 sleep;
-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 'sleep' at line 1
+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 '' at line 1
 ;
 ERROR 42000: Query was empty
 select "b" as col1, "c" as col2;
@@ -685,7 +685,7 @@ txt
 ABCDfF bbddff h
 create table t2 ( a char(10));
 garbage;
-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 'garbage' at line 1
+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 '' at line 1
 garbage;
 Got one of the listed errors
 garbage;
diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result
index 326d37e..7e7fe4e 100644
--- a/mysql-test/r/ps_1general.result
+++ b/mysql-test/r/ps_1general.result
@@ -70,11 +70,11 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
 prepare stmt1 from ;
 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 '' at line 1
 prepare_garbage stmt1 from ' select 1 ' ;
-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 'prepare_garbage stmt1 from ' select 1 '' at line 1
+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 'stmt1 from ' select 1 '' at line 1
 prepare stmt1 from_garbage ' select 1 ' ;
 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_garbage ' select 1 '' at line 1
 prepare stmt1 from ' select_garbage 1 ' ;
-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 'select_garbage 1' at line 1
+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' at line 1
 prepare from ' select 1 ' ;
 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 ' select 1 '' at line 1
 prepare stmt1 ' select 1 ' ;
diff --git a/mysql-test/suite/funcs_1/r/innodb_views.result b/mysql-test/suite/funcs_1/r/innodb_views.result
index 59eec5b..76ddc81 100644
--- a/mysql-test/suite/funcs_1/r/innodb_views.result
+++ b/mysql-test/suite/funcs_1/r/innodb_views.result
@@ -3647,11 +3647,11 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
 CREATE v1 AS SELECT * FROM tb2;
 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 'v1 AS SELECT * FROM tb2' at line 1
 VIEW v1 AS SELECT * FROM tb2;
-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 'VIEW v1 AS SELECT * FROM tb2' at line 1
+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 'v1 AS SELECT * FROM tb2' at line 1
 CREATE VIEW v1 AS SELECT 1;
 DROP VIEW v1;
 VIEW v1 AS SELECT 1;
-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 'VIEW v1 AS SELECT 1' at line 1
+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 'v1 AS SELECT 1' at line 1
 CREATE      v1 AS SELECT 1;
 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 'v1 AS SELECT 1' at line 1
 CREATE VIEW    AS SELECT 1;
diff --git a/mysql-test/suite/funcs_1/r/memory_views.result b/mysql-test/suite/funcs_1/r/memory_views.result
index 995787a..b1fa094 100644
--- a/mysql-test/suite/funcs_1/r/memory_views.result
+++ b/mysql-test/suite/funcs_1/r/memory_views.result
@@ -3648,11 +3648,11 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
 CREATE v1 AS SELECT * FROM tb2;
 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 'v1 AS SELECT * FROM tb2' at line 1
 VIEW v1 AS SELECT * FROM tb2;
-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 'VIEW v1 AS SELECT * FROM tb2' at line 1
+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 'v1 AS SELECT * FROM tb2' at line 1
 CREATE VIEW v1 AS SELECT 1;
 DROP VIEW v1;
 VIEW v1 AS SELECT 1;
-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 'VIEW v1 AS SELECT 1' at line 1
+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 'v1 AS SELECT 1' at line 1
 CREATE      v1 AS SELECT 1;
 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 'v1 AS SELECT 1' at line 1
 CREATE VIEW    AS SELECT 1;
diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result
index f0e1ee7..485082a 100644
--- a/mysql-test/suite/funcs_1/r/storedproc.result
+++ b/mysql-test/suite/funcs_1/r/storedproc.result
@@ -15982,8 +15982,7 @@ insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'xyz'
 until count1 < 3
 END repeat label1;
 END//
-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 'label1;
-END' at line 8
+ERROR 42000: End-label label1 without match
 
 Testcase 4.3.21:
 --------------------------------------------------------------------------------
@@ -16024,9 +16023,7 @@ insert into res_t3_itisalongname_1381742_itsaverylongname_1381742 values( 'xyz'
 END while label1;
 END while;
 END//
-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 'label1;
-END while;
-END' at line 11
+ERROR 42000: End-label label1 without match
 
 Testcase 4.3.25:
 --------------------------------------------------------------------------------
diff --git a/mysql-test/suite/funcs_1/t/storedproc.test b/mysql-test/suite/funcs_1/t/storedproc.test
index ca9dfcb..061e676 100644
--- a/mysql-test/suite/funcs_1/t/storedproc.test
+++ b/mysql-test/suite/funcs_1/t/storedproc.test
@@ -19239,7 +19239,7 @@ DROP PROCEDURE IF EXISTS sp20;
 --enable_warnings
 
 delimiter //;
---error ER_PARSE_ERROR
+--error ER_SP_LABEL_MISMATCH
 CREATE PROCEDURE sp20( )
 BEGIN
     declare count1 integer default 1;
@@ -19306,7 +19306,7 @@ DROP PROCEDURE IF EXISTS sp23;
 --enable_warnings
 
 delimiter //;
---error ER_PARSE_ERROR
+--error ER_SP_LABEL_MISMATCH
 CREATE PROCEDURE sp23( )
 BEGIN
     declare count1 integer default 1;
diff --git a/mysql-test/suite/plugins/r/server_audit.result b/mysql-test/suite/plugins/r/server_audit.result
index bf71e51..dd977d9 100644
--- a/mysql-test/suite/plugins/r/server_audit.result
+++ b/mysql-test/suite/plugins/r/server_audit.result
@@ -60,7 +60,7 @@ id
 select * from t_doesnt_exist;
 ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
 syntax_error_query;
-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 'syntax_error_query' at line 1
+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 '' at line 1
 drop table renamed_t1, t2;
 show variables like 'server_audit%';
 Variable_name	Value
diff --git a/mysql-test/suite/plugins/r/sql_error_log.result b/mysql-test/suite/plugins/r/sql_error_log.result
index 3086b1f..4efe22d 100644
--- a/mysql-test/suite/plugins/r/sql_error_log.result
+++ b/mysql-test/suite/plugins/r/sql_error_log.result
@@ -12,7 +12,7 @@ set global sql_error_log_rate=1;
 select * from t_doesnt_exist;
 ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
 syntax_error_query;
-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 'syntax_error_query' at line 1
+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 '' at line 1
 CREATE PROCEDURE test_error()
 BEGIN
 DECLARE CONTINUE HANDLER
@@ -39,7 +39,7 @@ uninstall plugin SQL_ERROR_LOG;
 Warnings:
 Warning	1620	Plugin is busy and will be uninstalled on shutdown
 TIME HOSTNAME ERROR 1146: Table 'test.t_doesnt_exist' doesn't exist : select * from t_doesnt_exist
-TIME HOSTNAME ERROR 1064: 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 'syntax_error_query' at line 1 : syntax_error_query
+TIME HOSTNAME ERROR 1064: 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 '' at line 1 : syntax_error_query
 TIME HOSTNAME ERROR 1146: Table 'test.temptab' doesn't exist : SELECT `c` FROM `temptab`
 TIME HOSTNAME ERROR 1000: new message : RESIGNAL SQLSTATE '40000' SET
 MYSQL_ERRNO = 1000,
diff --git a/mysql-test/suite/plugins/r/thread_pool_server_audit.result b/mysql-test/suite/plugins/r/thread_pool_server_audit.result
index bf71e51..dd977d9 100644
--- a/mysql-test/suite/plugins/r/thread_pool_server_audit.result
+++ b/mysql-test/suite/plugins/r/thread_pool_server_audit.result
@@ -60,7 +60,7 @@ id
 select * from t_doesnt_exist;
 ERROR 42S02: Table 'test.t_doesnt_exist' doesn't exist
 syntax_error_query;
-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 'syntax_error_query' at line 1
+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 '' at line 1
 drop table renamed_t1, t2;
 show variables like 'server_audit%';
 Variable_name	Value
diff --git a/mysql-test/t/compound.test b/mysql-test/t/compound.test
index 1c5d12a..cabdf96 100644
--- a/mysql-test/t/compound.test
+++ b/mysql-test/t/compound.test
@@ -150,3 +150,10 @@ select a from t1 having a > 1|
 begin not atomic select a from t1 having a > 1; end|
 drop table t1|
 
+--echo #
+--echo # MDEV-8615: Assertion `m_cpp_buf <= begin_ptr &&
+--echo # begin_ptr <= m_cpp_buf + m_buf_length' failed in
+--echo # Lex_input_stream::body_utf8_start
+--echo #
+--error ER_PARSE_ERROR
+--query b'
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index a5a62ae..74d308f 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -248,6 +248,36 @@ static bool maybe_start_compound_statement(THD *thd)
   return 0;
 }
 
+static bool process_control_statement_label(THD *thd, LEX_STRING label)
+{
+  if (label.str != NULL)
+  {
+    sp_pcontext *ctx= thd->lex->spcont;
+    sp_label *lab= ctx->find_label(label);
+
+    if (lab)
+    {
+      my_error(ER_SP_LABEL_REDEFINE, MYF(0), label.str);
+      return 1;
+    }
+    else
+    {
+      lab= thd->lex->spcont->push_label(thd, label,
+                                        thd->lex->sphead->instructions());
+      lab->type= sp_label::ITERATION;
+    }
+  }
+  else
+  {
+    if (maybe_start_compound_statement(thd))
+      return 1;
+    /* Unlabeled controls get an empty label. */
+    thd->lex->spcont->push_label(thd, empty_lex_str,
+                                 thd->lex->sphead->instructions());
+  }
+  return 0;
+}
+
 /**
   Helper action for a case expression statement (the expr in 'CASE expr').
   This helper is used for 'searched' cases only.
@@ -1688,7 +1718,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
         LEX_HOSTNAME ULONGLONG_NUM field_ident select_alias ident ident_or_text
         IDENT_sys TEXT_STRING_sys TEXT_STRING_literal
         NCHAR_STRING opt_component key_cache_name
-        sp_opt_label BIN_NUM label_ident TEXT_STRING_filesystem ident_or_empty
+        sp_opt_label sp_opt_set_label
+        BIN_NUM label_ident TEXT_STRING_filesystem ident_or_empty
         opt_constraint constraint opt_ident
 
 %type <lex_str_ptr>
@@ -1940,7 +1971,7 @@ END_OF_INPUT
 %type <spblock> sp_decls sp_decl
 %type <lex> sp_cursor_stmt
 %type <spname> sp_name
-%type <splabel> sp_block_content
+%type <splabel> sp_block_content sp_control_content
 %type <spvar> sp_param_name_and_type
 %type <spvar_mode> sp_opt_inout
 %type <index_hint> index_hint_type
@@ -3670,7 +3701,6 @@ sp_proc_stmt_compound_ok:
           sp_proc_stmt_if
         | case_stmt_specification
         | sp_unlabeled_block_not_atomic
-        | sp_unlabeled_control
         ;
 
 sp_proc_stmt_if:
@@ -3769,16 +3799,12 @@ sp_proc_stmt_return:
         ;
 
 sp_unlabeled_control:
-          {
-            if (maybe_start_compound_statement(thd))
-              MYSQL_YYABORT;
-            /* Unlabeled controls get an empty label. */
-            Lex->spcont->push_label(thd, empty_lex_str,
-                                    Lex->sphead->instructions());
-          }
           sp_control_content
           {
-            Lex->sphead->backpatch(Lex->spcont->pop_label());
+            if ($1->type != sp_label::IMPLICIT)
+            {
+              MYSQL_YYABORT;
+            }
           }
         ;
 
@@ -4201,37 +4227,18 @@ else_clause_opt:
         ;
 
 sp_labeled_control:
-          label_ident ':'
-          {
-            LEX *lex= Lex;
-            sp_pcontext *ctx= lex->spcont;
-            sp_label *lab= ctx->find_label($1);
-
-            if (lab)
-            {
-              my_error(ER_SP_LABEL_REDEFINE, MYF(0), $1.str);
-              MYSQL_YYABORT;
-            }
-            else
-            {
-              lab= lex->spcont->push_label(thd, $1, lex->sphead->instructions());
-              lab->type= sp_label::ITERATION;
-            }
-          }
           sp_control_content sp_opt_label
           {
-            LEX *lex= Lex;
-            sp_label *lab= lex->spcont->pop_label();
+            sp_label *lab= $1;
 
-            if ($5.str)
+            if ($2.str)
             {
-              if (my_strcasecmp(system_charset_info, $5.str, lab->name.str) != 0)
+              if (my_strcasecmp(system_charset_info, $2.str, lab->name.str) != 0)
               {
-                my_error(ER_SP_LABEL_MISMATCH, MYF(0), $5.str);
+                my_error(ER_SP_LABEL_MISMATCH, MYF(0), $2.str);
                 MYSQL_YYABORT;
               }
             }
-            lex->sphead->backpatch(lab);
           }
         ;
 
@@ -4240,6 +4247,11 @@ sp_opt_label:
         | label_ident   { $$= $1; }
         ;
 
+sp_opt_set_label:
+          /* Empty  */    { $$= null_lex_str; }
+        | label_ident ':' { $$= $1; }
+        ;
+
 sp_labeled_block:
           label_ident ':' BEGIN_SYM
           {
@@ -4328,7 +4340,11 @@ sp_block_content:
         ;
 
 sp_control_content:
-          LOOP_SYM
+          sp_opt_set_label LOOP_SYM
+          {
+            if (process_control_statement_label(thd, $1))
+              MYSQL_YYABORT;
+          }
           sp_proc_stmts1 END LOOP_SYM
           {
             LEX *lex= Lex;
@@ -4339,16 +4355,21 @@ sp_control_content:
             if (i == NULL ||
                 lex->sphead->add_instr(i))
               MYSQL_YYABORT;
+            lex->sphead->backpatch($$= Lex->spcont->pop_label());
+          }
+        | sp_opt_set_label WHILE_SYM 
+          {
+            if (process_control_statement_label(thd, $1))
+              MYSQL_YYABORT;
+            Lex->sphead->reset_lex(thd);
           }
-        | WHILE_SYM 
-          { Lex->sphead->reset_lex(thd); }
           expr DO_SYM
           {
             LEX *lex= Lex;
             sp_head *sp= lex->sphead;
             uint ip= sp->instructions();
             sp_instr_jump_if_not *i= new (lex->thd->mem_root)
-              sp_instr_jump_if_not(ip, lex->spcont, $3, lex);
+              sp_instr_jump_if_not(ip, lex->spcont, $4, lex);
             if (i == NULL ||
                 /* Jumping forward */
                 sp->push_backpatch(i, lex->spcont->last_label()) ||
@@ -4369,8 +4390,14 @@ sp_control_content:
                 lex->sphead->add_instr(i))
               MYSQL_YYABORT;
             lex->sphead->do_cont_backpatch();
+            lex->sphead->backpatch($$= Lex->spcont->pop_label());
+          }
+        | sp_opt_set_label REPEAT_SYM
+          {
+            if (process_control_statement_label(thd, $1))
+              MYSQL_YYABORT;
           }
-        | REPEAT_SYM sp_proc_stmts1 UNTIL_SYM 
+          sp_proc_stmts1 UNTIL_SYM 
           { Lex->sphead->reset_lex(thd); }
           expr END REPEAT_SYM
           {
@@ -4378,7 +4405,7 @@ sp_control_content:
             uint ip= lex->sphead->instructions();
             sp_label *lab= lex->spcont->last_label();  /* Jumping back */
             sp_instr_jump_if_not *i= new (lex->thd->mem_root)
-              sp_instr_jump_if_not(ip, lex->spcont, $5, lab->ip, lex);
+              sp_instr_jump_if_not(ip, lex->spcont, $7, lab->ip, lex);
             if (i == NULL ||
                 lex->sphead->add_instr(i))
               MYSQL_YYABORT;
@@ -4386,6 +4413,7 @@ sp_control_content:
               MYSQL_YYABORT;
             /* We can shortcut the cont_backpatch here */
             i->m_cont_dest= ip+1;
+            lex->sphead->backpatch($$= Lex->spcont->pop_label());
           }
         ;
 
@@ -15804,7 +15832,13 @@ begin:
           ;
 
 compound_statement:
-          sp_proc_stmt_compound_ok
+           sp_proc_stmt_compound_ok
+          {
+            Lex->sql_command= SQLCOM_COMPOUND;
+            Lex->sphead->set_stmt_end(thd);
+            Lex->sphead->restore_thd_mem_root(thd);
+          }
+          | sp_unlabeled_control
           {
             Lex->sql_command= SQLCOM_COMPOUND;
             Lex->sphead->set_stmt_end(thd);
diff --git a/storage/test_sql_discovery/mysql-test/sql_discovery/simple.result b/storage/test_sql_discovery/mysql-test/sql_discovery/simple.result
index 94f3bd1..4452e21 100644
--- a/storage/test_sql_discovery/mysql-test/sql_discovery/simple.result
+++ b/storage/test_sql_discovery/mysql-test/sql_discovery/simple.result
@@ -14,7 +14,7 @@ select * from t1;
 ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'foobar bwa-ha-ha'
 show warnings;
 Level	Code	Message
-Error	1064	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 'foobar bwa-ha-ha' at line 1
+Error	1064	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 'bwa-ha-ha' at line 1
 Error	1939	Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'foobar bwa-ha-ha'
 set @@test_sql_discovery_statement='t1:select 1';
 select * from t1;



More information about the commits mailing list