added mysql backend

This commit is contained in:
2023-12-17 22:11:43 +01:00
parent 2893f749b6
commit 320d06bb20
39 changed files with 1272 additions and 46 deletions
@@ -35,7 +35,7 @@ public:
sql::record describe(const std::string& table) override;
bool exists(const std::string &table_name) override;
bool exists(const std::string &schema_name, const std::string &table_name) override;
private:
[[nodiscard]] static std::string generate_statement_name(const sql::query_context &query) ;
@@ -12,7 +12,7 @@ namespace matador::backends::postgres {
class postgres_statement final : public sql::statement_impl
{
public:
postgres_statement(PGconn *db, PGresult *result, const std::string &name, const sql::query_context &query);
postgres_statement(PGconn *db, PGresult *result, std::string name, const sql::query_context &query);
size_t execute() override;
std::unique_ptr<sql::query_result_impl> fetch() override;
@@ -161,9 +161,9 @@ sql::record postgres_connection::describe(const std::string &table)
return std::move(prototype);
}
bool postgres_connection::exists(const std::string &table_name)
bool postgres_connection::exists(const std::string &schema_name, const std::string &table_name)
{
std::string stmt("SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = '" + table_name + "'");
std::string stmt("SELECT 1 FROM information_schema.tables WHERE table_schema = '" + schema_name + "' AND table_name = '" + table_name + "'");
PGresult *res = PQexec(conn_, stmt.c_str());
+2 -2
View File
@@ -4,11 +4,11 @@
namespace matador::backends::postgres {
postgres_statement::postgres_statement(PGconn *db, PGresult *result, const std::string &name, const sql::query_context &query)
postgres_statement::postgres_statement(PGconn *db, PGresult *result, std::string name, const sql::query_context &query)
: statement_impl(query)
, db_(db)
, result_(result)
, name_(name)
, name_(std::move(name))
, binder_(query_.bind_vars.size())
{}