topo_node_sqlite: dynamic idx_sql allocation instead of fixed 128-byte buffer

This commit is contained in:
Evgeny committed 2026-07-22 09:18:54 +03:00
1 parent c9ba750486
commit bea3fa021c
1 file changed
+8 -3
+8 -3
View File
@@ -278,10 +278,15 @@ int topo_node_sqlite_channel_put(sqlite3* db, const char* channel_id,
u_free(ddl);
}
char idx_sql[128];
snprintf(idx_sql, sizeof(idx_sql),
int idx_sz = snprintf(NULL, 0,
"CREATE INDEX IF NOT EXISTS \"idx_%s_type_rtt\" ON \"%s\" (node_type, node_RTT)", peers_tbl, peers_tbl);
sqlite3_exec(db, idx_sql, NULL, NULL, NULL);
char* idx_sql = u_malloc(idx_sz + 1);
if (idx_sql) {
snprintf(idx_sql, idx_sz + 1,
"CREATE INDEX IF NOT EXISTS \"idx_%s_type_rtt\" ON \"%s\" (node_type, node_RTT)", peers_tbl, peers_tbl);
sqlite3_exec(db, idx_sql, NULL, NULL, NULL);
u_free(idx_sql);
}
sqlite3_stmt* stmt = NULL;
if (sqlite3_prepare_v2(db,