aboutsummaryrefslogtreecommitdiff
path: root/contrib/postgres_fdw/deparse.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-02-22 09:21:50 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2013-02-22 09:21:50 -0500
commit6da378dbc97f1b96bf5778a558e168a0dc405bce (patch)
treef702a08f31aa1eb3ef421835cd109a197ec8eaa5 /contrib/postgres_fdw/deparse.c
parent211e157a51bf94dfcc143e78221951411f87e4b2 (diff)
downloadpostgresql-6da378dbc97f1b96bf5778a558e168a0dc405bce.tar.gz
postgresql-6da378dbc97f1b96bf5778a558e168a0dc405bce.zip
Fix whole-row references in postgres_fdw.
The optimization to not retrieve unnecessary columns wasn't smart enough. Noted by Thom Brown.
Diffstat (limited to 'contrib/postgres_fdw/deparse.c')
-rw-r--r--contrib/postgres_fdw/deparse.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c
index 93f2541cfc1..0293115054f 100644
--- a/contrib/postgres_fdw/deparse.c
+++ b/contrib/postgres_fdw/deparse.c
@@ -364,6 +364,7 @@ deparseSimpleSql(StringInfo buf,
{
RangeTblEntry *rte = root->simple_rte_array[baserel->relid];
Bitmapset *attrs_used = NULL;
+ bool have_wholerow;
bool first;
AttrNumber attr;
ListCell *lc;
@@ -381,6 +382,10 @@ deparseSimpleSql(StringInfo buf,
&attrs_used);
}
+ /* If there's a whole-row reference, we'll need all the columns. */
+ have_wholerow = bms_is_member(0 - FirstLowInvalidHeapAttributeNumber,
+ attrs_used);
+
/*
* Construct SELECT list
*
@@ -401,7 +406,8 @@ deparseSimpleSql(StringInfo buf,
appendStringInfo(buf, ", ");
first = false;
- if (bms_is_member(attr - FirstLowInvalidHeapAttributeNumber,
+ if (have_wholerow ||
+ bms_is_member(attr - FirstLowInvalidHeapAttributeNumber,
attrs_used))
deparseColumnRef(buf, baserel->relid, attr, root);
else