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

Cursor OPEN statements do not write to the slow log

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 12.2
    • 12.2
    • Stored routines
    • None
    • Can result in unexpected behaviour

    Description

      CREATE OR REPLACE TABLE t1 (a INT);
      CREATE OR REPLACE TABLE t2 (a INT);
      DELIMITER $$
      CREATE OR REPLACE PROCEDURE p1() 
      BEGIN
        DECLARE c CURSOR FOR SELECT COUNT(a), SLEEP(0.05) FROM t2;
        OPEN c;
        CLOSE c;
        SELECT COUNT(a), SLEEP(0.05) FROM t1;
      END;
      $$
      DELIMITER ;
       
      SET GLOBAL slow_query_log=ON;
      SET SESSION authorization root@localhost;
      SET SESSION log_slow_verbosity='explain';
      SET log_slow_disabled_statements=admin;
      SET long_query_time=0.01;
      USE test;
      CALL p1();
      

      # User@Host: root[root] @ localhost []
      # Thread_id: 3  Schema: test  QC_hit: No
      # Query_time: 0.100438  Lock_time: 0.050300  Rows_sent: 1  Rows_examined: 0
      # Rows_affected: 0  Bytes_sent: 105
      # Stored_routine: test.p1
      SET timestamp=1768974530;
      SELECT COUNT(a), SLEEP(0.05) FROM t1;
      # User@Host: root[root] @ localhost []
      # Thread_id: 3  Schema: test  QC_hit: No
      # Query_time: 0.100488  Lock_time: 0.000012  Rows_sent: 1  Rows_examined: 0
      # Rows_affected: 0  Bytes_sent: 116
      SET timestamp=1768974530;
      CALL p1();
      

      Problems:

      • The slow log record for the SELECT FROM t1 statement has an entry in the log, while the cursor OPEN statement does not.
      • The Query_time in the slow log entry for the SELECT FROM t1 does not look correct. It likely includes the time spent on the OPEN statement.

      Note, there is also a problem that the SELECT FROM t1 statement does not have an Explain entry. This is reported in a separate issue MDEV-38611.

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              bar Alexander Barkov
              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.