From 2a4116ebf5f6b838dd3df64c78322c4e70375b6f Mon Sep 17 00:00:00 2001 From: Ideriha Takeshi Date: Mon, 30 Sep 2024 00:24:13 +0000 Subject: [PATCH] Set and unset bsysscan flag in systable_*_ordered. We call HandleConcurrentAbort in systable_getnext_ordered so that we can handle concurrent abort case in logical decoding same as systable_getnext. Set and unset bsysscan flag is forgotten. --- src/backend/access/index/genam.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index 52fde5cc4d..2ecc3e8b31 100644 --- a/src/backend/access/index/genam.c +++ b/src/backend/access/index/genam.c @@ -713,6 +713,14 @@ systable_beginscan_ordered(Relation heapRelation, index_rescan(sysscan->iscan, idxkey, nkeys, NULL, 0); sysscan->scan = NULL; + /* + * If CheckXidAlive is set then set a flag to indicate that system table + * scan is in-progress. See detailed comments in xact.c where these + * variables are declared. + */ + if (TransactionIdIsValid(CheckXidAlive)) + bsysscan = true; + return sysscan; } @@ -757,6 +765,14 @@ systable_endscan_ordered(SysScanDesc sysscan) index_endscan(sysscan->iscan); if (sysscan->snapshot) UnregisterSnapshot(sysscan->snapshot); + + /* + * Reset the bsysscan flag at the end of the systable scan. See detailed + * comments in xact.c where these variables are declared. + */ + if (TransactionIdIsValid(CheckXidAlive)) + bsysscan = false; + pfree(sysscan); } -- 2.40.1