The shortcut exit that I recently added to ExecInitIndexScan() for
authorTom Lane
Thu, 31 May 2007 20:45:26 +0000 (20:45 +0000)
committerTom Lane
Thu, 31 May 2007 20:45:26 +0000 (20:45 +0000)
EXPLAIN-only operation was a little too short; it skipped initializing the
node's result tuple type, which may be needed depending on what's above the
indexscan node.  Call ExecAssignResultTypeFromTL before exiting.  (For good
luck I moved up the ExecAssignScanProjectionInfo call as well, so that
everything except indexscan-specific initialization will still be done.)
Per example from Grant Finnemore.

src/backend/executor/nodeIndexscan.c

index 8c22e3ade0ec42229934d614a0d688c4e7997251..a1fb29ad2c182e01ab3f6bb4680f4371853512ae 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.122 2007/05/25 17:54:25 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.123 2007/05/31 20:45:26 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -522,6 +522,12 @@ ExecInitIndexScan(IndexScan *node, EState *estate, int eflags)
     */
    ExecAssignScanType(&indexstate->ss, RelationGetDescr(currentRelation));
 
+   /*
+    * Initialize result tuple type and projection info.
+    */
+   ExecAssignResultTypeFromTL(&indexstate->ss.ps);
+   ExecAssignScanProjectionInfo(&indexstate->ss);
+
    /*
     * If we are just doing EXPLAIN (ie, aren't going to run the plan),
     * stop here.  This allows an index-advisor plugin to EXPLAIN a plan
@@ -589,12 +595,6 @@ ExecInitIndexScan(IndexScan *node, EState *estate, int eflags)
                                               indexstate->iss_NumScanKeys,
                                               indexstate->iss_ScanKeys);
 
-   /*
-    * Initialize result tuple type and projection info.
-    */
-   ExecAssignResultTypeFromTL(&indexstate->ss.ps);
-   ExecAssignScanProjectionInfo(&indexstate->ss);
-
    /*
     * all done.
     */