summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4404b79)
raw | patch | inline | side by side (parent: 4404b79)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 19 May 2015 18:08:56 +0000 (20:08 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Tue, 19 May 2015 18:08:56 +0000 (20:08 +0200) |
This prepares a logical expression described by an AST for execution as a
store matcher. This is useful for anything that uses the lower level store
lookup functions.
store matcher. This is useful for anything that uses the lower level store
lookup functions.
diff --git a/src/core/store_query.c b/src/core/store_query.c
index 9855063304346f983d4abc768fd9c75e3f1dc65a..17ee17f6e4178845734657c2ac7951c26d999beb 100644 (file)
--- a/src/core/store_query.c
+++ b/src/core/store_query.c
return QUERY(sdb_object_create(SDB_AST_TYPE_TO_STRING(ast), query_type, ast));
} /* sdb_store_query_prepare */
+sdb_store_matcher_t *
+sdb_store_query_prepare_matcher(sdb_ast_node_t *ast)
+{
+ return node_to_matcher(ast);
+} /* sdb_store_query_prepare_matcher */
+
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
index fb59c7c1ba5f8cf7c2d09e56295c74d6512d54e7..48866a7df79e1d3835daf89ccf65e3c46353e4fb 100644 (file)
--- a/src/include/core/store.h
+++ b/src/include/core/store.h
sdb_store_query_t *
sdb_store_query_prepare(sdb_ast_node_t *ast);
+/*
+ * sdb_store_query_prepare_matcher:
+ * Prepare the logical expression described by 'ast' for execution as a store
+ * matcher.
+ *
+ * Returns:
+ * - a matcher on success
+ * - NULL else
+ */
+sdb_store_matcher_t *
+sdb_store_query_prepare_matcher(sdb_ast_node_t *ast);
+
/*
* sdb_store_query_execute:
* Execute a previously prepared query. The query result will be written to
index 48c128c0573b5943e2fdfec200958be71e51bb64..679fb548418092fbe1377cd9232dadf07e1af928 100644 (file)
#include "core/store.h"
#include "core/store-private.h"
-#include "frontend/parser.h"
+#include "parser/parser.h"
#include "testutils.h"
#include <check.h>
}
if (expr_iter_data[_i].filter) {
- filter = sdb_fe_parse_matcher(expr_iter_data[_i].filter, -1, NULL);
+ sdb_ast_node_t *ast;
+ ast = sdb_parser_parse_conditional(expr_iter_data[_i].filter, -1, NULL);
+ filter = sdb_store_query_prepare_matcher(ast);
+ sdb_object_deref(SDB_OBJ(ast));
ck_assert(filter != NULL);
}
index 3555495d79e4dfd681cf5ad5dc6220ade578a5ea..4466b153c93b557285a908bd2872044f5133a548 100644 (file)
#include "core/store.h"
#include "core/store-private.h"
-#include "frontend/parser.h"
+#include "parser/parser.h"
#include "testutils.h"
#include <assert.h>
{
sdb_strbuf_t *errbuf = sdb_strbuf_create(64);
sdb_store_matcher_t *m, *filter = NULL;
+ sdb_ast_node_t *ast;
int check, n;
n = 0;
fail_unless(n == 3,
"sdb_store_scan called callback %d times; expected: 3", (int)n);
- m = sdb_fe_parse_matcher(scan_data[_i].query, -1, errbuf);
+ ast = sdb_parser_parse_conditional(scan_data[_i].query, -1, errbuf);
+ m = sdb_store_query_prepare_matcher(ast);
+ sdb_object_deref(SDB_OBJ(ast));
fail_unless(m != NULL,
- "sdb_fe_parse_matcher(%s, -1) = NULL; expected: <matcher> "
+ "sdb_parser_parse_conditional(%s, -1) = NULL; expected: <ast> "
"(parser error: %s)", scan_data[_i].query,
sdb_strbuf_string(errbuf));
if (scan_data[_i].filter) {
- filter = sdb_fe_parse_matcher(scan_data[_i].filter, -1, errbuf);
+ ast = sdb_parser_parse_conditional(scan_data[_i].filter, -1, errbuf);
+ filter = sdb_store_query_prepare_matcher(ast);
+ sdb_object_deref(SDB_OBJ(ast));
fail_unless(filter != NULL,
- "sdb_fe_parse_matcher(%s, -1) = NULL; "
- "expected: <matcher> (parser error: %s)",
+ "sdb_parser_parse_conditional(%s, -1) = NULL; "
+ "expected: <ast> (parser error: %s)",
scan_data[_i].filter, sdb_strbuf_string(errbuf));
}
index a90b00f915f1b302fd03c5e3242f4acc5e9a2cb4..9cb613fa7dcb58a355e6935f04f820bfeb11b1cd 100644 (file)
#endif
#include "frontend/connection.h"
-#include "frontend/parser.h"
#include "frontend/connection-private.h"
#include "testutils.h"