From 7d146c24e78c57af633c57fc75883602083fb83b Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Fri, 27 Feb 2015 19:15:47 +0100 Subject: [PATCH] analyzer: Check types of comparison operands. --- src/frontend/analyzer.c | 10 +++++++--- t/integration/query.sh | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/frontend/analyzer.c b/src/frontend/analyzer.c index 894cc22..607015c 100644 --- a/src/frontend/analyzer.c +++ b/src/frontend/analyzer.c @@ -212,9 +212,13 @@ analyze_matcher(int context, sdb_store_matcher_t *m, sdb_strbuf_t *errbuf) return -1; if ((CMP_M(m)->left->data_type > 0) - && (CMP_M(m)->right->data_type > 0) - && (CMP_M(m)->left->data_type == CMP_M(m)->right->data_type)) - return 0; + && (CMP_M(m)->right->data_type > 0)) { + if (CMP_M(m)->left->data_type == CMP_M(m)->right->data_type) + return 0; + cmp_error(errbuf, m->type, CMP_M(m)->left->data_type, + CMP_M(m)->right->data_type); + return -1; + } if ((CMP_M(m)->left->data_type > 0) && (CMP_M(m)->left->data_type & SDB_TYPE_ARRAY)) { cmp_error(errbuf, m->type, CMP_M(m)->left->data_type, diff --git a/t/integration/query.sh b/t/integration/query.sh index 72a0b88..5bd09b4 100755 --- a/t/integration/query.sh +++ b/t/integration/query.sh @@ -118,7 +118,7 @@ echo "$output" | grep -F 'other.host.name' && exit 1 echo "$output" | grep -F 'some.host.name' && exit 1 output="$( run_sysdb -H "$SOCKET_FILE" \ - -c "FETCH host 'host1.example.com' FILTER last_update < 0" 2>&1 )" \ + -c "FETCH host 'host1.example.com' FILTER last_update < 0s" 2>&1 )" \ && exit 1 echo "$output" | grep -F 'not found' @@ -126,7 +126,7 @@ echo "$output" | grep -F 'not found' | run_sysdb -H "$SOCKET_FILE" output="$( run_sysdb -H "$SOCKET_FILE" \ - -c "FETCH host 'host1.example.com' FILTER age < 0" 2>&1 )" && exit 1 + -c "FETCH host 'host1.example.com' FILTER age < 0s" 2>&1 )" && exit 1 echo "$output" | grep -F 'not found' # When requesting information for unknown hosts, expect a non-zero exit code. -- 2.30.2