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

GROUP BY temp table fields should provide ColumnStore with info about their origin.

    XMLWordPrintable

Details

    Description

      Consider an example:

      select sum(i)+1 from cs1 group by i;
      

      Initially in JOIN::make_aggr_tables_info() the all_fields list has these elements

      (gdb) p dbug_print_item(all_fields.elem(0))
      $5 = 0x5592c6ec3b20 <dbug_item_print_buf> "cs1.i"
      (gdb) p dbug_print_item(all_fields.elem(1))
      $6 = 0x5592c6ec3b20 <dbug_item_print_buf> "sum(cs1.i)"
      (gdb) p dbug_print_item(all_fields.elem(2))
      $7 = 0x5592c6ec3b20 <dbug_item_print_buf> "sum(cs1.i) + 1"
      

      By the time we reach this point:

      #0  cal_impl_if::getGroupPlan (gwi=..., select_lex=..., csep=..., gi=..., isUnion=false)
          at /git/mariadb-columnstore-server/d2-mariadb-columnstore-engine/dbcon/mysql/ha_calpont_execplan.cpp:8167
      #1  0x00007fd1981c3a3c in cal_impl_if::cp_get_group_plan (thd=0x7fd0e4000b00, csep=..., gi=...)
          at /git/mariadb-columnstore-server/d2-mariadb-columnstore-engine/dbcon/mysql/ha_calpont_execplan.cpp:8090
      #2  0x00007fd198144577 in ha_calpont_impl_group_by_init (group_hand=0x7fd0e4010e50, table=0x7fd0e401d2b8)
          at /git/mariadb-columnstore-server/d2-mariadb-columnstore-engine/dbcon/mysql/ha_calpont_impl.cpp:5298
      #3  0x00007fd19812bc52 in ha_calpont_group_by_handler::init_scan (this=0x7fd0e4010e50)
          at /git/mariadb-columnstore-server/d2-mariadb-columnstore-engine/dbcon/mysql/ha_calpont.cpp:1187
      #4  0x00005592c59b825b in Pushdown_query::execute (this=0x7fd0e4015ed8, join=0x7fd0e4014190) at /git/mariadb-columnstore-server/sql/group_by_handler.cc:48
      #5  0x00005592c5978138 in do_select (join=0x7fd0e4014190, procedure=0x0) at /git/mariadb-columnstore-server/sql/sql_select.cc:18321
      #6  0x00005592c5953153 in JOIN::exec_inner (this=0x7fd0e4014190) at /git/mariadb-columnstore-server/sql/sql_select.cc:3729
      #7  0x00005592c5951e7a in JOIN::exec (this=0x7fd0e4014190) at /git/mariadb-columnstore-server/sql/sql_select.cc:3316
      #8  0x00005592c5953922 in mysql_select (thd=0x7fd0e4000b00, tables=0x7fd0e4013918, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7fd0e4014048, 
          having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fd0e4014170, unit=0x7fd0e40047f8, select_lex=0x7fd0e4004f30)
          at /git/mariadb-columnstore-server/sql/sql_select.cc:3964
      

      The expression in the list points to a field in the temporary table:

      (gdb) p dbug_print_item(gi.groupByFields->elem(0))
      $18 = 0x5592c6ec3b20 <dbug_item_print_buf> "cs1.i"
      (gdb) p dbug_print_item(gi.groupByFields->elem(1))
      $19 = 0x5592c6ec3b20 <dbug_item_print_buf> "sum(cs1.i)"
      (gdb) p dbug_print_item(gi.groupByFields->elem(2))
      $20 = 0x5592c6ec3b20 <dbug_item_print_buf> "tmp_field + 1"
      

      (Here gi.groupByFields points to JOIN::all_fields)

      more details about the "tmp_field" :

      (gdb) p gi.groupByFields
      $23 = (List<Item> *) 0x7fd0e40144b0
      (gdb) p dbug_print_item(gi.groupByFields->elem(2))
      $24 = 0x5592c6ec3b20 <dbug_item_print_buf> "tmp_field + 1"
       
      (gdb) p  gi.groupByFields->elem(2)
      $25 = (Item_func_plus *) 0x7fd0e40137e8
      (gdb) p  gi.groupByFields->elem(2)->args[0]
      $26 = (Item_aggregate_ref *) 0x7fd0e4014888
      (gdb) p  gi.groupByFields->elem(2)->args[0]->ref[0]
      $27 = (Item_temptable_field *) 0x7fd0e4016310
      (gdb) p  gi.groupByFields->elem(2)->args[0]->ref[0]->field_name
      $28 = 0x0
      (gdb) p  gi.groupByFields->elem(2)->args[0]->ref[0]->table_name
      $29 = 0x5592c63c4f56 ""
      (gdb) p  gi.groupByFields->elem(2)->args[0]->ref[0]->field
      $30 = (Field_new_decimal *) 0x7fd0e401e968
      (gdb) p  gi.groupByFields->elem(2)->args[0]->ref[0]->field_name
      $31 = 0x0
      

      So, one can see this is a field in the group-by temp.table, but there is no way to figure out what expression it refers to.

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            drrtuy Roman
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.