diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index 03a4f2277..8c81c41d0 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -160,7 +160,7 @@ void IdoMysqlConnection::Reconnect(void) CONTEXT("Reconnecting to MySQL IDO database '" + GetName() + "'"); - m_SessionToken = Utility::NewUniqueID(); + m_SessionToken = static_cast(Utility::GetTime()); SetShouldConnect(true); @@ -382,7 +382,7 @@ void IdoMysqlConnection::Reconnect(void) void IdoMysqlConnection::ClearCustomVarTable(const String& table) { - Query("DELETE FROM " + GetTablePrefix() + table + " WHERE session_token <> '" + Escape(m_SessionToken) + "'"); + Query("DELETE FROM " + GetTablePrefix() + table + " WHERE session_token <> " + Convert::ToString(m_SessionToken)); } void IdoMysqlConnection::ClearConfigTable(const String& table) @@ -683,7 +683,7 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va return true; } if (key == "session_token") { - *result = "'" + Escape(m_SessionToken) + "'"; + *result = m_SessionToken; return true; } if (key == "notification_id") { diff --git a/lib/db_ido_mysql/idomysqlconnection.hpp b/lib/db_ido_mysql/idomysqlconnection.hpp index bab16a7a8..684c73b98 100644 --- a/lib/db_ido_mysql/idomysqlconnection.hpp +++ b/lib/db_ido_mysql/idomysqlconnection.hpp @@ -69,7 +69,7 @@ protected: private: DbReference m_InstanceID; - String m_SessionToken; + int m_SessionToken; WorkQueue m_QueryQueue; diff --git a/lib/db_ido_mysql/schema/mysql.sql b/lib/db_ido_mysql/schema/mysql.sql index ea004edd4..f1a2f8d06 100644 --- a/lib/db_ido_mysql/schema/mysql.sql +++ b/lib/db_ido_mysql/schema/mysql.sql @@ -342,7 +342,7 @@ CREATE TABLE IF NOT EXISTS icinga_customvariables ( varname varchar(255) character set latin1 collate latin1_general_cs default NULL, varvalue TEXT character set latin1 default '', is_json smallint default 0, - session_token varchar(512) character set latin1 default NULL, + session_token int default NULL, PRIMARY KEY (customvariable_id), UNIQUE KEY object_id_2 (object_id,config_type,varname), KEY varname (varname) @@ -363,7 +363,7 @@ CREATE TABLE IF NOT EXISTS icinga_customvariablestatus ( varname varchar(255) character set latin1 collate latin1_general_cs default NULL, varvalue TEXT character set latin1 default '', is_json smallint default 0, - session_token varchar(512) character set latin1 default NULL, + session_token int default NULL, PRIMARY KEY (customvariablestatus_id), UNIQUE KEY object_id_2 (object_id,varname), KEY varname (varname) diff --git a/lib/db_ido_mysql/schema/upgrade/2.4.0.sql b/lib/db_ido_mysql/schema/upgrade/2.4.0.sql index a7bf0fcb0..498c3e39f 100644 --- a/lib/db_ido_mysql/schema/upgrade/2.4.0.sql +++ b/lib/db_ido_mysql/schema/upgrade/2.4.0.sql @@ -52,8 +52,8 @@ ALTER TABLE icinga_hoststatus ADD COLUMN original_attributes TEXT character set -- #10436 deleted custom vars -- ----------------------------------------- -ALTER TABLE icinga_customvariables ADD COLUMN session_token varchar(512) character set latin1 default NULL; -ALTER TABLE icinga_customvariablestatus ADD COLUMN session_token varchar(512) character set latin1 default NULL; +ALTER TABLE icinga_customvariables ADD COLUMN session_token int default NULL; +ALTER TABLE icinga_customvariablestatus ADD COLUMN session_token int default NULL; CREATE INDEX cv_session_del_idx ON icinga_customvariables (session_token); CREATE INDEX cvs_session_del_idx ON icinga_customvariablestatus (session_token); diff --git a/lib/db_ido_pgsql/idopgsqlconnection.cpp b/lib/db_ido_pgsql/idopgsqlconnection.cpp index 8af2b30a4..d59ec7815 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.cpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.cpp @@ -160,7 +160,7 @@ void IdoPgsqlConnection::Reconnect(void) CONTEXT("Reconnecting to PostgreSQL IDO database '" + GetName() + "'"); - m_SessionToken = Utility::NewUniqueID(); + m_SessionToken = static_cast(Utility::GetTime()); SetShouldConnect(true); @@ -377,7 +377,7 @@ void IdoPgsqlConnection::Reconnect(void) void IdoPgsqlConnection::ClearCustomVarTable(const String& table) { - Query("DELETE FROM " + GetTablePrefix() + table + " WHERE session_token <> '" + Escape(m_SessionToken) + "'"); + Query("DELETE FROM " + GetTablePrefix() + table + " WHERE session_token <> " + Convert::ToString(m_SessionToken)); } void IdoPgsqlConnection::ClearConfigTable(const String& table) @@ -561,7 +561,7 @@ bool IdoPgsqlConnection::FieldToEscapedString(const String& key, const Value& va return true; } if (key == "session_token") { - *result = "'" + Escape(m_SessionToken) + "'"; + *result = m_SessionToken; return true; } if (key == "notification_id") { diff --git a/lib/db_ido_pgsql/idopgsqlconnection.hpp b/lib/db_ido_pgsql/idopgsqlconnection.hpp index d3cedff01..2fa2ba8e0 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.hpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.hpp @@ -61,7 +61,7 @@ protected: private: DbReference m_InstanceID; - String m_SessionToken; + int m_SessionToken; WorkQueue m_QueryQueue; diff --git a/lib/db_ido_pgsql/schema/pgsql.sql b/lib/db_ido_pgsql/schema/pgsql.sql index 8b9a8ce7f..13b4396b6 100644 --- a/lib/db_ido_pgsql/schema/pgsql.sql +++ b/lib/db_ido_pgsql/schema/pgsql.sql @@ -368,7 +368,7 @@ CREATE TABLE icinga_customvariables ( varname TEXT default '', varvalue TEXT default '', is_json INTEGER default 0, - session_token TEXT default NULL, + session_token INTEGER default NULL, CONSTRAINT PK_customvariable_id PRIMARY KEY (customvariable_id) , CONSTRAINT UQ_customvariables UNIQUE (object_id,config_type,varname) ) ; @@ -389,7 +389,7 @@ CREATE TABLE icinga_customvariablestatus ( varname TEXT default '', varvalue TEXT default '', is_json INTEGER default 0, - session_token TEXT default NULL, + session_token INTEGER default NULL, CONSTRAINT PK_customvariablestatus_id PRIMARY KEY (customvariablestatus_id) , CONSTRAINT UQ_customvariablestatus UNIQUE (object_id,varname) ) ; diff --git a/lib/db_ido_pgsql/schema/upgrade/2.4.0.sql b/lib/db_ido_pgsql/schema/upgrade/2.4.0.sql index 909869a50..1e50ec3e2 100644 --- a/lib/db_ido_pgsql/schema/upgrade/2.4.0.sql +++ b/lib/db_ido_pgsql/schema/upgrade/2.4.0.sql @@ -162,8 +162,8 @@ ALTER TABLE icinga_hoststatus ADD COLUMN original_attributes TEXT default NULL; -- #10436 deleted custom vars -- ----------------------------------------- -ALTER TABLE icinga_customvariables ADD COLUMN session_token TEXT default NULL; -ALTER TABLE icinga_customvariablestatus ADD COLUMN session_token TEXT default NULL; +ALTER TABLE icinga_customvariables ADD COLUMN session_token INTEGER default NULL; +ALTER TABLE icinga_customvariablestatus ADD COLUMN session_token INTEGER default NULL; CREATE INDEX cv_session_del_idx ON icinga_customvariables (session_token); CREATE INDEX cvs_session_del_idx ON icinga_customvariablestatus (session_token);