Fix pcp_node_info() in pgpool_adm extension.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 14 Feb 2021 00:41:15 +0000 (09:41 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 14 Feb 2021 00:41:15 +0000 (09:41 +0900)
The weight info was mistakenly handled by Float8GetDatum although the
function prototype is float4. The oversight made the weight value to 0
or certain insane value. Change it to Float4GetDatum.  It is amazing
that nobody (including me) did not notice it until today.

src/sql/pgpool_adm/pgpool_adm.c

index de94d49c73b1dfd0790fb99bc3912ae041a9eaba..fbbe4f08ae0ce58594e0f50d6797ad5a4adfd1be 100644 (file)
@@ -3,7 +3,7 @@
  * pgpool_adm.c
  *
  *
- * Copyright (c) 2002-2015, PostgreSQL Global Development Group
+ * Copyright (c) 2002-2021, PostgreSQL Global Development Group
  *
  * Author: Jehan-Guillaume (ioguix) de Rorthais <jgdr@dalibo.com>
  *
@@ -197,7 +197,7 @@ _pcp_node_info(PG_FUNCTION_ARGS)
                        break;
        }
        nulls[2] = false;
-       values[3] = Float8GetDatum(backend_info->backend_weight/RAND_MAX);
+       values[3] = Float4GetDatum(backend_info->backend_weight / RAND_MAX);
        nulls[3] = false;
 
        pcp_disconnect(pcpConnInfo);