From: Paul Förster <paul.foerster@gmail.com>
To: Rob Sargent <robjsargent@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: localhost ssl
Date: Sat, 23 Jan 2021 10:03:18 +0100
Message-ID: <0583B416-4A3B-44DE-8C1B-3345775B1180@gmail.com> (raw)
In-Reply-To: <e7ed512c-9d9e-3c0e-64e2-247224076c98@gmail.com>
References: <e77dddba-3c98-4cb2-5492-c0cf694c084d@gmail.com>
<1ca17e3b-14de-69ff-5f0b-4082376571ca@aklaver.com>
<73ae4494-3b65-6ecd-b610-9a9ac5c9cce1@gmail.com>
<5f8db865-2f0e-6764-f2f0-b344feb42368@aklaver.com>
<2f653f6c-5f27-13fd-49be-90845a45ef43@gmail.com>
<4665f2de-d2a2-4623-8c61-0f42c899e8a3@aklaver.com>
<e7ed512c-9d9e-3c0e-64e2-247224076c98@gmail.com>
Hi Rob,
> On 22. Jan, 2021, at 23:48, Rob Sargent <robjsargent@gmail.com> wrote:
>
> Yes, I'm confused. As I said in reply to Jeff, I would rather not need to remember to set the search_path, which I can avoid if I login as "role".
I didn't follow the whole discussion, so sorry, to just jump in here.
You don't need to remember the search_path once your role is set up correctly. The following example demonstrates that you can set a default search_path for a role. But keep in mind that it is a *default* search_path for that role, which means a) it's for that role only and b) since it's a default, it is in effect only after the next login to that role.
db01=# \conninfo
You are connected to database "db01" as user "paul" on host ...
db01=# show search_path;
search_path
-----------------
"$user", public
(1 row)
db01=# \dn
List of schemas
Name | Owner
--------+----------
public | postgres
(1 row)
db01=# create schema s1;
CREATE SCHEMA
db01=# create schema s2;
CREATE SCHEMA
db01=# create schema s3;
CREATE SCHEMA
db01=# \dn
List of schemas
Name | Owner
--------+----------
public | postgres
s1 | paul
s2 | paul
s3 | paul
(4 rows)
Now comes the crucial part. Notice that the search path still shows the old value until I reconnect:
db01=# alter role paul set search_path to s2, s3;
ALTER ROLE
db01=# show search_path;
search_path
-----------------
"$user", public
(1 row)
db01=# \c db01
psql (13.1, server 12.5)
You are now connected to database "db01" as user "paul".
db01=# show search_path;
search_path
-------------
s2, s3
(1 row)
See? No $user, public or s1 after connecting to the database, only s2 and s3 as specified by me.
The same applies to resetting it to its default values "$user", public:
db01=# alter role paul reset search_path;
ALTER ROLE
db01=# show search_path;
search_path
-------------
s2, s3
(1 row)
db01=# \c db01
psql (13.1, server 12.5)
You are now connected to database "db01" as user "paul".
db01=# show search_path;
search_path
-----------------
"$user", public
(1 row)
There's a lot of descriptions on how this works. Just google for something like "postgres set default search path".
Also, see chapter 5.9.3 of the docs: The Schema Search Path
https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-PATH
Hope this helps.
Cheers,
Paul
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: paul.foerster@gmail.com, robjsargent@gmail.com, adrian.klaver@aklaver.com
Subject: Re: localhost ssl
In-Reply-To: <0583B416-4A3B-44DE-8C1B-3345775B1180@gmail.com>
References: <e77dddba-3c98-4cb2-5492-c0cf694c084d@gmail.com> <1ca17e3b-14de-69ff-5f0b-4082376571ca@aklaver.com> <73ae4494-3b65-6ecd-b610-9a9ac5c9cce1@gmail.com> <5f8db865-2f0e-6764-f2f0-b344feb42368@aklaver.com> <2f653f6c-5f27-13fd-49be-90845a45ef43@gmail.com> <4665f2de-d2a2-4623-8c61-0f42c899e8a3@aklaver.com> <e7ed512c-9d9e-3c0e-64e2-247224076c98@gmail.com> <0583B416-4A3B-44DE-8C1B-3345775B1180@gmail.com>
* 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