From bd4f35bfa4c5709808169b847d64d350eae38804 Mon Sep 17 00:00:00 2001
From: rkhapov <r.khapov@ya.ru>
Date: Tue, 24 Jun 2025 06:17:29 +0000
Subject: [PATCH] dummy RFQ hook impl

Signed-off-by: rkhapov <r.khapov@ya.ru>
---
 src/backend/tcop/postgres.c | 6 ++++++
 src/include/postgres.h      | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 2f8c3d5f918..e76b625ec31 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -104,6 +104,8 @@ int			client_connection_check_interval = 0;
 /* flags for non-system relation kinds to restrict use */
 int			restrict_nonsystem_relation_kind;
 
+ReadyForQuery_hook_type ReadyForQuery_hook = NULL;
+
 /* ----------------
  *		private typedefs etc
  * ----------------
@@ -4680,6 +4682,10 @@ PostgresMain(const char *dbname, const char *username)
 							   (double) auth_duration / NS_PER_US));
 			}
 
+			if (ReadyForQuery_hook) {
+				ReadyForQuery_hook(/* some arguments to determine connection state here */);
+			}
+
 			ReadyForQuery(whereToSendOutput);
 			send_ready_for_query = false;
 		}
diff --git a/src/include/postgres.h b/src/include/postgres.h
index 8a41a668687..c844742d977 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -581,4 +581,8 @@ extern Datum Float8GetDatum(float8 X);
 #define NON_EXEC_STATIC static
 #endif
 
+/* Hook for plugins to catch RFQ sending */
+typedef void (*ReadyForQuery_hook_type) ();
+extern PGDLLIMPORT ReadyForQuery_hook_type ReadyForQuery_hook;
+
 #endif							/* POSTGRES_H */
-- 
2.43.0

