Re: Odd system-column handling in postgres_fdw join pushdown patch

From: Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Odd system-column handling in postgres_fdw join pushdown patch
Date: 2016-09-26 07:37:51
Message-ID: 19a643b2-b83b-2632-8525-6b0d7cb5f04a@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2016/09/21 0:40, Robert Haas wrote:
> On Fri, Jul 1, 2016 at 3:10 AM, Etsuro Fujita
> <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp> wrote:
>> On 2016/04/14 4:57, Robert Haas wrote:

>>> 1. For a regular FDW scan, zero the xmin, xmax, and cid of the tuple
>>> before returning it from postgres_fdw, so that we don't expose the
>>> datum-tuple fields. I can't see any reason this isn't safe, but I
>>> might be missing something.

>> I noticed odd behavior of this in EvalPlanQual. Consider:
>>
>> -- session 1
>> postgres=# create extension postgres_fdw;
>> CREATE EXTENSION
>> postgres=# create server fs foreign data wrapper postgres_fdw options
>> (dbname 'postgres');
>> CREATE SERVER
>> postgres=# create user mapping for public server fs;
>> CREATE USER MAPPING
>> postgres=# create table t1 (a int, b int);
>> CREATE TABLE
>> postgres=# create table t2 (a int, b int);
>> CREATE TABLE
>> postgres=# insert into t1 values (1, 1);
>> INSERT 0 1
>> postgres=# insert into t2 values (1, 1);
>> INSERT 0 1
>> postgres=# create foreign table ft1 (a int, b int) server fs options
>> (table_name 't1');
>> CREATE FOREIGN TABLE
>> postgres=# select xmin, xmax, cmin, * from ft1;
>> xmin | xmax | cmin | a | b
>> ------+------+------+---+---
>> 0 | 0 | 0 | 1 | 1
>> (1 row)
>>
>> -- session 2
>> postgres=# begin;
>> BEGIN
>> postgres=# update t2 set a = a;
>> UPDATE 1
>>
>> -- session 1
>> postgres=# select ft1.xmin, ft1.xmax, ft1.cmin, ft1.* from ft1, t2 for
>> update;
>>
>> -- session 2
>> postgres=# commit;
>> COMMIT
>>
>> -- session 1 (will show the following)
>> xmin | xmax | cmin | a | b
>> ------+------------+-------+---+---
>> 128 | 4294967295 | 16398 | 1 | 1
>> (1 row)
>>
>> The values of xmin, xmax, and cmin are not 0! The reason for that is that
>> we don't zero these values in a test tuple stored by
>> EvalPlanQualFetchRowMarks for EvalPlanQual re-evaluations.
>>
>> That cleanup applies to the file_fdw foreign table case as well, so I think
>> xmin, xmax, and cid in tuples from such tables should be set to 0, too. And
>> ISTM that it's better that the core (ie, ForeignNext) supports doing that,
>> rather than each FDW does that work. That would also minimize the overhead
>> because ForeignNext does that if needed. Please find attached a patch.

> If you want this to be considered, you'll need to rebase it and submit
> it to the next CommitFest.

Will do.

Best regards,
Etsuro Fujita

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2016-09-26 07:49:27 Re: Declarative partitioning - another take
Previous Message Etsuro Fujita 2016-09-26 07:35:17 Re: Push down more full joins in postgres_fdw