Skip to content

Commit

Permalink
Fix string escape problem with PostgreSQL >= 9.1 and standard_conform…
Browse files Browse the repository at this point in the history
…ing_strings=on

fixes #9244
  • Loading branch information
dnsmichi committed Sep 5, 2015
1 parent 35bc567 commit e06375d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion doc/2-getting-started.md
Expand Up @@ -408,6 +408,7 @@ RHEL/CentOS 5/6:
RHEL/CentOS 7:

# yum install postgresql-server postgresql
# postgresql-setup --initdb
# systemctl enable postgresql
# systemctl start postgresql

Expand Down Expand Up @@ -471,7 +472,7 @@ authentication method and restart the postgresql server.
# IPv6 local connections:
host all all ::1/128 ident

# /etc/init.d/postgresql restart
# service postgresql restart


After creating the database and permissions you can import the Icinga 2 IDO
Expand Down
10 changes: 9 additions & 1 deletion lib/db_ido_pgsql/idopgsqlconnection.cpp
Expand Up @@ -217,8 +217,16 @@ void IdoPgsqlConnection::Reconnect(void)
BOOST_THROW_EXCEPTION(std::runtime_error(message));
}

IdoPgsqlResult result;

/* explicitely require legacy mode for string escaping in PostgreSQL >= 9.1
* changing standard_conforming_strings to on by default
*/
if (PQserverVersion(m_Connection) >= 90100)
result = Query("SET standard_conforming_strings TO off");

String dbVersionName = "idoutils";
IdoPgsqlResult result = Query("SELECT version FROM " + GetTablePrefix() + "dbversion WHERE name=E'" + Escape(dbVersionName) + "'");
result = Query("SELECT version FROM " + GetTablePrefix() + "dbversion WHERE name=E'" + Escape(dbVersionName) + "'");

Dictionary::Ptr row = FetchRow(result, 0);

Expand Down

0 comments on commit e06375d

Please sign in to comment.