diff --git a/src/parser/grammar.y b/src/parser/grammar.y
index 801462617755d305739e4ef28ac237dd8ce4d5cd..61891888d18423823141f4086bdb70e80ac55cfa 100644 (file)
--- a/src/parser/grammar.y
+++ b/src/parser/grammar.y
@@ -104,7 +104,7 @@ sdb_parser_yyerrorf(YYLTYPE *lval, sdb_parser_yyscan_t scanner, const char *fmt,
sdb_llist_t *list;
sdb_ast_node_t *node;
sdb_llist_t *list;
sdb_ast_node_t *node;
- struct { char *type; char *id; } metric_store;
+ struct { char *type; char *id; sdb_time_t last_update; } metric_store;
}
%start statements
}
%start statements
@@ -127,6 +127,8 @@ sdb_parser_yyerrorf(YYLTYPE *lval, sdb_parser_yyscan_t scanner, const char *fmt,
/* NULL token */
%token NULL_T
/* NULL token */
%token NULL_T
+%token TRUE FALSE
+
%token FETCH LIST LOOKUP STORE TIMESERIES
%token <str> IDENTIFIER STRING
%token FETCH LIST LOOKUP STORE TIMESERIES
%token <str> IDENTIFIER STRING
fetch_statement:
FETCH object_type STRING filter_clause
{
fetch_statement:
FETCH object_type STRING filter_clause
{
- $$ = sdb_ast_fetch_create($2, NULL, $3, $4);
+ $$ = sdb_ast_fetch_create($2, NULL, -1, NULL, $3, 1, $4);
CK_OOM($$);
}
|
FETCH object_type STRING '.' STRING filter_clause
{
CK_OOM($$);
}
|
FETCH object_type STRING '.' STRING filter_clause
{
- $$ = sdb_ast_fetch_create($2, $3, $5, $6);
+ $$ = sdb_ast_fetch_create($2, $3, -1, NULL, $5, 1, $6);
CK_OOM($$);
}
;
CK_OOM($$);
}
;
STORE HOST_T STRING last_update_clause
{
$$ = sdb_ast_store_create(SDB_HOST, NULL, 0, NULL,
STORE HOST_T STRING last_update_clause
{
$$ = sdb_ast_store_create(SDB_HOST, NULL, 0, NULL,
- $3, $4, NULL, NULL, SDB_DATA_NULL);
+ $3, $4, NULL, NULL, 0, SDB_DATA_NULL);
CK_OOM($$);
}
|
STORE SERVICE_T STRING '.' STRING last_update_clause
{
$$ = sdb_ast_store_create(SDB_SERVICE, $3, 0, NULL,
CK_OOM($$);
}
|
STORE SERVICE_T STRING '.' STRING last_update_clause
{
$$ = sdb_ast_store_create(SDB_SERVICE, $3, 0, NULL,
- $5, $6, NULL, NULL, SDB_DATA_NULL);
+ $5, $6, NULL, NULL, 0, SDB_DATA_NULL);
CK_OOM($$);
}
|
STORE METRIC_T STRING '.' STRING metric_store_clause last_update_clause
{
$$ = sdb_ast_store_create(SDB_METRIC, $3, 0, NULL,
CK_OOM($$);
}
|
STORE METRIC_T STRING '.' STRING metric_store_clause last_update_clause
{
$$ = sdb_ast_store_create(SDB_METRIC, $3, 0, NULL,
- $5, $7, $6.type, $6.id, SDB_DATA_NULL);
+ $5, $7, $6.type, $6.id, $6.last_update, SDB_DATA_NULL);
CK_OOM($$);
}
|
STORE HOST_T ATTRIBUTE_T STRING '.' STRING data last_update_clause
{
$$ = sdb_ast_store_create(SDB_ATTRIBUTE, $4, 0, NULL,
CK_OOM($$);
}
|
STORE HOST_T ATTRIBUTE_T STRING '.' STRING data last_update_clause
{
$$ = sdb_ast_store_create(SDB_ATTRIBUTE, $4, 0, NULL,
- $6, $8, NULL, NULL, $7);
+ $6, $8, NULL, NULL, 0, $7);
CK_OOM($$);
}
|
STORE SERVICE_T ATTRIBUTE_T STRING '.' STRING '.' STRING data last_update_clause
{
$$ = sdb_ast_store_create(SDB_ATTRIBUTE, $4, SDB_SERVICE, $6,
CK_OOM($$);
}
|
STORE SERVICE_T ATTRIBUTE_T STRING '.' STRING '.' STRING data last_update_clause
{
$$ = sdb_ast_store_create(SDB_ATTRIBUTE, $4, SDB_SERVICE, $6,
- $8, $10, NULL, NULL, $9);
+ $8, $10, NULL, NULL, 0, $9);
CK_OOM($$);
}
|
STORE METRIC_T ATTRIBUTE_T STRING '.' STRING '.' STRING data last_update_clause
{
$$ = sdb_ast_store_create(SDB_ATTRIBUTE, $4, SDB_METRIC, $6,
CK_OOM($$);
}
|
STORE METRIC_T ATTRIBUTE_T STRING '.' STRING '.' STRING data last_update_clause
{
$$ = sdb_ast_store_create(SDB_ATTRIBUTE, $4, SDB_METRIC, $6,
- $8, $10, NULL, NULL, $9);
+ $8, $10, NULL, NULL, 0, $9);
CK_OOM($$);
}
;
CK_OOM($$);
}
;
/* empty */ { $$ = sdb_gettime(); }
metric_store_clause:
/* empty */ { $$ = sdb_gettime(); }
metric_store_clause:
- STORE STRING STRING { $$.type = $2; $$.id = $3; }
+ STORE STRING STRING datetime { $$.type = $2; $$.id = $3; $$.last_update = $4; }
+ |
+ STORE STRING STRING { $$.type = $2; $$.id = $3; $$.last_update = 0; }
|
|
- /* empty */ { $$.type = $$.id = NULL; }
+ /* empty */ { $$.type = $$.id = NULL; $$.last_update = 0; }
/*
/*
- * TIMESERIES <host>.<metric> [START <datetime>] [END <datetime>];
+ * TIMESERIES <host>.<metric>[<data-source>...] [START <datetime>] [END <datetime>];
*
* Returns a time-series for the specified host's metric.
*/
timeseries_statement:
TIMESERIES STRING '.' STRING start_clause end_clause
{
*
* Returns a time-series for the specified host's metric.
*/
timeseries_statement:
TIMESERIES STRING '.' STRING start_clause end_clause
{
- $$ = sdb_ast_timeseries_create($2, $4, $5, $6);
+ $$ = sdb_ast_timeseries_create($2, $4, NULL, 0, $5, $6);
+ CK_OOM($$);
+ }
+ |
+ TIMESERIES STRING '.' STRING array start_clause end_clause
+ {
+ char **ds;
+ size_t ds_num;
+
+ if ($5.type != (SDB_TYPE_ARRAY | SDB_TYPE_STRING)) {
+ sdb_parser_yyerrorf(&yylloc, scanner, YY_("syntax error, "
+ "unexpected array of type %s; expected STRING"),
+ SDB_TYPE_TO_STRING($5.type));
+ sdb_data_free_datum(&$5);
+ free($2);
+ free($4);
+ YYABORT;
+ }
+
+ ds = $5.data.array.values;
+ ds_num = $5.data.array.length;
+
+ $$ = sdb_ast_timeseries_create($2, $4, ds, ds_num, $6, $7);
CK_OOM($$);
}
;
CK_OOM($$);
}
;
CK_OOM($$);
}
|
CK_OOM($$);
}
|
+ expression IS TRUE
+ {
+ $$ = sdb_ast_op_create(SDB_AST_ISTRUE, NULL, $1);
+ CK_OOM($$);
+ }
+ |
+ expression IS NOT TRUE
+ {
+ $$ = sdb_ast_op_create(SDB_AST_ISTRUE, NULL, $1);
+ CK_OOM($$);
+ $$ = sdb_ast_op_create(SDB_AST_NOT, NULL, $$);
+ CK_OOM($$);
+ }
+ |
+ expression IS FALSE
+ {
+ $$ = sdb_ast_op_create(SDB_AST_ISFALSE, NULL, $1);
+ CK_OOM($$);
+ }
+ |
+ expression IS NOT FALSE
+ {
+ $$ = sdb_ast_op_create(SDB_AST_ISFALSE, NULL, $1);
+ CK_OOM($$);
+ $$ = sdb_ast_op_create(SDB_AST_NOT, NULL, $$);
+ CK_OOM($$);
+ }
+ |
expression IN expression
{
$$ = sdb_ast_op_create(SDB_AST_IN, $1, $3);
expression IN expression
{
$$ = sdb_ast_op_create(SDB_AST_IN, $1, $3);
BACKEND_T { $$ = SDB_FIELD_BACKEND; }
|
VALUE_T { $$ = SDB_FIELD_VALUE; }
BACKEND_T { $$ = SDB_FIELD_BACKEND; }
|
VALUE_T { $$ = SDB_FIELD_VALUE; }
+ |
+ TIMESERIES { $$ = SDB_FIELD_TIMESERIES; }
;
cmp:
;
cmp: