You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by re...@apache.org on 2025/01/10 21:44:37 UTC

(cloudberry) 03/05: brin ao/co: Correct partial scan bounds logic

This is an automated email from the ASF dual-hosted git repository.

reshke pushed a commit to branch brin2
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit cd6748f62252e6a11d1e41407b3f09ca52eb2b0b
Author: Soumyadeep Chakraborty <so...@gmail.com>
AuthorDate: Fri May 12 09:26:26 2023 -0700

    brin ao/co: Correct partial scan bounds logic
    
    We were not correctly bounding the scan (ignoring block sequences).
    Tests will be added in a later commit.
---
 src/backend/access/aocs/aocsam_handler.c             | 8 ++++----
 src/backend/access/appendonly/appendonlyam_handler.c | 5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/backend/access/aocs/aocsam_handler.c b/src/backend/access/aocs/aocsam_handler.c
index 042de999a2..315434d734 100644
--- a/src/backend/access/aocs/aocsam_handler.c
+++ b/src/backend/access/aocs/aocsam_handler.c
@@ -1867,12 +1867,12 @@ aoco_index_build_range_scan(Relation heapRelation,
 		bool		tupleIsAlive;
 		BlockNumber		blockno;
 		AOTupleId 	*aoTupleId;
+		BlockNumber currblockno = ItemPointerGetBlockNumber(&slot->tts_tid);
 
 		CHECK_FOR_INTERRUPTS();
-		blockno = ItemPointerGetBlockNumber(&slot->tts_tid);
-		if (blockno != lastBlock)
+		if (current_blkno != lastBlock)
 		{
-			lastBlock = blockno;
+			lastBlock = current_blkno;
 			++blockcounts;
 		}
 
@@ -1882,7 +1882,7 @@ aoco_index_build_range_scan(Relation heapRelation,
 		 * range. That's clearly very inefficient.
 		 */
 		if (blockno < start_blockno ||
-			(numblocks != InvalidBlockNumber && blockno >= numblocks))
+			(numblocks != InvalidBlockNumber && current_blkno >= (start_blockno + numblocks)))
 			continue;
 
 		/* Report scan progress, if asked to. */
diff --git a/src/backend/access/appendonly/appendonlyam_handler.c b/src/backend/access/appendonly/appendonlyam_handler.c
index ba3a8ebcc3..3867ec9ca1 100644
--- a/src/backend/access/appendonly/appendonlyam_handler.c
+++ b/src/backend/access/appendonly/appendonlyam_handler.c
@@ -1708,6 +1708,7 @@ appendonly_index_build_range_scan(Relation heapRelation,
 	{
 		bool		tupleIsAlive;
 		AOTupleId 	*aoTupleId;
+		BlockNumber currblockno = ItemPointerGetBlockNumber(&slot->tts_tid);
 
 		CHECK_FOR_INTERRUPTS();
 
@@ -1716,8 +1717,8 @@ appendonly_index_build_range_scan(Relation heapRelation,
 		 * we scan the whole table, and throw away tuples that are not in the
 		 * range. That's clearly very inefficient.
 		 */
-		if (ItemPointerGetBlockNumber(&slot->tts_tid) < start_blockno ||
-			(numblocks != InvalidBlockNumber && ItemPointerGetBlockNumber(&slot->tts_tid) >= numblocks))
+		if (currblockno < start_blockno ||
+			(numblocks != InvalidBlockNumber && currblockno >= (start_blockno + numblocks)))
 			continue;
 
 		if (progress)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org