Code

frontend/grammar: Added (limited) support for attribute values in expressions.
authorSebastian Harl <sh@tokkee.org>
Tue, 14 Oct 2014 07:16:09 +0000 (09:16 +0200)
committerSebastian Harl <sh@tokkee.org>
Tue, 14 Oct 2014 07:16:09 +0000 (09:16 +0200)
This is not fully supported yet as expressions may not be used in all places
yet.

src/core/store_lookup.c
src/frontend/grammar.y

index 6aa4095bc5de2370f965e88500bc01f8c817cc8d..0c9d36199abca8e6db5fea26e34c0c52c80b852f 100644 (file)
@@ -1007,9 +1007,8 @@ sdb_store_matcher_parse_cmp(const char *obj_type, const char *attr,
        if (! expr)
                return NULL;
 
-       if (sdb_store_expr_eval(expr, NULL, &value))
-               return NULL;
-       if (value.type != SDB_TYPE_STRING) {
+       if (sdb_store_expr_eval(expr, NULL, &value) ||
+                       (value.type != SDB_TYPE_STRING)) {
                sdb_data_free_datum(&value);
                if (type != SDB_ATTRIBUTE)
                        return NULL;
index 93616ac07caa9bf7c9419577e89a559b3f6e38dd..0f01bd33e8a12ba517f4f062315c25a2444602d5 100644 (file)
@@ -495,6 +495,13 @@ expression:
                        $$ = sdb_store_expr_fieldvalue(field);
                }
        |
+       IDENTIFIER '[' IDENTIFIER ']'
+               {
+                       $$ = sdb_store_expr_attrvalue($3);
+                       free($1); $1 = NULL;
+                       free($3); $3 = NULL;
+               }
+       |
        data
                {
                        $$ = sdb_store_expr_constvalue(&$1);