Re: bug in update tuple routing with foreign partitions

Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>

From: Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2019-04-19T03:15:11Z
Lists: pgsql-hackers
(2019/04/18 22:10), Etsuro Fujita wrote:
> Notes:
>
> * I kept all the changes in the previous patch, because otherwise
> postgres_fdw would fail to release resources for a foreign-insert
> operation created by postgresBeginForeignInsert() for a tuple-routable
> foreign table (ie, a foreign-table subplan resultrel that has been
> updated already) during postgresEndForeignInsert().

I noticed that this explanation was not right.  Let me correct myself. 
The reason why I kept those changes is: without those changes, we would 
fail to release the resources for a foreign-update operation (ie, 
fmstate) created by postgresBeginForeignModify(), replaced by the 
fmstate for the foreign-insert operation, because when doing 
ExecEndPlan(), we first call postgresEndForeignModify() and then call 
postgresEndForeignInsert(); so, if we didn't keep those changes, we 
would *mistakenly* release the fmstate for the foreign-insert operation 
in postgresEndForeignModify(), and we wouldn't do anything about the 
fmstate for the foreign-update operation in that function and in the 
subsequent postgresEndForeignInsert().

Best regards,
Etsuro Fujita




Commits

  1. postgres_fdw: Fix incorrect handling of row movement for remote partitions.