From 112d3d27bef3276dc011ec6d310823fa86e6fd06 Mon Sep 17 00:00:00 2001 From: stefanocasazza Date: Sun, 3 Sep 2017 17:12:27 +0200 Subject: [PATCH] postgres fix --- configure | 6 +++++- include/ulib/base/utility.h | 4 ++++ include/ulib/internal/config.h.in | 3 +++ m4/ax_lib_postgresql.m4 | 7 ++++--- tests/examples/benchmark/FrameworkBenchmarks/ULib/ulib.sh | 5 ++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 6bf841bb..e05ad6c9 100755 --- a/configure +++ b/configure @@ -28614,10 +28614,14 @@ $as_echo_n "checking for PostgreSQL client libraries... " >&6; } POSTGRESQL_CPPFLAGS="-I`$PG_CONFIG --includedir` -I`$PG_CONFIG --includedir-server`" POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` - if test -f "$postgresql_libdir/libpgport.a" -o -f "$postgresql_libdir/libpgport.so"; then + if test -f "$postgresql_libdir/libpgport.a" -o -f "$postgresql_libdir/libpgport.so" -o -f "/usr/lib/libpgport.a" -o -f "/usr/lib/libpgport.so"; then POSTGRESQL_LIBS="-lpq -lpgport" else POSTGRESQL_LIBS="-lpq" + + +$as_echo "#define LIBPGPORT_NOT_FOUND 1" >>confdefs.h + fi diff --git a/include/ulib/base/utility.h b/include/ulib/base/utility.h index cb3a94c9..73128bfc 100644 --- a/include/ulib/base/utility.h +++ b/include/ulib/base/utility.h @@ -731,6 +731,10 @@ static inline uint64_t u_getValue(uint16_t tag, void* payload) static inline void u_setTag(uint16_t tag, uint64_t* pval) { uint64_t payload = u_getPayload(*pval); *pval = u_getValue(tag, (void*)(long)payload); } +#if defined(USE_PGSQL) && defined(LIBPGPORT_NOT_FOUND) +static inline void pg_qsort(void* a, size_t n, size_t es, int (*cmp)(const void*, const void*)) { qsort(a, n, es, cmp); } +#endif + #ifdef __cplusplus } #endif diff --git a/include/ulib/internal/config.h.in b/include/ulib/internal/config.h.in index b6d2c1da..aaa0da2a 100644 --- a/include/ulib/internal/config.h.in +++ b/include/ulib/internal/config.h.in @@ -589,6 +589,9 @@ /* Standard C lib version */ #undef LIBC_VERSION +/* Define to 1 if PostgreSQL libpgport is not available */ +#undef LIBPGPORT_NOT_FOUND + /* Libraries */ #undef LIBS_VAR diff --git a/m4/ax_lib_postgresql.m4 b/m4/ax_lib_postgresql.m4 index b9e76470..b134fbf8 100644 --- a/m4/ax_lib_postgresql.m4 +++ b/m4/ax_lib_postgresql.m4 @@ -100,14 +100,15 @@ AC_DEFUN([AX_LIB_POSTGRESQL], POSTGRESQL_CPPFLAGS="-I`$PG_CONFIG --includedir` -I`$PG_CONFIG --includedir-server`" POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'` - if test -f "$postgresql_libdir/libpgport.a" -o -f "$postgresql_libdir/libpgport.so"; then + if test -f "$postgresql_libdir/libpgport.a" -o -f "$postgresql_libdir/libpgport.so" -o -f "/usr/lib/libpgport.a" -o -f "/usr/lib/libpgport.so"; then POSTGRESQL_LIBS="-lpq -lpgport" else POSTGRESQL_LIBS="-lpq" + + AC_DEFINE([LIBPGPORT_NOT_FOUND], [1], [Define to 1 if PostgreSQL libpgport is not available]) fi - AC_DEFINE([HAVE_POSTGRESQL], [1], - [Define to 1 if PostgreSQL libraries are available]) + AC_DEFINE([HAVE_POSTGRESQL], [1], [Define to 1 if PostgreSQL libraries are available]) AC_MSG_RESULT([$POSTGRESQL_LIBS]) fi diff --git a/tests/examples/benchmark/FrameworkBenchmarks/ULib/ulib.sh b/tests/examples/benchmark/FrameworkBenchmarks/ULib/ulib.sh index 227111a8..058d6313 100755 --- a/tests/examples/benchmark/FrameworkBenchmarks/ULib/ulib.sh +++ b/tests/examples/benchmark/FrameworkBenchmarks/ULib/ulib.sh @@ -14,7 +14,10 @@ ULIB_DOCUMENT_ROOT=$ULIB_ROOT/ULIB_DOCUMENT_ROOT mkdir -p $ULIB_ROOT mkdir -p $ULIB_DOCUMENT_ROOT -#sudo apt-get install -y libpq-dev +if [ "$TRAVIS" = "true" ]; then +# AVOID "fatal error: postgres_fe.h: No such file or directory" +sudo apt-get install -y postgresql-server-dev-all +fi # make use of FIFO scheduling policy possible (we must avoid use of test because bash signal trapping) #type setcap >/dev/null 2>/dev/null