summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-21 11:42:55 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-21 11:42:55 +0000
commit95ac8e2fd305798bdaa6d0e1720fb36e3f954b18 (patch)
tree9fbf87e6a7ea0c36689865ad3ebf7548e30139c1 /src/modules
parent2c6c072c1f5f19d1471feb43fa94bba0030e5fb6 (diff)
Add tiny perl script to detect version and pass an appropriate -D to gcc. Make m_pgsql #ifdef around PQescapeStringConn() which is only available in PostgreSQL >= 8.1.4
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4472 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-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));