pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Bryn Llewellyn <bryn@yugabyte.com>
To: David G. Johnston <david.g.johnston@gmail.com>
To: Tom Lane PostgreSQL <tgl@sss.pgh.pa.us>
Cc: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Christophe Pettus <xof@thebuild.com>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: Re: Seems to be impossible to set a NULL search_path
Date: Wed, 6 Jul 2022 08:42:56 -0700
Message-ID: <7bdd0ecd-0bf6-b5ac-534c-1f2f428c84b7@aklaver.com> (raw)
In-Reply-To: <0E972410-9DF5-46B4-ACEA-56B06E5BA96D@yugabyte.com>
References: <4B5F24E6-2FF9-4964-BF07-C609DC38E377@yugabyte.com>
	<0c649c8e-dfff-7dea-908a-7b68611fd18f@aklaver.com>
	<CAFj8pRA2fHFe-zqxnuR27MVGE+waKWsPoDAVD3W3iMj9TTFDjw@mail.gmail.com>
	<593de6cc-08df-bbcb-5164-8796db554851@aklaver.com>
	<51E0A66E-C09E-4F6F-8B53-BBB83F810F90@yugabyte.com>
	<1997258.1657048380@sss.pgh.pa.us>
	<CAKFQuwbgvmJBQ2x8HRDHMpVBxt8+UCND0CpbUsfrf9wrWJOEyw@mail.gmail.com>
	<0E972410-9DF5-46B4-ACEA-56B06E5BA96D@yugabyte.com>

On 7/5/22 20:55, Bryn Llewellyn wrote:
> //
>> /david.g.johnston@gmail.com <mailto:david.g.johnston@gmail.com> wrote:
>> /
>>> tgl@sss.pgh.pa.us <mailto:tgl@sss.pgh.pa.us> wrote:
>>>
>>> search_path's value is not a SQL name.  It's a list of SQL 
>>> names wrapped in a string ... and the list can be empty.
>>
>> This doesn't seem to be correct - wrapping them in single quotes in 
>> the SET command ends up behaving as if you wrapped them in double 
>> quotes anywhere else (and wrapping them individually in double quotes 
>> here works just fine too).
> 
> And then...
> 
>> /adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com> wrote:/
>>
>> Those are creating objects. Set search_path is setting a configuration 
>> value. Pretty sure it is:
>>
>> { TO | = } { value | 'value' | DEFAULT 
> 
> There's different use cases. For example:
> 
> *set my_namspace.x = 'Dog house';*
> *show my_namspace.x ;

Not sure what your point is?

> *
> I can't reconcile what you three (Tom, David, and Adrian) have said. I'm 
> interested to hear how you interpret what I showed in this reply:
> 
> https://www.postgresql.org/message-id/48E1391E-5A21-4736-B4B1-8B9468ECAFD4%40yugabyte.com 
> <https://www.postgresql.org/message-id/48E1391E-5A21-4736-B4B1-8B9468ECAFD4%40yugabyte.com;
> 
> and in particular to this:
> 
> *create schema "s1, s2";
> create table "s1, s2".t(k int);
> insert into "s1, s2".t(k) values(42);
> set search_path = "s1, s2";*
> *show **search_path;**
> select k from t;*
> 
> OR (with single quotes in "set search_path":
> 
> *create schema "s1, s2";
> create table "s1, s2".t(k int);
> insert into "s1, s2".t(k) values(42);
> set search_path = 's1, s2';
> **show **search_path;**
> **select k from t;
> *

 From here 
https://www.postgresql.org/docs/current/runtime-config-client.html:

search_path (string)
...
The value for search_path must be a comma-separated list of schema names
...

By quoting the above in either single or double quotes you change what 
looks like a list pf schemas into a single schema:

show search_path;
  search_path
-------------
  "s1, s2"

If you want that to be a list of schemas then:

set search_path = s1, s2;
SET

show search_path;
  search_path
-------------
  s1, s2


> I get a resounding 42 in both cases. Now try this:
> 
> *set search_path = no_such_schema, "No Such Schema";*
> *show **search_path;**

Which is same as:

set search_path = no_such_schema, 'No Such Schema';

show search_path;
            search_path
----------------------------------
  no_such_schema, "No Such Schema"

Since the list of names will end up being identifiers for schema any 
name with spaces needs to be quoted. Otherwise:

set search_path = no_such_schema, No Such Schema;
ERROR:  syntax error at or near "Such"
LINE 1: set search_path = no_such_schema, No Such Schema;


> *
> 
> All outcomes accord with the mental model that you tell me is wrong.
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (31+ messages)  latest in thread

Message-ID: <7bdd0ecd-0bf6-b5ac-534c-1f2f428c84b7@aklaver.com>
Permalink:  ../7bdd0ecd-0bf6-b5ac-534c-1f2f428c84b7@aklaver.com/
Also on:    postgresql.org/message-id/7bdd0ecd-0bf6-b5ac-534c-1f2f428c84b7@aklaver.com

 · 

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: adrian.klaver@aklaver.com, bryn@yugabyte.com, david.g.johnston@gmail.com, tgl@sss.pgh.pa.us, pavel.stehule@gmail.com, xof@thebuild.com
  Subject: Re: Seems to be impossible to set a NULL search_path
  In-Reply-To: <7bdd0ecd-0bf6-b5ac-534c-1f2f428c84b7@aklaver.com>
  References: <4B5F24E6-2FF9-4964-BF07-C609DC38E377@yugabyte.com> <0c649c8e-dfff-7dea-908a-7b68611fd18f@aklaver.com> <CAFj8pRA2fHFe-zqxnuR27MVGE+waKWsPoDAVD3W3iMj9TTFDjw@mail.gmail.com> <593de6cc-08df-bbcb-5164-8796db554851@aklaver.com> <51E0A66E-C09E-4F6F-8B53-BBB83F810F90@yugabyte.com> <1997258.1657048380@sss.pgh.pa.us> <CAKFQuwbgvmJBQ2x8HRDHMpVBxt8+UCND0CpbUsfrf9wrWJOEyw@mail.gmail.com> <0E972410-9DF5-46B4-ACEA-56B06E5BA96D@yugabyte.com> <7bdd0ecd-0bf6-b5ac-534c-1f2f428c84b7@aklaver.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