Re: BeginCopyTo - remove switching to old memory context in between COPY TO command processing

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-01-28T11:23:57Z
Lists: pgsql-hackers
On Fri, Jan 28, 2022 at 03:41:11PM +0530, Bharath Rupireddy wrote:
> While reviewing patch at [1], it has been found that the memory
> context switch to oldcontext from cstate->copycontext in between
> BeginCopyTo is not correct because the intention of the copycontext is
> to use it through the copy command processing. It looks like a thinko
> from the commit c532d1 [2]. Attaching a small patch to remove this.
> 
> Thoughts?

I think that you are right.  Before c532d15d, BeginCopy() was
internally doing one switch with copycontext and the current memory
context.  This commit has just moved the internals of BeginCopy()
into BeginCopyTo(), so this looks like a copy-paste error to me.  I'll
go fix it, thanks for the report!
-
Michael

Commits

  1. Fix incorrect memory context switch in COPY TO execution

  2. Split copy.c into four files.