ss_currentScanDesc_20100226.patch

application/octet-stream

Filename: ss_currentScanDesc_20100226.patch
Type: application/octet-stream
Part: 0
Message: code cleanup: ss_currentScanDesc

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: context
File+
src/backend/executor/nodeBitmapHeapscan.c 7 7
src/backend/executor/nodeBitmapIndexscan.c 0 1
src/backend/executor/nodeIndexscan.c 0 1
src/backend/executor/nodeSeqscan.c 20 20
src/backend/executor/nodeTidscan.c 0 1
src/include/nodes/execnodes.h 12 6
diff -cprN head/src/backend/executor/nodeBitmapHeapscan.c work/src/backend/executor/nodeBitmapHeapscan.c
*** head/src/backend/executor/nodeBitmapHeapscan.c	2010-01-04 09:10:26.638773000 +0900
--- work/src/backend/executor/nodeBitmapHeapscan.c	2010-02-26 14:34:20.629724292 +0900
*************** BitmapHeapNext(BitmapHeapScanState *node
*** 74,80 ****
  	 */
  	econtext = node->ss.ps.ps_ExprContext;
  	slot = node->ss.ss_ScanTupleSlot;
! 	scan = node->ss.ss_currentScanDesc;
  	tbm = node->tbm;
  	tbmiterator = node->tbmiterator;
  	tbmres = node->tbmres;
--- 74,80 ----
  	 */
  	econtext = node->ss.ps.ps_ExprContext;
  	slot = node->ss.ss_ScanTupleSlot;
! 	scan = node->currentScanDesc;
  	tbm = node->tbm;
  	tbmiterator = node->tbmiterator;
  	tbmres = node->tbmres;
*************** ExecBitmapHeapReScan(BitmapHeapScanState
*** 439,445 ****
  	}
  
  	/* rescan to release any page pin */
! 	heap_rescan(node->ss.ss_currentScanDesc, NULL);
  
  	if (node->tbmiterator)
  		tbm_end_iterate(node->tbmiterator);
--- 439,445 ----
  	}
  
  	/* rescan to release any page pin */
! 	heap_rescan(node->currentScanDesc, NULL);
  
  	if (node->tbmiterator)
  		tbm_end_iterate(node->tbmiterator);
*************** ExecEndBitmapHeapScan(BitmapHeapScanStat
*** 475,481 ****
  	 * extract information from the node
  	 */
  	relation = node->ss.ss_currentRelation;
! 	scanDesc = node->ss.ss_currentScanDesc;
  
  	/*
  	 * Free the exprcontext
--- 475,481 ----
  	 * extract information from the node
  	 */
  	relation = node->ss.ss_currentRelation;
! 	scanDesc = node->currentScanDesc;
  
  	/*
  	 * Free the exprcontext
*************** ExecInitBitmapHeapScan(BitmapHeapScan *n
*** 588,597 ****
  	 * Even though we aren't going to do a conventional seqscan, it is useful
  	 * to create a HeapScanDesc --- most of the fields in it are usable.
  	 */
! 	scanstate->ss.ss_currentScanDesc = heap_beginscan_bm(currentRelation,
! 														 estate->es_snapshot,
! 														 0,
! 														 NULL);
  
  	/*
  	 * get the scan type from the relation descriptor.
--- 588,597 ----
  	 * Even though we aren't going to do a conventional seqscan, it is useful
  	 * to create a HeapScanDesc --- most of the fields in it are usable.
  	 */
! 	scanstate->currentScanDesc = heap_beginscan_bm(currentRelation,
! 												   estate->es_snapshot,
! 												   0,
! 												   NULL);
  
  	/*
  	 * get the scan type from the relation descriptor.
diff -cprN head/src/backend/executor/nodeBitmapIndexscan.c work/src/backend/executor/nodeBitmapIndexscan.c
*** head/src/backend/executor/nodeBitmapIndexscan.c	2010-01-04 09:10:26.638773000 +0900
--- work/src/backend/executor/nodeBitmapIndexscan.c	2010-02-26 14:27:50.199723199 +0900
*************** ExecInitBitmapIndexScan(BitmapIndexScan 
*** 242,248 ****
  	 */
  
  	indexstate->ss.ss_currentRelation = NULL;
- 	indexstate->ss.ss_currentScanDesc = NULL;
  
  	/*
  	 * If we are just doing EXPLAIN (ie, aren't going to run the plan), stop
--- 242,247 ----
diff -cprN head/src/backend/executor/nodeIndexscan.c work/src/backend/executor/nodeIndexscan.c
*** head/src/backend/executor/nodeIndexscan.c	2010-01-04 09:10:26.638773000 +0900
--- work/src/backend/executor/nodeIndexscan.c	2010-02-26 14:27:52.223712119 +0900
*************** ExecInitIndexScan(IndexScan *node, EStat
*** 526,532 ****
  	currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid);
  
  	indexstate->ss.ss_currentRelation = currentRelation;
- 	indexstate->ss.ss_currentScanDesc = NULL;	/* no heap scan here */
  
  	/*
  	 * get the scan type from the relation descriptor.
--- 526,531 ----
diff -cprN head/src/backend/executor/nodeSeqscan.c work/src/backend/executor/nodeSeqscan.c
*** head/src/backend/executor/nodeSeqscan.c	2010-01-04 09:10:26.638773000 +0900
--- work/src/backend/executor/nodeSeqscan.c	2010-02-26 14:33:43.076003022 +0900
*************** SeqNext(SeqScanState *node)
*** 56,64 ****
  	 * get information from the estate and scan state
  	 */
  	scandesc = node->ss_currentScanDesc;
! 	estate = node->ps.state;
  	direction = estate->es_direction;
! 	slot = node->ss_ScanTupleSlot;
  
  	/*
  	 * get the next tuple from the table
--- 56,64 ----
  	 * get information from the estate and scan state
  	 */
  	scandesc = node->ss_currentScanDesc;
! 	estate = node->ss.ps.state;
  	direction = estate->es_direction;
! 	slot = node->ss.ss_ScanTupleSlot;
  
  	/*
  	 * get the next tuple from the table
*************** InitScanRelation(SeqScanState *node, ESt
*** 134,150 ****
  	 * open that relation and acquire appropriate lock on it.
  	 */
  	currentRelation = ExecOpenScanRelation(estate,
! 									 ((SeqScan *) node->ps.plan)->scanrelid);
  
  	currentScanDesc = heap_beginscan(currentRelation,
  									 estate->es_snapshot,
  									 0,
  									 NULL);
  
! 	node->ss_currentRelation = currentRelation;
  	node->ss_currentScanDesc = currentScanDesc;
  
! 	ExecAssignScanType(node, RelationGetDescr(currentRelation));
  }
  
  
