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

[PATCH] UDF aggregate functions with WITH ROLLUP wrong results

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.5, 10.6, 5.1.67, 5.5.40, 10.0.15, 10.3(EOL), 10.4(EOL), 10.7(EOL), 10.8(EOL), 10.9(EOL)
    • 5.5(EOL), 10.3(EOL)
    • OTHER

    Description

      upstream: http://bugs.mysql.com/bug.php?id=38297

      CREATE AGGREGATE FUNCTION avgcost
              RETURNS REAL SONAME "udf_example.so";
      create table t1(sum int, price float(24), g int);
      insert into t1 values(100, 50.00, 1), (100, 100.00, 1);
      insert into t1 values(10, 2.00, 2), (100, 100.00, 2);
       
      MariaDB [test]> select avgcost(sum, price) from t1 where g=1;
      +---------------------+
      | avgcost(sum, price) |
      +---------------------+
      |             75.0000 |
      +---------------------+
      1 row in set (0.06 sec)
       
      MariaDB [test]> select avgcost(sum, price) from t1 where g=2;
      +---------------------+
      | avgcost(sum, price) |
      +---------------------+
      |             91.0909 |
      +---------------------+
      1 row in set (0.00 sec)
       
      MariaDB [test]> select avgcost(sum, price) from t1;
      +---------------------+
      | avgcost(sum, price) |
      +---------------------+
      |             80.7097 |
      +---------------------+
      1 row in set (0.00 sec)
       
      MariaDB [test]> select avgcost(sum, price) from t1 group by g;
      +---------------------+
      | avgcost(sum, price) |
      +---------------------+
      |             75.0000 |
      |             91.0909 |
      +---------------------+
       
      MariaDB [test]> select avgcost(sum, price) from t1 group by g with rollup;
      +---------------------+
      | avgcost(sum, price) |
      +---------------------+
      |             83.3333 |
      |             91.0909 |
      |             91.0909 |
      +---------------------+

      The ROLLUP structure is copied however the UDF init function isn't called meaning the initid->ptr is use for an aggregation and the rollup calculation at the same time.

      Patch based on upstream submission. Added test case but its not got the correct result yet.

      Attachments

        Activity

          People

            serg Sergei Golubchik
            danblack Daniel Black
            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.