← Back to team overview

maria-developers team mailing list archive

On the DBUG_ASSERT in create_ref_for_key()


Hi Sergei,

Re the 
  DBUG_ASSERT(length > 0 && keyparts != 0);

line in create_ref_for_key() in 5.3: I've looked - the assert can be 
commented out, because it's valid to have length=0 && !keyparts for a variant
of LooseScan algorithm.

Some more details:

I've tried to come up another assert statement, that would allow length==0 only
when LooseScan is used. Unfortunately, it is not easy - the query plan is
encoded in join->best_positions, while create_ref_for_key() has access only to
the JOIN_TAB. Since SJ-Materialization, the query plan is represented with 
multiple JOIN_TAB arrays, while there is only one POSITION array, which means
that one needs to loop to find the POSITION which corresponds to the JOIN_TAB.

EXPLAIN and execution use JOIN_TAB::loosescan_match_tab, but it is set by
setup_semijoin_dups_elimination() which is invoked after create_ref_for_key()

Sergei Petrunia, Software Developer
Monty Program AB, http://askmonty.org
Blog: http://s.petrunia.net/blog