Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c6a01d9

Browse files
committed
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: https://postgr.es/m/CAFj8pRCL_Rjw-MCR6J7VX9OF7MR6PA5K8qUbrMvprW_e-aHkfQ%40mail.gmail.com
1 parent 8292c06 commit c6a01d9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

contrib/postgres_fdw/postgres_fdw.c

+3
Original file line numberDiff line numberDiff line change
@@ -3903,7 +3903,10 @@ create_foreign_modify(EState *estate,
39033903
/* Set up remote query information. */
39043904
fmstate->query = query;
39053905
if (operation == CMD_INSERT)
3906+
{
3907+
fmstate->query = pstrdup(fmstate->query);
39063908
fmstate->orig_query = pstrdup(fmstate->query);
3909+
}
39073910
fmstate->target_attrs = target_attrs;
39083911
fmstate->values_end = values_end;
39093912
fmstate->has_returning = has_returning;

0 commit comments

Comments
 (0)