Re: Postgres_fdw join pushdown - wrong results with whole-row reference

From: Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
To: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
Cc: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Postgres_fdw join pushdown - wrong results with whole-row reference
Date: 2016-06-24 06:20:32
Message-ID: ea121f7f-0f0b-3102-d71e-467776e3868c@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2016/06/22 19:37, Ashutosh Bapat wrote:
> On Wed, Jun 22, 2016 at 3:57 PM, Etsuro Fujita
> Maybe I'm confused, but I think that in the system-column case it's
> the user's responsibility to specify system columns for foreign
> tables in a local query only when that makes sense on the remote
> end, as shown in the below counter example:
>
> postgres=# create foreign table fv1 (a int, b int) server myserver
> options (table_name 'v1');
> CREATE FOREIGN TABLE
> postgres=# select ctid, * from fv1;
> ERROR: column "ctid" does not exist
> CONTEXT: Remote SQL command: SELECT a, b, ctid FROM public.v1

> But a ctid, when available, would rightly get nullified when referenced
> as a column of table.

Really?

> What happens with the other system columns is we 0
> them out locally, whether they are available at the foreign server or
> not. We never try to check whether they are available at the foreign
> server or not. If we use such column's column name to decide whether to
> report 0 or null and if that column is not available at the foreign
> table, we will get error. I think we should avoid that. Those column
> anyway do not make any sense.

Agreed except for oid. I think we should handle oid in the same way as
ctid, which I'll work on in the next CF.

I think the proposed idea of applying record::text explicit coercion to
a whole-row reference in the IS NOT NULL condition in the CASE WHEN
conversion would work as expected as you explained, but I'm concerned
that the cost wouldn't be negligible when the foreign table has a lot of
columns.

Best regards,
Etsuro Fujita

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2016-06-24 06:22:03 Re: initdb issue on 64-bit Windows - (Was: [pgsql-packagers] PG 9.6beta2 tarballs are ready)
Previous Message Michael Paquier 2016-06-24 05:46:25 Re: [BUG] pg_basebackup from disconnected standby fails