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:
@ -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
|
||||
|
Reference in New Issue
Block a user