Don't try to load db rows when chart_id or dim_id is null (#13608)
dont try to load rows with chart_id or dim_id missing
Emmanuel Vasilakis committed
Sep 1, 2022 at 14:02 UTC
dbfc1c27794e1e365d9cb6b7d00f86a0f8867671
2 files changed
+3
-3
database/sqlite/sqlite_context.c
+2
-2
@@ -125,7 +125,7 @@ void sql_close_context_database(void)
125
// Fetching data
126
//
127
#define CTX_GET_CHART_LIST "SELECT c.chart_id, c.type||'.'||c.id, c.name, c.context, c.title, c.unit, c.priority, " \
128
- "c.update_every, c.chart_type, c.family FROM meta.chart c WHERE c.host_id = @host_id; "
128
+ "c.update_every, c.chart_type, c.family FROM meta.chart c WHERE c.host_id = @host_id and c.chart_id is not null; "
129
130
void ctx_get_chart_list(uuid_t *host_uuid, void (*dict_cb)(SQL_CHART_DATA *, void *), void *data)
131
{
@@ -171,7 +171,7 @@ skip_load:
171
}
172
173
// Dimension list
174
-#define CTX_GET_DIMENSION_LIST "SELECT d.dim_id, d.id, d.name FROM meta.dimension d WHERE d.chart_id = @id;"
174
+#define CTX_GET_DIMENSION_LIST "SELECT d.dim_id, d.id, d.name FROM meta.dimension d WHERE d.chart_id = @id and d.dim_id is not null;"
175
void ctx_get_dimension_list(uuid_t *chart_uuid, void (*dict_cb)(SQL_DIMENSION_DATA *, void *), void *data)
176
{
177
int rc;
database/sqlite/sqlite_functions.h
+1
-1
@@ -35,7 +35,7 @@ typedef enum db_check_action_type {
35
"history_entries) values (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15,?16);"
36
37
#define SQL_FIND_CHART_UUID \
38
- "select chart_id from chart where host_id = @host and type=@type and id=@id and (name is null or name=@name);"
38
+ "select chart_id from chart where host_id = @host and type=@type and id=@id and (name is null or name=@name) and chart_id is not null;"
39
40
#define SQL_STORE_ACTIVE_CHART \
41
"insert or replace into chart_active (chart_id, date_created) values (@id, unixepoch());"