X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=src%2Fcore%2Fstore.c;h=7671e9800f13a0ac0a81e2b24817d95b0f0a83ef;hp=f672c120a3c646b3893f06583a717b13ad9f22cf;hb=742c60b383c9373b2156c3af5ff9e7605c056e60;hpb=07e184c400bb2061279e084a065a628599183445 diff --git a/src/core/store.c b/src/core/store.c index f672c12..7671e98 100644 --- a/src/core/store.c +++ b/src/core/store.c @@ -831,6 +831,31 @@ static sdb_store_writer_t store_writer = { store_attribute, store_service_attr, store_metric_attr, }; +/* + * TODO: let prepare and execute accept a store object as their user_data + * object + */ + +static sdb_object_t * +prepare_query(sdb_ast_node_t *ast, + sdb_strbuf_t __attribute__((unused)) *errbuf, + sdb_object_t __attribute__((unused)) *user_data) +{ + return SDB_OBJ(sdb_store_query_prepare(ast)); +} /* prepare_query */ + +static int +execute_query(sdb_object_t *q, + sdb_strbuf_t *buf, sdb_strbuf_t *errbuf, + sdb_object_t __attribute__((unused)) *user_data) +{ + return sdb_store_query_execute(QUERY(q), buf, errbuf); +} /* execute_query */ + +static sdb_store_reader_t store_reader = { + prepare_query, execute_query, +}; + /* * public API */ @@ -846,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