aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_relation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/parser/parse_relation.c')
-rw-r--r--src/backend/parser/parse_relation.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 30b307b191c..3f2177b9aff 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -508,10 +508,17 @@ scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte, char *colname,
attnum = specialAttNum(colname);
if (attnum != InvalidAttrNumber)
{
- /* now check to see if column actually is defined */
+ /*
+ * Now check to see if column actually is defined. Because of
+ * an ancient oversight in DefineQueryRewrite, it's possible that
+ * pg_attribute contains entries for system columns for a view,
+ * even though views should not have such --- so we also check
+ * the relkind. This kluge will not be needed in 9.3 and later.
+ */
if (SearchSysCacheExists2(ATTNUM,
ObjectIdGetDatum(rte->relid),
- Int16GetDatum(attnum)))
+ Int16GetDatum(attnum)) &&
+ get_rel_relkind(rte->relid) != RELKIND_VIEW)
{
var = make_var(pstate, rte, attnum, location);
/* Require read access to the column */