diff --git a/rdbms/Constants.hpp b/rdbms/Constants.hpp new file mode 100644 index 0000000000000000000000000000000000000000..928a0e092ff7606af0bd88e2f51ce3df3ce08b66 --- /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 be47b1bf5dd63d7b0a47cae8b2a3f15661020270..78d996358a94a686b574c21abd6e0bcc30468ad1 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 3ee0a3a6dcafe8de91a61baef0ded6a97953c39f..6617371318fd302ef7d965cf45388f2afce26535 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: /**