• Dmitry Shulga's avatar
    MDEV-24411: Trigger doesn't work correctly with bulk insert · 8b169949
    Dmitry Shulga authored
    Executing an INSERT statement in PS mode having positional parameter
    bound with an array could result in incorrect number of inserted rows
    in case there is a BEFORE INSERT trigger that executes yet another
    INSERT statement to put a copy of row being inserted into some table.
    
    The reason for incorrect number of inserted rows is that a data structure
    used for binding positional argument with its actual values is stored
    in THD (this is thd->bulk_param) and reused on processing every INSERT
    statement. It leads to consuming actual values bound with top-level
    INSERT statement by other INSERT statements used by triggers' body.
    
    To fix the issue, reset the thd->bulk_param temporary to the value nullptr
    before invoking triggers and restore its value on finishing its execution.
    8b169949
sql_insert.cc 173 KB