Re: Feature proposal: www_fdw

From: Florian Pflug <fgp(at)phlo(dot)org>
To: "Dickson S(dot) Guedes" <listas(at)guedesoft(dot)net>
Cc: Alexander Soudakov <cygakob(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Feature proposal: www_fdw
Date: 2011-09-29 15:06:20
Message-ID: 6DC097C7-CAD1-4FF3-94EA-F0B07B2BD181@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sep29, 2011, at 16:43 , Dickson S. Guedes wrote:
> 2011/9/29 Florian Pflug <fgp(at)phlo(dot)org>:
>> You could use a hash table, allocated in the top-level memory context,
>> to store one authentication token per combination of server and local user.
>
> In fact I started something in this way, with ldap_fdw, stashing the
> connection away using memory context and something using es_query_cxt
> from EState, just testing until now. How do this from PlanForeignScan
> I couldn't figure out yet.

Maybe I'm missing something, but I'd say just allocate the hash table in
TopMemoryContext (or however that's called) and store a reference
to in a global variable. At least in the RESTful API case, you don't really
need to worry about purging entries from the table I think. You might
want to use <server, remote user> instead of <server, local user> as the
key, though. That should avoid unnecessary authentication steps and hashtable
entries if multiple local users are mapped to the same remote user, which
is probably quite common for webservices.

>> I suggest you look at the MySQL FDW (https://github.com/dpage/mysql_fdw)
>> - they presumably re-use the same connection over multiple foreign scans,
>> which seems to be a problem similar to yours.
>
> From what I understand they re-use between BeginForeignScan and the
> subsequent IterateForeignScans and freeing at end. In my tests, there
> is a (re)connection for each SELECT * FROM ...

Oh, OK, I didn't know that. They're probably not the best model, then...

best regards,
Florian Pflug

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2011-09-29 15:20:50 Re: pg_upgrade - add config directory setting
Previous Message MauMau 2011-09-29 15:05:36 Re: Does RelCache/SysCache shrink except when relations are deleted?