pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ц <pfunk@mail.ru>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Invalid name syntax on to_regrole(session_user)
Date: Tue, 14 Apr 2020 10:04:43 -0400
Message-ID: <16503.1586873083@sss.pgh.pa.us> (raw)
In-Reply-To: <1586868479.588975920@f425.i.mail.ru>
References: <158686573592.9421.7178775688662332959@malur.postgresql.org>
	<1586868479.588975920@f425.i.mail.ru>

=?UTF-8?B?0KY=?= <pfunk@mail.ru> writes:
> create role "dot.net"
> set session authorization 'dot.net';
> select to_regrole(session_user); ERROR: invalid name syntax

Well, we've got this:

regression=> select session_user;
 session_user 
--------------
 dot.net
(1 row)

which is reasonable: that output shouldn't be quoted.
But then:

regression=> select 'dot.net'::regrole;
ERROR:  invalid name syntax
LINE 1: select 'dot.net'::regrole;
               ^

which is also reasonable.  So you need to provide the quoting if
you want to interface these.

regression=> select to_regrole(quote_ident(session_user));
 to_regrole 
------------
 "dot.net"
(1 row)

> Is there other way (without extra type conversions) for getting oid of session_user?

select oid from pg_roles where rolname = session_user


			regards, tom lane





view thread (2+ messages)

Message-ID: <16503.1586873083@sss.pgh.pa.us>
Permalink:  ../16503.1586873083@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16503.1586873083@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pfunk@mail.ru
  Subject: Re: Invalid name syntax on to_regrole(session_user)
  In-Reply-To: <16503.1586873083@sss.pgh.pa.us>
  References: <158686573592.9421.7178775688662332959@malur.postgresql.org> <1586868479.588975920@f425.i.mail.ru> <16503.1586873083@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox