From 2a9bd029dcb180b01e0274ae6ef18faf647ff777 Mon Sep 17 00:00:00 2001
From: Miha <m7onov@yandex.com>
Date: Thu, 6 Oct 2022 19:13:26 +0300
Subject: [PATCH] Check system cache invalidations before each command in
 transaction

---
 src/backend/access/transam/xact.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index c1ffbd89b8..c7593b6c55 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -2939,14 +2939,22 @@ StartTransactionCommand(void)

 			/*
 			 * We are somewhere in a transaction block or subtransaction and
-			 * about to start a new command.  For now we do nothing, but
-			 * someday we may do command-local resource initialization. (Note
-			 * that any needed CommandCounterIncrement was done by the
-			 * previous CommitTransactionCommand.)
+			 * about to start a new command. (Note that any needed
+			 * CommandCounterIncrement was done by the previous
+			 * CommitTransactionCommand.)
 			 */
 		case TBLOCK_INPROGRESS:
-		case TBLOCK_IMPLICIT_INPROGRESS:
 		case TBLOCK_SUBINPROGRESS:
+			AcceptInvalidationMessages();
+			break;
+
+			/*
+			 * We are somewhere in implicit transaction block. For now we do
+			 * nothing, but someday we may do command-local resource
+			 * initialization. (Note that any needed  CommandCounterIncrement
+			 * was done by the previous CommitTransactionCommand.)
+			 */
+		case TBLOCK_IMPLICIT_INPROGRESS:
 			break;

 			/*
--
2.25.1

