1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-11 20:28:21 +03:00

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.
This commit is contained in:
Robert Haas
2016-06-24 15:06:19 -04:00
parent 267569b24c
commit 9e9c38e159
3 changed files with 50 additions and 25 deletions

View File

@ -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(");