• Tomas Vondra's avatar
    Fix copying data into slots with FDW batching · 99cea49d
    Tomas Vondra authored
    Commit b676ac44 optimized handling of tuple slots with bulk inserts
    into foreign tables, so that the slots are initialized only once and
    reused for all batches. The data was however copied into the slots only
    after the initialization, inserting duplicate values when the slot gets
    reused. Fixed by moving the ExecCopySlot outside the init branch.
    
    The existing postgres_fdw tests failed to catch this due to inserting
    data into foreign tables without unique indexes, and then checking only
    the number of inserted rows. This adds a new test with both a unique
    index and a check of inserted values.
    
    Reported-by: Alexander Pyhalov
    Discussion: https://postgr.es/m/7a8cf8d56b3d18e5c0bccd6cd42d04ac%40postgrespro.ru
    99cea49d
postgres_fdw.out 501 KB