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

Wrong result with small join_buffer_space_limit and hash join

    XMLWordPrintable

Details

    • Bug
    • Status: Stalled (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 10.4, 10.5, 10.6, 10.8, 10.9, 10.10, 10.11, 11.0
    • 10.4
    • Optimizer
    • None

    Description

      If join_buffer_space_limit is small enough and join_cache_level is set to 4 then queries with left joins may return wrong results.
      The following test case demonstrates this problem:

      set join_cache_level=4;
      set join_buffer_space_limit=4000;
      create table t1 (pk varchar(512), a varchar(512));
      insert into t1 select seq, seq from seq_1_to_10;
      create table t2 (pk varchar(512), a varchar(512));
      insert into t2 select seq, seq from seq_1_to_10;
      create table t3 (pk varchar(512), a varchar(512));
      insert into t3 select seq, seq from seq_1_to_5;
      create table t4 (pk varchar(512), a varchar(512), key(a));
      insert into t4 select seq, seq from seq_1_to_5;
      select count(*) from t1,t2,t3 left join t4 on t3.pk=t4.a where t1.a=t2.pk and t2.pk=t3.a;
      

      MariaDB [test]> select count(*) from t1,t2,t3 left join t4 on t3.pk=t4.a where t1.a=t2.pk and t2.pk=t3.a;
      +----------+
      | count(*) |
      +----------+
      |       25 |
      +----------+
      

      With bigger enough join_buffer_space_limit the expected result is returned:

      MariaDB [test]> set join_buffer_space_limit=10000;
       
      MariaDB [test]> select count(*) from t1,t2,t3 left join t4 on t3.pk=t4.a where t1.a=t2.pk and t2.pk=t3.a;
      +----------+
      | count(*) |
      +----------+
      |        5 |
      +----------+
      

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              igor Igor Babaev
              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.