Re: Questions and experiences writing a Foreign Data Wrapper

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Questions and experiences writing a Foreign Data Wrapper
Date: 2011-07-21 19:00:44
Message-ID: 18259.1311274844@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> writes:
> I wrote a FDW for Oracle to a) learn some server coding
> and b) see how well the FDW API works for me.

> I came up with three questions/experiences:

> 1) GetUserMapping throws an error if there is no
> user mapping for the user (or PUBLIC).
> I think that it would be much more useful if
> it would return NULL or something similar instead.

We could make it do that, but under what circumstances would it be
useful to not throw an error? It doesn't seem like you should try
to establish a remote connection anyway, if there's no mapping.

> 3) I am confused by the order of function calls
> during execution of a subplan. It is like this:
> BeginForeignScan
> ReScanForeignScan
> IterateForeignScan
> IterateForeignScan
> ...
> ReScanForeignScan
> IterateForeignScan
> IterateForeignScan
> ...
> EndForeignScan
> So the first ReScan is done immediately after
> BeginForeignScan. Moreover, internal parameters are not
> set in the BeginForeignScan call.

> This is probably working as designed, but BeginForeignScan
> has no way to know whether it should execute a remote
> query or not.

I'd say it probably shouldn't, ever. If you look at the executor's node
init functions, none of them do any actual data fetching. They just
prepare data structures.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-07-21 19:15:56 Re: sinval synchronization considered harmful
Previous Message Tom Lane 2011-07-21 18:50:08 Re: sinval synchronization considered harmful