--- 134,150 ----
  	 * open that relation and acquire appropriate lock on it.
  	 */
  	currentRelation = ExecOpenScanRelation(estate,
! 									 ((SeqScan *) node->ss.ps.plan)->scanrelid);
  
  	currentScanDesc = heap_beginscan(currentRelation,
  									 estate->es_snapshot,
  									 0,
  									 NULL);
  
! 	node->ss.ss_currentRelation = currentRelation;
  	node->ss_currentScanDesc = currentScanDesc;
  
! 	ExecAssignScanType(&node->ss, RelationGetDescr(currentRelation));
  }
  
  
*************** ExecInitSeqScan(SeqScan *node, EState *e
*** 168,211 ****
  	 * create state structure
  	 */
  	scanstate = makeNode(SeqScanState);
! 	scanstate->ps.plan = (Plan *) node;
! 	scanstate->ps.state = estate;
  
  	/*
  	 * Miscellaneous initialization
  	 *
  	 * create expression context for node
  	 */
! 	ExecAssignExprContext(estate, &scanstate->ps);
  
  	/*
  	 * initialize child expressions
  	 */
! 	scanstate->ps.targetlist = (List *)
  		ExecInitExpr((Expr *) node->plan.targetlist,
  					 (PlanState *) scanstate);
! 	scanstate->ps.qual = (List *)
  		ExecInitExpr((Expr *) node->plan.qual,
  					 (PlanState *) scanstate);
  
  	/*
  	 * tuple table initialization
  	 */
! 	ExecInitResultTupleSlot(estate, &scanstate->ps);
! 	ExecInitScanTupleSlot(estate, scanstate);
  
  	/*
  	 * initialize scan relation
  	 */
  	InitScanRelation(scanstate, estate);
  
! 	scanstate->ps.ps_TupFromTlist = false;
  
  	/*
  	 * Initialize result tuple type and projection info.
  	 */
! 	ExecAssignResultTypeFromTL(&scanstate->ps);
! 	ExecAssignScanProjectionInfo(scanstate);
  
  	return scanstate;
  }
--- 168,211 ----
  	 * create state structure
  	 */
  	scanstate = makeNode(SeqScanState);
! 	scanstate->ss.ps.plan = (Plan *) node;
! 	scanstate->ss.ps.state = estate;
  
  	/*
  	 * Miscellaneous initialization
  	 *
  	 * create expression context for node
  	 */
! 	ExecAssignExprContext(estate, &scanstate->ss.ps);
  
  	/*
  	 * initialize child expressions
  	 */
! 	scanstate->ss.ps.targetlist = (List *)
  		ExecInitExpr((Expr *) node->plan.targetlist,
  					 (PlanState *) scanstate);
! 	scanstate->ss.ps.qual = (List *)
  		ExecInitExpr((Expr *) node->plan.qual,
  					 (PlanState *) scanstate);
  
  	/*
  	 * tuple table initialization
  	 */
! 	ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
! 	ExecInitScanTupleSlot(estate, &scanstate->ss);
  
  	/*
  	 * initialize scan relation
  	 */
  	InitScanRelation(scanstate, estate);
  
! 	scanstate->ss.ps.ps_TupFromTlist = false;
  
  	/*
  	 * Initialize result tuple type and projection info.
  	 */
! 	ExecAssignResultTypeFromTL(&scanstate->ss.ps);
! 	ExecAssignScanProjectionInfo(&scanstate->ss);
  
  	return scanstate;
  }
