X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=src%2Fparser%2Fanalyzer.c;h=dea83d7e0c828d8966fbffe9e91a2895c466fdf7;hp=01539edbe71f870de8486b52320caa6dd9fa4444;hb=1ef0d00327e4b5f56b438f44053f48fd8b198baa;hpb=2a5aff78eb32778a27b707aa99a2494b1371a5dd diff --git a/src/parser/analyzer.c b/src/parser/analyzer.c index 01539ed..dea83d7 100644 --- a/src/parser/analyzer.c +++ b/src/parser/analyzer.c @@ -155,6 +155,8 @@ analyze_logical(int context, sdb_ast_op_t *op, sdb_strbuf_t *errbuf) break; case SDB_AST_ISNULL: + case SDB_AST_ISTRUE: + case SDB_AST_ISFALSE: if (analyze_node(context, op->right, errbuf)) return -1; break; @@ -317,10 +319,20 @@ analyze_value(int context, sdb_ast_value_t *v, sdb_strbuf_t *errbuf) return -1; } - if ((context != SDB_ATTRIBUTE) && (v->type == SDB_FIELD_VALUE)) { - sdb_strbuf_sprintf(errbuf, "Invalid expression %s.value", - SDB_FIELD_TO_NAME(v->type)); - return -1; + if (context != UNSPEC_CONTEXT) { + /* skip these checks if we don't know the context; it's up to the + * caller to check again once the right context information is + * available */ + if ((context != SDB_ATTRIBUTE) && (v->type == SDB_FIELD_VALUE)) { + sdb_strbuf_sprintf(errbuf, "Invalid expression %s.value", + SDB_FIELD_TO_NAME(context)); + return -1; + } + if ((context != SDB_METRIC) && (v->type == SDB_FIELD_TIMESERIES)) { + sdb_strbuf_sprintf(errbuf, "Invalid expression %s.timeseries", + SDB_FIELD_TO_NAME(context)); + return -1; + } } return 0; } /* analyze_value */ @@ -347,7 +359,7 @@ analyze_typed(int context, sdb_ast_typed_t *t, sdb_strbuf_t *errbuf) /* self-references are allowed and services and metrics may reference * their parent host; everything may reference attributes */ - if ((context != t->type) && (context != UNSPEC_CONTEXT) + if ((context != t->type) && (context > 0) && (((context != SDB_SERVICE) && (context != SDB_METRIC)) || (t->type != SDB_HOST)) && (t->type != SDB_ATTRIBUTE)) {