From 1fe96ac38c92b8c09776605c43600c27f6f7e321 Mon Sep 17 00:00:00 2001 From: Eliot Gable Date: Tue, 9 Oct 2012 18:42:23 +0000 Subject: [PATCH] Handle building on different PGSQL versions and update error message in Sofia. --- configure.in | 7 +++++++ src/mod/endpoints/mod_sofia/sofia.c | 14 +++++++------- src/switch_pgsql.c | 8 ++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/configure.in b/configure.in index e8ab623d7f..b8db9bc4a7 100644 --- a/configure.in +++ b/configure.in @@ -406,7 +406,14 @@ if test "$PG_CONFIG" != "no"; then POSTGRESQL_CXXFLAGS="`$PG_CONFIG --cppflags` -I`$PG_CONFIG --includedir`" POSTGRESQL_LDFLAGS="`$PG_CONFIG --ldflags` -L`$PG_CONFIG --libdir` -lpq" POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` + POSTGRESQL_MAJOR_VERSION=`$PG_CONFIG --version | sed -re 's#PostgreSQL ([0-9]+).[0-9]+.[0-9]+#\1#'` + POSTGRESQL_MINOR_VERSION=`$PG_CONFIG --version | sed -re 's#PostgreSQL [0-9]+.([0-9]+).[0-9]+#\1#'` + POSTGRESQL_PATCH_VERSION=`$PG_CONFIG --version | sed -re 's#PostgreSQL [0-9]+.[0-9]+.([0-9]+)#\1#'` AC_DEFINE([SWITCH_HAVE_PGSQL], [1], [Define to 1 if PostgreSQL libraries are available]) + AC_DEFINE_UNQUOTED([POSTGRESQL_VERSION], "${POSTGRESQL_VERSION}", [Specifies the version of PostgreSQL we are linking against]) + AC_DEFINE_UNQUOTED([POSTGRESQL_MAJOR_VERSION], ${POSTGRESQL_MAJOR_VERSION}, [Specifies the version of PostgreSQL we are linking against]) + AC_DEFINE_UNQUOTED([POSTGRESQL_MINOR_VERSION], ${POSTGRESQL_MINOR_VERSION}, [Specifies the version of PostgreSQL we are linking against]) + AC_DEFINE_UNQUOTED([POSTGRESQL_PATCH_VERSION], ${POSTGRESQL_PATCH_VERSION}, [Specifies the version of PostgreSQL we are linking against]) AC_CHECK_LIB([pq], [PQgetvalue],, AC_MSG_ERROR([no usable libpq; please install PostgreSQL devel package or equivalent])) AC_MSG_RESULT([yes]) SWITCH_AM_CXXFLAGS="$POSTGRESQL_CXXFLAGS $SWITCH_AM_CXXFLAGS" diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index e738cf2fb0..ae501d57e7 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -4423,14 +4423,14 @@ switch_status_t config_sofia(int reload, char *profile_name) } } } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NEITHER ODBC NOR PGSQL ARE AVAILABLE!\n"); + } + } else if (!strcasecmp(var, "forward-unsolicited-mwi-notify")) { + if (switch_true(val)) { + sofia_set_pflag(profile, PFLAG_FORWARD_MWI_NOTIFY); + } else { + sofia_clear_pflag(profile, PFLAG_FORWARD_MWI_NOTIFY); } - } else if (!strcasecmp(var, "forward-unsolicited-mwi-notify")) { - if (switch_true(val)) { - sofia_set_pflag(profile, PFLAG_FORWARD_MWI_NOTIFY); - } else { - sofia_clear_pflag(profile, PFLAG_FORWARD_MWI_NOTIFY); - } } else if (!strcasecmp(var, "registration-thread-frequency")) { profile->ireg_seconds = atoi(val); if (profile->ireg_seconds < 0) { diff --git a/src/switch_pgsql.c b/src/switch_pgsql.c index 8093aac1ee..6c4e2e069d 100644 --- a/src/switch_pgsql.c +++ b/src/switch_pgsql.c @@ -254,6 +254,10 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_next_result_timed(switch_pgsq *result_out = res; res->status = PQresultStatus(res->result); switch(res->status) { +#if POSTGRESQL_MAJOR_VERSION >= 9 && POSTGRESQL_MINOR_VERSION >= 2 + case PGRES_SINGLE_TUPLE: + /* Added in PostgreSQL 9.2 */ +#endif case PGRES_TUPLES_OK: { res->rows = PQntuples(res->result); @@ -261,6 +265,10 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_next_result_timed(switch_pgsq res->cols = PQnfields(res->result); } break; +#if POSTGRESQL_MAJOR_VERSION >= 9 && POSTGRESQL_MINOR_VERSION >= 1 + case PGRES_COPY_BOTH: + /* Added in PostgreSQL 9.1 */ +#endif case PGRES_COPY_OUT: case PGRES_COPY_IN: case PGRES_COMMAND_OK: