Skip to content

Commit 9e9c38e

Browse files
committed
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.
1 parent 267569b commit 9e9c38e

File tree

3 files changed

+50
-25
lines changed

3 files changed

+50
-25
lines changed

contrib/postgres_fdw/deparse.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,9 +1599,9 @@ deparseColumnRef(StringInfo buf, int varno, int varattno, PlannerInfo *root,
15991599

16001600
if (qualify_col)
16011601
{
1602-
appendStringInfoString(buf, "CASE WHEN ");
1602+
appendStringInfoString(buf, "CASE WHEN (");
16031603
ADD_REL_QUALIFIER(buf, varno);
1604-
appendStringInfo(buf, "* IS NOT NULL THEN %u END", fetchval);
1604+
appendStringInfo(buf, "*)::pg_catalog.text IS NOT NULL THEN %u END", fetchval);
16051605
}
16061606
else
16071607
appendStringInfo(buf, "%u", fetchval);
@@ -1643,9 +1643,9 @@ deparseColumnRef(StringInfo buf, int varno, int varattno, PlannerInfo *root,
16431643
*/
16441644
if (qualify_col)
16451645
{
1646-
appendStringInfoString(buf, "CASE WHEN ");
1646+
appendStringInfoString(buf, "CASE WHEN (");
16471647
ADD_REL_QUALIFIER(buf, varno);
1648-
appendStringInfo(buf, "* IS NOT NULL THEN ");
1648+
appendStringInfo(buf, "*)::pg_catalog.text IS NOT NULL THEN ");
16491649
}
16501650

16511651
appendStringInfoString(buf, "ROW(");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy