[MDEV-29630] Remove unneded code in join_read_always_key() Created: 2022-09-25  Updated: 2023-12-22

Status: Stalled
Project: MariaDB Server
Component/s: Optimizer
Fix Version/s: 11.5

Type: Task Priority: Minor
Reporter: Sergei Petrunia Assignee: Oleg Smirnov
Resolution: Unresolved Votes: 0
Labels: None


 Description   

join_read_always_key() has this code:

static int
join_read_always_key(JOIN_TAB *tab)
{
  int error;
  TABLE *table= tab->table;
 
  /* Initialize the index first */
  if (!table->file->inited)
  {
    if (unlikely((error= table->file->ha_index_init(tab->ref.key,
                                                    tab->sorted))))
    {
      (void) report_error(table, error);
      return 1;
    }
  }
 
  if (unlikely(cp_buffer_from_ref(tab->join->thd, table, &tab->ref)))
    return -1;
  if (unlikely((error=
                table->file->prepare_index_key_scan_map(tab->ref.key_buff,
                                                        make_prev_keypart_map(tab->ref.key_parts))))) 

The if (!table->file->inited) {...} part is (or should be) redundant. This task is to remove it. Wait for the testsuite to pass .



 Comments   
Comment by Weijun Huang [ 2023-03-22 ]

Could I pick it ticket up? It seems it still need to work.

Comment by Oleg Smirnov [ 2023-03-22 ]

Sure, Weijun Huang, please do.

Comment by Oleg Smirnov [ 2023-03-27 ]

Turns out the code is actually is use, we cannot remove it. Removing the code breaks almost everything: https://buildbot.mariadb.org/#/grid?branch=refs/pull/2563/merge.
Weijun Huang, thanks for your contribution but we cannot accept it for obvious reasons.

Comment by Oleg Smirnov [ 2023-03-29 ]

We decided to look more thoroughly to the cases when this code is executed. These could be particular types of queries or tables like for example, semi-joins, derived tables and so on.

Generated at Thu Feb 08 10:10:05 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.