aboutsummaryrefslogtreecommitdiff
path: root/contrib/postgres_fdw/deparse.c
diff options
context:
space:
mode:
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