• Mithun C Y's avatar
    Bug #20447262: REPEATED EXECUTION OF PREPARED STATEMENTS FAILS, IF DEFAULT DATABASE IS CHANGED. · dea23408
    Mithun C Y authored
    Issue:
    ======
    While re-preparing the statement in
    Prepared_statement::swap_prepared_statement for swapping
    the database of PS we only swapped the db string but not
    its length. This resulted in mismatch between the actual
    string and its length. In one particular case where db
    of PS was dropped, we have db as null pointer and length
    as non-zero. strdup which used above values resulted in
    invalid memory access.
    
    Solution:
    =========
    In Prepared_statement::swap_prepared_statement also swap
    db_length along with db variable. Also, remove
    DBUG_ASSERT(db_length == copy->db_length) as this have
    no meaning if they are 2 different entities.
    dea23408
sql_prepare.cc 125 KB