Re: patch: improve "user mapping not found" error message

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: improve "user mapping not found" error message
Date: 2023-11-30 04:42:26
Message-ID: 780e3ad4-6b57-4598-8168-53f2559d8ec9@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 23.11.23 09:41, Peter Eisentraut wrote:
> On 20.11.23 02:25, Ian Lawrence Barwick wrote:
>> 2023年7月3日(月) 18:22 Peter Eisentraut <peter(at)eisentraut(dot)org>:
>>>
>>> On 23.06.23 09:45, Ian Lawrence Barwick wrote:
>>>>        if (!HeapTupleIsValid(tp))
>>>> +     {
>>>> +             ForeignServer *server = GetForeignServer(serverid);
>>>> +
>>>>                ereport(ERROR,
>>>>                                (errcode(ERRCODE_UNDEFINED_OBJECT),
>>>> -                              errmsg("user mapping not found for
>>>> \"%s\"",
>>>> -
>>>> MappingUserName(userid))));
>>>> +                              errmsg("user mapping not found for
>>>> user \"%s\", server \"%s\"",
>>>> +                                             MappingUserName(userid),
>>>> +                                             server->servername)));
>>>> +     }
>>>
>>> What if the foreign server does not exist either?  Then this would show
>>> a "cache lookup failed" error message, which I think we should avoid.
>>>
>>> There is existing logic for handling this in
>>> get_object_address_usermapping().
>>
>> Apologies, missed this response somewhere. Does the attached fix that?
>
> Hmm, now that I look at this again, under what circumstances would the
> server not be found?  Maybe the first patch was right and it should give
> a "scary" error in that case, instead of just omitting it.
>
> In any case, this patch appears to be missing an update in the
> postgres_fdw test output.

I have committed the first version of the patch together with the
required test changes.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2023-11-30 04:50:27 Re: should check collations when creating partitioned index
Previous Message jian he 2023-11-30 04:35:14 Re: Improve rowcount estimate for UNNEST(column)