Skip to content

Commit 8c169f5

Browse files
committed
MDEV-28220: Assert failure in sp_head::~sp_head on parsing a syntax incorrect statement CREATE SEQUENCE ... RESTART inside CREATE PROCEDURE/CREATE FUNCTION
This bug report is about the same issue as MDEV-28129 and MDEV-21173. The issue is that the macros YYABORT is called instead of MYSQL_YYABORT on parse error. In result the method LEX::cleanup_lex_after_parse_error is not called to clean up data structures created on parsing of the statement.
1 parent 49aee1a commit 8c169f5

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

mysql-test/main/sp.result

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8921,4 +8921,17 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
89218921
BEGIN
89228922
RETURN '';
89238923
END' at line 2
8924+
#
8925+
# MDEV-28220: Assert failure in sp_head::~sp_head on parsing a syntax incorrect statement CREATE SEQUENCE ... RESTART inside CREATE PROCEDURE/CREATE FUNCTION
8926+
8927+
# Specifying the RESTART clause for the statement CREATE SEQUENCE is a syntax error.
8928+
# Check that CREATE PROCEDURE doesn't crash server if the statement
8929+
# CREATE SEQUNCE ... RESTART is specified in its body.
8930+
#
8931+
CREATE PROCEDURE sp1() CREATE SEQUENCE s1 START WITH 300 INCREMENT BY 30 RESTART;
8932+
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 'RESTART' at line 1
8933+
# CREATE SEQUNCE ... RESTART and CREATE SEQUNCE ... RESTART WITH ... are
8934+
# handled by different grammar rules, so check the both cases.
8935+
CREATE PROCEDURE sp1() CREATE SEQUENCE s1 START WITH 300 INCREMENT BY 30 RESTART WITH 100;
8936+
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 'RESTART' at line 1
89248937
# End of 10.3 tests

mysql-test/main/sp.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10474,4 +10474,19 @@ END;
1047410474
$$
1047510475
DELIMITER ;$$
1047610476

10477+
--echo #
10478+
--echo # MDEV-28220: Assert failure in sp_head::~sp_head on parsing a syntax incorrect statement CREATE SEQUENCE ... RESTART inside CREATE PROCEDURE/CREATE FUNCTION
10479+
--echo
10480+
10481+
--echo # Specifying the RESTART clause for the statement CREATE SEQUENCE is a syntax error.
10482+
--echo # Check that CREATE PROCEDURE doesn't crash server if the statement
10483+
--echo # CREATE SEQUNCE ... RESTART is specified in its body.
10484+
--echo #
10485+
--error ER_PARSE_ERROR
10486+
CREATE PROCEDURE sp1() CREATE SEQUENCE s1 START WITH 300 INCREMENT BY 30 RESTART;
10487+
--echo # CREATE SEQUNCE ... RESTART and CREATE SEQUNCE ... RESTART WITH ... are
10488+
--echo # handled by different grammar rules, so check the both cases.
10489+
--error ER_PARSE_ERROR
10490+
CREATE PROCEDURE sp1() CREATE SEQUENCE s1 START WITH 300 INCREMENT BY 30 RESTART WITH 100;
10491+
1047710492
--echo # End of 10.3 tests

sql/sql_yacc.yy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,7 +3037,7 @@ sequence_def:
30373037
if (unlikely(Lex->sql_command != SQLCOM_ALTER_SEQUENCE))
30383038
{
30393039
thd->parse_error(ER_SYNTAX_ERROR, "RESTART");
3040-
YYABORT;
3040+
MYSQL_YYABORT;
30413041
}
30423042
if (unlikely(Lex->create_info.seq_create_info->used_fields &
30433043
seq_field_used_restart))
@@ -3049,7 +3049,7 @@ sequence_def:
30493049
if (unlikely(Lex->sql_command != SQLCOM_ALTER_SEQUENCE))
30503050
{
30513051
thd->parse_error(ER_SYNTAX_ERROR, "RESTART");
3052-
YYABORT;
3052+
MYSQL_YYABORT;
30533053
}
30543054
if (unlikely(Lex->create_info.seq_create_info->used_fields &
30553055
seq_field_used_restart))

0 commit comments

Comments
 (0)