summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b4d485c)
raw | patch | inline | side by side (parent: b4d485c)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 2 Aug 2014 20:52:25 +0000 (22:52 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sat, 2 Aug 2014 20:52:25 +0000 (22:52 +0200) |
This 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 a2ae448cc744166875afd8e0f4904b5a186ad5cf..3ece01a9bddc708285789cf2ab59c3c756419908 100644 (file)
--- a/src/frontend/grammar.y
+++ b/src/frontend/grammar.y
;
/*
- * FETCH <hostname>;
+ * FETCH <hostname> [FILTER <condition>];
*
* Retrieve detailed information about a single host.
*/
;
/*
- * LIST;
+ * LIST <type> [FILTER <condition>];
*
* Returns a list of all hosts in the store.
*/
list_statement:
- LIST filter_clause
+ LIST IDENTIFIER filter_clause
{
+ /* TODO: support other types as well */
+ if (strcasecmp($2, "hosts")) {
+ 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;
+ sdb_object_deref(SDB_OBJ($3));
+ YYABORT;
+ }
+
$$ = SDB_CONN_NODE(sdb_object_create_dT(/* name = */ NULL,
conn_list_t, conn_list_destroy));
- CONN_LIST($$)->filter = CONN_MATCHER($2);
+ CONN_LIST($$)->filter = CONN_MATCHER($3);
$$->cmd = CONNECTION_LIST;
+ free($2); $2 = NULL;
}
;
index 86ac03fd80962dae080dc08c7425ee4319f172c3..942b77cb9960ff7da15c88f0afe1080307d6e878 100755 (executable)
echo "$output" | grep "parse error: syntax error"
# Simple, successful commands.
-output="$( run_sysdb -H "$SOCKET_FILE" -c LIST )"
+output="$( run_sysdb -H "$SOCKET_FILE" -c 'LIST hosts' )"
echo "$output" \
| grep -F '"host1.example.com"' \
| grep -F '"host2.example.com"' \
| grep -F '"other.host.name"' \
| grep -F '"some.host.name"'
-output="$( echo 'LIST;' | run_sysdb -H "$SOCKET_FILE" )" || echo $?
+output="$( echo 'LIST hosts;' | run_sysdb -H "$SOCKET_FILE" )" || echo $?
echo "$output" \
| grep -F '"host1.example.com"' \
| grep -F '"host2.example.com"' \
echo "$output" | grep -F 'other.host.name' && exit 1
echo "$output" | grep -F 'some.host.name' && exit 1
-(echo 'LIST;'; sleep 1; echo "FETCH 'host1.example.com'") \
+(echo 'LIST hosts;'; sleep 1; echo "FETCH 'host1.example.com'") \
| run_sysdb -H "$SOCKET_FILE"
# When requesting information for unknown hosts, expect a non-zero exit code.
index bca86452dffc44afe22f2fb5b3418eaa7e6f42f3..16f61afaf79bd07e6457176382430a08fb4501a8 100644 (file)
{ "FETCH 'host' FILTER "
"host = 'host'", -1, 1, CONNECTION_FETCH },
- { "LIST", -1, 1, CONNECTION_LIST },
- { "LIST -- comment", -1, 1, CONNECTION_LIST },
- { "LIST;", -1, 1, CONNECTION_LIST },
- { "LIST; INVALID", 5, 1, CONNECTION_LIST },
- { "LIST FILTER "
+ { "LIST hosts", -1, 1, CONNECTION_LIST },
+ { "LIST hosts -- foo", -1, 1, CONNECTION_LIST },
+ { "LIST hosts;", -1, 1, CONNECTION_LIST },
+ { "LIST hosts; INVALID", 11, 1, CONNECTION_LIST },
+ { "LIST hosts FILTER "
"host = 'host'", -1, 1, CONNECTION_LIST },
{ "LOOKUP hosts", -1, 1, CONNECTION_LOOKUP },
{ "LIST; INVALID", 8, -1, 0 },
{ "/* some incomplete", -1, -1, 0 },
+ { "LIST", -1, -1, 0 },
{ "LIST MATCHING "
"host = 'host'", -1, -1, 0 },
{ "FETCH 'host' MATCHING "