Re: Questions and experiences writing a Foreign Data Wrapper

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: Tom Lane *EXTERN* <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Questions and experiences writing a Foreign Data Wrapper
Date: 2011-07-22 09:29:43
Message-ID: 4E294307.7050305@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2011-07-22 09:38:35 Re: WIP: Fast GiST index build
Previous Message Yeb Havinga 2011-07-22 09:23:21 Re: [v9.1] sepgsql - userspace access vector cache