Re: EvalPlanQual behaves oddly for FDW queries involving system columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: EvalPlanQual behaves oddly for FDW queries involving system columns
Date: 2015-04-07 22:44:07
Message-ID: 14504.1428446647@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp> writes:
> To support ROW_MARK_REFERENCE on (postgres_fdw) foreign tables, I'd like
> to propose the following FDW APIs:

> RowMarkType
> GetForeignRowMarkType(Oid relid,
> LockClauseStrength strength);

> Decide which rowmark type to use for a foreign table (that has strength
> = LCS_NONE), ie, ROW_MARK_REFERENCE or ROW_MARK_COPY. (For now, the
> second argument takes LCS_NONE only, but is intended to be used for the
> possible extension to the other cases.) This is called during
> select_rowmark_type() in the planner.

Why would you restrict that to LCS_NONE? Seems like the point is to give
the FDW control of the rowmark behavior, not only partial control.
(For the same reason I disagree with the error check in the patch that
restricts which ROW_MARK options this function can return. If the FDW has
TIDs, seems like it could reasonably use whatever options tables can use.)

> void
> BeginForeignFetch(EState *estate,
> ExecRowMark *erm,
> List *fdw_private,
> int eflags);

> Begin a remote fetch. This is called during InitPlan() in the executor.

The begin/end functions seem like useless extra mechanism. Why wouldn't
the FDW just handle this during its regular scan setup? It could look to
see whether the foreign table is referenced by any ExecRowMarks (possibly
there's room to add some convenience functions to help with that). What's
more, that design would make it simpler if the basic row fetch needs to be
modified.

> And I'd also like to propose to add a table/server option,
> row_mark_reference, to postgres_fdw. When a user sets the option to
> true for eg a foreign table, ROW_MARK_REFERENCE will be used for the
> table, not ROW_MARK_COPY.

Why would we leave that in the hands of the user? Hardly anybody is going
to know what to do with the option, or even that they should do something
with it. It's basically only of value for debugging AFAICS, but if we
expose an option we're going to be stuck with supporting it forever.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Qingqing Zhou 2015-04-07 22:57:00 Re: rare avl shutdown slowness (related to signal handling)
Previous Message Jim Nasby 2015-04-07 22:42:34 Re: New error code to track unsupported contexts