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

Commit5b94e27

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 parent1b5841d commit5b94e27

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
@@ -1130,6 +1130,7 @@ check_and_drop_existing_subscriptions(PGconn *conn,
11301130

11311131
PQclear(res);
11321132
destroyPQExpBuffer(query);
1133+
PQfreemem(dbname);
11331134
}
11341135

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

1332-
pg_free(slot_name_esc);
1333+
PQfreemem(slot_name_esc);
13331334

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

@@ -1375,7 +1376,7 @@ drop_replication_slot(PGconn *conn, struct LogicalRepInfo *dbinfo,
13751376

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

1378-
pg_free(slot_name_esc);
1379+
PQfreemem(slot_name_esc);
13791380

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

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

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

@@ -1638,7 +1639,7 @@ drop_publication(PGconn *conn, struct LogicalRepInfo *dbinfo)
16381639

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

1641-
pg_free(pubname_esc);
1642+
PQfreemem(pubname_esc);
16421643

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

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

1705-
pg_free(pubname_esc);
1706-
pg_free(subname_esc);
1707-
pg_free(pubconninfo_esc);
1708-
pg_free(replslotname_esc);
1706+
PQfreemem(pubname_esc);
1707+
PQfreemem(subname_esc);
1708+
PQfreemem(pubconninfo_esc);
1709+
PQfreemem(replslotname_esc);
17091710

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

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

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

1859-
pg_free(subname);
1860+
PQfreemem(subname);
18601861
destroyPQExpBuffer(str);
18611862
}
18621863

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp