From 3cd649023680bd49f9865fd62474d4db6a9d7c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 14 Jan 2018 21:44:22 +0100 Subject: Remove all the ugly database debug --- src/database/insert_query.hpp | 5 +---- src/database/postgresql_engine.cpp | 3 --- src/database/postgresql_statement.hpp | 13 ++----------- src/database/query.cpp | 3 --- src/database/select_query.hpp | 1 - src/database/sqlite3_engine.cpp | 5 ----- src/database/sqlite3_statement.hpp | 1 - src/database/table.hpp | 15 ++------------- 8 files changed, 5 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/database/insert_query.hpp b/src/database/insert_query.hpp index 853b7f1..17cc245 100644 --- a/src/database/insert_query.hpp +++ b/src/database/insert_query.hpp @@ -16,10 +16,7 @@ update_autoincrement_id(std::tuple& columns, Statement& statement) { using ColumnType = typename std::decay(columns))>::type; if (std::is_same::value) - { - log_debug("EXTRACTING LAST ID"); - auto&& column = std::get(columns); - } + auto&& column = std::get(columns); update_autoincrement_id(columns, statement); } diff --git a/src/database/postgresql_engine.cpp b/src/database/postgresql_engine.cpp index 4ee4223..150ca42 100644 --- a/src/database/postgresql_engine.cpp +++ b/src/database/postgresql_engine.cpp @@ -20,7 +20,6 @@ PostgresqlEngine::~PostgresqlEngine() std::unique_ptr PostgresqlEngine::open(const std::string& conninfo) { - log_debug("trying to open: ", conninfo); PGconn* con = PQconnectdb(conninfo.data()); if (!con) @@ -47,13 +46,11 @@ std::set PostgresqlEngine::get_all_columns_from_table(const std::st while (statement->step() == StepResult::Row) columns.insert(statement->get_column_text(0)); - log_debug("found ", columns.size(), " columns."); return columns; } std::tuple PostgresqlEngine::raw_exec(const std::string& query) { - log_debug("raw_exec:", query); PGresult* res = PQexec(this->conn, query.data()); auto sg = utils::make_scope_guard([res](){ PQclear(res); diff --git a/src/database/postgresql_statement.hpp b/src/database/postgresql_statement.hpp index 30c3ec2..571c8f1 100644 --- a/src/database/postgresql_statement.hpp +++ b/src/database/postgresql_statement.hpp @@ -96,12 +96,7 @@ private: params.reserve(this->params.size()); for (const auto& param: this->params) - { - log_debug("param:", param); - params.push_back(param.data()); - } - - log_debug("body: ", body); + params.push_back(param.data()); const int param_size = static_cast(this->params.size()); this->result = PQexecParams(this->conn, this->body.data(), param_size, @@ -111,11 +106,7 @@ private: nullptr, 0); const auto status = PQresultStatus(this->result); - if (status == PGRES_TUPLES_OK) - { - log_debug("PGRES_TUPLES_OK"); - } - else if (status != PGRES_COMMAND_OK) + if (status != PGRES_TUPLES_OK && status != PGRES_COMMAND_OK) { log_error("Failed to execute command: ", PQresultErrorMessage(this->result)); return false; diff --git a/src/database/query.cpp b/src/database/query.cpp index 6f305b2..4054007 100644 --- a/src/database/query.cpp +++ b/src/database/query.cpp @@ -3,19 +3,16 @@ void actual_bind(Statement& statement, const std::string& value, int index) { - log_debug("binding string:", value, " to col ", index); statement.bind_text(index, value); } void actual_bind(Statement& statement, const std::size_t value, int index) { - log_debug("binding size_t:", value); statement.bind_int64(index, value); } void actual_bind(Statement& statement, const OptionalBool& value, int index) { - log_debug("binding optional_t:", value.to_string()); if (!value.is_set) statement.bind_int64(index, 0); else if (value.value) diff --git a/src/database/select_query.hpp b/src/database/select_query.hpp index 837a866..af2ac1c 100644 --- a/src/database/select_query.hpp +++ b/src/database/select_query.hpp @@ -115,7 +115,6 @@ struct SelectQuery: public Query while (statement->step() == StepResult::Row) { - log_debug("one result."); Row row(this->table_name); extract_row_values(row, *statement); rows.push_back(row); diff --git a/src/database/sqlite3_engine.cpp b/src/database/sqlite3_engine.cpp index d159540..92d514b 100644 --- a/src/database/sqlite3_engine.cpp +++ b/src/database/sqlite3_engine.cpp @@ -39,9 +39,6 @@ std::set Sqlite3Engine::get_all_columns_from_table(const std::strin sqlite3_free(errmsg); } - log_debug("List of columns in table ", table_name, ":"); - for (const auto& c: result) - log_debug(c); return result; } @@ -74,7 +71,6 @@ std::tuple Sqlite3Engine::raw_exec(const std::string& query) std::unique_ptr Sqlite3Engine::prepare(const std::string& query) { sqlite3_stmt* stmt; - log_debug("SQLITE3: ", query); auto res = sqlite3_prepare(db, query.data(), static_cast(query.size()) + 1, &stmt, nullptr); if (res != SQLITE_OK) @@ -88,7 +84,6 @@ std::unique_ptr Sqlite3Engine::prepare(const std::string& query) void Sqlite3Engine::extract_last_insert_rowid(Statement&) { this->last_inserted_rowid = sqlite3_last_insert_rowid(this->db); - log_debug("extracted inserted ID: ", this->last_inserted_rowid); } std::string Sqlite3Engine::id_column_type() diff --git a/src/database/sqlite3_statement.hpp b/src/database/sqlite3_statement.hpp index 42a5220..7738fa6 100644 --- a/src/database/sqlite3_statement.hpp +++ b/src/database/sqlite3_statement.hpp @@ -19,7 +19,6 @@ class Sqlite3Statement: public Statement StepResult step() override final { auto res = sqlite3_step(this->get()); - log_debug("step: ", res); if (res == SQLITE_ROW) return StepResult::Row; else if (res == SQLITE_DONE) diff --git a/src/database/table.hpp b/src/database/table.hpp index 5fbc301..680e7cc 100644 --- a/src/database/table.hpp +++ b/src/database/table.hpp @@ -65,11 +65,10 @@ class Table { std::string query{"CREATE TABLE IF NOT EXISTS "}; query += this->name; - query += " (\n"; + query += " ("; this->add_column_create(db, query); query += ")"; - log_debug("create:" , query); auto result = db.raw_exec(query); if (std::get<0>(result) == false) log_error("Error executing query: ", std::get<1>(result)); @@ -112,21 +111,11 @@ class Table add_column_create(DatabaseEngine& db, std::string& str) { using ColumnType = typename std::remove_reference(std::declval()))>::type; -// using RealType = typename ColumnType::real_type; str += ColumnType::name; str += " "; -// if (std::is_same::value) -// { -// str += "INTEGER PRIMARY KEY AUTOINCREMENT"; -// } -// else -// { - str += ToSQLType(db); -// append_option(str); -// } + str += ToSQLType(db); if (N != sizeof...(T) - 1) str += ","; - str += "\n"; add_column_create(db, str); } -- cgit v1.2.3