From 95ac8e2fd305798bdaa6d0e1720fb36e3f954b18 Mon Sep 17 00:00:00 2001 From: om Date: Fri, 21 Jul 2006 11:42:55 +0000 Subject: 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 --- src/modules/extra/m_pgsql.cpp | 11 ++++++++--- src/modules/extra/pgsql_config.pl | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 src/modules/extra/pgsql_config.pl 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)); -- cgit v1.2.3