Code

analyzer: Check types of comparison operands.
authorSebastian Harl <sh@tokkee.org>
Fri, 27 Feb 2015 18:15:47 +0000 (19:15 +0100)
committerSebastian Harl <sh@tokkee.org>
Fri, 27 Feb 2015 18:15:47 +0000 (19:15 +0100)
src/frontend/analyzer.c
t/integration/query.sh

index 894cc22f706376ac5df8fff483803a612ea07284..607015c233ce15cd4df4129b32024b95e7c735e1 100644 (file)
@@ -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,
index 72a0b88426adae7496deee4c9b4d8f6d7e845c02..5bd09b4507961be4614dd59f7c54334fef3d1bf7 100755 (executable)
@@ -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.