From 3b9c109f98e8682bad7deba40c7d185bf5fe2158 Mon Sep 17 00:00:00 2001 From: Shigeru Hanada Date: Fri, 19 Nov 2010 09:45:42 +0900 Subject: [PATCH] Fix postgresql_fdw to not use prefix in deparsed SQL except table reference in FROM clause. This fix avoids errors which occurs on child table scan with qual. --- contrib/postgresql_fdw/postgresql_fdw.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/postgresql_fdw/postgresql_fdw.c b/contrib/postgresql_fdw/postgresql_fdw.c index 9aa460e29f..98629900eb 100644 --- a/contrib/postgresql_fdw/postgresql_fdw.c +++ b/contrib/postgresql_fdw/postgresql_fdw.c @@ -389,9 +389,14 @@ deparseSql(ForeignScanState *scanstate) estate->es_range_table); /* - * Scanning multiple relations in a ForeignScan node is not supported. + * XXX: Prefix is set to false always because setting prefix to true makes + * the SQL invalid when this is a child scan for an inherited table and qual + * is not empty (need to generate WHERE clause). It might be needed to fix + * deparse_expression() to deparse column references in the qual into + * name of the child table, instead of name of the parent table, or table + * alias. */ - prefix = list_length(estate->es_range_table) > 1; + prefix = true; /* deparse SELECT and FROM clauses */ deparseSelectClause(&sql, table, scanstate->ss.ss_currentRelation->rd_att, -- 2.39.5