implemented the first version of statement_cache
This commit is contained in:
@@ -3,30 +3,28 @@
|
||||
#include "matador/sql/field.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
statement::statement(std::unique_ptr<statement_impl> impl, const std::shared_ptr<abstract_sql_logger> &logger)
|
||||
: statement_(std::move(impl))
|
||||
, logger_(logger)
|
||||
{}
|
||||
statement::statement(const std::shared_ptr<statement_proxy>& proxy, logger_ptr logger)
|
||||
: statement_proxy_(proxy)
|
||||
, logger_(std::move(logger)){}
|
||||
|
||||
statement &statement::bind(const size_t pos, const char *value)
|
||||
{
|
||||
statement_->bind(pos, value, 0);
|
||||
statement &statement::bind(const size_t pos, const char *value) {
|
||||
statement_proxy_->bind(pos, value, strlen(value));
|
||||
return *this;
|
||||
}
|
||||
|
||||
statement &statement::bind(const size_t pos, std::string &val, const size_t size)
|
||||
{
|
||||
statement_->bind(pos, val, size);
|
||||
statement_proxy_->bind(pos, val, size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
utils::result<size_t, utils::error> statement::execute() const
|
||||
{
|
||||
utils::result<size_t, utils::error> statement::execute() const {
|
||||
// logger_.info(statement_->query_.sql);
|
||||
return statement_->execute();
|
||||
return statement_proxy_->execute();
|
||||
}
|
||||
|
||||
//bool is_unknown(const std::vector<object::column_definition> &columns) {
|
||||
@@ -35,13 +33,13 @@ utils::result<size_t, utils::error> statement::execute() const
|
||||
// });
|
||||
//}
|
||||
|
||||
utils::result<query_result<record>, utils::error> statement::fetch() const
|
||||
{
|
||||
utils::result<query_result<record>, utils::error> statement::fetch() const {
|
||||
// if (is_unknown(statement_->query_.prototype)) {
|
||||
//
|
||||
// }
|
||||
|
||||
auto result = statement_->fetch();
|
||||
|
||||
auto result = statement_proxy_->fetch();
|
||||
if (!result.is_ok()) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
@@ -51,7 +49,7 @@ utils::result<query_result<record>, utils::error> statement::fetch() const
|
||||
|
||||
utils::result<std::optional<record>, utils::error> statement::fetch_one() const {
|
||||
// logger_.info(statement_->query_.sql);
|
||||
auto result = statement_->fetch();
|
||||
auto result = statement_proxy_->fetch();
|
||||
if (!result.is_ok()) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
@@ -67,7 +65,7 @@ utils::result<std::optional<record>, utils::error> statement::fetch_one() const
|
||||
|
||||
void statement::reset() const
|
||||
{
|
||||
statement_->reset();
|
||||
statement_proxy_->reset();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user