1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Fix whole-row references in postgres_fdw.

The optimization to not retrieve unnecessary columns wasn't smart enough.
Noted by Thom Brown.
This commit is contained in:
Tom Lane
2013-02-22 09:21:50 -05:00
parent 211e157a51
commit 6da378dbc9
3 changed files with 39 additions and 1 deletions

View File

@ -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