From 6efa08926a3f15b38dd008198680a60c80a5fc63 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 3 Nov 2014 07:28:28 +0100 Subject: [PATCH] frontend: Let FETCH apply filters to the host as well. --- src/frontend/query.c | 3 ++- t/integration/query.sh | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend/query.c b/src/frontend/query.c index 1cb32dd..e9c2d22 100644 --- a/src/frontend/query.c +++ b/src/frontend/query.c @@ -273,7 +273,8 @@ sdb_fe_exec_fetch(sdb_conn_t *conn, int type, const char *name, } host = sdb_store_get_host(name); - if (! host) { + if ((! host) || (filter + && (! sdb_store_matcher_matches(filter, host, NULL)))) { sdb_log(SDB_LOG_DEBUG, "frontend: Failed to fetch host '%s': " "not found", name); diff --git a/t/integration/query.sh b/t/integration/query.sh index e034e7c..39522cf 100755 --- a/t/integration/query.sh +++ b/t/integration/query.sh @@ -93,6 +93,11 @@ echo "$output" | grep -F 'localhost' && exit 1 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" )" \ + && exit 1 +echo "$output" | grep -F 'not found' + (echo 'LIST hosts;'; sleep 1; echo "FETCH host 'host1.example.com'") \ | run_sysdb -H "$SOCKET_FILE" -- 2.30.2