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

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
moreuseful if  it would return NULL or something similar instead.  Otherwise one would have to check for existence
beforehand,which is no less complicated than what  GetUserMapping does. 

2) If I decide to close remote database connections after  use, I would like to do so where reasonable.  I would like
tokeep the connection open between query  planning and query execution and close it when the  scan is done.  The
exceptioncould be named prepared statements.  Is there a way to tell if that is the case during  planing or execution? 

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,
internalparameters 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
ornot. I ended up doing that in the first call to IterateForeignScan because I saw no other way. 
 That seems a bit unfortunate. Is there an easy way to change that? If not, it should be documented.

Yours,
Laurenz Albe


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [v9.1] sepgsql - userspace access vector cache
Next
From: Tom Lane
Date:
Subject: Re: Another issue with invalid XML values