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

From Heikki Linnakangas
Subject Re: Questions and experiences writing a Foreign Data Wrapper
Date
Msg-id 4E294307.7050305@enterprisedb.com
Whole thread Raw
In response to Re: 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
Re: Questions and experiences writing a Foreign Data Wrapper
List pgsql-hackers
On 22.07.2011 11:08, Albe Laurenz wrote:
> Tom Lane wrote:
>>> 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.
>
> I guess I misunderstood the concept of user mapping.
> I assumed that the user of the mapping is the table owner and
> the mapping provides default values for all foreign tables
> the user owns.
>
> Does it refer to the user that executes a query?

Typically, a user mapping maps the user that executes the query, to a 
username and password in the remote system.

Instead of a username and password, it could be other connection 
information needed to connect to the foreign server, like SSL 
certificates. Or it could even specify the server to connect to, the 
details are wrapper-specific.

Note that the "user that executes a query" might not be the user that 
logged in, if the query is in a security definer function.

> Or is a user mapping intended to be the only source of
> connection information?

No, you can specify connection details at per-server and 
per-foreign-table level too. The FDW implementation is free to accept or 
reject options where-ever it wants.

> I guess it is time to read my SQL Standard, but some clarification
> in the documentation sure wouldn't hurt.

Agreed, there doesn't seem to be any documentation on user mappings, 
aside from the reference page for the CREATE USER MAPPING command. The 
"5.10 Foreign Data" section should explain what user mappings are. Want 
to give it a shot?

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Yeb Havinga
Date:
Subject: Re: [v9.1] sepgsql - userspace access vector cache
Next
From: Alexander Korotkov
Date:
Subject: Re: WIP: Fast GiST index build