Code

frontend: Use the plugin query interface instead of direct store access.
authorSebastian Harl <sh@tokkee.org>
Wed, 5 Aug 2015 08:45:11 +0000 (10:45 +0200)
committerSebastian Harl <sh@tokkee.org>
Wed, 5 Aug 2015 08:45:11 +0000 (10:45 +0200)
The built-in store is registered as a reader automatically at the moment.

src/core/store.c
src/frontend/connection-private.h
src/frontend/query.c
src/parser/parser.c

index 2d32e0d2cdbbb7419c54094d607c3eb771d99a8f..7671e9800f13a0ac0a81e2b24817d95b0f0a83ef 100644 (file)
@@ -871,8 +871,11 @@ sdb_store_init(void)
                sdb_log(SDB_LOG_ERR, "store: Failed to allocate store");
                return -1;
        }
-       return sdb_plugin_register_writer("memstore",
-                       &store_writer, SDB_OBJ(global_store));
+       if (sdb_plugin_register_writer("memstore",
+                               &store_writer, SDB_OBJ(global_store)))
+               return -1;
+       return sdb_plugin_register_reader("memstore",
+                       &store_reader, SDB_OBJ(global_store));
 } /* sdb_store_init */
 
 void
index 94c3b4a576ef443602b14ebf4e0b969cd0a22cfd..acdc699c107f11294905fc58fc8ed655551ba49e 100644 (file)
@@ -35,7 +35,6 @@
 #include "frontend/connection.h"
 
 #include "core/object.h"
-#include "core/store.h"
 #include "core/timeseries.h"
 #include "utils/ssl.h"
 #include "utils/strbuf.h"
index 97698fd300be6af87607c13d9b7c2336cea54b48..9315582292fa181b19e2f663a1591ff5fddda592 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "sysdb.h"
 
-#include "core/store.h"
+#include "core/plugin.h"
 #include "frontend/connection-private.h"
 #include "parser/ast.h"
 #include "parser/parser.h"
@@ -55,7 +55,6 @@ sstrdup(const char *s)
 static int
 query_exec(sdb_conn_t *conn, sdb_ast_node_t *ast)
 {
-       sdb_store_query_t *q;
        sdb_strbuf_t *buf;
        int status;
 
@@ -64,21 +63,12 @@ query_exec(sdb_conn_t *conn, sdb_ast_node_t *ast)
                return -1;
        }
 
-       q = sdb_store_query_prepare(ast);
-       if (! q) {
-               /* this shouldn't happen */
-               sdb_strbuf_sprintf(conn->errbuf, "failed to compile AST");
-               sdb_log(SDB_LOG_ERR, "frontend: failed to compile AST");
-               return -1;
-       }
-
        buf = sdb_strbuf_create(1024);
        if (! buf) {
                sdb_strbuf_sprintf(conn->errbuf, "Out of memory");
-               sdb_object_deref(SDB_OBJ(q));
                return -1;
        }
-       status = sdb_store_query_execute(q, buf, conn->errbuf);
+       status = sdb_plugin_query(ast, buf, conn->errbuf);
        if (status < 0) {
                char query[conn->cmd_len + 1];
                strncpy(query, sdb_strbuf_string(conn->buf), conn->cmd_len);
@@ -90,7 +80,6 @@ query_exec(sdb_conn_t *conn, sdb_ast_node_t *ast)
                                (uint32_t)sdb_strbuf_len(buf), sdb_strbuf_string(buf));
 
        sdb_strbuf_destroy(buf);
-       sdb_object_deref(SDB_OBJ(q));
        return status < 0 ? status : 0;
 } /* query_exec */
 
index e3073a9a627534d6ea5c5ca2e6ac3859a0eeeafc..2e0b864a9132e78c644e6b3316fa5724afde327b 100644 (file)
@@ -27,8 +27,6 @@
 
 #include "sysdb.h"
 
-#include "core/store.h"
-
 #include "parser/ast.h"
 #include "parser/parser.h"
 #include "parser/grammar.h"