• Yuchen Pei's avatar
    MDEV-26247 Re-implement spider gbh query rewrite of tables · 17839657
    Yuchen Pei authored
    Spider GBH's query rewrite of table joins is overly complex and
    error-prone. We replace it with something closer to what
    dbug_print() (more specifically, print_join()) does, but catered to
    spider.
    
    More specifically, we replace the body of
    spider_db_mbase_util::append_from_and_tables() with a call to
    spider_db_mbase_util::append_join(), and remove downstream append_X
    functions.
    
    We make it handle const tables by rewriting them as (select 1). This
    fixes the main issue in MDEV-26247.
    
    We also ban semijoin from spider gbh, which fixes MDEV-31645 and
    MDEV-30392, as semi-join is an "internal" join, and "semi join" does
    not parse, and it is different from "join" in that it deduplicates the
    right hand side
    
    Not all queries passed to a group by handler are valid (MDEV-32273),
    for example, a join on expr may refer outer fields not in the current
    context. We detect this during the handler creation when walking the
    join. See also gbh_outer_fields_in_join.test.
    
    It also skips eliminated tables, which fixes MDEV-26193.
    17839657
spd_db_mysql.cc 519 KB