aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-11-11 16:36:27 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2013-11-11 16:36:41 -0500
commite243bd79d98ff4dc5acc20a290dbdc1ad2e17e91 (patch)
tree18f71e1242c3bbe0ba08c825bee01acbc75179ce
parentfbbd150a25676076b5ed0e68f77adafcf46c1f4d (diff)
downloadpostgresql-e243bd79d98ff4dc5acc20a290dbdc1ad2e17e91.tar.gz
postgresql-e243bd79d98ff4dc5acc20a290dbdc1ad2e17e91.zip
Fix failure with whole-row reference to a subquery.
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.
-rw-r--r--src/backend/utils/adt/selfuncs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index d8c1a889edc..9e00f229944 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -4505,6 +4505,12 @@ examine_simple_variable(PlannerInfo *root, Var *var,
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
* particularly nasty; if we forged ahead, we would return stats