]> granicus.if.org Git - icinga2/commitdiff
Fix string escape problem with PostgreSQL >= 9.1 and standard_conforming_strings=on
authorMichael Friedrich <michael.friedrich@gmail.com>
Sat, 5 Sep 2015 12:08:35 +0000 (14:08 +0200)
committerMichael Friedrich <michael.friedrich@gmail.com>
Sat, 5 Sep 2015 12:08:35 +0000 (14:08 +0200)
fixes #9244

doc/2-getting-started.md
lib/db_ido_pgsql/idopgsqlconnection.cpp

index 6ed72997e7801c6e9e30ca62878f590e8303e128..276e043fd4065bce1e5cb16f5558d645fa938eb4 100644 (file)
@@ -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
 
@@ -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
index db9e7a6edd487e780858f8faab1b607558e29c28..8b28930c9622fa0f3edf50db92c535911c5b3558 100644 (file)
@@ -215,8 +215,16 @@ void IdoPgsqlConnection::Reconnect(void)
 
                SetConnected(true);
 
+               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);