Bug #106825 SELECT INTO distorts CONTINUE HANDLER FOR CURSOR
Submitted: 24 Mar 2022 19:03 Modified: 28 Mar 2022 14:34
Reporter: Mikh Mikhailov Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version: 5.6.37 OS:Windows
Assigned to: CPU Architecture:Any
Tags: SELECT INTO variables inside CURSOR

[24 Mar 2022 19:03] Mikh Mikhailov
Description:
SELECT ... INTO variables set CONTINUE HANDLER FOR NOT FOUND to 1(TRUE)

How to repeat:
  DECLARE t_teil_sachnr, t_teil_alt CHAR(7);

  DECLARE v_optm_id_sachnr, v_optm_id_alt INTEGER DEFAULT NULL;  

  DECLARE curs_done INTEGER DEFAULT FALSE;
  DECLARE curs_Teilen CURSOR FOR SELECT teil_sachnr, teil_alt FROM my_table WHERE teil_alt <> '';
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET curs_done = TRUE;

  #
  OPEN curs_Teilen;

  # 
  loop_fill: LOOP
    FETCH curs_Teilen INTO t_teil_sachnr, t_teil_alt;
    IF curs_done THEN LEAVE loop_fill; END IF;

    SELECT id INTO v_optm_id_sachnr
      FROM optm_teil_alt_list
      WHERE teil_alt_list = '0000334';

  END LOOP loop_fill;
  CLOSE curs_Teilen;
[28 Mar 2022 13:40] MySQL Verification Team
Hi Mr. Mikhailov,

Thank you for your bug report.

However, 5.6 is not supported any more, for a very long time.

Do feel free to file a new report if you can repeat that behaviour in 8.0.28.

Unsupported.
[28 Mar 2022 14:34] Mikh Mikhailov
I got around this bug. 
https://stackoverflow.com/questions/71608326/select-into-variables-set-continue-handler-fo...

There is currently no way to test this bug in version 8.