From 9e9c38e15947f4f3ed478f8b70e74b55e31fe950 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 24 Jun 2016 15:06:19 -0400 Subject: postgres_fdw: Fix incorrect NULL handling in join pushdown. something.* IS NOT NULL means that every attribute of the row is not NULL, not that the row itself is non-NULL (e.g. because it's coming from below an outer join. Use (somevar.*)::pg_catalog.text IS NOT NULL instead. Ashutosh Bapat, per a report by Rushabh Lathia. Reviewed by Amit Langote and Etsuro Fujita. Schema-qualification added by me. --- contrib/postgres_fdw/deparse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'contrib/postgres_fdw/deparse.c') diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c index b0558edbf1b..2ca0e0ccf12 100644 --- a/contrib/postgres_fdw/deparse.c +++ b/contrib/postgres_fdw/deparse.c @@ -1599,9 +1599,9 @@ deparseColumnRef(StringInfo buf, int varno, int varattno, PlannerInfo *root, if (qualify_col) { - appendStringInfoString(buf, "CASE WHEN "); + appendStringInfoString(buf, "CASE WHEN ("); ADD_REL_QUALIFIER(buf, varno); - appendStringInfo(buf, "* IS NOT NULL THEN %u END", fetchval); + appendStringInfo(buf, "*)::pg_catalog.text IS NOT NULL THEN %u END", fetchval); } else appendStringInfo(buf, "%u", fetchval); @@ -1643,9 +1643,9 @@ deparseColumnRef(StringInfo buf, int varno, int varattno, PlannerInfo *root, */ if (qualify_col) { - appendStringInfoString(buf, "CASE WHEN "); + appendStringInfoString(buf, "CASE WHEN ("); ADD_REL_QUALIFIER(buf, varno); - appendStringInfo(buf, "* IS NOT NULL THEN "); + appendStringInfo(buf, "*)::pg_catalog.text IS NOT NULL THEN "); } appendStringInfoString(buf, "ROW("); -- cgit v1.2.3