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

Weak REF CURSOR declared as a package type is not opened using a dynamic SQL statement

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 13.1
    • 13.1
    • Stored routines
    • None
    • Not for Release Notes
    • Q3/2026 Server Maintenance

    Description

      13.1.0-opt>SET sql_mode=ORACLE;
      Query OK, 0 rows affected (0.000 sec)
       
      13.1.0-opt>CREATE TABLE t (id INT, name VARCHAR(100));
      Query OK, 0 rows affected (0.008 sec)
       
      13.1.0-opt>INSERT INTO t VALUES (1,'Test');
      Query OK, 1 row affected (0.001 sec)
       
      13.1.0-opt>
      13.1.0-opt>DELIMITER $$
      13.1.0-opt>CREATE PACKAGE pc AS TYPE wc IS REF CURSOR; END;
          -> $$
      Query OK, 0 rows affected (0.002 sec)
       
      13.1.0-opt>CREATE PROCEDURE pdyn AS c pc.wc; vi INT; vn VARCHAR(100);
          -> BEGIN
          -> OPEN c FOR 'SELECT id, name FROM t';
          -> FETCH c INTO vi, vn;
          -> SELECT vi, vn;
          -> CLOSE c;
          -> END;
          -> $$
      ERROR 1221 (HY000): Incorrect usage of c and OPEN..FOR <dynamic string>
      13.1.0-opt>
      

      MTR test

      DELIMITER $$;
      CREATE PACKAGE pc AS TYPE wc IS REF CURSOR; END;
      $$
      CREATE PROCEDURE pdyn AS c pc.wc; vi INT; vn VARCHAR(100);
      BEGIN
          OPEN c FOR 'SELECT id, name FROM t';
          FETCH c INTO vi, vn;
          SELECT vi, vn;
          CLOSE c;
      END;
      $$
       
      DELIMITER ;$$
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 1d
                  1d
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 0.5h Time Not Required
                  0.5h

                  Git Integration

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