Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitff6d9cf

Browse files
committed
Fix some inconsistencies with memory freeing in pg_createsubscriber
The correct function documented to free the memory allocated for theresult returned by PQescapeIdentifier() and PQescapeLiteral() isPQfreemem(). pg_createsubscriber.c relied on pg_free() instead, whichis not incorrect as both do a free() internally, but inconsistent withthe documentation.While on it, this commit fixes a small memory leak introduced by4867f8a, as the code of pg_createsubscriber makes this effort.Author: Ranier VilelaReviewed-by: Euler TaveiraDiscussion:https://postgr.es/m/CAEudQAp=AW5dJXrGLbC_aZg_9nOo=42W7uLDRONFQE-gcgnkgQ@mail.gmail.comBackpatch-through: 17
1 parentfa761d9 commitff6d9cf

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

‎src/bin/pg_basebackup/pg_createsubscriber.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@ check_and_drop_existing_subscriptions(PGconn *conn,
11311131

11321132
PQclear(res);
11331133
destroyPQExpBuffer(query);
1134+
PQfreemem(dbname);
11341135
}
11351136

11361137
/*
@@ -1330,7 +1331,7 @@ create_logical_replication_slot(PGconn *conn, struct LogicalRepInfo *dbinfo)
13301331
"SELECT lsn FROM pg_catalog.pg_create_logical_replication_slot(%s, 'pgoutput', false, false, false)",
13311332
slot_name_esc);
13321333

1333-
pg_free(slot_name_esc);
1334+
PQfreemem(slot_name_esc);
13341335

13351336
pg_log_debug("command is: %s",str->data);
13361337

@@ -1376,7 +1377,7 @@ drop_replication_slot(PGconn *conn, struct LogicalRepInfo *dbinfo,
13761377

13771378
appendPQExpBuffer(str,"SELECT pg_catalog.pg_drop_replication_slot(%s)",slot_name_esc);
13781379

1379-
pg_free(slot_name_esc);
1380+
PQfreemem(slot_name_esc);
13801381

13811382
pg_log_debug("command is: %s",str->data);
13821383

@@ -1615,8 +1616,8 @@ create_publication(PGconn *conn, struct LogicalRepInfo *dbinfo)
16151616
/* For cleanup purposes */
16161617
dbinfo->made_publication= true;
16171618

1618-
pg_free(ipubname_esc);
1619-
pg_free(spubname_esc);
1619+
PQfreemem(ipubname_esc);
1620+
PQfreemem(spubname_esc);
16201621
destroyPQExpBuffer(str);
16211622
}
16221623

@@ -1639,7 +1640,7 @@ drop_publication(PGconn *conn, struct LogicalRepInfo *dbinfo)
16391640

16401641
appendPQExpBuffer(str,"DROP PUBLICATION %s",pubname_esc);
16411642

1642-
pg_free(pubname_esc);
1643+
PQfreemem(pubname_esc);
16431644

16441645
pg_log_debug("command is: %s",str->data);
16451646

@@ -1703,10 +1704,10 @@ create_subscription(PGconn *conn, const struct LogicalRepInfo *dbinfo)
17031704
"slot_name = %s, copy_data = false)",
17041705
subname_esc,pubconninfo_esc,pubname_esc,replslotname_esc);
17051706

1706-
pg_free(pubname_esc);
1707-
pg_free(subname_esc);
1708-
pg_free(pubconninfo_esc);
1709-
pg_free(replslotname_esc);
1707+
PQfreemem(pubname_esc);
1708+
PQfreemem(subname_esc);
1709+
PQfreemem(pubconninfo_esc);
1710+
PQfreemem(replslotname_esc);
17101711

17111712
pg_log_debug("command is: %s",str->data);
17121713

@@ -1813,8 +1814,8 @@ set_replication_progress(PGconn *conn, const struct LogicalRepInfo *dbinfo, cons
18131814
PQclear(res);
18141815
}
18151816

1816-
pg_free(subname);
1817-
pg_free(dbname);
1817+
PQfreemem(subname);
1818+
PQfreemem(dbname);
18181819
pg_free(originname);
18191820
pg_free(lsnstr);
18201821
destroyPQExpBuffer(str);
@@ -1857,7 +1858,7 @@ enable_subscription(PGconn *conn, const struct LogicalRepInfo *dbinfo)
18571858
PQclear(res);
18581859
}
18591860

1860-
pg_free(subname);
1861+
PQfreemem(subname);
18611862
destroyPQExpBuffer(str);
18621863
}
18631864

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp