index cf077de41174df7e913ae46b835fd429218b535c..01e1ad357adec6502fc7efc74768bee7cdf03969 100644 (file)
--- a/src/frontend/analyzer.c
+++ b/src/frontend/analyzer.c
if (context == (int)e->data.data.integer)
return 0;
if ((e->data.data.integer == SDB_HOST) &&
- ((context == SDB_SERVICE) || (context == SDB_METRIC)))
+ ((context == SDB_SERVICE) || (context == SDB_METRIC)
+ || (context < 0)))
return 0;
sdb_strbuf_sprintf(errbuf, "Invalid expression %s.%s "
"in %s context",
SDB_STORE_TYPE_TO_NAME(e->data.data.integer),
- EXPR_TO_STRING(e->left), SDB_STORE_TYPE_TO_NAME(context));
+ EXPR_TO_STRING(e->left),
+ context == -1 ? "generic" : SDB_STORE_TYPE_TO_NAME(context));
return -1;
case ATTR_VALUE:
- case FIELD_VALUE:
case 0:
break;
+ case FIELD_VALUE:
+ if ((e->data.data.integer == SDB_FIELD_VALUE)
+ && (context != SDB_ATTRIBUTE)) {
+ sdb_strbuf_sprintf(errbuf, "Invalid expression %s.value "
+ "(only attributes have a value)",
+ SDB_STORE_TYPE_TO_NAME(context));
+ return -1;
+ }
+ break;
+
default:
if (analyze_expr(context, e->left, errbuf))
return -1;
if ((ITER_M(m)->iter->type == TYPED_EXPR)
|| (ITER_M(m)->iter->type == FIELD_VALUE))
- type = ITER_M(m)->iter->data.data.integer;
+ type = (int)ITER_M(m)->iter->data.data.integer;
if (context == -1) { /* inside a filter */
/* attributes are always iterable */