*************** ExecEndSeqScan(SeqScanState *node)
*** 225,243 ****
  	/*
  	 * get information from node
  	 */
! 	relation = node->ss_currentRelation;
  	scanDesc = node->ss_currentScanDesc;
  
  	/*
  	 * Free the exprcontext
  	 */
! 	ExecFreeExprContext(&node->ps);
  
  	/*
  	 * clean out the tuple table
  	 */
! 	ExecClearTuple(node->ps.ps_ResultTupleSlot);
! 	ExecClearTuple(node->ss_ScanTupleSlot);
  
  	/*
  	 * close heap scan
--- 225,243 ----
  	/*
  	 * get information from node
  	 */
! 	relation = node->ss.ss_currentRelation;
  	scanDesc = node->ss_currentScanDesc;
  
  	/*
  	 * Free the exprcontext
  	 */
! 	ExecFreeExprContext(&node->ss.ps);
  
  	/*
  	 * clean out the tuple table
  	 */
! 	ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
! 	ExecClearTuple(node->ss.ss_ScanTupleSlot);
  
  	/*
  	 * close heap scan
*************** ExecSeqRestrPos(SeqScanState *node)
*** 305,311 ****
  	 * heap_restrpos will change; we'd have an internally inconsistent slot if
  	 * we didn't do this.
  	 */
! 	ExecClearTuple(node->ss_ScanTupleSlot);
  
  	heap_restrpos(scan);
  }
--- 305,311 ----
  	 * heap_restrpos will change; we'd have an internally inconsistent slot if
  	 * we didn't do this.
  	 */
! 	ExecClearTuple(node->ss.ss_ScanTupleSlot);
  
  	heap_restrpos(scan);
  }
diff -cprN head/src/backend/executor/nodeTidscan.c work/src/backend/executor/nodeTidscan.c
*** head/src/backend/executor/nodeTidscan.c	2010-01-04 09:10:26.638773000 +0900
--- work/src/backend/executor/nodeTidscan.c	2010-02-26 14:27:40.397702346 +0900
*************** ExecInitTidScan(TidScan *node, EState *e
*** 539,545 ****
  	currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid);
  
  	tidstate->ss.ss_currentRelation = currentRelation;
- 	tidstate->ss.ss_currentScanDesc = NULL;		/* no heap scan here */
  
  	/*
  	 * get the scan type from the relation descriptor.
--- 539,544 ----
diff -cprN head/src/include/nodes/execnodes.h work/src/include/nodes/execnodes.h
*** head/src/include/nodes/execnodes.h	2010-02-15 09:36:12.612700000 +0900
--- work/src/include/nodes/execnodes.h	2010-02-26 14:29:08.168697413 +0900
*************** typedef struct BitmapOrState
*** 1111,1117 ****
   *		retrieved from the subplan.
   *
   *		currentRelation    relation being scanned (NULL if none)
-  *		currentScanDesc    current scan descriptor for scan (NULL if none)
   *		ScanTupleSlot	   pointer to slot in tuple table holding scan tuple
   * ----------------
   */
--- 1111,1116 ----
*************** typedef struct ScanState
*** 1119,1133 ****
  {
  	PlanState	ps;				/* its first field is NodeTag */
  	Relation	ss_currentRelation;
- 	HeapScanDesc ss_currentScanDesc;
  	TupleTableSlot *ss_ScanTupleSlot;
  } ScanState;
  
! /*
!  * SeqScan uses a bare ScanState as its state node, since it needs
!  * no additional fields.
   */
! typedef ScanState SeqScanState;
  
  /*
   * These structs store information about index quals that don't have simple
--- 1118,1137 ----
  {
  	PlanState	ps;				/* its first field is NodeTag */
  	Relation	ss_currentRelation;
  	TupleTableSlot *ss_ScanTupleSlot;
  } ScanState;
  
! /* ----------------
!  *	 SeqScanState information
!  *
!  *		currentScanDesc    current scan descriptor for scan
!  * ----------------
   */
! typedef struct SeqScanState
! {
! 	ScanState	ss;				/* its first field is NodeTag */
! 	HeapScanDesc ss_currentScanDesc;
! } SeqScanState;
  
  /*
   * These structs store information about index quals that don't have simple
*************** typedef struct BitmapIndexScanState
*** 1214,1219 ****
--- 1218,1224 ----
  /* ----------------
   *	 BitmapHeapScanState information
   *
+  *		currentScanDesc    current scan descriptor for scan
   *		bitmapqualorig	   execution state for bitmapqualorig expressions
   *		tbm				   bitmap obtained from child index scan(s)
   *		tbmiterator		   iterator for scanning current pages
*************** typedef struct BitmapIndexScanState
*** 1226,1231 ****
--- 1231,1237 ----
  typedef struct BitmapHeapScanState
  {
  	ScanState	ss;				/* its first field is NodeTag */
+ 	HeapScanDesc currentScanDesc;
  	List	   *bitmapqualorig;
  	TIDBitmap  *tbm;
  	TBMIterator *tbmiterator;