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

Ian Lawrence Barwick <barwick@gmail.com>

From: Ian Lawrence Barwick <barwick@gmail.com>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2023-11-20T01:25:42Z
Lists: pgsql-hackers

Attachments

2023年7月3日(月) 18:22 Peter Eisentraut <peter@eisentraut.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?

Regards

Ian Barwick

Commits

  1. Improve "user mapping not found" error message