Re: escaped rolenames in pg_has_role - Mailing list pgsql-general

From Tom Lane
Subject Re: escaped rolenames in pg_has_role
Date
Msg-id 19846.1182870353@sss.pgh.pa.us
Whole thread Raw
In response to escaped rolenames in pg_has_role  ("Willy-Bas Loos" <willybas@gmail.com>)
Responses Re: escaped rolenames in pg_has_role  ("Willy-Bas Loos" <willybas@gmail.com>)
List pgsql-general
"Willy-Bas Loos" <willybas@gmail.com> writes:
> The problem is that pg_has_role does not recognize the usernames when they
> are escaped by quote_literal or quote_ident.

Don't use quote_ident here.  In fact, I'd say that you appear to have
completely misunderstood the appropriate rules for quoting at all.
If you are passed data that you don't know if it's quoted or not, what
the heck are you supposed to do with it?  A quote in the data might be
real data or quoting, and you have no way to tell the difference.

You need to redesign your function stack to eliminate that ambiguity.
I'd recommend that data items never have quoting, except at the instant
that they get embedded into SQL strings (which this function isn't doing
at all, and so it does not need to quote the name).

            regards, tom lane

pgsql-general by date:

Previous
From: "Willy-Bas Loos"
Date:
Subject: escaped rolenames in pg_has_role
Next
From: Andrew Sullivan
Date:
Subject: Re: how to implement unusual constraint