• Sergei Petrunia's avatar
    MDEV-22779: Crash: Prepared Statement with a '?' parameter inside a re-used CTE · 21e79331
    Sergei Petrunia authored
    When a prepared statement parameter '?' is used in a CTE that is used
    multiple times, the following happens:
    - The CTE definition is re-parsed multiple times.
    - There are multiple Item_param objects referring to the same "?" in
    the original query.
    - Prepared_statement::param has a pointer to the first of them, the
      others are "clones".
    - When prepared statement parameter gets the value, it should be passed
      over to clones with param->sync_clones() call.
    
    This call is made in insert_params(), etc. It was not made in
    insert_params_with_log().
    
    This would cause Item_param to not have any value which would confuse
    the query optimizer.
    
    Added the missing call.
    21e79331
sql_select.cc 874 KB