summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8014e0b)
raw | patch | inline | side by side (parent: 8014e0b)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 2 Aug 2014 21:05:44 +0000 (23:05 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sat, 2 Aug 2014 21:05:44 +0000 (23:05 +0200) |
This also seems more consistent.
src/frontend/grammar.y | patch | blob | history | |
t/integration/simple_query.sh | patch | blob | history | |
t/unit/frontend/parser_test.c | patch | blob | history |
diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y
index 3ece01a9bddc708285789cf2ab59c3c756419908..a297714c074f20a22690245c5c51a8ab1f6d89bb 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
;
/*
- * FETCH <hostname> [FILTER <condition>];
+ * FETCH <type> <hostname> [FILTER <condition>];
*
* Retrieve detailed information about a single host.
*/
fetch_statement:
- FETCH STRING filter_clause
+ FETCH IDENTIFIER STRING filter_clause
{
+ /* TODO: support other types as well */
+ if (strcasecmp($2, "host")) {
+ char errmsg[strlen($2) + 32];
+ snprintf(errmsg, sizeof(errmsg),
+ YY_("unknown data-source %s"), $2);
+ sdb_fe_yyerror(&yylloc, scanner, errmsg);
+ free($2); $2 = NULL;
+ free($3); $3 = NULL;
+ sdb_object_deref(SDB_OBJ($4));
+ YYABORT;
+ }
+
$$ = SDB_CONN_NODE(sdb_object_create_dT(/* name = */ NULL,
conn_fetch_t, conn_fetch_destroy));
- CONN_FETCH($$)->name = strdup($2);
- CONN_FETCH($$)->filter = CONN_MATCHER($3);
+ CONN_FETCH($$)->name = $3;
+ CONN_FETCH($$)->filter = CONN_MATCHER($4);
$$->cmd = CONNECTION_FETCH;
free($2); $2 = NULL;
}
index 942b77cb9960ff7da15c88f0afe1080307d6e878..f191d650babfa663d1d78eb47104d1614406ec4a 100755 (executable)
| grep -F '"other.host.name"' \
| grep -F '"some.host.name"'
-output="$( run_sysdb -H "$SOCKET_FILE" -c "FETCH 'host1.example.com'" )"
+output="$( run_sysdb -H "$SOCKET_FILE" -c "FETCH host 'host1.example.com'" )"
echo "$output" \
| grep -F '"host1.example.com"' \
| grep -F '"mock service"' \
echo "$output" | grep -F 'other.host.name' && exit 1
echo "$output" | grep -F 'some.host.name' && exit 1
-(echo 'LIST hosts;'; sleep 1; echo "FETCH 'host1.example.com'") \
+(echo 'LIST hosts;'; sleep 1; echo "FETCH host 'host1.example.com'") \
| run_sysdb -H "$SOCKET_FILE"
# When requesting information for unknown hosts, expect a non-zero exit code.
-output="$( run_sysdb -H "$SOCKET_FILE" -c "FETCH 'does.not.exist'" )" \
+output="$( run_sysdb -H "$SOCKET_FILE" -c "FETCH host 'does.not.exist'" )" \
&& exit 1
echo "$output" | grep -F 'not found'
index 16f61afaf79bd07e6457176382430a08fb4501a8..e6b30635fd3dc94ec14f36f66b4b96f57f44e5c4 100644 (file)
{ ";;", -1, 0, 0 },
/* valid commands */
- { "FETCH 'host'", -1, 1, CONNECTION_FETCH },
- { "FETCH 'host' FILTER "
+ { "FETCH host 'host'", -1, 1, CONNECTION_FETCH },
+ { "FETCH host 'host' FILTER "
"host = 'host'", -1, 1, CONNECTION_FETCH },
{ "LIST hosts", -1, 1, CONNECTION_LIST },
/* syntax errors */
{ "INVALID", -1, -1, 0 },
{ "FETCH host", -1, -1, 0 },
- { "LIST; INVALID", 8, -1, 0 },
+ { "FETCH 'host'", -1, -1, 0 },
+ { "LIST hosts; INVALID", -1, -1, 0 },
{ "/* some incomplete", -1, -1, 0 },
{ "LIST", -1, -1, 0 },
- { "LIST MATCHING "
+ { "LIST foo", -1, -1, 0 },
+ { "LIST hosts MATCHING "
"host = 'host'", -1, -1, 0 },
- { "FETCH 'host' MATCHING "
+ { "LIST foo FILTER "
+ "host = 'host'", -1, -1, 0 },
+ { "FETCH host 'host' MATCHING "
+ "host = 'host'", -1, -1, 0 },
+ { "FETCH foo 'host'", -1, -1, 0 },
+ { "FETCH foo 'host' FILTER "
"host = 'host'", -1, -1, 0 },
{ "LOOKUP foo", -1, -1, 0 },