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

context capture should work for stored procedures

    XMLWordPrintable

Details

    Description

      include a scenario where in, given table is referenced both inside and outside of the stored function with in a sql query.

      create table t1 (
          a int,
          b int,
          index idx_ab(a, b)
      ) ENGINE=InnoDB;
       
      insert into t1 select seq%2, seq%3 from seq_1_to_20;
      

      delimiter //;
       
      CREATE FUNCTION count_all(b_val INT)
      RETURNS INT
      READS SQL DATA
      DETERMINISTIC
      BEGIN
          DECLARE a_cnt INT;
          SELECT COUNT(*) INTO a_cnt FROM t1 WHERE b = b_val;
          RETURN a_cnt;
      END
      //
       
      DELIMITER ;//
       
      set optimizer_record_context=1;
      explain format=json select t1.a, t1.b, count_all(t1.b) from t1;
       
      -- capture the context
      truncate table t1;
      set optimizer_replay_context='captured_context_var';
      

      ensure that the cost metrics for the query would be same after the captured_context is replayed on the same query, even though the table is truncated.

      Attachments

        Issue Links

          Activity

            People

              bsrikanth Srikanth Bondalapati
              bsrikanth Srikanth Bondalapati
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.