Re: Re: Add support for specifying tables in pg_createsubscriber.
Peter Smith <smithpb2250@gmail.com>
From: Peter Smith <smithpb2250@gmail.com>
To: tianbing <tian_bing_0531@163.com>
Cc: Shubham Khanna <khannashubham1197@gmail.com>,
vignesh C <vignesh21@gmail.com>, Chao Li <li.evan.chao@gmail.com>,
"Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-04T02:16:35Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Support existing publications in pg_createsubscriber.
- 85ddcc2f4cde 19 (unreleased) landed
Attachments
- v22-0001-Support-existing-publications-in-pg_createsubscr.patch (application/octet-stream) patch v22-0001
On Wed, Dec 3, 2025 at 4:47 PM tianbing <tian_bing_0531@163.com> wrote:
>
> Hi, Peter,
> I have reviewed the v21 patch and noticed that there seems to be a memory leak.
>
> +static bool
> +check_publication_exists(PGconn *conn, const char *pubname, const char *dbname)
> +{
> + PGresult *res;
> + bool exists;
> + char *query;
> +
> + query = psprintf("SELECT 1 FROM pg_publication WHERE pubname = %s",
> + PQescapeLiteral(conn, pubname, strlen(pubname)));
> + res = PQexec(conn, query);
> +
> + if (PQresultStatus(res) != PGRES_TUPLES_OK)
> + pg_fatal("could not check for publication \"%s\" in database \"%s\": %s",
> + pubname, dbname, PQerrorMessage(conn));
> +
> + exists = (PQntuples(res) == 1);
> +
> + PQclear(res);
> + pg_free(query);
> + return exists;
> +}
>
> The PQescapeLiteral() function through malloc to allocate memmory,and should be free by PQfreemem。
>
> I suggest making the following modifications:
>
> + char *pub = PQescapeLiteral(conn, pubname, strlen(pubname);
> + query = psprintf("SELECT 1 FROM pg_publication WHERE pubname = %s", pub);
> ......
> + PQfreemem(pub);
>
Fixed in v22.
======
Kind Regards,
Peter Smith.
Fujitsu Australia