summaryrefslogtreecommitdiff
path: root/src/database/postgresql_engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/database/postgresql_engine.cpp')
-rw-r--r--src/database/postgresql_engine.cpp44
1 files changed, 5 insertions, 39 deletions
diff --git a/src/database/postgresql_engine.cpp b/src/database/postgresql_engine.cpp
index d97f2ff..59bc885 100644
--- a/src/database/postgresql_engine.cpp
+++ b/src/database/postgresql_engine.cpp
@@ -2,7 +2,6 @@
#ifdef PQ_FOUND
#include <utils/scopeguard.hpp>
-#include <utils/tolower.hpp>
#include <database/query.hpp>
@@ -13,7 +12,6 @@
#include <logger/logger.hpp>
#include <cstring>
-#include <database/database.hpp>
PostgresqlEngine::PostgresqlEngine(PGconn*const conn):
conn(conn)
@@ -54,14 +52,14 @@ std::unique_ptr<DatabaseEngine> PostgresqlEngine::open(const std::string& connin
return std::make_unique<PostgresqlEngine>(con);
}
-std::map<std::string, std::string> PostgresqlEngine::get_all_columns_from_table(const std::string& table_name)
+std::set<std::string> PostgresqlEngine::get_all_columns_from_table(const std::string& table_name)
{
- const auto query = "SELECT column_name, data_type from information_schema.columns where table_name='" + table_name + "'";
+ const auto query = "SELECT column_name from information_schema.columns where table_name='" + table_name + "'";
auto statement = this->prepare(query);
- std::map<std::string, std::string> columns;
+ std::set<std::string> columns;
while (statement->step() == StepResult::Row)
- columns[utils::tolower(statement->get_column_text(0))] = utils::tolower(statement->get_column_text(1));
+ columns.insert(statement->get_column_text(0));
return columns;
}
@@ -98,41 +96,9 @@ std::string PostgresqlEngine::get_returning_id_sql_string(const std::string& col
return " RETURNING " + col_name;
}
-std::string PostgresqlEngine::id_column_type() const
+std::string PostgresqlEngine::id_column_type()
{
return "SERIAL";
}
-std::string PostgresqlEngine::datetime_column_type() const
-{
- return "TIMESTAMP";
-}
-
-void PostgresqlEngine::convert_date_format(DatabaseEngine& db)
-{
- const auto table_name = Database::muc_log_lines.get_name();
- const std::string column_name = Database::Date::name;
- const std::string query = "ALTER TABLE " + table_name + " ALTER COLMUN " + column_name + " SET DATA TYPE timestamp USING to_timestamp(" + column_name + ")";
-
- auto result = db.raw_exec(query);
- if (!std::get<bool>(result))
- log_error("Failed to execute query: ", std::get<std::string>(result));
-}
-
-std::string PostgresqlEngine::escape_param_number(int nb) const
-{
- return "to_timestamp(" + DatabaseEngine::escape_param_number(nb) + ")";
-}
-
-void PostgresqlEngine::init_session()
-{
- const auto res = this->raw_exec("SET SESSION TIME ZONE 'UTC'");
- if (!std::get<bool>(res))
- log_error("Failed to set UTC timezone: ", std::get<std::string>(res));
-}
-long double PostgresqlEngine::epoch_to_floating_value(long double seconds) const
-{
- return seconds;
-}
-
#endif