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

Crash in EXECUTE IMMEDIATE with an expression returning a GRANT command

    Details

    • Sprint:
      10.1.22

      Description

      I create a role and a procedure p1:

      CREATE ROLE IF NOT EXISTS testrole;
      DELIMITER /
      CREATE OR REPLACE PROCEDURE p1() 
      BEGIN
      END;
      /
      DELIMITER ;
      

      Now I create a procedure p2 and execute it. It works fine:

      DELIMITER /
      CREATE OR REPLACE PROCEDURE p2 (IN wgrp  VARCHAR(10))
      BEGIN
        DECLARE wcmd VARCHAR(200);
        set wcmd=concat('GRANT EXECUTE ON PROCEDURE p1 TO ',wgrp);
        -- This works fine
        EXECUTE IMMEDIATE wcmd;
       END;
      /
      DELIMITER ;
      CALL p2('testrole');
      

      Now I change the procedure body slightly and re-run it. It crashes:

      DELIMITER /
      CREATE OR REPLACE PROCEDURE p2 (wgrp  VARCHAR(10))
      BEGIN
        -- assertion failed
        EXECUTE IMMEDIATE concat('GRANT EXECUTE ON PROCEDURE p1 TO ',wgrp);
      END;
      /
      DELIMITER ;
      CALL p2('testrole');
      

      This procedure also crashes:

      DELIMITER /
      CREATE OR REPLACE PROCEDURE p2 ()
      BEGIN
        EXECUTE IMMEDIATE concat(_utf8'GRANT EXECUTE ON PROCEDURE p1 TO ',_latin1'testrole');
      END;
      /
      DELIMITER ;
      CALL p2();
      

      So does this one:

      DELIMITER /
      CREATE OR REPLACE PROCEDURE p2 ()
      BEGIN
        PREPARE stmt FROM concat(_utf8'GRANT EXECUTE ON PROCEDURE p1 TO ',_latin1' testrole');
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
      END;
      /
      DELIMITER ;
      CALL p2();
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: