Feature: add pgpool_adm_pcp_proc_info.
authorTatsuo Ishii <ishii@postgresql.org>
Tue, 24 Jun 2025 10:16:15 +0000 (19:16 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Tue, 24 Jun 2025 11:57:43 +0000 (20:57 +0900)
This commit adds new pgpool_adm extension function:
pcp_proc_info. Also add new fields: client_host, client_port and SQL
statement to pcp_proc_info and "show pool_pools". With these additions
now it is possible to track the relationship among clients of pgpool,
pgpool itself and PostgreSQL.

Moreover the commit allows to know what commands (statements) are last
executed by using pcp_proc_info. Previously it was not possible unless
looking into the pgpool log.

lipcp.so version is bumped from 2.0 to 2.1.

27 files changed:
doc.ja/src/sgml/ref/allfiles.sgml
doc.ja/src/sgml/ref/pcp_proc_info.sgml
doc.ja/src/sgml/ref/pgpool_adm_pcp_proc_info.sgml [new file with mode: 0644]
doc.ja/src/sgml/ref/show_pool_pools.sgml
doc.ja/src/sgml/reference.sgml
doc/src/sgml/ref/allfiles.sgml
doc/src/sgml/ref/pcp_proc_info.sgml
doc/src/sgml/ref/pgpool_adm_pcp_proc_info.sgml [new file with mode: 0644]
doc/src/sgml/ref/show_pool_pools.sgml
doc/src/sgml/reference.sgml
src/Makefile.am
src/include/pcp/libpcp_ext.h
src/include/protocol/pool_proto_modules.h
src/libs/pcp/Makefile.am
src/protocol/child.c
src/protocol/pool_proto_modules.c
src/sql/pgpool_adm/Makefile
src/sql/pgpool_adm/pgpool_adm--1.5--1.6.sql [new file with mode: 0644]
src/sql/pgpool_adm/pgpool_adm--1.6.sql [new file with mode: 0644]
src/sql/pgpool_adm/pgpool_adm.c
src/sql/pgpool_adm/pgpool_adm.control
src/sql/pgpool_adm/pgpool_adm.h
src/test/regression/tests/038.pcp_commands/expected [new file with mode: 0644]
src/test/regression/tests/038.pcp_commands/test.sh
src/tools/pcp/pcp_frontend_client.c
src/utils/pool_health_check_stats.c
src/utils/pool_process_reporting.c

index 89be154bc1d2e5ab293f0d8d8dc680a8332fce58..7127cb553ec5411ee4502a71eb74f24b9eff5944 100644 (file)
@@ -45,3 +45,4 @@ Complete list of usable sgml source files in this directory.
 <!ENTITY pgpoolAdmPcpNodeCount SYSTEM "pgpool_adm_pcp_node_count.sgml">
 <!ENTITY pgpoolAdmPcpAttachNode SYSTEM "pgpool_adm_pcp_attach_node.sgml">
 <!ENTITY pgpoolAdmPcpDetachNode SYSTEM "pgpool_adm_pcp_detach_node.sgml">
+<!ENTITY pgpoolAdmPcpProcInfo SYSTEM "pgpool_adm_pcp_proc_info.sgml">
index c37b3dd05d2a985eb5488d3a3071e7a0b5204018..0fc06c9d5959321f26c7afc041fa0b46cc3ffce3 100644 (file)
@@ -118,14 +118,11 @@ Pgpool-II documentation
    -->
    例を示します。
    <programlisting>
-$ pcp_proc_info -p 1100
-test postgres 2021-09-28 04:16:00 (4:56 before process restarting) 1 3 0 2021-09-28 04:16:16 2021-09-28 04:16:16 0 2021-09-28 04:16:33 1 30795 0 30750 0 Wait for connection
-test postgres 2021-09-28 04:16:00 (4:56 before process restarting) 1 3 0 2021-09-28 04:16:16 2021-09-28 04:16:16 0 2021-09-28 04:16:33 1 30796 0 30750 1 Wait for connection
-test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03 34 (4:26 before client disconnected)  1 30763 1 30751 0 Idle
-test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03 34 (4:26 before client disconnected)  1 30764 1 30751 1 Idle
-$ pcp_proc_info -p 11001 30751
-test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03 58 (4:02 before client disconnected)  1 30763 1 30751 0 Idle
-test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03 58 (4:02 before client disconnected)  1 30764 1 30751 1 Idle
+$ pcp_proc_info -p 11001
+test t-ishii 2025-06-24 10:53:35 0 3 0 2025-06-24 10:55:58 2025-06-24 10:55:59 0  1 1336703 1 1336537 0 Idle 0 192.168.10.11 39216
+test t-ishii 2025-06-24 10:53:35 0 3 0 2025-06-24 10:55:58 2025-06-24 10:55:59 0  1 1336704 1 1336537 1 Idle 1 192.168.10.11 39216
+test t-ishii 2025-06-24 10:53:35 (4:03 before process restarting) 1 3 0 2025-06-24 10:53:42 2025-06-24 10:53:42 0 2025-06-24 10:55:37 1 1336573 0 1336544 0 Wait for connection 0 192.168.10.11 39162
+test t-ishii 2025-06-24 10:53:35 (4:03 before process restarting) 1 3 0 2025-06-24 10:53:42 2025-06-24 10:53:42 0 2025-06-24 10:55:37 1 1336574 0 1336544 1 Wait for connection 0 192.168.10.11 39162
    </programlisting>
   </para>
   <para>
@@ -152,6 +149,9 @@ test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03
     15. PostgreSQL backend id
     16. process status
     17. 1 if backend is load balance node and frontend connected, 0 otherwise
+    18. client's host name
+    19. client's port number (not shown if Unix domain socket or localhost)
+    20. SQL statement last executed
     -->
     1. 接続先のデータベース名
     2. 接続先のユーザ名
@@ -170,6 +170,9 @@ test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03
     15. PostgreSQLバックエンドID
     16. プロセスの状態
   17. フロントエンドが接続中でバックエンドが負荷分散ノードならば1, そうでなければ0
+    18. クライアントのホスト名
+    19. クライアントのポート番号 (Unixドメインソケット、localhostでは表示されません)
+    20. 最後に実行したSQL文
    </literallayout>
   </para>
   <para>
@@ -190,76 +193,88 @@ test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03
   <programlisting>
 $ pcp_proc_info -p 11001 --verbose
 Database                  : test
-Username                  : postgres
-Start time                : 2021-09-28 04:16:00 (2:52 before process restarting)
-Client connection count   : 1
+Username                  : t-ishii
+Start time                : 2025-06-24 10:53:35
+Client connection count   : 0
 Major                     : 3
 Minor                     : 0
-Backend connection time   : 2021-09-28 04:16:16
-Client connection time    : 2021-09-28 04:16:16
+Backend connection time   : 2025-06-24 10:55:58
+Client connection time    : 2025-06-24 10:55:59
 Client idle duration      : 0
-Client disconnection time : 2021-09-28 04:16:33
+Client disconnection time : 
 Pool Counter              : 1
-Backend PID               : 30795
-Connected                 : 0
-PID                       : 30750
+Backend PID               : 1336703
+Connected                 : 1
+PID                       : 1336537
 Backend ID                : 0
-Status                    : Wait for connection
+Status                    : Idle
 Load balance node         : 0
+client_host               : 192.168.10.11
+client_port               : 39216
+statement                 : 
 
 Database                  : test
-Username                  : postgres
-Start time                : 2021-09-28 04:16:00 (2:52 before process restarting)
-Client connection count   : 1
+Username                  : t-ishii
+Start time                : 2025-06-24 10:53:35
+Client connection count   : 0
 Major                     : 3
 Minor                     : 0
-Backend connection time   : 2021-09-28 04:16:16
-Client connection time    : 2021-09-28 04:16:16
+Backend connection time   : 2025-06-24 10:55:58
+Client connection time    : 2025-06-24 10:55:59
 Client idle duration      : 0
-Client disconnection time : 2021-09-28 04:16:33
+Client disconnection time : 
 Pool Counter              : 1
-Backend PID               : 30796
-Connected                 : 0
-PID                       : 30750
+Backend PID               : 1336704
+Connected                 : 1
+PID                       : 1336537
 Backend ID                : 1
-Status                    : Wait for connection
-Load balance node         : 0
+Status                    : Idle
+Load balance node         : 1
+client_host               : 192.168.10.11
+client_port               : 39216
+statement                 : select 1;
 
 Database                  : test
-Username                  : kawamoto
-Start time                : 2021-09-28 04:16:00
-Client connection count   : 0
+Username                  : t-ishii
+Start time                : 2025-06-24 10:53:35 (4:33 before process restarting)
+Client connection count   : 1
 Major                     : 3
 Minor                     : 0
-Backend connection time   : 2021-09-28 04:16:03
-Client connection time    : 2021-09-28 04:16:03
-Client idle duration      : 158 (2:22 before client disconnected)
-Client disconnection time :
+Backend connection time   : 2025-06-24 10:53:42
+Client connection time    : 2025-06-24 10:53:42
+Client idle duration      : 0
+Client disconnection time : 2025-06-24 10:55:37
 Pool Counter              : 1
-Backend PID               : 30763
-Connected                 : 1
-PID                       : 30751
+Backend PID               : 1336573
+Connected                 : 0
+PID                       : 1336544
 Backend ID                : 0
-Status                    : Idle
-Load balance node         : 1
+Status                    : Wait for connection
+Load balance node         : 0
+client_host               : 192.168.10.11
+client_port               : 39162
+statement                 : DISCARD ALL
 
 Database                  : test
-Username                  : kawamoto
-Start time                : 2021-09-28 04:16:00
-Client connection count   : 0
+Username                  : t-ishii
+Start time                : 2025-06-24 10:53:35 (4:33 before process restarting)
+Client connection count   : 1
 Major                     : 3
 Minor                     : 0
-Backend connection time   : 2021-09-28 04:16:03
-Client connection time    : 2021-09-28 04:16:03
-Client idle duration      : 158 (2:22 before client disconnected)
-Client disconnection time :
+Backend connection time   : 2025-06-24 10:53:42
+Client connection time    : 2025-06-24 10:53:42
+Client idle duration      : 0
+Client disconnection time : 2025-06-24 10:55:37
 Pool Counter              : 1
-Backend PID               : 30764
-Connected                 : 1
-PID                       : 30751
+Backend PID               : 1336574
+Connected                 : 0
+PID                       : 1336544
 Backend ID                : 1
-Status                    : Idle
-Load balance node         : 1
+Status                    : Wait for connection
+Load balance node         : 0
+client_host               : 192.168.10.11
+client_port               : 39162
+statement                 : 
   </programlisting>
  </refsect1>
 
diff --git a/doc.ja/src/sgml/ref/pgpool_adm_pcp_proc_info.sgml b/doc.ja/src/sgml/ref/pgpool_adm_pcp_proc_info.sgml
new file mode 100644 (file)
index 0000000..a5a82e6
--- /dev/null
@@ -0,0 +1,257 @@
+<!--
+doc/src/sgml/ref/pgpool_adm_pcp_proc_info.sgml
+Pgpool-II documentation
+-->
+
+<refentry id="PGPOOL-ADM-PCP-PROC-INFO">
+ <indexterm zone="pgpool-adm-pcp-proc-info">
+  <primary>pgpool_adm_pcp_proc_info</primary>
+ </indexterm>
+
+ <refmeta>
+  <refentrytitle>pgpool_adm_pcp_proc_info</refentrytitle>
+  <manvolnum>3</manvolnum>
+  <refmiscinfo>pgpool_adm extension</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+  <refname>pgpool_adm_pcp_proc_info</refname>
+  <refpurpose>
+   <productname>Pgpool-II</productname>の子プロセスの情報を表示する関数
+   </refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+  <funcsynopsis>
+   <funcprototype>
+    <funcdef><function>pcp_proc_info</function> returns record</funcdef>
+    <paramdef>text <parameter>host</parameter></paramdef>
+    <paramdef>integer <parameter>port</parameter></paramdef>
+    <paramdef>text <parameter>username</parameter></paramdef>
+    <paramdef>text <parameter>password</parameter></paramdef>
+    <paramdef>out <parameter>database text</parameter></paramdef>
+    <paramdef>out <parameter>username text</parameter></paramdef>
+    <paramdef>out <parameter>start_time text</parameter></paramdef>
+    <paramdef>out <parameter>client_connection_count text</parameter></paramdef>
+    <paramdef>out <parameter>major text</parameter></paramdef>
+    <paramdef>out <parameter>minor text</parameter></paramdef>
+    <paramdef>out <parameter>backend_connection_time text</parameter></paramdef>
+    <paramdef>out <parameter>client_connection_time text</parameter></paramdef>
+    <paramdef>out <parameter>client_idle_duration text</parameter></paramdef>
+    <paramdef>out <parameter>client_disconnection_time text</parameter></paramdef>
+    <paramdef>out <parameter>pool_counter text</parameter></paramdef>
+    <paramdef>out <parameter>backend_pid text</parameter></paramdef>
+    <paramdef>out <parameter>connected text</parameter></paramdef>
+    <paramdef>out <parameter>pid text</parameter></paramdef>
+    <paramdef>out <parameter>backend_id text</parameter></paramdef>
+    <paramdef>out <parameter>status text</parameter></paramdef>
+    <paramdef>out <parameter>load_balance_node text</parameter></paramdef>
+    <paramdef>out <parameter>client_host text</parameter></paramdef>
+    <paramdef>out <parameter>client_port text</parameter></paramdef>
+    <paramdef>out <parameter>statement </parameter></paramdef>
+   </funcprototype>
+
+   <funcprototype>
+    <funcdef><function>pcp_proc_info</function> returns record</funcdef>
+    <paramdef>integer <parameter>node_id</parameter></paramdef>
+    <paramdef>text <parameter>pcp_server</parameter></paramdef>
+    <paramdef>out <parameter>database text</parameter></paramdef>
+    <paramdef>out <parameter>username text</parameter></paramdef>
+    <paramdef>out <parameter>start_time text</parameter></paramdef>
+    <paramdef>out <parameter>client_connection_count text</parameter></paramdef>
+    <paramdef>out <parameter>major text</parameter></paramdef>
+    <paramdef>out <parameter>minor text</parameter></paramdef>
+    <paramdef>out <parameter>backend_connection_time text</parameter></paramdef>
+    <paramdef>out <parameter>client_connection_time text</parameter></paramdef>
+    <paramdef>out <parameter>client_idle_duration text</parameter></paramdef>
+    <paramdef>out <parameter>client_disconnection_time text</parameter></paramdef>
+    <paramdef>out <parameter>pool_counter text</parameter></paramdef>
+    <paramdef>out <parameter>backend_pid text</parameter></paramdef>
+    <paramdef>out <parameter>connected text</parameter></paramdef>
+    <paramdef>out <parameter>pid text</parameter></paramdef>
+    <paramdef>out <parameter>backend_id text</parameter></paramdef>
+    <paramdef>out <parameter>status text</parameter></paramdef>
+    <paramdef>out <parameter>load_balance_node text</parameter></paramdef>
+    <paramdef>out <parameter>client_host text</parameter></paramdef>
+    <paramdef>out <parameter>client_port text</parameter></paramdef>
+    <paramdef>out <parameter>statement </parameter></paramdef>
+   </funcprototype>
+
+  </funcsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="R3-PCP-PROC-INFO-3">
+  <title>説明</title>
+  <para>
+   <function>pcp_proc_info</function>
+   <productname>Pgpool-II</productname>の子プロセスの情報を表示します。
+   表示される情報は<xref linkend="pcp-proc-info">と同じです。
+   すべてのデータ型は"text"です。
+  </para>
+ </refsect1>
+
+ <refsect1>
+  <title>引数</title>
+  <para>
+   <variablelist>
+
+    <varlistentry>
+     <term><replaceable class="parameter">pcp_server</replaceable></term>
+     <listitem>
+      <para>
+       pcpサーバの外部サーバ名
+      </para>
+     </listitem>
+    </varlistentry>
+
+    <varlistentry>
+     <term><option>他の引数</option></term>
+     <listitem>
+      <para>
+       <xref linkend="pcp-common-options">を参照ください。
+      </para>
+     </listitem>
+    </varlistentry>
+   </variablelist>
+  </para>
+ </refsect1>
+
+ <refsect1>
+  <title>使用例</title>
+  <para>
+   以下の例では、検索条件で"connected"列 = '1'を指定して、現在クライアントから接続のあるプロセス情報のみを表示しています。
+   このpsqlセッションでfrom pcp_proc_infoを呼び出していて、その情報は行1と2に表示されています。
+   select文はbackend_id = '0'(おそらくprimaryです)にのみ送信されているので、行1の"status"列は"Execute command"となっており、"statement"列には実行したselect文が表示されていますが、backend_id = '1'にはselect文が送信されていないので、行2のstatementは空白となっています。
+   </para>
+   <para>
+    別psqlセッションの情報は行2, 3に表示されています。
+    この例では"select 1"は"backend_id" = '1'(おそらくstandby)に送信されています。
+   <programlisting>
+test=# select * from pcp_proc_info(host => '', port => 11001, username => 't-ishii', password => 't-ishii') where connected = '1';
+-[ RECORD 1 ]-------------+----------------------------------------------------------------------------------------------------------------------------
+database                  | test
+username                  | t-ishii
+start_time                | 2025-02-22 20:56:08
+client_connection_count   | 0
+major                     | 3
+minor                     | 0
+backend_connection_time   | 2025-02-22 20:58:37
+client_connection_time    | 2025-02-22 20:58:37
+client_idle_duration      | 0
+client_disconnection_time | 
+pool_counter              | 1
+backend_pid               | 14750
+connected                 | 1
+pid                       | 14585
+backend_id                | 0
+status                    | Execute command
+load_balance_node         | 1
+client_host               | 127.0.0.1
+client_port               | 59120
+statement                 | select * from pcp_proc_info(host => '', port => 11001, username => 't-ishii', password => 't-ishii') where connected = '1';
+-[ RECORD 2 ]-------------+----------------------------------------------------------------------------------------------------------------------------
+database                  | test
+username                  | t-ishii
+start_time                | 2025-02-22 20:56:08
+client_connection_count   | 0
+major                     | 3
+minor                     | 0
+backend_connection_time   | 2025-02-22 20:58:37
+client_connection_time    | 2025-02-22 20:58:37
+client_idle_duration      | 0
+client_disconnection_time | 
+pool_counter              | 1
+backend_pid               | 14751
+connected                 | 1
+pid                       | 14585
+backend_id                | 1
+status                    | Execute command
+load_balance_node         | 0
+client_host               | 127.0.0.1
+client_port               | 59120
+statement                 | 
+-[ RECORD 3 ]-------------+----------------------------------------------------------------------------------------------------------------------------
+database                  | test
+username                  | t-ishii
+start_time                | 2025-02-22 20:56:08
+client_connection_count   | 0
+major                     | 3
+minor                     | 0
+backend_connection_time   | 2025-02-22 20:58:56
+client_connection_time    | 2025-02-22 20:58:56
+client_idle_duration      | 0
+client_disconnection_time | 
+pool_counter              | 1
+backend_pid               | 14767
+connected                 | 1
+pid                       | 14601
+backend_id                | 0
+status                    | Idle
+load_balance_node         | 0
+client_host               | 127.0.0.1
+client_port               | 54072
+statement                 | 
+-[ RECORD 4 ]-------------+----------------------------------------------------------------------------------------------------------------------------
+database                  | test
+username                  | t-ishii
+start_time                | 2025-02-22 20:56:08
+client_connection_count   | 0
+major                     | 3
+minor                     | 0
+backend_connection_time   | 2025-02-22 20:58:56
+client_connection_time    | 2025-02-22 20:58:56
+client_idle_duration      | 0
+client_disconnection_time | 
+pool_counter              | 1
+backend_pid               | 14768
+connected                 | 1
+pid                       | 14601
+backend_id                | 1
+status                    | Idle
+load_balance_node         | 1
+client_host               | 127.0.0.1
+client_port               | 54072
+statement                 | select 1;
+   </programlisting>
+  </para>
+  <para>
+   次の例では、"pgpool_query_info"という関数を登録し、pgpool_adm_pcp_proc_info、pgpool_adm_pcp_node_info、pgpool_adm_pcp_pool_statusを結合してpgpoolの子プロセスが最後に実行したクエリを、次の情報と一緒に表示します。
+   usernae, database, client host, client port, pgpool host, pgpool
+   port, pgpool pid, backend host, backend port, backend pid, backend
+   role and SQL statement。
+   <programlisting>
+create function pgpool_query_info(pcp_host text, pcp_port int, pgpool_username text, password text)
+returns table (username text, database text, client_host text, client_port text,
+pgpool_host text, pgpool_port text, pgpool_pid text,
+backend_host text, backend_port text, backend_pid text, backend_role text, statement text) as $$
+select p.username, p.database, p.client_host,p.client_port,
+$1 as pgpool_host, s.value as pgpool_port, p.pid as pgpool_pid,
+b.host as backend_host, b.port as backend_port, p.backend_pid as backend_pid,
+b.role as backend_role,
+p.statement
+from pcp_proc_info(host=> $1, port => $2, username => $3, password => $4) as p,
+pcp_node_info(node_id=>p.backend_id::int, host => $1, port => $2,
+username => $3, password => $4) as b,
+pcp_pool_status(host=> $1, port => $2, username => $3, password => $4) as s
+where p.connected = 1::text and p.statement != '' and
+p.statement !~ 'pcp_proc_info' and p.statement !~ 'pgpool_query_info' and
+s.item = 'port'
+$$
+language SQL;
+CREATE FUNCTION
+
+select * from pgpool_query_info('192.168.10.11', 11001, 't-ishii', 't-ishii');
+ username | database |  client_host  | client_port |  pgpool_host  | pgpool_port | pgpool_pid | backend_host | backend_port | backend_pid | backend_role | statement 
+----------+----------+---------------+-------------+---------------+-------------+------------+--------------+--------------+-------------+--------------+-----------
+ t-ishii  | test     | 192.168.10.11 | 60542       | 192.168.10.11 | 11000       | 1356156    | localhost    | 11002        | 1356240     | Primary      | select 2;
+ t-ishii  | test     | 192.168.10.11 | 43856       | 192.168.10.11 | 11000       | 1356167    | localhost    | 11003        | 1356255     | Standby      | select 1;
+(2 rows)
+   </programlisting>
+  </para>
+  <para>
+   表示データの詳細に関しては<xref linkend="pcp-proc-info">をご覧ください。
+  </para>
+
+ </refsect1>
+
+</refentry>
index 7fa142cb57ebca2a44bb7b467f0141cd830327c2..3fd3955fb84f1e4146d0932800f61b5f955850a8 100644 (file)
@@ -46,9 +46,9 @@
   </para>
   <para>
    <!--
-   It has 17 columns:
+   It has 20 columns:
    -->
-   17のカラムがあります。
+   20のカラムがあります。
    <itemizedlist>
     <listitem>
      <para>
      </para>
     </listitem>
 
+    <listitem>
+     <para>
+      <!--
+      <literal>client_host</literal> is client's host name or IP address.
+      -->
+      <literal>client_host</literal>はクライアントのホスト名またはIPアドレスです。
+     </para>
+    </listitem>
+
+    <listitem>
+     <para>
+      <!--
+      <literal>client_port</literal> is client's port number.
+      -->
+      <literal>client_port</literal>はクライアントのポート番号です(Unixドメインソケット、localhostでは表示されません)。
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+      <!--
+      <literal>statement</literal> is the SQL statement last executed.
+      -->
+      <literal>statement</literal>は最後に実行したSQL文です。
+     </para>
+    </listitem>
+
    </itemizedlist>
   </para>
   <para>
      ここでは例を示します。
      <programlisting>
 test=# show pool_pools;
- pool_pid |     start_time      | client_connection_count | pool_id | backend_id | database | username | backend_connection_time | client_connection_time | client_disconnection_time | client_idle_duration | majorversion | minorversion | pool_counter | pool_backendpid | pool_connected |       status        | load_balance_node 
-----------+---------------------+-------------------------+---------+------------+----------+----------+-------------------------+------------------------+---------------------------+----------------------+--------------+--------------+--------------+-----------------+----------------+---------------------+-------------------
- 641408   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 0       | 0          | test     | t-ishii  | 2023-07-10 13:20:56     | 2023-07-10 13:20:56    |                           | 0                    | 3            | 0            | 1            | 641448          | 1              | Idle                | 1
- 641412   | 2023-07-10 13:20:51 | 0                       | 0       | 1          | test     | t-ishii  | 2023-07-10 13:20:56     | 2023-07-10 13:20:56    |                           | 0                    | 3            | 0            | 1            | 641449          | 1              | Idle                | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 0       | 0          | test     | t-ishii  | 2023-07-10 13:21:04     | 2023-07-10 13:21:04    |                           | 0                    | 3            | 0            | 1            | 641455          | 1              | Execute command     | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 0       | 1          | test     | t-ishii  | 2023-07-10 13:21:04     | 2023-07-10 13:21:04    |                           | 0                    | 3            | 0            | 1            | 641456          | 1              | Execute command     | 1
- 641415   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Execute command     | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Execute command     | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Execute command     | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Execute command     | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Execute command     | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Execute command     | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
-(128 rows)
+ pool_pid |                      start_time                      | client_connection_count | pool_id | backend_id | database | username | backend_connection_time | client_connection_time | client_disconnection_time | client_idle_duration | majorversion | minorversion | pool_counter | pool_backendpid | pool_connected |       status        | load_balance_node |  client_host  | client_port |  statement  
+----------+------------------------------------------------------+-------------------------+---------+------------+----------+----------+-------------------------+------------------------+---------------------------+----------------------+--------------+--------------+--------------+-----------------+----------------+---------------------+-------------------+---------------+-------------+-------------
+[snip]
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 0       | 0          | test     | t-ishii  | 2025-06-24 10:55:58     | 2025-06-24 10:55:59    |                           | 0                    | 3            | 0            | 1            | 1336703         | 1              | Idle                | 0                 | 192.168.10.11 | 39216       | 
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 0       | 1          | test     | t-ishii  | 2025-06-24 10:55:58     | 2025-06-24 10:55:59    |                           | 0                    | 3            | 0            | 1            | 1336704         | 1              | Idle                | 1                 | 192.168.10.11 | 39216       | select 1;
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0                 | 192.168.10.11 | 39216       | 
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0                 | 192.168.10.11 | 39216       | select 1;
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0                 | 192.168.10.11 | 39216       | 
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0                 | 192.168.10.11 | 39216       | select 1;
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0                 | 192.168.10.11 | 39216       | 
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0                 | 192.168.10.11 | 39216       | select 1;
+[snip]
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 0       | 0          | test     | t-ishii  | 2025-06-24 10:53:42     | 2025-06-24 10:53:42    | 2025-06-24 10:55:37       | 0                    | 3            | 0            | 1            | 1336573         | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | DISCARD ALL
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 0       | 1          | test     | t-ishii  | 2025-06-24 10:53:42     | 2025-06-24 10:53:42    | 2025-06-24 10:55:37       | 0                    | 3            | 0            | 1            | 1336574         | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | 
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | DISCARD ALL
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | 
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | DISCARD ALL
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | 
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | DISCARD ALL
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | 
+[snip]
+(256 rows)
      </programlisting>
 
   </para>
index adfe8e1e18f8c8474e158c951188fd5ac8244b2a..41055616729de641588fab62f4e11c6b3ddf1b5c 100644 (file)
@@ -360,6 +360,7 @@ $ psql ...
   &pgpoolAdmPcpNodeCount
   &pgpoolAdmPcpAttachNode
   &pgpoolAdmPcpDetachNode
+  &pgpoolAdmPcpProcInfo
 
  </reference>
 
index 89be154bc1d2e5ab293f0d8d8dc680a8332fce58..7127cb553ec5411ee4502a71eb74f24b9eff5944 100644 (file)
@@ -45,3 +45,4 @@ Complete list of usable sgml source files in this directory.
 <!ENTITY pgpoolAdmPcpNodeCount SYSTEM "pgpool_adm_pcp_node_count.sgml">
 <!ENTITY pgpoolAdmPcpAttachNode SYSTEM "pgpool_adm_pcp_attach_node.sgml">
 <!ENTITY pgpoolAdmPcpDetachNode SYSTEM "pgpool_adm_pcp_detach_node.sgml">
+<!ENTITY pgpoolAdmPcpProcInfo SYSTEM "pgpool_adm_pcp_proc_info.sgml">
index df61d551b431af17139fbbc008adcb630e541d9c..9a433da4fd1dd84a23bfbb65adc5bd8385b92191 100644 (file)
@@ -85,14 +85,11 @@ Pgpool-II documentation
   <para>
    Here is an example output:
    <programlisting>
-$ pcp_proc_info -p 1100
-test postgres 2021-09-28 04:16:00 (4:56 before process restarting) 1 3 0 2021-09-28 04:16:16 2021-09-28 04:16:16 0 2021-09-28 04:16:33 1 30795 0 30750 0 Wait for connection
-test postgres 2021-09-28 04:16:00 (4:56 before process restarting) 1 3 0 2021-09-28 04:16:16 2021-09-28 04:16:16 0 2021-09-28 04:16:33 1 30796 0 30750 1 Wait for connection
-test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03 34 (4:26 before client disconnected)  1 30763 1 30751 0 Idle
-test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03 34 (4:26 before client disconnected)  1 30764 1 30751 1 Idle
-$ pcp_proc_info -p 11001 30751
-test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03 58 (4:02 before client disconnected)  1 30763 1 30751 0 Idle
-test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03 58 (4:02 before client disconnected)  1 30764 1 30751 1 Idle
+$ pcp_proc_info -p 11001
+test t-ishii 2025-06-24 10:53:35 0 3 0 2025-06-24 10:55:58 2025-06-24 10:55:59 0  1 1336703 1 1336537 0 Idle 0 192.168.10.11 39216
+test t-ishii 2025-06-24 10:53:35 0 3 0 2025-06-24 10:55:58 2025-06-24 10:55:59 0  1 1336704 1 1336537 1 Idle 1 192.168.10.11 39216
+test t-ishii 2025-06-24 10:53:35 (4:03 before process restarting) 1 3 0 2025-06-24 10:53:42 2025-06-24 10:53:42 0 2025-06-24 10:55:37 1 1336573 0 1336544 0 Wait for connection 0 192.168.10.11 39162
+test t-ishii 2025-06-24 10:53:35 (4:03 before process restarting) 1 3 0 2025-06-24 10:53:42 2025-06-24 10:53:42 0 2025-06-24 10:55:37 1 1336574 0 1336544 1 Wait for connection 0 192.168.10.11 39162
    </programlisting>
   </para>
   <para>
@@ -115,6 +112,9 @@ test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03
     15. PostgreSQL backend id
     16. process status
     17. 1 if backend is load balance node and frontend connected, 0 otherwise
+    18. client's host name
+    19. client's port number (not shown if Unix domain socket or localhost)
+    20. SQL statement last executed
    </literallayout>
   </para>
   <para>
@@ -129,76 +129,88 @@ test kawamoto 2021-09-28 04:16:00 0 3 0 2021-09-28 04:16:03 2021-09-28 04:16:03
   <programlisting>
 $ pcp_proc_info -p 11001 --verbose
 Database                  : test
-Username                  : postgres
-Start time                : 2021-09-28 04:16:00 (2:52 before process restarting)
-Client connection count   : 1
+Username                  : t-ishii
+Start time                : 2025-06-24 10:53:35
+Client connection count   : 0
 Major                     : 3
 Minor                     : 0
-Backend connection time   : 2021-09-28 04:16:16
-Client connection time    : 2021-09-28 04:16:16
+Backend connection time   : 2025-06-24 10:55:58
+Client connection time    : 2025-06-24 10:55:59
 Client idle duration      : 0
-Client disconnection time : 2021-09-28 04:16:33
+Client disconnection time : 
 Pool Counter              : 1
-Backend PID               : 30795
-Connected                 : 0
-PID                       : 30750
+Backend PID               : 1336703
+Connected                 : 1
+PID                       : 1336537
 Backend ID                : 0
-Status                    : Wait for connection
+Status                    : Idle
 Load balance node         : 0
+client_host               : 192.168.10.11
+client_port               : 39216
+statement                 : 
 
 Database                  : test
-Username                  : postgres
-Start time                : 2021-09-28 04:16:00 (2:52 before process restarting)
-Client connection count   : 1
+Username                  : t-ishii
+Start time                : 2025-06-24 10:53:35
+Client connection count   : 0
 Major                     : 3
 Minor                     : 0
-Backend connection time   : 2021-09-28 04:16:16
-Client connection time    : 2021-09-28 04:16:16
+Backend connection time   : 2025-06-24 10:55:58
+Client connection time    : 2025-06-24 10:55:59
 Client idle duration      : 0
-Client disconnection time : 2021-09-28 04:16:33
+Client disconnection time : 
 Pool Counter              : 1
-Backend PID               : 30796
-Connected                 : 0
-PID                       : 30750
+Backend PID               : 1336704
+Connected                 : 1
+PID                       : 1336537
 Backend ID                : 1
-Status                    : Wait for connection
-Load balance node         : 0
+Status                    : Idle
+Load balance node         : 1
+client_host               : 192.168.10.11
+client_port               : 39216
+statement                 : select 1;
 
 Database                  : test
-Username                  : kawamoto
-Start time                : 2021-09-28 04:16:00
-Client connection count   : 0
+Username                  : t-ishii
+Start time                : 2025-06-24 10:53:35 (4:33 before process restarting)
+Client connection count   : 1
 Major                     : 3
 Minor                     : 0
-Backend connection time   : 2021-09-28 04:16:03
-Client connection time    : 2021-09-28 04:16:03
-Client idle duration      : 158 (2:22 before client disconnected)
-Client disconnection time :
+Backend connection time   : 2025-06-24 10:53:42
+Client connection time    : 2025-06-24 10:53:42
+Client idle duration      : 0
+Client disconnection time : 2025-06-24 10:55:37
 Pool Counter              : 1
-Backend PID               : 30763
-Connected                 : 1
-PID                       : 30751
+Backend PID               : 1336573
+Connected                 : 0
+PID                       : 1336544
 Backend ID                : 0
-Status                    : Idle
-Load balance node         : 1
+Status                    : Wait for connection
+Load balance node         : 0
+client_host               : 192.168.10.11
+client_port               : 39162
+statement                 : DISCARD ALL
 
 Database                  : test
-Username                  : kawamoto
-Start time                : 2021-09-28 04:16:00
-Client connection count   : 0
+Username                  : t-ishii
+Start time                : 2025-06-24 10:53:35 (4:33 before process restarting)
+Client connection count   : 1
 Major                     : 3
 Minor                     : 0
-Backend connection time   : 2021-09-28 04:16:03
-Client connection time    : 2021-09-28 04:16:03
-Client idle duration      : 158 (2:22 before client disconnected)
-Client disconnection time :
+Backend connection time   : 2025-06-24 10:53:42
+Client connection time    : 2025-06-24 10:53:42
+Client idle duration      : 0
+Client disconnection time : 2025-06-24 10:55:37
 Pool Counter              : 1
-Backend PID               : 30764
-Connected                 : 1
-PID                       : 30751
+Backend PID               : 1336574
+Connected                 : 0
+PID                       : 1336544
 Backend ID                : 1
-Status                    : Idle
-Load balance node         : 1
+Status                    : Wait for connection
+Load balance node         : 0
+client_host               : 192.168.10.11
+client_port               : 39162
+statement                 : 
   </programlisting>
  </refsect1>
 
diff --git a/doc/src/sgml/ref/pgpool_adm_pcp_proc_info.sgml b/doc/src/sgml/ref/pgpool_adm_pcp_proc_info.sgml
new file mode 100644 (file)
index 0000000..4346e68
--- /dev/null
@@ -0,0 +1,271 @@
+<!--
+doc/src/sgml/ref/pgpool_adm_pcp_proc_info.sgml
+Pgpool-II documentation
+-->
+
+<refentry id="PGPOOL-ADM-PCP-PROC-INFO">
+ <indexterm zone="pgpool-adm-pcp-proc-info">
+  <primary>pgpool_adm_pcp_proc_info</primary>
+ </indexterm>
+
+ <refmeta>
+  <refentrytitle>pgpool_adm_pcp_proc_info</refentrytitle>
+  <manvolnum>3</manvolnum>
+  <refmiscinfo>pgpool_adm extension</refmiscinfo>
+ </refmeta>
+
+ <refnamediv>
+  <refname>pgpool_adm_pcp_proc_info</refname>
+  <refpurpose>
+   a function to display the information
+   on <productname>Pgpool-II</productname> child process
+   </refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+  <funcsynopsis>
+   <funcprototype>
+    <funcdef><function>pcp_proc_info</function> returns record</funcdef>
+    <paramdef>text <parameter>host</parameter></paramdef>
+    <paramdef>integer <parameter>port</parameter></paramdef>
+    <paramdef>text <parameter>username</parameter></paramdef>
+    <paramdef>text <parameter>password</parameter></paramdef>
+    <paramdef>out <parameter>database text</parameter></paramdef>
+    <paramdef>out <parameter>username text</parameter></paramdef>
+    <paramdef>out <parameter>start_time text</parameter></paramdef>
+    <paramdef>out <parameter>client_connection_count text</parameter></paramdef>
+    <paramdef>out <parameter>major text</parameter></paramdef>
+    <paramdef>out <parameter>minor text</parameter></paramdef>
+    <paramdef>out <parameter>backend_connection_time text</parameter></paramdef>
+    <paramdef>out <parameter>client_connection_time text</parameter></paramdef>
+    <paramdef>out <parameter>client_idle_duration text</parameter></paramdef>
+    <paramdef>out <parameter>client_disconnection_time text</parameter></paramdef>
+    <paramdef>out <parameter>pool_counter text</parameter></paramdef>
+    <paramdef>out <parameter>backend_pid text</parameter></paramdef>
+    <paramdef>out <parameter>connected text</parameter></paramdef>
+    <paramdef>out <parameter>pid text</parameter></paramdef>
+    <paramdef>out <parameter>backend_id text</parameter></paramdef>
+    <paramdef>out <parameter>status text</parameter></paramdef>
+    <paramdef>out <parameter>load_balance_node text</parameter></paramdef>
+    <paramdef>out <parameter>client_host text</parameter></paramdef>
+    <paramdef>out <parameter>client_port text</parameter></paramdef>
+    <paramdef>out <parameter>statement </parameter></paramdef>
+   </funcprototype>
+
+   <funcprototype>
+    <funcdef><function>pcp_proc_info</function> returns record</funcdef>
+    <paramdef>integer <parameter>node_id</parameter></paramdef>
+    <paramdef>text <parameter>pcp_server</parameter></paramdef>
+    <paramdef>out <parameter>database text</parameter></paramdef>
+    <paramdef>out <parameter>username text</parameter></paramdef>
+    <paramdef>out <parameter>start_time text</parameter></paramdef>
+    <paramdef>out <parameter>client_connection_count text</parameter></paramdef>
+    <paramdef>out <parameter>major text</parameter></paramdef>
+    <paramdef>out <parameter>minor text</parameter></paramdef>
+    <paramdef>out <parameter>backend_connection_time text</parameter></paramdef>
+    <paramdef>out <parameter>client_connection_time text</parameter></paramdef>
+    <paramdef>out <parameter>client_idle_duration text</parameter></paramdef>
+    <paramdef>out <parameter>client_disconnection_time text</parameter></paramdef>
+    <paramdef>out <parameter>pool_counter text</parameter></paramdef>
+    <paramdef>out <parameter>backend_pid text</parameter></paramdef>
+    <paramdef>out <parameter>connected text</parameter></paramdef>
+    <paramdef>out <parameter>pid text</parameter></paramdef>
+    <paramdef>out <parameter>backend_id text</parameter></paramdef>
+    <paramdef>out <parameter>status text</parameter></paramdef>
+    <paramdef>out <parameter>load_balance_node text</parameter></paramdef>
+    <paramdef>out <parameter>client_host text</parameter></paramdef>
+    <paramdef>out <parameter>client_port text</parameter></paramdef>
+    <paramdef>out <parameter>statement </parameter></paramdef>
+   </funcprototype>
+
+  </funcsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="R3-PCP-PROC-INFO-3">
+  <title>Description</title>
+  <para>
+   <function>pcp_proc_info</function>
+   displays the information
+   on <productname>Pgpool-II</productname> child process.
+   All the information is same as <xref linkend="pcp-proc-info">.
+   All the data types are "text".
+  </para>
+ </refsect1>
+
+ <refsect1>
+  <title>Arguments</title>
+  <para>
+   <variablelist>
+
+    <varlistentry>
+     <term><replaceable class="parameter">pcp_server</replaceable></term>
+     <listitem>
+      <para>
+       The foreign server name for pcp server.
+      </para>
+     </listitem>
+    </varlistentry>
+
+    <varlistentry>
+     <term><option>Other arguments </option></term>
+     <listitem>
+      <para>
+       See <xref linkend="pcp-common-options">.
+      </para>
+     </listitem>
+    </varlistentry>
+   </variablelist>
+  </para>
+ </refsect1>
+
+ <refsect1>
+  <title>Example</title>
+  <para>
+   In the example below a search condition "connected" column = '1' is
+   specified, and only the information on the process connected from
+   clients. In this psql session pcp_proc_info is called in the from
+   clause, and the information is shown on row 1 and 2. The select
+   statement is sent to only backend_id = '0' (which is probably the
+   primary), and the "status" column of the row 1 is "Execute
+   command", the "statement" column shows the select statement which
+   was executed. On the other hand the "statement" column of the row 2
+   is empty, since the select statement is was not sent to backend_id
+   = '1'.
+  </para>
+  <para>
+   The information on the other psql session is shown on the row 2 and
+   3.  In this example "select 1" was sent to "backend_id" = '1'
+   (probably standby).
+   <programlisting>
+test=# select * from pcp_proc_info(host => '', port => 11001, username => 't-ishii', password => 't-ishii') where connected = '1';
+-[ RECORD 1 ]-------------+----------------------------------------------------------------------------------------------------------------------------
+database                  | test
+username                  | t-ishii
+start_time                | 2025-02-22 20:56:08
+client_connection_count   | 0
+major                     | 3
+minor                     | 0
+backend_connection_time   | 2025-02-22 20:58:37
+client_connection_time    | 2025-02-22 20:58:37
+client_idle_duration      | 0
+client_disconnection_time | 
+pool_counter              | 1
+backend_pid               | 14750
+connected                 | 1
+pid                       | 14585
+backend_id                | 0
+status                    | Execute command
+load_balance_node         | 1
+client_host               | 127.0.0.1
+client_port               | 59120
+statement                 | select * from pcp_proc_info(host => '', port => 11001, username => 't-ishii', password => 't-ishii') where connected = '1';
+-[ RECORD 2 ]-------------+----------------------------------------------------------------------------------------------------------------------------
+database                  | test
+username                  | t-ishii
+start_time                | 2025-02-22 20:56:08
+client_connection_count   | 0
+major                     | 3
+minor                     | 0
+backend_connection_time   | 2025-02-22 20:58:37
+client_connection_time    | 2025-02-22 20:58:37
+client_idle_duration      | 0
+client_disconnection_time | 
+pool_counter              | 1
+backend_pid               | 14751
+connected                 | 1
+pid                       | 14585
+backend_id                | 1
+status                    | Execute command
+load_balance_node         | 0
+client_host               | 127.0.0.1
+client_port               | 59120
+statement                 | 
+-[ RECORD 3 ]-------------+----------------------------------------------------------------------------------------------------------------------------
+database                  | test
+username                  | t-ishii
+start_time                | 2025-02-22 20:56:08
+client_connection_count   | 0
+major                     | 3
+minor                     | 0
+backend_connection_time   | 2025-02-22 20:58:56
+client_connection_time    | 2025-02-22 20:58:56
+client_idle_duration      | 0
+client_disconnection_time | 
+pool_counter              | 1
+backend_pid               | 14767
+connected                 | 1
+pid                       | 14601
+backend_id                | 0
+status                    | Idle
+load_balance_node         | 0
+client_host               | 127.0.0.1
+client_port               | 54072
+statement                 | 
+-[ RECORD 4 ]-------------+----------------------------------------------------------------------------------------------------------------------------
+database                  | test
+username                  | t-ishii
+start_time                | 2025-02-22 20:56:08
+client_connection_count   | 0
+major                     | 3
+minor                     | 0
+backend_connection_time   | 2025-02-22 20:58:56
+client_connection_time    | 2025-02-22 20:58:56
+client_idle_duration      | 0
+client_disconnection_time | 
+pool_counter              | 1
+backend_pid               | 14768
+connected                 | 1
+pid                       | 14601
+backend_id                | 1
+status                    | Idle
+load_balance_node         | 1
+client_host               | 127.0.0.1
+client_port               | 54072
+statement                 | select 1;
+   </programlisting>
+  </para>
+  <para>
+   In the example below we define a function called
+   "pgpool_query_info" which shows last executed query in each pgpool
+   child process along with associated information: usernae, database,
+   client host, client port, pgpool host, pgpool port, pgpool pid,
+   backend host, backend port, backend pid, backend role and SQL
+   statement, by joining pgpool_adm_pcp_proc_info,
+   pgpool_adm_pcp_node_info and pgpool_adm_pcp_pool_status.
+   <programlisting>
+create function pgpool_query_info(pcp_host text, pcp_port int, pgpool_username text, password text)
+returns table (username text, database text, client_host text, client_port text,
+pgpool_host text, pgpool_port text, pgpool_pid text,
+backend_host text, backend_port text, backend_pid text, backend_role text, statement text) as $$
+select p.username, p.database, p.client_host,p.client_port,
+$1 as pgpool_host, s.value as pgpool_port, p.pid as pgpool_pid,
+b.host as backend_host, b.port as backend_port, p.backend_pid as backend_pid,
+b.role as backend_role,
+p.statement
+from pcp_proc_info(host=> $1, port => $2, username => $3, password => $4) as p,
+pcp_node_info(node_id=>p.backend_id::int, host => $1, port => $2,
+username => $3, password => $4) as b,
+pcp_pool_status(host=> $1, port => $2, username => $3, password => $4) as s
+where p.connected = 1::text and p.statement != '' and
+p.statement !~ 'pcp_proc_info' and p.statement !~ 'pgpool_query_info' and
+s.item = 'port'
+$$
+language SQL;
+CREATE FUNCTION
+
+select * from pgpool_query_info('192.168.10.11', 11001, 't-ishii', 't-ishii');
+ username | database |  client_host  | client_port |  pgpool_host  | pgpool_port | pgpool_pid | backend_host | backend_port | backend_pid | backend_role | statement 
+----------+----------+---------------+-------------+---------------+-------------+------------+--------------+--------------+-------------+--------------+-----------
+ t-ishii  | test     | 192.168.10.11 | 60542       | 192.168.10.11 | 11000       | 1356156    | localhost    | 11002        | 1356240     | Primary      | select 2;
+ t-ishii  | test     | 192.168.10.11 | 43856       | 192.168.10.11 | 11000       | 1356167    | localhost    | 11003        | 1356255     | Standby      | select 1;
+(2 rows)
+   </programlisting>
+  </para>
+  <para>
+   See <xref linkend="pcp-proc-info"> for more information on each
+   shown data.
+  </para>
+
+ </refsect1>
+
+</refentry>
index 07a604e590cec204823d5da6638a610e59ca74d8..6dad9279bee59d49a791b2b399a6aee307893ddd 100644 (file)
@@ -37,7 +37,7 @@
    <productname>Pgpool-II</productname>
   </para>
   <para>
-   It has 17 columns:
+   It has 20 columns:
    <itemizedlist>
     <listitem>
      <para>
       frontend is currently using this backend and the backend is load balance node.
      </para>
     </listitem>
+    <listitem>
+     <para>
+      <literal>client_host</literal> is client's host name or IP address.
+     </para>
+    </listitem>
+
+    <listitem>
+     <para>
+      <literal>client_port</literal> is client's port number.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+      <literal>statement</literal> is the SQL statement last executed.
+     </para>
+    </listitem>
+
    </itemizedlist>
   </para>
   <para>
      number_of_backends lines.  Here is an example session:
      <programlisting>
 test=# show pool_pools;
- pool_pid |     start_time      | client_connection_count | pool_id | backend_id | database | username | backend_connection_time | client_connection_time | client_disconnection_time | client_idle_duration | majorversion | minorversion | pool_counter | pool_backendpid | pool_connected |       status        | load_balance_node 
-----------+---------------------+-------------------------+---------+------------+----------+----------+-------------------------+------------------------+---------------------------+----------------------+--------------+--------------+--------------+-----------------+----------------+---------------------+-------------------
- 641408   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641408   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641409   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641410   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641411   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 0       | 0          | test     | t-ishii  | 2023-07-10 13:20:56     | 2023-07-10 13:20:56    |                           | 0                    | 3            | 0            | 1            | 641448          | 1              | Idle                | 1
- 641412   | 2023-07-10 13:20:51 | 0                       | 0       | 1          | test     | t-ishii  | 2023-07-10 13:20:56     | 2023-07-10 13:20:56    |                           | 0                    | 3            | 0            | 1            | 641449          | 1              | Idle                | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0
- 641412   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641413   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641414   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 0       | 0          | test     | t-ishii  | 2023-07-10 13:21:04     | 2023-07-10 13:21:04    |                           | 0                    | 3            | 0            | 1            | 641455          | 1              | Execute command     | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 0       | 1          | test     | t-ishii  | 2023-07-10 13:21:04     | 2023-07-10 13:21:04    |                           | 0                    | 3            | 0            | 1            | 641456          | 1              | Execute command     | 1
- 641415   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Execute command     | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Execute command     | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Execute command     | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Execute command     | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Execute command     | 0
- 641415   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Execute command     | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641416   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641417   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641418   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641419   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641420   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641421   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641422   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 0       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 0       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
- 641423   | 2023-07-10 13:20:51 | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0
-(128 rows)
+ pool_pid |                      start_time                      | client_connection_count | pool_id | backend_id | database | username | backend_connection_time | client_connection_time | client_disconnection_time | client_idle_duration | majorversion | minorversion | pool_counter | pool_backendpid | pool_connected |       status        | load_balance_node |  client_host  | client_port |  statement  
+----------+------------------------------------------------------+-------------------------+---------+------------+----------+----------+-------------------------+------------------------+---------------------------+----------------------+--------------+--------------+--------------+-----------------+----------------+---------------------+-------------------+---------------+-------------+-------------
+[snip]
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 0       | 0          | test     | t-ishii  | 2025-06-24 10:55:58     | 2025-06-24 10:55:59    |                           | 0                    | 3            | 0            | 1            | 1336703         | 1              | Idle                | 0                 | 192.168.10.11 | 39216       | 
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 0       | 1          | test     | t-ishii  | 2025-06-24 10:55:58     | 2025-06-24 10:55:59    |                           | 0                    | 3            | 0            | 1            | 1336704         | 1              | Idle                | 1                 | 192.168.10.11 | 39216       | select 1;
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0                 | 192.168.10.11 | 39216       | 
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0                 | 192.168.10.11 | 39216       | select 1;
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0                 | 192.168.10.11 | 39216       | 
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0                 | 192.168.10.11 | 39216       | select 1;
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0                 | 192.168.10.11 | 39216       | 
+ 1336537  | 2025-06-24 10:53:35                                  | 0                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Idle                | 0                 | 192.168.10.11 | 39216       | select 1;
+[snip]
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 0       | 0          | test     | t-ishii  | 2025-06-24 10:53:42     | 2025-06-24 10:53:42    | 2025-06-24 10:55:37       | 0                    | 3            | 0            | 1            | 1336573         | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | DISCARD ALL
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 0       | 1          | test     | t-ishii  | 2025-06-24 10:53:42     | 2025-06-24 10:53:42    | 2025-06-24 10:55:37       | 0                    | 3            | 0            | 1            | 1336574         | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | 
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 1       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | DISCARD ALL
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 1       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | 
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 2       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | DISCARD ALL
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 2       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | 
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 3       | 0          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | DISCARD ALL
+ 1336544  | 2025-06-24 10:53:35 (0:23 before process restarting) | 1                       | 3       | 1          |          |          |                         |                        |                           | 0                    | 0            | 0            | 0            | 0               | 0              | Wait for connection | 0                 | 192.168.10.11 | 39162       | 
+[snip]
+(256 rows)
      </programlisting>
 
   </para>
index 2b2db4947cc8404b038cc71b036f50da210d6da4..6d2ea97ce3b91042278c9441eb2d68dc1c5462a3 100644 (file)
   &pgpoolAdmPcpNodeCount
   &pgpoolAdmPcpAttachNode
   &pgpoolAdmPcpDetachNode
+  &pgpoolAdmPcpProcInfo
 
  </reference>
 
index 56f4121c4ddd990ae72e111a18c7e96d97750387..4678ab53055e828a37b6477801640aff17ff84a7 100644 (file)
@@ -157,6 +157,8 @@ EXTRA_DIST = sample/pgpool.pam \
                sql/pgpool_adm/pgpool_adm--1.3--1.4.sql \
                sql/pgpool_adm/pgpool_adm--1.5.sql \
                sql/pgpool_adm/pgpool_adm--1.4--1.5.sql \
+               sql/pgpool_adm/pgpool_adm--1.6.sql \
+               sql/pgpool_adm/pgpool_adm--1.5--1.6.sql \
                sql/pgpool_adm/Makefile \
                test/parser/expected/copy.out test/parser/expected/create.out \
                test/parser/expected/cursor.out test/parser/expected/delete.out \
index 232dc8143033f67aa76e517c8c614eb5b8aa1896..d79ddc1568d28c978fd82089e5cbd2d0feab9d96 100644 (file)
@@ -4,7 +4,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2024     PgPool Global Development Group
+ * Copyright (c) 2003-2025     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -26,6 +26,8 @@
 #ifndef LIBPCP_EXT_H
 #define LIBPCP_EXT_H
 
+#include <netdb.h>
+
 #include <signal.h>
 #include <stdio.h>
 
@@ -33,6 +35,9 @@
 #include "parser/pg_config_manual.h"
 #endif
 
+/* returns number of bits in the data type or variable */
+#define        BITS_PER_TYPE(type)     (sizeof(type) * BITS_PER_BYTE)
+
 /*
  * startup packet definitions (v2) stolen from PostgreSQL
  */
@@ -170,6 +175,9 @@ typedef struct
  * process information
  * This object put on shared memory.
  */
+
+#define MAXSTMTLEN     1024
+
 typedef struct
 {
        pid_t           pid;                    /* OS's process id */
@@ -180,6 +188,10 @@ typedef struct
                                                                                 * this process */
        int                     client_connection_count;        /* how many times clients used this process */
        ProcessStatus   status;
+       char    client_host[NI_MAXHOST];        /* client host. Only valid if status != WAIT_FOR_CONNECT */
+       char    client_port[NI_MAXSERV];        /* client port. Only valid if status != WAIT_FOR_CONNECT */
+       char    statement[MAXSTMTLEN];  /* the last statement sent to backend */
+       uint64  node_ids[2];                    /* "statement" is sent to the node id (bitmap) */
        bool            need_to_restart;        /* If non 0, exit this child process as
                                                                         * soon as current session ends. Typical
                                                                         * case this flag being set is failback a
@@ -266,6 +278,9 @@ typedef struct
        char            pool_connected[POOLCONFIG_MAXCOUNTLEN + 1];
        char            status[POOLCONFIG_MAXPROCESSSTATUSLEN + 1];
        char            load_balance_node[POOLCONFIG_MAXPROCESSSTATUSLEN + 1];
+       char            client_host[NI_MAXHOST];
+       char            client_port[NI_MAXSERV];
+       char            statement[MAXSTMTLEN];
 }                      POOL_REPORT_POOLS;
 
 /* version struct */
index fc2aa31d89fd66133cbc97124931d6563671fa99..663dcc9844c2dba0d2d06329753487e9e7befbbd 100644 (file)
@@ -6,7 +6,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2024     PgPool Global Development Group
+ * Copyright (c) 2003-2025     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -213,4 +213,8 @@ extern void NoticeResponse(POOL_CONNECTION * frontend,
 extern char per_node_error_log(POOL_CONNECTION_POOL * backend, int node_id,
                                                           char *query, char *prefix, bool unread);
 
+extern void init_pi_set(void);
+extern void pi_set(int node_id);
+extern bool is_pi_set(uint64 *node_ids, int node_id);
+
 #endif
index 9127c782764450aa2fa5e8c2d2c5f2e18fd3356b..c3172c203b315950e872072361e5fec097fb689d 100644 (file)
@@ -1,13 +1,15 @@
 AM_CPPFLAGS = -D_GNU_SOURCE -DPOOL_PRIVATE -I @PGSQL_INCLUDE_DIR@
 
 lib_LTLIBRARIES = libpcp.la
-libpcp_la_LDFLAGS = -version-info 2:0:0
+libpcp_la_LDFLAGS = -version-info 2:1:0
 dist_libpcp_la_SOURCES = pcp.c \
                                        ../../utils/pool_path.c \
                                        ../../tools/fe_port.c \
                                        ../../tools/fe_memutils.c \
                                        ../../utils/strlcpy.c \
-                                       ../../utils/pool_health_check_stats.c
+                                       ../../utils/pool_health_check_stats.c \
+                                       ../../utils/sprompt.c
+
 nodist_libpcp_la_SOURCES = pcp_stream.c \
                                        md5.c \
                                        json.c
index dc1bef392cfd4bf06a1c15a56ed3f99df13d6235..f4142f90dcc238994ead08e81515f28dd3e343c0 100644 (file)
@@ -1898,11 +1898,18 @@ static POOL_CONNECTION *
 get_connection(int front_end_fd, SockAddr *saddr)
 {
        POOL_CONNECTION *cp;
+       ProcessInfo     *pi;
 
        ereport(DEBUG1,
                        (errmsg("I am %d accept fd %d", getpid(), front_end_fd)));
 
        pool_getnameinfo_all(saddr, remote_host, remote_port);
+
+       /* save remote client host and port info onto shared memory */
+       pi = pool_get_my_process_info();
+       StrNCpy(pi->client_host, remote_host, NI_MAXHOST);
+       StrNCpy(pi->client_port, remote_port, NI_MAXSERV);
+
        print_process_status(remote_host, remote_port);
 
        set_ps_display("accept connection", false);
index d793572114f974f6cb48757980cbf461526c7c61..a6336f8e278d7d126e5106c5405eae8e28338301 100644 (file)
@@ -397,6 +397,11 @@ SimpleQuery(POOL_CONNECTION * frontend,
                 */
                pool_start_query(query_context, contents, len, node);
 
+               /*
+                * Initialize ProcessInfo->node_ids and ProcessInfo->statement.
+                */
+               init_pi_set();
+
                /*
                 * Check if the transaction is in abort status. If so, we do nothing
                 * and just return an error message to frontend, execpt for
@@ -758,6 +763,8 @@ SimpleQuery(POOL_CONNECTION * frontend,
                        session_context->uncompleted_message = NULL;
        }
 
+       /* initialize backend send statement bitmap */
+       init_pi_set();
 
        if (!RAW_MODE)
        {
@@ -1149,6 +1156,9 @@ Execute(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend,
        /* check if query is "COMMIT" or "ROLLBACK" */
        commit = is_commit_or_rollback_query(node);
 
+       /* initialize backend send statement bitmap */
+       init_pi_set();
+
        if (!SL_MODE)
        {
                /*
@@ -3780,11 +3790,56 @@ generate_error_message(char *prefix, int specific_error, char *query)
 void
 per_node_statement_log(POOL_CONNECTION_POOL * backend, int node_id, char *query)
 {
+       ProcessInfo     *pi = pool_get_my_process_info();
        POOL_CONNECTION_POOL_SLOT *slot = backend->slots[node_id];
 
        if (pool_config->log_per_node_statement)
                ereport(LOG,
                                (errmsg("DB node id: %d backend pid: %d statement: %s", node_id, ntohl(slot->pid), query)));
+       
+       pi_set(node_id);
+       StrNCpy(pi->statement, query, MAXSTMTLEN);
+}
+
+/*
+ * Initialize ProcessInfo->node_ids and ProcessInfo->statement.
+ */
+void
+init_pi_set(void)
+{
+       ProcessInfo     *pi = pool_get_my_process_info();
+
+       memset(pi->node_ids, 0, sizeof(pi->node_ids));
+       pi->statement[0] = '\0';
+}
+
+/*
+ * Set ProcessInfo->node_ids.
+ */
+void
+pi_set(int node_id)
+{
+       ProcessInfo     *pi = pool_get_my_process_info();
+
+       if (node_id < BITS_PER_TYPE(uint64))
+               pi->node_ids[0] |= (1 << node_id);
+       else
+               pi->node_ids[1] |= (1 << (node_id - BITS_PER_TYPE(uint64)));
+}
+
+/*
+ * Returns true if node_id bit in ProcessInfo->node_ids is on.
+ */
+bool
+is_pi_set(uint64 *node_ids, int node_id)
+{
+       int     set;
+
+       if (node_id < BITS_PER_TYPE(uint64))
+               set = node_ids[0] & (1 << node_id);
+       else
+               set = node_ids[1] & (1 << (node_id - BITS_PER_TYPE(uint64)));
+       return set != 0;
 }
 
 /*
index 199772207ddb4ebb86b19a5088eacb1c406fb93d..6dde6ccf6333fd5300ff82f7255de1d745d0eec2 100644 (file)
@@ -8,7 +8,8 @@ EXTENSION = pgpool_adm
 DATA = pgpool_adm--1.0.sql pgpool_adm--1.1.sql pgpool_adm--1.2.sql pgpool_adm--1.3.sql \
 pgpool_adm--1.0--1.1.sql pgpool_adm--1.1--1.2.sql pgpool_adm--1.2--1.3.sql \
 pgpool_adm--1.4.sql pgpool_adm--1.3--1.4.sql \
-pgpool_adm--1.5.sql pgpool_adm--1.4--1.5.sql
+pgpool_adm--1.5.sql pgpool_adm--1.4--1.5.sql \
+pgpool_adm--1.6.sql pgpool_adm--1.5--1.6.sql
 SHLIB_LINK =  -L../../libs/pcp/.libs -lpcp -Wl,--as-needed -Wl,-rpath,'${prefix}/lib',--enable-new-dtags
 # if you are using PostgreSQL 8.0 or later,
 # using pg_config is recommended.
diff --git a/src/sql/pgpool_adm/pgpool_adm--1.5--1.6.sql b/src/sql/pgpool_adm/pgpool_adm--1.5--1.6.sql
new file mode 100644 (file)
index 0000000..881cfb7
--- /dev/null
@@ -0,0 +1,61 @@
+/* contrib/pgpool_adm/pgpool_adm--1.5--1.6.sql */
+
+-- complain if script is sourced in psql, rather than via ALTER EXTENSION
+\echo Use "ALTER EXTENSION pgpool_adm UPDATE TO '1.6'" to load this file. \quit
+
+/**
+ * input parameters: node_id, host, port, username, password
+ */
+CREATE FUNCTION pcp_proc_info(IN host text, IN port integer, IN username text, IN password text,
+OUT database text,
+OUT username text,
+OUT start_time text,
+OUT client_connection_count text,
+OUT major text,
+OUT minor text,
+OUT backend_connection_time text,
+OUT client_connection_time text,
+OUT client_idle_duration text,
+OUT client_disconnection_time text,
+OUT pool_counter text,
+OUT backend_pid text,
+OUT connected text,
+OUT pid text,
+OUT backend_id text,
+OUT status text,
+OUT load_balance_node text,
+OUT client_host text,
+OUT client_port text,
+OUT statement text)
+RETURNS SETOF record
+AS 'MODULE_PATHNAME', '_pcp_proc_info'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: node_id, pcp_server
+ */
+CREATE FUNCTION pcp_proc_info(IN pcp_server text,
+OUT database text,
+OUT username text,
+OUT start_time text,
+OUT client_connection_count text,
+OUT major text,
+OUT minor text,
+OUT backend_connection_time text,
+OUT client_connection_time text,
+OUT client_idle_duration text,
+OUT client_disconnection_time text,
+OUT pool_counter text,
+OUT backend_pid text,
+OUT connected text,
+OUT pid text,
+OUT backend_id text,
+OUT status text,
+OUT load_balance_node text,
+OUT client_host text,
+OUT client_port text,
+OUT statement text)
+RETURNS SETOF record
+AS 'MODULE_PATHNAME', '_pcp_proc_info'
+LANGUAGE C VOLATILE STRICT;
+
diff --git a/src/sql/pgpool_adm/pgpool_adm--1.6.sql b/src/sql/pgpool_adm/pgpool_adm--1.6.sql
new file mode 100644 (file)
index 0000000..4d5c262
--- /dev/null
@@ -0,0 +1,158 @@
+/* contrib/pgpool_adm/pgpool_adm--1.6.sql */
+
+/* ***********************************************
+ * Administrative functions for pgPool
+ * *********************************************** */
+
+/**
+ * input parameters: node_id, host, port, username, password
+ */
+CREATE FUNCTION pcp_node_info(IN node_id integer, IN host text, IN port integer, IN username text, IN password text, OUT host text, OUT port integer, OUT status text, OUT pg_status text, OUT weight float4, OUT role text, OUT pg_role text, OUT replication_delay bigint, OUT replication_state text, OUT replication_sync_state text, OUT last_status_change timestamp)
+RETURNS record
+AS 'MODULE_PATHNAME', '_pcp_node_info'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: node_id, pcp_server
+ */
+CREATE FUNCTION pcp_node_info(IN node_id integer, IN pcp_server text, OUT host text, OUT port integer, OUT status text, OUT weight float4)
+RETURNS record
+AS 'MODULE_PATHNAME', '_pcp_node_info'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: node_id, host, port, username, password
+ */
+CREATE FUNCTION pcp_health_check_stats(IN node_id integer, IN host text, IN port integer, IN username text, IN password text, OUT node_id integer, OUT host text, OUT port integer, OUT status text, OUT role text, OUT last_status_change timestamp, OUT total_count bigint, OUT success_count bigint, OUT fail_count bigint, OUT skip_count bigint, OUT retry_count bigint, OUT average_retry_count float4, OUT max_retry_count bigint, OUT max_health_check_duration bigint, OUT min_health_check_duration bigint, OUT average_health_check_duration float4, OUT last_health_check timestamp, OUT last_successful_health_check timestamp, OUT last_skip_health_check timestamp, OUT last_failed_health_check timestamp)
+RETURNS record
+AS 'MODULE_PATHNAME', '_pcp_health_check_stats'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: node_id, pcp_server
+ */
+CREATE FUNCTION pcp_health_check_stats(IN node_id integer, IN pcp_server text, OUT host text, OUT port integer, OUT status text, OUT weight float4)
+RETURNS record
+AS 'MODULE_PATHNAME', '_pcp_health_check_stats'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: host, port, username, password
+ */
+CREATE FUNCTION pcp_pool_status(IN host text, IN port integer, IN username text, IN password text, OUT item text, OUT value text, OUT description text)
+RETURNS SETOF record
+AS 'MODULE_PATHNAME', '_pcp_pool_status'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: pcp_server
+ */
+CREATE FUNCTION pcp_pool_status(IN pcp_server text, OUT item text, OUT value text, OUT description text)
+RETURNS SETOF record
+AS 'MODULE_PATHNAME', '_pcp_pool_status'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: host, port, username, password
+ */
+CREATE FUNCTION pcp_node_count(IN host text, IN port integer, IN username text, IN password text, OUT node_count integer)
+RETURNS integer
+AS 'MODULE_PATHNAME', '_pcp_node_count'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: pcp_server
+ */
+CREATE FUNCTION pcp_node_count(IN pcp_server text, OUT node_count integer)
+RETURNS integer
+AS 'MODULE_PATHNAME', '_pcp_node_count'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: node_id, host, port, username, password
+ */
+CREATE FUNCTION pcp_attach_node(IN node_id integer, IN host text, IN port integer, IN username text, IN password text, OUT node_attached boolean)
+RETURNS boolean
+AS 'MODULE_PATHNAME', '_pcp_attach_node'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: node_id, pcp_server
+ */
+CREATE FUNCTION pcp_attach_node(IN node_id integer, IN pcp_server text, OUT node_attached boolean)
+RETURNS boolean
+AS 'MODULE_PATHNAME', '_pcp_attach_node'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: node_id, gracefully, host, port, username, password
+ */
+CREATE FUNCTION pcp_detach_node(IN node_id integer, IN gracefully boolean, IN host text, IN port integer, IN username text, IN password text, OUT node_detached boolean)
+RETURNS boolean
+AS 'MODULE_PATHNAME', '_pcp_detach_node'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: node_id, gracefully, pcp_server
+ */
+CREATE FUNCTION pcp_detach_node(IN node_id integer, IN gracefully boolean, IN pcp_server text, OUT node_detached boolean)
+RETURNS boolean
+AS 'MODULE_PATHNAME', '_pcp_detach_node'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: node_id, host, port, username, password
+ */
+CREATE FUNCTION pcp_proc_info(IN host text, IN port integer, IN username text, IN password text,
+OUT database text,
+OUT username text,
+OUT start_time text,
+OUT client_connection_count text,
+OUT major text,
+OUT minor text,
+OUT backend_connection_time text,
+OUT client_connection_time text,
+OUT client_idle_duration text,
+OUT client_disconnection_time text,
+OUT pool_counter text,
+OUT backend_pid text,
+OUT connected text,
+OUT pid text,
+OUT backend_id text,
+OUT status text,
+OUT load_balance_node text,
+OUT client_host text,
+OUT client_port text,
+OUT statement text)
+RETURNS SETOF record
+AS 'MODULE_PATHNAME', '_pcp_proc_info'
+LANGUAGE C VOLATILE STRICT;
+
+/**
+ * input parameters: node_id, pcp_server
+ */
+CREATE FUNCTION pcp_proc_info(IN pcp_server text,
+OUT database text,
+OUT username text,
+OUT start_time text,
+OUT client_connection_count text,
+OUT major text,
+OUT minor text,
+OUT backend_connection_time text,
+OUT client_connection_time text,
+OUT client_idle_duration text,
+OUT client_disconnection_time text,
+OUT pool_counter text,
+OUT backend_pid text,
+OUT connected text,
+OUT pid text,
+OUT backend_id text,
+OUT status text,
+OUT load_balance_node text,
+OUT client_host text,
+OUT client_port text,
+OUT statement text)
+RETURNS SETOF record
+AS 'MODULE_PATHNAME', '_pcp_proc_info'
+LANGUAGE C VOLATILE STRICT;
+
index 9a8cb9648343c6bae5c97594f81609084a0376dd..b1e2f58225bf2d1b771ae5743188265eae34565e 100644 (file)
@@ -751,3 +751,179 @@ Timestamp str2timestamp(char *str)
                                                                                                  Int32GetDatum(-1))));
 }
 
+/**
+ * host_or_srv: server name or ip address of the pgpool server
+ * port: pcp port number
+ * user: user to connect with
+ * pass: password
+ **/
+Datum
+_pcp_proc_info(PG_FUNCTION_ARGS)
+{
+       MemoryContext oldcontext;
+       FuncCallContext *funcctx;
+       int32           nrows;
+       int32           call_cntr;
+       int32           max_calls;
+       AttInMetadata *attinmeta;
+       PCPConnInfo *pcpConnInfo;
+       PCPResultInfo *pcpResInfo;
+
+       int                     an;
+
+#define NUM_COLS       20      /* number of columns */
+
+       /* stuff done only on the first call of the function */
+       if (SRF_IS_FIRSTCALL())
+       {
+               TupleDesc       tupdesc;
+               char       *host_or_srv = text_to_cstring(PG_GETARG_TEXT_PP(0));
+
+               /* create a function context for cross-call persistence */
+               funcctx = SRF_FIRSTCALL_INIT();
+
+               /* switch to memory context appropriate for multiple function calls */
+               oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
+
+               if (PG_NARGS() == 4)
+               {
+                       char       *user,
+                                          *pass;
+                       int                     port;
+
+                       port = PG_GETARG_INT16(1);
+                       user = text_to_cstring(PG_GETARG_TEXT_PP(2));
+                       pass = text_to_cstring(PG_GETARG_TEXT_PP(3));
+                       pcpConnInfo = connect_to_server(host_or_srv, port, user, pass);
+               }
+               else if (PG_NARGS() == 1)
+                       pcpConnInfo = connect_to_server_from_foreign_server(host_or_srv);
+               else
+               {
+                       MemoryContextSwitchTo(oldcontext);
+                       ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("Wrong number of argument.")));
+               }
+
+               pcpResInfo = pcp_process_info(pcpConnInfo, 0);
+               if (pcpResInfo == NULL || PCPResultStatus(pcpResInfo) != PCP_RES_COMMAND_OK)
+               {
+                       char       *error = pcp_get_last_error(pcpConnInfo) ? pstrdup(pcp_get_last_error(pcpConnInfo)) : NULL;
+
+                       pcp_disconnect(pcpConnInfo);
+                       pcp_free_connection(pcpConnInfo);
+
+                       MemoryContextSwitchTo(oldcontext);
+                       ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
+                                                       errmsg("failed to get pool status"),
+                                                       errdetail("%s\n", error ? error : "unknown reason")));
+               }
+
+               nrows = pcp_result_slot_count(pcpResInfo);
+               pcp_disconnect(pcpConnInfo);
+               /* Construct a tuple descriptor for the result rows */
+#if defined(PG_VERSION_NUM) && (PG_VERSION_NUM >= 120000)
+               tupdesc = CreateTemplateTupleDesc(NUM_COLS);
+#else
+               tupdesc = CreateTemplateTupleDesc(NUM_COLS, false);
+#endif
+               an = 1;
+               TupleDescInitEntry(tupdesc, an++, "database", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "username", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "start_time", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "client_connection_count", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "major", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "minor", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "backend_connection_time", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "client_connection_time", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "client_idle_duration", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "client_disconnection_time", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "pool_counter", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "backend_pid", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "connected", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "pid", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "backend_id", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "status", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "load_balance_node", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "client_host", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "client_port", TEXTOID, -1, 0);
+               TupleDescInitEntry(tupdesc, an++, "statement", TEXTOID, -1, 0);
+
+               /*
+                * Generate attribute metadata needed later to produce tuples from raw
+                * C strings
+                */
+               attinmeta = TupleDescGetAttInMetadata(tupdesc);
+               funcctx->attinmeta = attinmeta;
+
+               if (nrows > 0)
+               {
+                       funcctx->max_calls = nrows;
+
+                       /* got results, keep track of them */
+                       funcctx->user_fctx = pcpConnInfo;
+               }
+               else
+               {
+                       /* fast track when no results */
+                       MemoryContextSwitchTo(oldcontext);
+                       SRF_RETURN_DONE(funcctx);
+               }
+
+               MemoryContextSwitchTo(oldcontext);
+       }
+
+       /* stuff done on every call of the function */
+       funcctx = SRF_PERCALL_SETUP();
+
+       /* initialize per-call variables */
+       call_cntr = funcctx->call_cntr;
+       max_calls = funcctx->max_calls;
+
+       pcpConnInfo = (PCPConnInfo *) funcctx->user_fctx;
+       pcpResInfo = (PCPResultInfo *) pcpConnInfo->pcpResInfo;
+       attinmeta = funcctx->attinmeta;
+
+       if (call_cntr < max_calls)      /* executed while there is more left to send */
+       {
+               char       *values[NUM_COLS];
+               HeapTuple       tuple;
+               Datum           result;
+               int                     i = 0;
+               POOL_REPORT_POOLS *pools = (POOL_REPORT_POOLS *) pcp_get_binary_data(pcpResInfo, call_cntr);
+
+               values[i++] = pstrdup(pools->database);
+               values[i++] = pstrdup(pools->username);
+               values[i++] = pstrdup(pools->process_start_time);
+               values[i++] = pstrdup(pools->client_connection_count);
+               values[i++] = pstrdup(pools->pool_majorversion);
+               values[i++] = pstrdup(pools->pool_minorversion);
+               values[i++] = pstrdup(pools->backend_connection_time);
+               values[i++] = pstrdup(pools->client_connection_time);
+               values[i++] = pstrdup(pools->client_idle_duration);
+               values[i++] = pstrdup(pools->client_disconnection_time);
+               values[i++] = pstrdup(pools->pool_counter);
+               values[i++] = pstrdup(pools->pool_backendpid);
+               values[i++] = pstrdup(pools->pool_connected);
+               values[i++] = pstrdup(pools->pool_pid);
+               values[i++] = pstrdup(pools->backend_id);
+               values[i++] = pstrdup(pools->status);
+               values[i++] = pstrdup(pools->load_balance_node);
+               values[i++] = pstrdup(pools->client_host);
+               values[i++] = pstrdup(pools->client_port);
+               values[i++] = pstrdup(pools->statement);
+
+               /* build the tuple */
+               tuple = BuildTupleFromCStrings(attinmeta, values);
+
+               /* make the tuple into a datum */
+               result = HeapTupleGetDatum(tuple);
+
+               SRF_RETURN_NEXT(funcctx, result);
+       }
+       else
+       {
+               /* do when there is no more left */
+               pcp_free_connection(pcpConnInfo);
+               SRF_RETURN_DONE(funcctx);
+       }
+}
index b02b15441a7fe63759b6be1545bb35113499af85..ee808804260e099ba35308d17ac42132112a59a7 100644 (file)
@@ -1,5 +1,5 @@
 # pcp extension
 comment = 'Administrative functions for pgPool'
-default_version = '1.5'
+default_version = '1.6'
 module_pathname = '$libdir/pgpool_adm'
 relocatable = true
index e10e81e566b7acd9e60b1cfdbedced6f7c676ea7..3f23f4f05e47186928a106d4c474ffca58b1591b 100644 (file)
@@ -3,7 +3,8 @@
  * pgpool_adm.h
  *
  *
- * Copyright (c) 2002-2018, PostgreSQL Global Development Group
+ * Copyright (c) 2002-2025, PostgreSQL Global Development Group
+ * Copyright (c) 2019-2025, PgPool Global Development Group
  *
  * Author: Jehan-Guillaume (ioguix) de Rorthais <jgdr@dalibo.com>
  *
@@ -25,6 +26,7 @@ Datum         _pcp_pool_status(PG_FUNCTION_ARGS);
 Datum          _pcp_node_count(PG_FUNCTION_ARGS);
 Datum          _pcp_attach_node(PG_FUNCTION_ARGS);
 Datum          _pcp_detach_node(PG_FUNCTION_ARGS);
+Datum          _pcp_proc_info(PG_FUNCTION_ARGS);
 
 PG_FUNCTION_INFO_V1(_pcp_node_info);
 PG_FUNCTION_INFO_V1(_pcp_health_check_stats);
@@ -32,5 +34,6 @@ PG_FUNCTION_INFO_V1(_pcp_pool_status);
 PG_FUNCTION_INFO_V1(_pcp_node_count);
 PG_FUNCTION_INFO_V1(_pcp_attach_node);
 PG_FUNCTION_INFO_V1(_pcp_detach_node);
+PG_FUNCTION_INFO_V1(_pcp_proc_info);
 
 #endif
diff --git a/src/test/regression/tests/038.pcp_commands/expected b/src/test/regression/tests/038.pcp_commands/expected
new file mode 100644 (file)
index 0000000..45e4591
--- /dev/null
@@ -0,0 +1,10 @@
+CREATE EXTENSION pgpool_adm;
+CREATE EXTENSION
+SELECT database, status, client_host, statement FROM pcp_proc_info
+(host => '', port => 11001, username => 't-ishii', password => 't-ishii')
+WHERE connected = '1' AND backend_id = '0' AND statement = 'SELECT pg_sleep(1)'
+ database |     status      | client_host |     statement      
+----------+-----------------+-------------+--------------------
+ test     | Execute command | 127.0.0.1   | SELECT pg_sleep(1)
+(1 row)
+
index 5b6e7b18c8a67f136ed52c093bb5d27ffbe59296..cb75d4a9d5d1805da38e174ae5c1bc466040f056 100755 (executable)
@@ -51,13 +51,40 @@ else
     fi
 fi
 
+#
+# test for pcp_proc_info, pgpool_adm: pcp_proc_info
+WHOAMI=`whoami`
+./shutdownall
+./startall
+wait_for_pgpool_startup
+$PSQL -a -h localhost -c "SELECT pg_sleep(1)" test &
+$PSQL -a -h localhost test > result 2>&1 <<EOF
+CREATE EXTENSION pgpool_adm;
+SELECT database, status, client_host, statement FROM pcp_proc_info
+(host => '', port => $PCP_PORT, username => '$WHOAMI', password => '$WHOAMI')
+WHERE connected = '1' AND backend_id = '0' AND statement = 'SELECT pg_sleep(1)'
+EOF
+if [ $? != 0 ];then
+    r2=fail
+    echo "test2 failed"
+else
+    cmp  ../expected result
+    if [ $? != 0 ];then
+       r2=fail
+       echo "test2 failed"
+    else
+       r2=ok
+    fi
+fi
+wait
 ./shutdownall
 
-if [ $r1 = ok ]; then
+if [ $r1 = ok -a $r2 = ok ]; then
     echo "all test succeeded"
     exit 0
 else
     echo "some tests failed"
     echo "test1: $r1"
+    echo "test2: $r2"
     exit 1
 fi
index a72b1327f74999667e26f427da3cc84eabe2ec63..be192dd27e8d81acb8ef8ed862c28cf1e8eccca5 100644 (file)
@@ -4,7 +4,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2024     PgPool Global Development Group
+ * Copyright (c) 2003-2025     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -735,14 +735,15 @@ output_procinfo_result(PCPResultInfo * pcpResInfo, bool all, bool verbose)
                "Database", "Username", "Start time", "Client connection count",
                "Major", "Minor", "Backend connection time", "Client connection time",
                "Client idle duration", "Client disconnection time", "Pool Counter", "Backend PID",
-               "Connected", "PID", "Backend ID", "Status", "Load balance node"
+               "Connected", "PID",     "Backend ID", "Status", "Load balance node",
+               "client_host", "client_port", "statement"
        };
        const char *types[] = {
                "s", "s", "s", "s",
                "s", "s", "s", "s",
                "s", "s", "s", "s",
                "s", "s", "s", "s",
-               "s"
+               "s", "s", "s", "s"
        };
 
 
@@ -750,7 +751,7 @@ output_procinfo_result(PCPResultInfo * pcpResInfo, bool all, bool verbose)
                format = format_titles(titles, types, sizeof(titles)/sizeof(char *));
        else
        {
-               format = "%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n";
+               format = "%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n";
        }
 
        for (i = 0; i < array_size; i++)
@@ -780,7 +781,10 @@ output_procinfo_result(PCPResultInfo * pcpResInfo, bool all, bool verbose)
                           pools->pool_pid,
                           pools->backend_id,
                           pools->status,
-                          pools->load_balance_node);
+                          pools->load_balance_node,
+                          pools->client_host,
+                          pools->client_port,
+                          pools->statement);
        }
        if (printed == false)
                printf("No process information available\n\n");
index f717b1a3e6d2a569e98f0f4f2634ded2b9fc0370..bb0ca97e888ad3e911c7f871be0fb55073d9a817 100644 (file)
@@ -4,7 +4,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2021     PgPool Global Development Group
+ * Copyright (c) 2003-2025     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -85,7 +85,10 @@ int * pool_report_pools_offsets(int *n)
                offsetof(POOL_REPORT_POOLS, pool_backendpid),
                offsetof(POOL_REPORT_POOLS, pool_connected),
                offsetof(POOL_REPORT_POOLS, status),
-               offsetof(POOL_REPORT_POOLS, load_balance_node)
+               offsetof(POOL_REPORT_POOLS, load_balance_node),
+               offsetof(POOL_REPORT_POOLS, client_host),
+               offsetof(POOL_REPORT_POOLS, client_port),
+               offsetof(POOL_REPORT_POOLS, statement)
        };
 
        *n = sizeof(offsettbl)/sizeof(int);
index 71f871bc4222600d13d217bb6fc868c8406c7863..01761c73efc4e950aa52c95e622036aff8dfff83 100644 (file)
@@ -5,7 +5,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2024     PgPool Global Development Group
+ * Copyright (c) 2003-2025     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -1685,6 +1685,20 @@ get_pools(int *nrows)
                                        StrNCpy(pools[lines].load_balance_node, "1", POOLCONFIG_MAXPROCESSSTATUSLEN);
                                else
                                        StrNCpy(pools[lines].load_balance_node, "0", POOLCONFIG_MAXPROCESSSTATUSLEN);
+
+                               StrNCpy(pools[lines].client_host, pi->client_host, NI_MAXHOST);
+                               StrNCpy(pools[lines].client_port, pi->client_port, NI_MAXSERV);
+
+                               /*
+                                * If this the statement was sent to backend id
+                                * report the statement.
+                                */
+                               if (is_pi_set(pi->node_ids, backend_id))
+                               {
+                                       StrNCpy(pools[lines].statement, pi->statement, MAXSTMTLEN);
+                                       elog(LOG, "pi->node_ids[0]:%ld pi->node_ids[1]:%ld",
+                                                pi->node_ids[0], pi->node_ids[1]);
+                               }
                                lines++;
                        }
                }
@@ -1705,7 +1719,7 @@ pools_reporting(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend)
                                                                  "backend_id", "database", "username", "backend_connection_time",
                                                                  "client_connection_time", "client_disconnection_time", "client_idle_duration",
                                                                  "majorversion", "minorversion", "pool_counter", "pool_backendpid", "pool_connected",
-                                                                 "status", "load_balance_node"};
+                                                                 "status", "load_balance_node", "client_host", "client_port", "statement"};
        int             n;
        int             *offsettbl;
        int             nrows;