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

Wrong result when using a smaller size for sort buffer

Details

    Description

      DATASET

      create table t1(a varchar(255), b varchar(255), c varchar(255),d int);
      insert into t1 values ("jkl","mno", "pqr",1),("abc","def","ghi",2);
      insert into t1 values ("jkl","mno", "pqr",1),("abc","def","ghi",2);
      insert into t1 values ("jkl","mno", "pqr",1),("abc","def","ghi",2);
      insert into t1 values ("jkl","mno", "pqr",1),("abc","def","ghi",2);
      insert into t1 values ("jkl","mno", "pqr",1),("abc","def","ghi",2);
      insert into t1 values ("jkl","mno", "pqr",1),("abc","def","ghi",2);
      insert into t1 values ("jkl","mno", "pqr",1),("abc","def","ghi",2);
      insert into t1 values ("jkl","mno", "pqr",1),("abc","def","ghi",2);
      

      MariaDB [test]> select * from t1 order  by d;
      +------+------+------+------+
      | a    | b    | c    | d    |
      +------+------+------+------+
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | abc  | def  | ghi  |    2 |
      | abc  | def  | ghi  |    2 |
      | abc  | def  | ghi  |    2 |
      | abc  | def  | ghi  |    2 |
      | abc  | def  | ghi  |    2 |
      | abc  | def  | ghi  |    2 |
      | abc  | def  | ghi  |    2 |
      | abc  | def  | ghi  |    2 |
      +------+------+------+------+
      16 rows in set (0.01 sec)
       
      MariaDB [test]> set sort_buffer_size=1024;
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB [test]> select * from t1 order  by d;
      +------+------+------+------+
      | a    | b    | c    | d    |
      +------+------+------+------+
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | jkl  | mno  | pqr  |    1 |
      | abc  | def  | ghi  |    2 |
      | abc  | def  | ghi  |    2 |
      | abc  | def  | ghi  |    2 |
      | abc  | def  | ghi  |    2 |
      | abc  | def  | ghi  |    2 |
      | abc  | def  | ghi  |    2 |
      +------+------+------+------+
      14 rows in set (0.00 sec)
      
      

      With smaller sort_buffer_size we get incorrect results, actual expected rows is 16

      Attachments

        Activity

          Transition Time In Source Status Execution Times
          Varun Gupta (Inactive) made transition -
          Open Confirmed
          2m 30s 1
          Varun Gupta (Inactive) made transition -
          Confirmed In Progress
          1d 19h 9m 1
          Varun Gupta (Inactive) made transition -
          In Progress In Review
          11s 1
          Sergei Petrunia made transition -
          In Review Stalled
          2d 4h 41m 1
          Varun Gupta (Inactive) made transition -
          Stalled Closed
          1d 1h 7m 1

          People

            varun Varun Gupta (Inactive)
            varun Varun Gupta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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