Re: Update "usename" in pg_user

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Ron <ronljohnsonjr(at)gmail(dot)com>
Cc: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Update "usename" in pg_user
Date: 2023-11-14 15:04:20
Message-ID: CAKFQuwZ-N89WysBAs0EGUrVqZM3jHGURAAv7ZddfdNjqzsxNRQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Tue, Nov 14, 2023 at 7:57 AM Ron <ronljohnsonjr(at)gmail(dot)com> wrote:

>
> A one-liner, that might have to be modified for double-quote handling:
> psql -c "SELECT format('ALTER ROLE %s RENAME TO \"%s(at)example(dot)com\"
> <%25s(at)example(dot)com%5C>;', username, username) FROM pg_user WHERE username
> != 'postgres'\gexec"
>
> The two username uses can be shrunk to one with appropriate use of %s
> modifiers that I don't remember off the top of my head.
>
>
Yeah, it's positional. I think (motivated individuals can check the docs)
%1$s

It would be nice to have an hstore and/or json variant of format so one can
use names instead of positions.

format('%greeting$s, my name is %name$s', jsonb_build_object('name',
'Dave', 'greeting', 'Yo!')))

David J.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Ramesh Penuballi 2023-11-14 15:39:32 Regarding the details of postgresql10 download
Previous Message Ron 2023-11-14 14:57:11 Re: Update "usename" in pg_user