Re: Questions and experiences writing a Foreign Data Wrapper - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Questions and experiences writing a Foreign Data Wrapper
Date
Msg-id 18259.1311274844@sss.pgh.pa.us
Whole thread Raw
In response to Questions and experiences writing a Foreign Data Wrapper  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
Responses Re: Questions and experiences writing a Foreign Data Wrapper
List pgsql-hackers
"Albe Laurenz" <laurenz.albe@wien.gv.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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: sinval synchronization considered harmful
Next
From: Robert Haas
Date:
Subject: Re: sinval synchronization considered harmful