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

Plugin aggregate DISTINCT replay order depends on the argument data type

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 13.2
    • 13.2
    • Plugins
    • None
    • Not for Release Notes

    Description

      Plugin aggregate DISTINCT replay order depends on the argument data type

      INSTALL SONAME 'func_test';
      CREATE TABLE t (i INT, vc VARCHAR(16), tx TEXT);
      INSERT INTO t VALUES  (9,'zzz','zzz'), (5,'mmm','mmm'), (9,'zzz','zzz'), (1,'aaa','aaa'), (5,'mmm','mmm');
       
      SELECT test_plugin_first(i),  test_plugin_first(vc),  test_plugin_first(tx)  FROM t;
      SELECT test_plugin_first(DISTINCT i), test_plugin_first(DISTINCT vc), test_plugin_first(DISTINCT tx) FROM t;
      

      column type              no DISTINCT    with DISTINCT  
      INT         (tree path)       9              1            
      VARCHAR(16) (tree path)     zzz            aaa            
      TEXT        (blob replay)   zzz            zzz            
      

      VARCHAR and TEXT holding identical values disagree:

      test_plugin_first(DISTINCT vc) = 'aaa'
      test_plugin_first(DISTINCT tx) = 'zzz'
      

      Adding DISTINCT also changes the answer for the non-blob types (9 -> 1, zzz -> aaa) while leaving the blob type unchanged.

      CLI Output

      13.2.0-dbg>INSTALL SONAME 'func_test';
      Query OK, 0 rows affected (0.003 sec)
       
      13.2.0-dbg>CREATE TABLE t (i INT, vc VARCHAR(16), tx TEXT);
      Query OK, 0 rows affected (0.010 sec)
       
      13.2.0-dbg>INSERT INTO t VALUES  (9,'zzz','zzz'), (5,'mmm','mmm'), (9,'zzz','zzz'), (1,'aaa','aaa'), (5,'mmm','mmm');
      Query OK, 5 rows affected (0.002 sec)
      Records: 5  Duplicates: 0  Warnings: 0
       
      13.2.0-dbg>
      13.2.0-dbg>SELECT test_plugin_first(i),  test_plugin_first(vc),  test_plugin_first(tx)  FROM t;
      +----------------------+-----------------------+-----------------------+
      | test_plugin_first(i) | test_plugin_first(vc) | test_plugin_first(tx) |
      +----------------------+-----------------------+-----------------------+
      |                    9 | zzz                   | zzz                   |
      +----------------------+-----------------------+-----------------------+
      1 row in set (0.000 sec)
       
      13.2.0-dbg>SELECT test_plugin_first(DISTINCT i), test_plugin_first(DISTINCT vc), test_plugin_first(DISTINCT tx) FROM t;
      +-------------------------------+--------------------------------+--------------------------------+
      | test_plugin_first(DISTINCT i) | test_plugin_first(DISTINCT vc) | test_plugin_first(DISTINCT tx) |
      +-------------------------------+--------------------------------+--------------------------------+
      |                             1 | aaa                            | zzz                            |
      +-------------------------------+--------------------------------+--------------------------------+
      1 row in set (0.002 sec)
       
      13.2.0-dbg>
      

      Attachments

        Issue Links

          Activity

            People

              drrtuy Roman
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 0.5h
                  0.5h

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.