Re: Postgres_fdw join pushdown - wrong results with whole-row reference - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Postgres_fdw join pushdown - wrong results with whole-row reference
Date
Msg-id CA+TgmoZwB5tYTBPzAfeXyJv+HY0ycottQxScKoj132EWjNuVWw@mail.gmail.com
Whole thread Raw
In response to Re: Postgres_fdw join pushdown - wrong results with whole-row reference  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
Responses Re: Postgres_fdw join pushdown - wrong results with whole-row reference  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
Re: Postgres_fdw join pushdown - wrong results with whole-row reference  (Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>)
List pgsql-hackers
On Wed, Jun 22, 2016 at 4:11 AM, Amit Langote
<Langote_Amit_f8@lab.ntt.co.jp> wrote:
>> In an outer join we have to differentiate between a row being null (because
>> there was no joining row on nullable side) and a non-null row with all
>> column values being null. If we cast the whole-row expression to a text
>> e.g. r.*::text and test the resultant value for nullness, it gives us what
>> we want. A null row casted to text is null and a row with all null values
>> casted to text is not null.
>
> You are right.  There may be non-null rows with all columns null which are
> handled wrongly (as Rushabh reports) and the hack I proposed is not right
> for.  Especially if from non-nullable side as in the reported case, NULL
> test for such a whole-row-var would produce the wrong result.  Casting to
> text as your patch does produces the correct behavior.

I agree, but I think we'd better cast to pg_catalog.text instead, just
to be safe.  Committed that way.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Odd behavior with domains
Next
From: Robert Haas
Date:
Subject: Re: Postgres_fdw join pushdown - wrong results with whole-row reference