From 742c60b383c9373b2156c3af5ff9e7605c056e60 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 5 Aug 2015 10:45:11 +0200 Subject: [PATCH] frontend: Use the plugin query interface instead of direct store access. The built-in store is registered as a reader automatically at the moment. --- src/core/store.c | 7 +++++-- src/frontend/connection-private.h | 1 - src/frontend/query.c | 15 ++------------- src/parser/parser.c | 2 -- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/core/store.c b/src/core/store.c index 2d32e0d..7671e98 100644 --- a/src/core/store.c +++ b/src/core/store.c @@ -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 diff --git a/src/frontend/connection-private.h b/src/frontend/connection-private.h index 94c3b4a..acdc699 100644 --- a/src/frontend/connection-private.h +++ b/src/frontend/connection-private.h @@ -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" diff --git a/src/frontend/query.c b/src/frontend/query.c index 97698fd..9315582 100644 --- a/src/frontend/query.c +++ b/src/frontend/query.c @@ -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 */ diff --git a/src/parser/parser.c b/src/parser/parser.c index e3073a9..2e0b864 100644 --- a/src/parser/parser.c +++ b/src/parser/parser.c @@ -27,8 +27,6 @@ #include "sysdb.h" -#include "core/store.h" - #include "parser/ast.h" #include "parser/parser.h" #include "parser/grammar.h" -- 2.30.2