session queries as statement progress
This commit is contained in:
@@ -18,15 +18,15 @@ column_generator::column_generator(std::vector<column> &column_infos,
|
||||
seen_tables.insert(table_name);
|
||||
}
|
||||
|
||||
std::vector<column> column_generator::generate( const object::repository& scm, const std::string& name, bool force_lazy ) {
|
||||
std::vector<column> column_generator::generate( const object::repository& scm, const std::string& name, bool /*force_lazy*/ ) {
|
||||
const auto info = scm.basic_info(name);
|
||||
if (!info) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<column> columns;
|
||||
for (const auto attr : info.value().get().definition()) {
|
||||
columns.push_back(column{attr.name()});
|
||||
for (const auto& attr : info.value().get().definition()) {
|
||||
columns.emplace_back(attr.name());
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
|
||||
@@ -28,20 +28,17 @@ public:
|
||||
};
|
||||
|
||||
}
|
||||
connection::connection(connection_info info, const std::shared_ptr<abstract_sql_logger> &sql_logger)
|
||||
: connection_info_(std::move(info))
|
||||
, logger_(sql_logger)
|
||||
connection::connection(const connection_info& info, const std::shared_ptr<abstract_sql_logger> &sql_logger)
|
||||
: logger_(sql_logger)
|
||||
{
|
||||
connection_.reset(backend_provider::instance().create_connection(connection_info_.type, connection_info_));
|
||||
connection_.reset(backend_provider::instance().create_connection(info.type, info));
|
||||
}
|
||||
|
||||
connection::connection(const std::string& dns, const std::shared_ptr<abstract_sql_logger> &sql_logger)
|
||||
: connection(connection_info::parse(dns), sql_logger)
|
||||
{}
|
||||
|
||||
connection::connection(const connection &x)
|
||||
: connection_info_(x.connection_info_)
|
||||
{
|
||||
connection::connection(const connection &x) {
|
||||
if (x.connection_) {
|
||||
throw std::runtime_error("couldn't copy connection with valid connection impl");
|
||||
}
|
||||
@@ -52,7 +49,6 @@ connection &connection::operator=(const connection &x) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
connection_info_ = x.connection_info_;
|
||||
if (x.connection_) {
|
||||
throw std::runtime_error("couldn't copy connection with valid connection impl");
|
||||
}
|
||||
@@ -60,13 +56,11 @@ connection &connection::operator=(const connection &x) {
|
||||
}
|
||||
|
||||
connection::connection( connection&& x ) noexcept
|
||||
: connection_info_(std::move(x.connection_info_))
|
||||
, connection_(std::move(x.connection_))
|
||||
: connection_(std::move(x.connection_))
|
||||
, logger_(std::move(x.logger_))
|
||||
{}
|
||||
|
||||
connection & connection::operator=(connection &&x) noexcept {
|
||||
connection_info_ = std::move(x.connection_info_);
|
||||
connection_ = std::move(x.connection_);
|
||||
logger_ = std::move(x.logger_);
|
||||
|
||||
@@ -80,7 +74,8 @@ connection::~connection() {
|
||||
if (connection_->is_open()) {
|
||||
connection_->close();
|
||||
}
|
||||
backend_provider::instance().destroy_connection(connection_info_.type, connection_.release());
|
||||
connection_impl* impl = connection_.release();
|
||||
backend_provider::instance().destroy_connection(impl->info().type, impl);
|
||||
connection_ = nullptr;
|
||||
}
|
||||
|
||||
@@ -108,11 +103,11 @@ utils::result<bool, utils::error> connection::is_open() const
|
||||
|
||||
const connection_info &connection::info() const
|
||||
{
|
||||
return connection_info_;
|
||||
return connection_->info();
|
||||
}
|
||||
|
||||
std::string connection::type() const {
|
||||
return connection_info_.type;
|
||||
return connection_->info().type;
|
||||
}
|
||||
|
||||
utils::result<void, utils::error> connection::begin() const {
|
||||
|
||||
@@ -58,12 +58,12 @@ connection_pool::connection_pool(const std::string& dns, size_t count)
|
||||
: info_(connection_info::parse(dns)) {
|
||||
connection_repo_.reserve(count);
|
||||
while (count) {
|
||||
connection c(info_);
|
||||
auto&& cc = std::move(c);
|
||||
const auto ic = identifiable_connection{count, std::move(cc)};
|
||||
connection_repo_.push_back(ic);
|
||||
// connection c(info_);
|
||||
// auto&& cc = std::move(c);
|
||||
// const auto ic = identifiable_connection{count, std::move(cc)};
|
||||
// connection_repo_.push_back(ic);
|
||||
// connection_repo_.emplace_back(count, std::move(cc));
|
||||
// connection_repo_.emplace_back(count, connection{info_});
|
||||
connection_repo_.emplace_back(count, connection{info_});
|
||||
auto &conn = connection_repo_.back();
|
||||
idle_connections_.emplace(conn.id, &conn);
|
||||
// Todo: handle result
|
||||
|
||||
Reference in New Issue
Block a user