Copy the INSERT query in postgres_fdw
authorTomas Vondra <tomas.vondra@postgresql.org>
Fri, 7 May 2021 20:29:43 +0000 (22:29 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Fri, 7 May 2021 20:29:43 +0000 (22:29 +0200)
commitc6a01d924939306e95c8deafd09352be6a955648
tree055432d1e88735defdb32b2898963a954732a120
parent8292c0675a793a5afd0a8eedbeb0db7abfb844f3
Copy the INSERT query in postgres_fdw

When executing the INSERT with batching, we may need to rebuild the
query when the batch size changes, in which case we pfree the current
string. We must not release the original string, stored in fdw_private,
because that may be needed in EXPLAIN ANALYZE. So make copy of the SQL,
but only for INSERT queries.

Reported-by: Pavel Stehule
Discussion: http://postgr.es/m/CAFj8pRCL_Rjw-MCR6J7VX9OF7MR6PA5K8qUbrMvprW_e-aHkfQ%40mail.gmail.com
contrib/postgres_fdw/postgres_fdw.c