Code

frontend: Let FETCH apply filters to the host as well.
authorSebastian Harl <sh@tokkee.org>
Mon, 3 Nov 2014 06:28:28 +0000 (07:28 +0100)
committerSebastian Harl <sh@tokkee.org>
Mon, 3 Nov 2014 06:28:28 +0000 (07:28 +0100)
src/frontend/query.c
t/integration/query.sh

index 1cb32dd307098f1290f011f3f83104bf97a5604b..e9c2d2212965638bf74dbbfd57e7ef3c1e72ca25 100644 (file)
@@ -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);
 
index e034e7c1d697e1694cb14e849885037832b5a706..39522cf9be6c09928952f121b621b6121286e54a 100755 (executable)
@@ -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"