Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-37155

Not found is not work of cursor in oracle mode and loop forever

    XMLWordPrintable

Details

    • Bug
    • Status: Needs Feedback (View Workflow)
    • Major
    • Resolution: Unresolved
    • 12.1
    • 12.1
    • PL/SQL
    • None

    Description

      CREATE TABLE t1 (a INT, b VARCHAR(10),c DATETIME(3));
      INSERT INTO t1 VALUES (1,'b1','2001-01-01 10:20:30.123');
      INSERT INTO t1 VALUES (2,'b2','2001-01-02 10:20:30.123');
      CREATE TABLE t2 LIKE t1;
      set sql_mode='oracle';
      DELIMITER $$
      CREATE PROCEDURE p1()
      AS
        done INT DEFAULT 0;
        v_a t1.a%type;
        v_b t1.b%type;
        v_c t1.c%type;
        CURSOR c IS SELECT a,b,c FROM t1;
        CONTINUE HANDLER FOR NOT FOUND SET done=TRUE;
      BEGIN
        OPEN c;
        <<read_loop>> LOOP
          FETCH c INTO v_a, v_b, v_c;
          IF done THEN
            LEAVE read_loop;
          END IF;
          INSERT INTO t2 (a,b,c) VALUES (v_a, v_b, v_c);
        END LOOP;
        CLOSE c;
      END;
      $$
      DELIMITER ;
      -- without fix this will insert forever
      CALL p1();

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              kongzhi.kz zhi kong
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.