Skip to content

Commit 7181ea5

Browse files
committed
MDEV-33245 SIGSEGV in wsrep_check_sequence
The segfault in wsrep_check_sequence is due to a null pointer deference on: db_type= thd->lex->create_info.db_type->db_type; Where create_info.db_type is null. This occured under a used_engine==true condition which is set in the calling function based on create_info.used_fields==HA_CREATE_USED_ENGINE. However the create_info.used_fields was a left over from the parsing of the previous failed CREATE TABLE where because of its failure, db_type wasn't populated. This is corrected by cleaning the create_info when we start to parse ALTER SEQUENCE statements. Other paths to wsrep_check_sequence is via CREATE SEQUENCE and CREATE TABLE LIKE which both initialize the create_info correctly.
1 parent ee28782 commit 7181ea5

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

mysql-test/suite/galera/r/galera_sequences.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,14 @@ NEXTVAL(t)
314314
connection node_1;
315315
DROP TABLE t1;
316316
DROP SEQUENCE t;
317+
318+
MDEV-33245 SIGSEGV in wsrep_check_sequence | Sql_cmd_alter_sequence::execute
319+
320+
CREATE TABLE t (a INT) ENGINE=InnoDB;
321+
INSERT INTO t VALUES (0);
322+
CREATE TABLE t1 (c VARCHAR) ENGINE=InnoDB;
323+
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 ') ENGINE=InnoDB' at line 1
324+
ALTER SEQUENCE IF EXISTS t MINVALUE=1;
325+
ERROR 42000: This version of MariaDB doesn't yet support 'CACHE without INCREMENT BY 0 in Galera cluster'
326+
DROP TABLE t;
327+
End of 10.5 tests

mysql-test/suite/galera/t/galera_sequences.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,18 @@ SELECT NEXTVAL(t);
341341
--connection node_1
342342
DROP TABLE t1;
343343
DROP SEQUENCE t;
344+
345+
--echo
346+
--echo MDEV-33245 SIGSEGV in wsrep_check_sequence | Sql_cmd_alter_sequence::execute
347+
--echo
348+
349+
CREATE TABLE t (a INT) ENGINE=InnoDB;
350+
INSERT INTO t VALUES (0);
351+
352+
--error ER_PARSE_ERROR
353+
CREATE TABLE t1 (c VARCHAR) ENGINE=InnoDB;
354+
--error ER_NOT_SUPPORTED_YET
355+
ALTER SEQUENCE IF EXISTS t MINVALUE=1;
356+
357+
DROP TABLE t;
358+
--echo End of 10.5 tests

sql/sql_yacc.yy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7472,6 +7472,7 @@ alter:
74727472
{
74737473
LEX *lex= Lex;
74747474
lex->sql_command= SQLCOM_ALTER_SEQUENCE;
7475+
lex->create_info.init();
74757476
DBUG_ASSERT(!lex->m_sql_cmd);
74767477
if (Lex->main_select_push())
74777478
MYSQL_YYABORT;

0 commit comments

Comments
 (0)