mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	BitmapHeapScan: begin scan after bitmap creation
Change the order so that the table scan is initialized only after initializing the index scan and building the bitmap. This is mostly a cosmetic change for now, but later commits will need to pass parameters to table_beginscan_bm() that are unavailable in ExecInitBitmapHeapScan(). Author: Melanie Plageman Reviewed-by: Tomas Vondra, Andres Freund, Heikki Linnakangas Discussion: https://postgr.es/m/CAAKRu_ZwCwWFeL_H3ia26bP2e7HiKLWt0ZmGXPVwPO6uXq0vaA%40mail.gmail.com
This commit is contained in:
		@@ -178,6 +178,21 @@ BitmapHeapNext(BitmapHeapScanState *node)
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
#endif							/* USE_PREFETCH */
 | 
					#endif							/* USE_PREFETCH */
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/*
 | 
				
			||||||
 | 
							 * If this is the first scan of the underlying table, create the table
 | 
				
			||||||
 | 
							 * scan descriptor and begin the scan.
 | 
				
			||||||
 | 
							 */
 | 
				
			||||||
 | 
							if (!scan)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								scan = table_beginscan_bm(node->ss.ss_currentRelation,
 | 
				
			||||||
 | 
														  node->ss.ps.state->es_snapshot,
 | 
				
			||||||
 | 
														  0,
 | 
				
			||||||
 | 
														  NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								node->ss.ss_currentScanDesc = scan;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		node->initialized = true;
 | 
							node->initialized = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -601,6 +616,7 @@ ExecReScanBitmapHeapScan(BitmapHeapScanState *node)
 | 
				
			|||||||
	PlanState  *outerPlan = outerPlanState(node);
 | 
						PlanState  *outerPlan = outerPlanState(node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* rescan to release any page pin */
 | 
						/* rescan to release any page pin */
 | 
				
			||||||
 | 
						if (node->ss.ss_currentScanDesc)
 | 
				
			||||||
		table_rescan(node->ss.ss_currentScanDesc, NULL);
 | 
							table_rescan(node->ss.ss_currentScanDesc, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* release bitmaps and buffers if any */
 | 
						/* release bitmaps and buffers if any */
 | 
				
			||||||
@@ -678,7 +694,9 @@ ExecEndBitmapHeapScan(BitmapHeapScanState *node)
 | 
				
			|||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * close heap scan
 | 
						 * close heap scan
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
 | 
						if (scanDesc)
 | 
				
			||||||
		table_endscan(scanDesc);
 | 
							table_endscan(scanDesc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ----------------------------------------------------------------
 | 
					/* ----------------------------------------------------------------
 | 
				
			||||||
@@ -783,11 +801,6 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate, int eflags)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	scanstate->ss.ss_currentRelation = currentRelation;
 | 
						scanstate->ss.ss_currentRelation = currentRelation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	scanstate->ss.ss_currentScanDesc = table_beginscan_bm(currentRelation,
 | 
					 | 
				
			||||||
														  estate->es_snapshot,
 | 
					 | 
				
			||||||
														  0,
 | 
					 | 
				
			||||||
														  NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * all done.
 | 
						 * all done.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user