From 201fa3682e58656e89d007eb187bbd2e539e985a Mon Sep 17 00:00:00 2001 From: Nick Porter Date: Thu, 7 Oct 2021 13:01:02 +0100 Subject: [PATCH] v4: Fixes for PostgreSQL 14 in CI (#4250) * Handle PGRES_PIPELINE_SYNC and PGRES PIPELINE_ABORTED * CI is now running PostgreSQL 14 --- .github/workflows/ci.yml | 2 +- .../drivers/rlm_sql_postgresql/config.h.in | 3 ++ .../drivers/rlm_sql_postgresql/configure | 30 +++++++++++++++++++ .../rlm_sql_postgresql/rlm_sql_postgresql.c | 11 +++++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7af22b0353e..22c386f0cf4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -273,7 +273,7 @@ jobs: sudo systemctl stop dovecot exim4 slapd openresty sudo aa-complain /usr/sbin/slapd - export PG_VER=13 + export PG_VER=14 sudo sh -c "echo host all all 127.0.0.1/32 trust > /etc/postgresql/$PG_VER/main/pg_hba.conf" sudo sh -c "echo local all all trust >> /etc/postgresql/$PG_VER/main/pg_hba.conf" diff --git a/src/modules/rlm_sql/drivers/rlm_sql_postgresql/config.h.in b/src/modules/rlm_sql/drivers/rlm_sql_postgresql/config.h.in index f2f2b46e3e9..066224d4294 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_postgresql/config.h.in +++ b/src/modules/rlm_sql/drivers/rlm_sql_postgresql/config.h.in @@ -6,6 +6,9 @@ /* Whether the PGRES_SINGLE_TUPLE constant is defined */ #undef HAVE_PGRES_SINGLE_TUPLE +/* Whether the PGRES_PIPELINE_SYNC constant is defined */ +#undef HAVE_PGRES_PIPELINE_SYNC + /* Define to 1 if you have the `PQinitOpenSSL' function. */ #undef HAVE_PQINITOPENSSL diff --git a/src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure b/src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure index 0680092b8ef..f54a376a7c1 100755 --- a/src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure +++ b/src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure @@ -2985,6 +2985,36 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PGRES_PIPELINE_SYNC" >&5 +$as_echo_n "checking for PGRES_PIPELINE_SYNC... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + if (PGRES_PIPELINE_SYNC) return 0; + return 1; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + +$as_echo "#define HAVE_PGRES_PIPELINE_SYNC 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi diff --git a/src/modules/rlm_sql/drivers/rlm_sql_postgresql/rlm_sql_postgresql.c b/src/modules/rlm_sql/drivers/rlm_sql_postgresql/rlm_sql_postgresql.c index c90127faa69..9d597feeff7 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_postgresql/rlm_sql_postgresql.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_postgresql/rlm_sql_postgresql.c @@ -178,6 +178,13 @@ static sql_rcode_t sql_classify_error(rlm_sql_postgres_t *inst, ExecStatusType s error_code = "42000"; break; + #ifdef HAVE_PGRES_PIPELINE_SYNC + case PGRES_PIPELINE_SYNC: + case PGRES_PIPELINE_ABORTED: + ERROR("libpq reported aborted pipeline"); + return RLM_SQL_ERROR; + #endif + case PGRES_BAD_RESPONSE: case PGRES_NONFATAL_ERROR: case PGRES_FATAL_ERROR: @@ -383,6 +390,10 @@ static CC_HINT(nonnull) sql_rcode_t sql_query(rlm_sql_handle_t *handle, rlm_sql_ case PGRES_BAD_RESPONSE: /* The server's response was not understood */ case PGRES_NONFATAL_ERROR: case PGRES_FATAL_ERROR: +#ifdef HAVE_PGRES_PIPELINE_SYNC + case PGRES_PIPELINE_SYNC: + case PGRES_PIPELINE_ABORTED: +#endif break; } -- 2.47.3