From 172fd0ec3f2245274d984be51b353f02af10d48a Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 17 Jan 2022 16:18:04 +0800 Subject: [PATCH] [TS-1114](other): monitor log database sql error when inserting data into vgroups_info table --- src/plugins/monitor/src/monMain.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/monitor/src/monMain.c b/src/plugins/monitor/src/monMain.c index 68bd98dd5e..33b95642b9 100644 --- a/src/plugins/monitor/src/monMain.c +++ b/src/plugins/monitor/src/monMain.c @@ -1157,7 +1157,9 @@ static uint32_t monBuildVgroupsInfoSql(char *sql, char *dbName) { monError("failed to save vgroup_%d info, reason: invalid row %s len, sql:%s", vgId, (char *)row[i], tsMonitor.sql); goto DONE; } - pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 1, ", "SQL_STR_FMT, (char *)row[i]); + char tmpBuf[10] = {0}; + memcpy(tmpBuf, row[i], charLen); + pos += snprintf(sql + pos, strlen(SQL_STR_FMT) + charLen + 1, ", "SQL_STR_FMT, tmpBuf); } else if (strcmp(fields[i].name, "onlines") == 0) { pos += snprintf(sql + pos, SQL_LENGTH, ", %d", *(int32_t *)row[i]); } else if (v_dnode_str && strcmp(v_dnode_str, "_dnode") == 0) { -- GitLab