From 82605756814adadc0fcad9ee55e472c1730bf9ba Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sat, 25 Oct 2014 21:41:16 +0200 Subject: [PATCH] store: Don't special case negated matchers in the ANY matcher. The old behavior no longer makes sense when thinking about matching *any* object. --- src/core/store_lookup.c | 6 ------ t/integration/filter.sh | 8 ++++---- t/integration/matching.sh | 8 ++++---- t/unit/core/store_lookup_test.c | 6 +++--- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/core/store_lookup.c b/src/core/store_lookup.c index f95f8ca..11d85fe 100644 --- a/src/core/store_lookup.c +++ b/src/core/store_lookup.c @@ -122,12 +122,6 @@ match_iter(sdb_store_matcher_t *m, sdb_store_obj_t *obj, if (obj->type != SDB_HOST) return 0; - /* negated matchers should only match if the respective positive matchers - * do not match; that is if the negated matcher matchers *all* children */ - if ((ITER_M(m)->m->type == MATCHER_NE) - || (ITER_M(m)->m->type == MATCHER_NREGEX)) - all = 1; - if (ITER_M(m)->type == SDB_SERVICE) iter = sdb_avltree_get_iter(HOST(obj)->services); else if (ITER_M(m)->type == SDB_METRIC) diff --git a/t/integration/filter.sh b/t/integration/filter.sh index 9c9fb0c..b4930b4 100755 --- a/t/integration/filter.sh +++ b/t/integration/filter.sh @@ -52,11 +52,11 @@ output="$( run_sysdb -H "$SOCKET_FILE" \ -c "LOOKUP hosts MATCHING ANY attribute != 'architecture' FILTER .age >= 0s" )" echo "$output" \ - | grep -F '"some.host.name"' \ | grep -F '"localhost"' -echo "$output" | grep -F 'other.host.name' && exit 1 -echo "$output" | grep -F 'host1.example.com' && exit 1 -echo "$output" | grep -F 'host2.example.com' && exit 1 +echo "$output" | grep -F 'some.host.name' && exit 1 +#echo "$output" | grep -F 'other.host.name' && exit 1 +#echo "$output" | grep -F 'host1.example.com' && exit 1 +#echo "$output" | grep -F 'host2.example.com' && exit 1 output="$( run_sysdb -H "$SOCKET_FILE" \ -c "LOOKUP hosts MATCHING ANY attribute != 'architecture' diff --git a/t/integration/matching.sh b/t/integration/matching.sh index 751b22b..21a730f 100755 --- a/t/integration/matching.sh +++ b/t/integration/matching.sh @@ -78,11 +78,11 @@ echo "$output" | grep -F 'some.host.name' && exit 1 output="$( run_sysdb -H "$SOCKET_FILE" \ -c "LOOKUP hosts MATCHING ANY attribute != 'architecture'" )" echo "$output" \ - | grep -F '"some.host.name"' \ | grep -F '"localhost"' -echo "$output" | grep -F 'other.host.name' && exit 1 -echo "$output" | grep -F 'host1.example.com' && exit 1 -echo "$output" | grep -F 'host2.example.com' && exit 1 +echo "$output" | grep -F 'some.host.name' && exit 1 +#echo "$output" | grep -F 'other.host.name' && exit 1 +#echo "$output" | grep -F 'host1.example.com' && exit 1 +#echo "$output" | grep -F 'host2.example.com' && exit 1 output="$( run_sysdb -H "$SOCKET_FILE" \ -c "LOOKUP hosts MATCHING ANY service = 'sysdbd'" )" diff --git a/t/unit/core/store_lookup_test.c b/t/unit/core/store_lookup_test.c index 3c99bb1..d532757 100644 --- a/t/unit/core/store_lookup_test.c +++ b/t/unit/core/store_lookup_test.c @@ -534,14 +534,14 @@ START_TEST(test_scan) { "ANY metric = 'm1'", "NOT attribute['x'] = ''", 2 }, /* filter always matches */ { "ANY metric =~ 'm'", NULL, 2 }, - { "ANY metric !~ 'm'", NULL, 1 }, + { "ANY metric !~ 'm'", NULL, 0 }, { "ANY metric =~ 'x'", NULL, 0 }, { "ANY service = 's1'", NULL, 2 }, { "ANY service = 's1'", "host = 'x'", 0 }, /* filter never matches */ { "ANY service = 's1'", "NOT attribute['x'] = ''", 2 }, /* filter always matches */ { "ANY service =~ 's'", NULL, 2 }, - { "ANY service !~ 's'", NULL, 1 }, + { "ANY service !~ 's'", NULL, 0 }, { "ANY attribute = 'k1'", NULL, 2 }, { "ANY attribute = 'k1'", "host = 'x'",0 }, /* filter never matches */ { "ANY attribute = 'k1'", @@ -575,7 +575,7 @@ START_TEST(test_scan) { "attribute['k1'] != 'v1'", NULL, 1 }, { "attribute['k1'] != 'v2'", NULL, 1 }, { "ANY attribute != 'x' " - "AND attribute['y'] !~ 'x'", NULL, 3 }, + "AND attribute['y'] !~ 'x'", NULL, 2 }, }; int check, n; -- 2.30.2