From 6357f49f867765d62a8a4398733194c07561281a Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Mon, 3 May 2021 20:04:38 +0900 Subject: [PATCH] Allow to build pgpool with PostgreSQL 9.0 or before. pool_process_reporting.c referrers to PQpingParams() which was introduced in PostgreSQL 9.1. Check existence of the function in configure and if it does not exist, set "pg_status" column of "show pool_nodes" and "pcp_node_info" to be set "unknown". --- configure.ac | 1 + doc.ja/src/sgml/ref/pcp_node_info.sgml | 6 ++++-- doc/src/sgml/ref/pcp_node_info.sgml | 15 ++++++++++----- src/utils/pool_process_reporting.c | 6 ++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index f550f5d17..22c79ae5a 100644 --- a/configure.ac +++ b/configure.ac @@ -429,6 +429,7 @@ LDFLAGS="-L$PGSQL_LIB_DIR $LDFLAGS" OLD_LIBS="$LIBS" AC_CHECK_LIB(pq, PQexecPrepared, [], [AC_MSG_ERROR(libpq is not installed or libpq is old)]) AC_CHECK_FUNCS(PQprepare) +AC_CHECK_FUNCS(PQpingParams) LDFLAGS="$OLD_LDFLAGS" LIBS="$OLD_LIBS" diff --git a/doc.ja/src/sgml/ref/pcp_node_info.sgml b/doc.ja/src/sgml/ref/pcp_node_info.sgml index 18c9a66e1..cf3b692c9 100644 --- a/doc.ja/src/sgml/ref/pcp_node_info.sgml +++ b/doc.ja/src/sgml/ref/pcp_node_info.sgml @@ -166,8 +166,10 @@ Pgpool-II documentation 6は実際のバックエンドの状態をリアルタイムで取得して表示します。 - 情報の取得はpg_isreadyを呼び出すことによって行われます。 - でバックエンドノードを切り離すと、Pgpool-IIが管理する状態は"Down"になりますが、バックエンドの実際の状態は"up"なので、5と6が一致しないことはあり得ます。 + 情報の取得は、このコマンドが実行された時にPQpingParamsを呼び出すことによって行われます。 + PQpingParamsはPostgreSQL 9.1以降でのみサポートされています。 + Pgpool-IIがPostgreSQL 9.0以前とともに構築されると、この列は"unknown"と表示します。 + でバックエンドノードを切り離すと、Pgpool-IIが管理する状態は"down"になりますが、バックエンドの実際の状態は"up"なので、5と6が一致しないことはあり得ます。 逆に、5が"up"なのに、6が"down"というのは起こらないはずです。 diff --git a/doc/src/sgml/ref/pcp_node_info.sgml b/doc/src/sgml/ref/pcp_node_info.sgml index a29f411bd..3ad2a0021 100644 --- a/doc/src/sgml/ref/pcp_node_info.sgml +++ b/doc/src/sgml/ref/pcp_node_info.sgml @@ -80,7 +80,7 @@ Pgpool-II documentation 3. status 4. load balance weight 5. status name - 6. actual backend status (taken from pg_isready. Pgpool-II 4.3 or later) + 6. actual backend status 7. backend role 8. actual backend role (taken from pg_is_in_recovery. Pgpool-II 4.3 or later) 9. replication delay @@ -120,10 +120,15 @@ Pgpool-II documentation - 6 shows the backend status in real time. The info is taken by - calling pg_isready. When a backend node is - detached by , the status managed by - Pgpool-II will be "Down", while the + 6 shows the backend status in real time. The info is obtained by + calling PQpingParams at the time when the + command is invoked. PQpingParams is only + available in PostgreSQL 9.1 or later. If + Pgpool-II was built with + PostgreSQL 9.0 or earlier, the column + shows "unknown". When a backend node is detached by , the status managed by + Pgpool-II will be "down", while the actual backend status is "up". Thus it is possible that 5 does not match with 6. However it should not happen that 5 is "up" while 6 is "down". diff --git a/src/utils/pool_process_reporting.c b/src/utils/pool_process_reporting.c index 0187bc33a..429864b0f 100644 --- a/src/utils/pool_process_reporting.c +++ b/src/utils/pool_process_reporting.c @@ -2170,6 +2170,7 @@ static void write_one_field_v2(POOL_CONNECTION * frontend, char *field) static char *db_node_status(int node) { +#ifdef HAVE_PQPINGPARAMS BackendInfo *bkinfo; int i; char portstr[32]; @@ -2177,6 +2178,7 @@ char *db_node_status(int node) const char *keywords[PARAMS_ARRAY_SIZE]; const char *values[PARAMS_ARRAY_SIZE]; PGPing ret; +#endif /* * If health check is not enabled, return "unknown". @@ -2186,6 +2188,7 @@ char *db_node_status(int node) return "unknown"; } +#ifdef HAVE_PQPINGPARAMS i = 0; keywords[i] = "user"; @@ -2221,6 +2224,9 @@ char *db_node_status(int node) return "up"; } return "down"; +#else + return "unknown"; +#endif } /* -- 2.39.5