From fcc75b2e7b54733d006bf460a67393842aa71cf0 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 20 May 2015 10:32:37 +0200 Subject: [PATCH] parser: Skip context-specific checks if the context is unspecified. Else, the analyzer may reject valid queries. It's up to the caller to run the analyzer using the right context once it's known. --- src/parser/analyzer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/parser/analyzer.c b/src/parser/analyzer.c index f352a0d..28d3121 100644 --- a/src/parser/analyzer.c +++ b/src/parser/analyzer.c @@ -319,10 +319,15 @@ 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 this check 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; + } } return 0; } /* analyze_value */ -- 2.30.2