]> granicus.if.org Git - postgresql/commitdiff
Fix failure with whole-row reference to a subquery.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 11 Nov 2013 21:36:27 +0000 (16:36 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 11 Nov 2013 21:36:41 +0000 (16:36 -0500)
Simple oversight in commit 1cb108efb0e60d87e4adec38e7636b6e8efbeb57 ---
recursively examining a subquery output column is only sane if the
original Var refers to a single output column.  Found by Kevin Grittner.

src/backend/utils/adt/selfuncs.c

index d8c1a889edcb865a860b2fe2272d6fdcfed1d71a..9e00f2299443d448234cd4998fb79df124508af7 100644 (file)
@@ -4504,6 +4504,12 @@ examine_simple_variable(PlannerInfo *root, Var *var,
                RelOptInfo *rel;
                TargetEntry *ste;
 
+               /*
+                * Punt if it's a whole-row var rather than a plain column reference.
+                */
+               if (var->varattno == InvalidAttrNumber)
+                       return;
+
                /*
                 * Punt if subquery uses set operations or GROUP BY, as these will
                 * mash underlying columns' stats beyond recognition.  (Set ops are