summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/extra/m_pgsql.cpp11
-rw-r--r--src/modules/extra/pgsql_config.pl6
2 files changed, 14 insertions, 3 deletions
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index 39849271d..c7feb2a22 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -31,7 +31,7 @@
#include "m_sqlv2.h"
/* $ModDesc: PostgreSQL Service Provider module for all other m_sql* modules, uses v2 of the SQL API */
-/* $CompileFlags: -I`pg_config --includedir` */
+/* $CompileFlags: -I`pg_config --includedir` `perl extra/pgsql_config.pl` */
/* $LinkerFlags: -L`pg_config --libdir` -lpq */
/* UGH, UGH, UGH, UGH, UGH, UGH
@@ -956,8 +956,13 @@ SQLerror SQLConn::DoQuery(const SQLrequest &req)
char* query = new char[(req.query.q.length()*2)+1];
int error = 0;
-
- // PQescapeStringConn(sql, query, req.query.q.c_str(), req.query.q.length(), error);
+
+#ifdef PGSQL_HAS_ESCAPECONN
+ PQescapeStringConn(sql, query, req.query.q.c_str(), req.query.q.length(), &error);
+#else
+ PQescapeString(query, req.query.q.c_str(), req.query.q.length());
+ error = 0;
+#endif
if(error == 0)
{
diff --git a/src/modules/extra/pgsql_config.pl b/src/modules/extra/pgsql_config.pl
new file mode 100644
index 000000000..4c56e4cf6
--- /dev/null
+++ b/src/modules/extra/pgsql_config.pl
@@ -0,0 +1,6 @@
+#!/usr/bin/perl
+
+my $v = substr(`pg_config --version`, 11);
+my($a, $b, $c) = split(/\./, $v);
+
+print "-D PGSQL_HAS_ESCAPECONN" if(($a >= 8) and ($b >= 1) and ($c >= 4));