Re: Call EndCopyFrom() after initial table sync in logical replication

From: cca5507 <cca5507(at)qq(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Shinya Kato <shinya11(dot)kato(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Call EndCopyFrom() after initial table sync in logical replication
Date: 2026-05-08 04:46:14
Message-ID: tencent_E3DAB4940B9931BCA203743BA350FFC2D807@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > Maybe we want to add "free_parsestate(pstate);" after the "EndCopyFrom()" as well?
>
> What actual issue could occur if free_parsestate() is not called there?
>
> Since pstate->p_target_relation does not seem to be used afterward,
> omitting free_parsestate() appears mostly harmless to me. Bascailly
> calling free_parsestate() after make_parsestate() seems intuitive,
> but from a quick grep I found several places that call make_parsestate()
> without a corresponding free_parsestate().

Yeah, I agree that it's harmless. I just noticed the comment above make_parsestate():

Caller should eventually release the ParseState via free_parsestate().

Not sure whether it's worth to fix all of these places.

--
Regards,
ChangAo Chen

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-05-08 05:09:38 Re: Call EndCopyFrom() after initial table sync in logical replication
Previous Message Etsuro Fujita 2026-05-08 04:40:01 Re: Bug: trailing comma syntax error in postgres_fdw fetch_attstats()