From: Sebastian Harl Date: Thu, 6 Nov 2014 09:10:06 +0000 (+0100) Subject: frontend/grammar: Drop support for the special 'host' field. X-Git-Tag: sysdb-0.6.0~21 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=499930e768ea550803018bc938783056e5921aa5;p=sysdb.git frontend/grammar: Drop support for the special 'host' field. The old implementation didn't work when querying services or metrics and for hosts it's the same as querying the 'name' field. --- diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index 2e52744..6791806 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -515,14 +515,6 @@ expression: sdb_object_deref(SDB_OBJ($3)); $3 = NULL; } | - HOST_T - { - /* XXX: this doesn't work correctly when not - * querying hosts => use . instead - * and let the analyzer verify */ - $$ = sdb_store_expr_fieldvalue(SDB_FIELD_NAME); - } - | field { $$ = sdb_store_expr_fieldvalue($1); diff --git a/t/integration/matching.sh b/t/integration/matching.sh index c96f7ab..8b25ed3 100755 --- a/t/integration/matching.sh +++ b/t/integration/matching.sh @@ -102,7 +102,7 @@ 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 host =~ 'example.com'" )" + -c "LOOKUP hosts MATCHING name =~ 'example.com'" )" echo "$output" \ | grep -F '"host1.example.com"' \ | grep -F '"host2.example.com"' diff --git a/t/unit/core/store_lookup_test.c b/t/unit/core/store_lookup_test.c index c256b23..dcf72fa 100644 --- a/t/unit/core/store_lookup_test.c +++ b/t/unit/core/store_lookup_test.c @@ -525,15 +525,15 @@ START_TEST(test_scan) int expected; } golden_data[] = { /* TODO: check the name of the expected hosts */ - { "host = 'a'", NULL, 1 }, - { "host = 'a'", "host = 'x'", 0 }, /* filter never matches */ - { "host = 'a'", + { "name = 'a'", NULL, 1 }, + { "name = 'a'", "name = 'x'", 0 }, /* filter never matches */ + { "name = 'a'", "NOT attribute['x'] = ''", 1 }, /* filter always matches */ - { "host =~ 'a|b'", NULL, 2 }, - { "host =~ 'host'", NULL, 0 }, - { "host =~ '.'", NULL, 3 }, + { "name =~ 'a|b'", NULL, 2 }, + { "name =~ 'host'", NULL, 0 }, + { "name =~ '.'", NULL, 3 }, { "ANY metric = 'm1'", NULL, 2 }, - { "ANY metric= 'm1'", "host = 'x'", 0 }, /* filter never matches */ + { "ANY metric= 'm1'", "name = 'x'", 0 }, /* filter never matches */ { "ANY metric = 'm1'", "NOT attribute['x'] = ''", 2 }, /* filter always matches */ { "ANY metric =~ 'm'", NULL, 2 }, @@ -546,7 +546,7 @@ START_TEST(test_scan) { "ALL metric !~ 'm'", NULL, 1 }, { "ANY metric =~ 'x'", NULL, 0 }, { "ANY service = 's1'", NULL, 2 }, - { "ANY service = 's1'", "host = 'x'", 0 }, /* filter never matches */ + { "ANY service = 's1'", "name = 'x'", 0 }, /* filter never matches */ { "ANY service = 's1'", "NOT attribute['x'] = ''", 2 }, /* filter always matches */ { "ANY service =~ 's'", NULL, 2 }, @@ -554,7 +554,7 @@ START_TEST(test_scan) { "ANY service =~ 's'", "name !~ '1'", 2 }, { "ANY service !~ 's'", NULL, 0 }, { "ANY attribute = 'k1'", NULL, 2 }, - { "ANY attribute = 'k1'", "host = 'x'",0 }, /* filter never matches */ + { "ANY attribute = 'k1'", "name = 'x'",0 }, /* filter never matches */ { "ANY attribute = 'k1'", "NOT attribute['x'] = ''", 2 }, /* filter always matches */ { "ANY attribute =~ 'k'", NULL, 2 }, diff --git a/t/unit/frontend/parser_test.c b/t/unit/frontend/parser_test.c index 947ef71..b3d5c8b 100644 --- a/t/unit/frontend/parser_test.c +++ b/t/unit/frontend/parser_test.c @@ -76,35 +76,35 @@ START_TEST(test_parse) { "LOOKUP hosts", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " - "host = 'host'", -1, 1, CONNECTION_LOOKUP }, + "name = 'host'", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING NOT " - "host = 'host'", -1, 1, CONNECTION_LOOKUP }, + "name = 'host'", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " - "host =~ 'p' AND " + "name =~ 'p' AND " "ANY service =~ 'p'", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING NOT " - "host =~ 'p' AND " + "name =~ 'p' AND " "ANY service =~ 'p'", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " - "host =~ 'p' AND " + "name =~ 'p' AND " "ANY service =~ 'p' OR " "ANY service =~ 'r'", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING NOT " - "host =~ 'p' AND " + "name =~ 'p' AND " "ANY service =~ 'p' OR " "ANY service =~ 'r'", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " - "host =~ 'p' " + "name =~ 'p' " "FILTER age > 1D", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " - "host =~ 'p' " + "name =~ 'p' " "FILTER age > 1D AND " "interval < 240s" , -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " - "host =~ 'p' " + "name =~ 'p' " "FILTER NOT age>1D", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " - "host =~ 'p' " + "name =~ 'p' " "FILTER age>" "interval", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP services", -1, 1, CONNECTION_LOOKUP }, @@ -128,15 +128,15 @@ START_TEST(test_parse) /* string constants */ { "LOOKUP hosts MATCHING " - "host = ''''", -1, 1, CONNECTION_LOOKUP }, + "name = ''''", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " - "host = '''foo'", -1, 1, CONNECTION_LOOKUP }, + "name = '''foo'", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " - "host = 'f''oo'", -1, 1, CONNECTION_LOOKUP }, + "name = 'f''oo'", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " - "host = 'foo'''", -1, 1, CONNECTION_LOOKUP }, + "name = 'foo'''", -1, 1, CONNECTION_LOOKUP }, { "LOOKUP hosts MATCHING " - "host = '''", -1, -1, 0 }, + "name = '''", -1, -1, 0 }, /* numeric constants */ { "LOOKUP hosts MATCHING " @@ -241,11 +241,11 @@ START_TEST(test_parse) { "LIST", -1, -1, 0 }, { "LIST foo", -1, -1, 0 }, { "LIST hosts MATCHING " - "host = 'host'", -1, -1, 0 }, + "name = 'host'", -1, -1, 0 }, { "LIST foo FILTER " "age > 60s", -1, -1, 0 }, { "FETCH host 'host' MATCHING " - "host = 'host'", -1, -1, 0 }, + "name = 'host'", -1, -1, 0 }, { "FETCH service 'host'",-1, -1, 0 }, { "FETCH metric 'host'", -1, -1, 0 }, { "FETCH host " @@ -256,11 +256,11 @@ START_TEST(test_parse) { "LOOKUP foo", -1, -1, 0 }, { "LOOKUP foo MATCHING " - "host = 'host'", -1, -1, 0 }, + "name = 'host'", -1, -1, 0 }, { "LOOKUP foo FILTER " "age > 60s", -1, -1, 0 }, { "LOOKUP foo MATCHING " - "host = 'host' FILTER " + "name = 'host' FILTER " "age > 60s", -1, -1, 0 }, { "LOOKUP hosts MATCHING " "attribute['foo'] <= " @@ -339,17 +339,17 @@ START_TEST(test_parse_matcher) { "", -1, -1 }, /* match hosts by name */ - { "host < 'localhost'", -1, MATCHER_LT }, - { "host <= 'localhost'", -1, MATCHER_LE }, - { "host = 'localhost'", -1, MATCHER_EQ }, - { "host != 'localhost'", -1, MATCHER_NE }, - { "host >= 'localhost'", -1, MATCHER_GE }, - { "host > 'localhost'", -1, MATCHER_GT }, - { "host =~ 'host'", -1, MATCHER_REGEX }, - { "host !~ 'host'", -1, MATCHER_NREGEX }, - { "host = 'localhost' -- foo", -1, MATCHER_EQ }, - { "host = 'host' ", 13, MATCHER_EQ }, - { "host &^ 'localhost'", -1, -1 }, + { "name < 'localhost'", -1, MATCHER_LT }, + { "name <= 'localhost'", -1, MATCHER_LE }, + { "name = 'localhost'", -1, MATCHER_EQ }, + { "name != 'localhost'", -1, MATCHER_NE }, + { "name >= 'localhost'", -1, MATCHER_GE }, + { "name > 'localhost'", -1, MATCHER_GT }, + { "name =~ 'host'", -1, MATCHER_REGEX }, + { "name !~ 'host'", -1, MATCHER_NREGEX }, + { "name = 'localhost' -- foo", -1, MATCHER_EQ }, + { "name = 'host' ", 13, MATCHER_EQ }, + { "name &^ 'localhost'", -1, -1 }, /* match hosts by service */ { "ANY service < 'name'", -1, MATCHER_ANY }, { "ANY service <= 'name'", -1, MATCHER_ANY }, @@ -380,11 +380,11 @@ START_TEST(test_parse_matcher) { "ANY attribute !~ 'pattern'", -1, MATCHER_ANY }, { "ANY attribute &^ 'pattern'", -1, -1 }, /* composite expressions */ - { "host =~ 'pattern' AND " + { "name =~ 'pattern' AND " "ANY service =~ 'pattern'", -1, MATCHER_AND }, - { "host =~ 'pattern' OR " + { "name =~ 'pattern' OR " "ANY service =~ 'pattern'", -1, MATCHER_OR }, - { "NOT host = 'host'", -1, MATCHER_NOT }, + { "NOT name = 'host'", -1, MATCHER_NOT }, /* numeric expressions */ { "attribute['foo'] < 123", -1, MATCHER_LT }, { "attribute['foo'] <= 123", -1, MATCHER_LE }, @@ -444,27 +444,27 @@ START_TEST(test_parse_matcher) { "'be' IN backend", -1, MATCHER_IN }, /* check operator precedence */ - { "host = 'name' OR " + { "name = 'name' OR " "ANY service = 'name' AND " "ANY attribute = 'name' OR " "attribute['foo'] = 'bar'", -1, MATCHER_OR }, - { "host = 'name' AND " + { "name = 'name' AND " "ANY service = 'name' AND " "ANY attribute = 'name' OR " "attribute['foo'] = 'bar'", -1, MATCHER_OR }, - { "host = 'name' AND " + { "name = 'name' AND " "ANY service = 'name' OR " "ANY attribute = 'name' AND " "attribute['foo'] = 'bar'", -1, MATCHER_OR }, - { "(host = 'name' OR " + { "(name = 'name' OR " "ANY service = 'name') AND " "(ANY attribute = 'name' OR " "attribute['foo'] = 'bar')", -1, MATCHER_AND }, - { "NOT host = 'name' OR " + { "NOT name = 'name' OR " "ANY service = 'name'", -1, MATCHER_OR }, - { "NOT host = 'name' OR " + { "NOT name = 'name' OR " "NOT ANY service = 'name'", -1, MATCHER_OR }, - { "NOT (host = 'name' OR " + { "NOT (name = 'name' OR " "NOT ANY service = 'name')", -1, MATCHER_NOT }, /* syntax errors */