修复libpqwalreceiver若干内存泄漏问题

(cherry picked commit from <gitee.com//opengauss/openGauss-server/commit/82d8bd50b0d477204cabeb2a47e8b4e9f3bbbefe>
This commit is contained in:
chenxiaobin19
2024-09-21 11:40:34 +08:00
committed by chenxiaobin
parent 9c06a4e035
commit 85275e7afe
5 changed files with 22 additions and 8 deletions

View File

@ -5694,6 +5694,8 @@ static AlterFunctionStmt* _copyAlterFunctionStmt(const AlterFunctionStmt* from)
COPY_SCALAR_FIELD(isProcedure);
}
COPY_SCALAR_FIELD(noargs);
return newnode;
}

View File

@ -1624,6 +1624,8 @@ static bool _equalAlterFunctionStmt(const AlterFunctionStmt* a, const AlterFunct
COMPARE_SCALAR_FIELD(isProcedure);
}
COMPARE_SCALAR_FIELD(noargs);
return true;
}

View File

@ -269,12 +269,14 @@ void StartRemoteStreaming(const LibpqrcvConnectParam *options)
appendStringInfo(&cmd, " %X/%X", (uint32)(options->startpoint >> 32), (uint32)(options->startpoint));
if (options->logical) {
char *pubnames_literal = NULL;
appendStringInfoString(&cmd, " (");
appendStringInfo(&cmd, "proto_version '%u'", options->protoVersion);
char *pubnames_str =
stringlist_to_identifierstr(t_thrd.libwalreceiver_cxt.streamConn, options->publicationNames);
appendStringInfo(&cmd, ", publication_names %s",
PQescapeLiteral(t_thrd.libwalreceiver_cxt.streamConn, pubnames_str, strlen(pubnames_str)));
pubnames_literal = PQescapeLiteral(t_thrd.libwalreceiver_cxt.streamConn, pubnames_str, strlen(pubnames_str));
appendStringInfo(&cmd, ", publication_names %s", pubnames_literal);
PQfreemem(pubnames_literal);
pfree(pubnames_str);
if (options->binary && PQserverVersion(t_thrd.libwalreceiver_cxt.streamConn) >= 90204) {
@ -1311,6 +1313,11 @@ void libpqrcv_disconnect(void)
{
PQfinish(t_thrd.libwalreceiver_cxt.streamConn);
t_thrd.libwalreceiver_cxt.streamConn = NULL;
if (t_thrd.libwalreceiver_cxt.recvBuf != NULL) {
PQfreemem(t_thrd.libwalreceiver_cxt.recvBuf);
t_thrd.libwalreceiver_cxt.recvBuf = NULL;
}
}
/*
@ -1709,13 +1716,20 @@ static char *stringlist_to_identifierstr(PGconn *conn, List *strings)
foreach (lc, strings) {
char *val = strVal(lfirst(lc));
char *val_escaped = NULL;
if (first) {
first = false;
} else {
appendStringInfoChar(&res, ',');
}
appendStringInfoString(&res, PQescapeIdentifier(conn, val, strlen(val)));
val_escaped = PQescapeIdentifier(conn, val, strlen(val));
if (!val_escaped) {
free(res.data);
return NULL;
}
appendStringInfoString(&res, val_escaped);
PQfreemem(val_escaped);
}
return res.data;

View File

@ -1096,11 +1096,6 @@ static void WalRcvDie(int code, Datum arg)
/* Wake up the startup process to notice promptly that we're gone */
WakeupRecovery();
if (t_thrd.libwalreceiver_cxt.recvBuf != NULL) {
PQfreemem(t_thrd.libwalreceiver_cxt.recvBuf);
t_thrd.libwalreceiver_cxt.recvBuf = NULL;
}
if (t_thrd.libwalreceiver_cxt.decompressBuf != NULL) {
pfree(t_thrd.libwalreceiver_cxt.decompressBuf);
t_thrd.libwalreceiver_cxt.decompressBuf = NULL;

View File

@ -1410,6 +1410,7 @@ typedef struct AlterFunctionStmt {
FuncWithArgs* func; /* name and args of function */
List* actions; /* list of DefElem */
bool isProcedure = false;
bool noargs; /* support alter function without args in dolphin */
} AlterFunctionStmt;
enum CompileEntry {