From 96fed194dc865005856540ec497396ee17d72591 Mon Sep 17 00:00:00 2001 From: Steven Murray <Steven.Murray@cern.ch> Date: Tue, 13 Mar 2018 12:07:58 +0100 Subject: [PATCH] Moved c_maxSqlLenInExceptions to rdbms/Constants.hpp --- rdbms/Constants.hpp | 33 +++++++++++++++++++++++++++++++++ rdbms/wrapper/Stmt.cpp | 9 +++++---- rdbms/wrapper/Stmt.hpp | 7 ------- 3 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 rdbms/Constants.hpp diff --git a/rdbms/Constants.hpp b/rdbms/Constants.hpp new file mode 100644 index 0000000000..928a0e092f --- /dev/null +++ b/rdbms/Constants.hpp @@ -0,0 +1,33 @@ +/* + * The CERN Tape Archive (CTA) project + * Copyright (C) 2015 CERN + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include <stdint.h> +#include <string> + +namespace cta { +namespace rdbms { + +/** + * The maximum length an SQL statement can have in exception error message. + */ +const uint32_t MAX_SQL_LEN_IN_EXCEPTIONS = 80; + +} // namespace rdbms +} // namespace cta diff --git a/rdbms/wrapper/Stmt.cpp b/rdbms/wrapper/Stmt.cpp index be47b1bf5d..78d996358a 100644 --- a/rdbms/wrapper/Stmt.cpp +++ b/rdbms/wrapper/Stmt.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "rdbms/Constants.hpp" #include "rdbms/wrapper/Stmt.hpp" namespace cta { @@ -62,13 +63,13 @@ uint32_t Stmt::getParamIdx(const std::string ¶mName) const { // getSqlForException //------------------------------------------------------------------------------ std::string Stmt::getSqlForException() const { - if(m_sql.length() <= c_maxSqlLenInExceptions) { + if(m_sql.length() <= MAX_SQL_LEN_IN_EXCEPTIONS) { return m_sql; } else { - if(c_maxSqlLenInExceptions >= 3) { - return m_sql.substr(0, c_maxSqlLenInExceptions - 3) + "..."; + if(MAX_SQL_LEN_IN_EXCEPTIONS >= 3) { + return m_sql.substr(0, MAX_SQL_LEN_IN_EXCEPTIONS - 3) + "..."; } else { - return std::string("..."). substr(0, c_maxSqlLenInExceptions); + return std::string("...").substr(0, MAX_SQL_LEN_IN_EXCEPTIONS); } } } diff --git a/rdbms/wrapper/Stmt.hpp b/rdbms/wrapper/Stmt.hpp index 3ee0a3a6dc..6617371318 100644 --- a/rdbms/wrapper/Stmt.hpp +++ b/rdbms/wrapper/Stmt.hpp @@ -190,13 +190,6 @@ public: */ std::string getSqlForException() const; -protected: - - /** - * The maximum length an SQL statement can have in exception error message. - */ - const uint32_t c_maxSqlLenInExceptions = 80; - private: /** -- GitLab