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

NOT FOUND condition not triggered in stored aggregate functions

    XMLWordPrintable

Details

    Description

      Both the following example show that NOT FOUND condition does not occur.

      This is a different problem than MDEV-16305. In that report, I shows HANDLERs which are never triggered even if the condition occurs. Here I show that a condition doesn't occur at all.

      Realistic test:

      CREATE AGGREGATE FUNCTION test1(p_value TEXT)
          RETURNS BOOL
      BEGIN
          DECLARE CONTINUE HANDLER
              FOR NOT FOUND
          BEGIN
              RETURN FALSE;
          END;
          FETCH GROUP NEXT ROW;
          RETURN TRUE;
      END;
       
      CREATE TABLE t_empty (
          a INT
      ) ENGINE InnoDB;
       
      MariaDB [test]> SELECT test1(n) FROM t;
      +----------+
      | test1(n) |
      +----------+
      |        1 |
      +----------+
      1 row in set (0.000 sec)
      

      Trivial test to prove that the problem is not HANDLER:

      CREATE AGGREGATE FUNCTION test2(p_value TEXT)
          RETURNS BOOL
      BEGIN
          FETCH GROUP NEXT ROW;
          FETCH GROUP NEXT ROW;
          FETCH GROUP NEXT ROW;
          RETURN TRUE;
      END;
       
      MariaDB [test]> SELECT test2(n) FROM t;
      +----------+
      | test2(n) |
      +----------+
      |     NULL |
      +----------+
      1 row in set (0.001 sec)
       
      MariaDB [test]> SHOW WARNINGS;
      Empty set (0.000 sec)
      

      Attachments

        Activity

          People

            cvicentiu Vicențiu Ciorbaru
            f_razzoli Federico Razzoli
            Votes:
            0 Vote for this issue
            Watchers:
            7 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.