Re: EvalPlanQual behaves oddly for FDW queries involving system columns

From: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
To: Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: EvalPlanQual behaves oddly for FDW queries involving system columns
Date: 2015-02-03 07:44:02
Message-ID: CAFjFpRf_RBQi7KL5nuAmmeRibov7SkFUOYTuNoKXL4yeYJgsNg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Fujita-san,
I am having some minor problems running this repro

On Thu, Jan 15, 2015 at 12:45 PM, Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp
> wrote:

> Here is an example using postgres_fdw.
>
> [Terminal 1]
> postgres=# create table t (a int, b int);
> CREATE TABLE
> postgres=# insert into t values (1, 1);
> INSERT 0 1
> postgres=# begin;
> BEGIN
> postgres=# update t set b = b * 2;
> UPDATE 1
>
> [Terminal 2]
> postgres=# create foreign table ft (a int) server loopback options
> (table_name 'lbt');
>

There isn't any table "lbt" mentioned here. Do you mean "t" here?

> CREATE FOREIGN TABLE
> postgres=# insert into ft values (1);
> INSERT 0 1
> postgres=# select tableoid, ctid, * from ft;
> tableoid | ctid | a
> ----------+-------+---
> 25092 | (0,1) | 1
> (1 row)
>

Shouldn't we see two values here one inserted in 't' and one in "ft"

>
> postgres=# select ft.tableoid, ft.ctid, ft.* from t, ft where t.a = ft.a
> for update;
>
> [Terminal 1]
> postgres=# commit;
> COMMIT
>
> [Terminal 2]
> postgres=# select ft.tableoid, ft.ctid, ft.* from t, ft where t.a = ft.a
> for update;
> tableoid | ctid | a
> ----------+----------------+---
> 0 | (4294967295,0) | 1
> (1 row)
>
>
Instead of this result, I got following error
ERROR: could not serialize access due to concurrent update
CONTEXT: Remote SQL command: SELECT a, ctid FROM public.t FOR UPDATE

Am I missing something while reproducing the problem?

> Note that tableoid and ctid have been changed!
>
> I think the reason for that is because EvalPlanQualFetchRowMarks doesn't
> properly set tableoid and ctid for foreign tables, IIUC. I think this
> should be fixed. Please find attached a patch. The patch slightly
> relates to [1], so if it is reasonable, I'll update [1] on top of this.
>
> [1] https://commitfest.postgresql.org/action/patch_view?id=1386
>
> Best regards,
> Etsuro Fujita
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
>

--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2015-02-03 07:44:58 Re: Some dead code in metaphone() of fuzzystrmatch.c
Previous Message Amit Langote 2015-02-03 07:43:46 Re: A minor comment typo in parse_utilcmd.c