File tree Expand file tree Collapse file tree 5 files changed +96
-1
lines changed
Expand file tree Collapse file tree 5 files changed +96
-1
lines changed Original file line number Diff line number Diff line change @@ -8792,3 +8792,18 @@ drop procedure p4;
87928792drop table t1;
87938793set @@sql_mode=@save_sql_mode;
87948794# End of 10.3 tests
8795+ #
8796+ # Start of 10.4 tests
8797+ #
8798+ #
8799+ # MDEV-19637 Crash on an SP variable assignment to a wrong subselect
8800+ #
8801+ BEGIN NOT ATOMIC
8802+ DECLARE a INT;
8803+ SET a=(SELECT 1 FROM DUAL UNION SELECT HIGH_PRIORITY 2 FROM DUAL);
8804+ END;
8805+ $$
8806+ ERROR 42000: Incorrect usage/placement of 'HIGH_PRIORITY'
8807+ #
8808+ # End of 10.4 tests
8809+ #
Original file line number Diff line number Diff line change @@ -10323,3 +10323,26 @@ drop table t1;
1032310323set @@sql_mode=@save_sql_mode;
1032410324
1032510325--echo # End of 10.3 tests
10326+
10327+
10328+ --echo #
10329+ --echo # Start of 10.4 tests
10330+ --echo #
10331+
10332+ --echo #
10333+ --echo # MDEV-19637 Crash on an SP variable assignment to a wrong subselect
10334+ --echo #
10335+
10336+ DELIMITER $$;
10337+ --error ER_CANT_USE_OPTION_HERE
10338+ BEGIN NOT ATOMIC
10339+ DECLARE a INT;
10340+ SET a=(SELECT 1 FROM DUAL UNION SELECT HIGH_PRIORITY 2 FROM DUAL);
10341+ END;
10342+ $$
10343+ DELIMITER ;$$
10344+
10345+
10346+ --echo #
10347+ --echo # End of 10.4 tests
10348+ --echo #
Original file line number Diff line number Diff line change @@ -2552,3 +2552,19 @@ idx
25522552idx
255325531
25542554DROP PROCEDURE p1;
2555+ #
2556+ # Start of 10.4 tests
2557+ #
2558+ #
2559+ # MDEV-19637 Crash on an SP variable assignment to a wrong subselect
2560+ #
2561+ DECLARE
2562+ a INT;
2563+ BEGIN
2564+ SET a=(SELECT 1 FROM DUAL UNION SELECT HIGH_PRIORITY 2 FROM DUAL);
2565+ END;
2566+ $$
2567+ ERROR 42000: Incorrect usage/placement of 'HIGH_PRIORITY'
2568+ #
2569+ # End of 10.4 tests
2570+ #
Original file line number Diff line number Diff line change @@ -2387,3 +2387,28 @@ $$
23872387DELIMITER ;$$
23882388CALL p1();
23892389DROP PROCEDURE p1;
2390+
2391+
2392+ --echo #
2393+ --echo # Start of 10.4 tests
2394+ --echo #
2395+
2396+
2397+ --echo #
2398+ --echo # MDEV-19637 Crash on an SP variable assignment to a wrong subselect
2399+ --echo #
2400+
2401+ DELIMITER $$;
2402+ --error ER_CANT_USE_OPTION_HERE
2403+ DECLARE
2404+ a INT;
2405+ BEGIN
2406+ SET a=(SELECT 1 FROM DUAL UNION SELECT HIGH_PRIORITY 2 FROM DUAL);
2407+ END;
2408+ $$
2409+ DELIMITER ;$$
2410+
2411+
2412+ --echo #
2413+ --echo # End of 10.4 tests
2414+ --echo #
Original file line number Diff line number Diff line change @@ -575,8 +575,24 @@ bool sp_create_assignment_instr(THD *thd, bool no_lookahead)
575575 return true;
576576 }
577577 lex->pop_select();
578- if (Lex->check_main_unit_semantics())
578+ if (lex->check_main_unit_semantics())
579+ {
580+ /*
581+ "lex" can be referrenced by:
582+ - sp_instr_set SET a= expr;
583+ - sp_instr_set_row_field SET r.a= expr;
584+ - sp_instr_stmt (just generated above) SET @a= expr;
585+ In this case, "lex" is fully owned by sp_instr_xxx and it will
586+ be deleted by the destructor ~sp_instr_xxx().
587+ So we should remove "lex" from the stack sp_head::m_lex,
588+ to avoid double free.
589+ Note, in case "lex" is not owned by any sp_instr_xxx,
590+ it's also safe to remove it from the stack right now.
591+ So we can remove it unconditionally, without testing lex->sp_lex_in_use.
592+ */
593+ lex->sphead->restore_lex(thd);
579594 return true;
595+ }
580596 enum_var_type inner_option_type= lex->option_type;
581597 if (lex->sphead->restore_lex(thd))
582598 return true;
You can’t perform that action at this time.
0 commit comments