Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fk8XR-0003qa-1P for pgsql-general@arkaria.postgresql.org; Mon, 30 Jul 2018 13:48:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fk8XO-0003bb-5p for pgsql-general@arkaria.postgresql.org; Mon, 30 Jul 2018 13:48:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fk8XN-0003bU-U9 for pgsql-general@lists.postgresql.org; Mon, 30 Jul 2018 13:48:37 +0000 Received: from hermes.gatewaynet.com ([193.92.121.98]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fk8XK-0007Lh-N5 for pgsql-general@lists.postgresql.org; Mon, 30 Jul 2018 13:48:36 +0000 Received: from smadev.internal.net (pc131.internal.net [10.9.200.131]) by hermes.gatewaynet.com (8.14.3/8.14.3/Debian-9.4) with ESMTP id w6UDmRNN032627 for ; Mon, 30 Jul 2018 16:48:32 +0300 Received: from smadev.internal.net (smadev [10.9.200.131]) by smadev.internal.net (8.15.2/8.15.2) with ESMTP id w6UDmRjx091107 for ; Mon, 30 Jul 2018 16:48:27 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) Subject: Re: ALTER ROLE SET search_path produced by pg_dumpall gives : ERROR: syntax error at or near "$" . To: pgsql-general@lists.postgresql.org References: <452f7783-eab3-0d2c-cb83-3ad473d8e9b2@aklaver.com> From: Achilleas Mantzios Message-ID: <0f8bedd8-dbcd-c99f-b700-11c66bfeb1ac@matrix.gatewaynet.com> Date: Mon, 30 Jul 2018 16:48:27 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <452f7783-eab3-0d2c-cb83-3ad473d8e9b2@aklaver.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Virus-Scanned: clamav-milter 0.98.7 at hermes X-Virus-Status: Clean X-Spam-Status: No, score=-28.9 required=5.0 tests=ALL_TRUSTED,DYN_HAM_COORD, DYN_HAM_IT,DYN_HAM_NAUTICAL,TW_PG autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on hermes.gatewaynet.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 30/07/2018 16:23, Adrian Klaver wrote: > On 07/30/2018 05:57 AM, Achilleas Mantzios wrote: >> This is with PostgreSQL 10.4. >> How to reproduce : >> postgres@smadev:~% psql >> psql (10.4) >> Type "help" for help. >> >> Alter the role for search path : >> dynacom=# ALTER ROLE amura3 SET search_path TO "$user", amuragents, public; >> ALTER ROLE >> dynacom=# >> >> Verify : >> postgres@smadev:~% psql -U amura3 >> Password for user amura3: >> psql (10.4) >> Type "help" for help. >> >> dynacom=> show search_path ; >>          search_path >> --------------------------- >>   $user, amuragents, public >> (1 row) >> >> dynacom=> >> >> pg_dumpall's output : >> ALTER ROLE amura3 SET search_path TO $user, amuragents, public; >> >> psql -f pg_dumpall_out.sql : >> dynacom=# ALTER ROLE amura3 SET search_path TO $user, amuragents, public; >> ERROR:  syntax error at or near "$" > > Well the above does not have $user double quoted. Was that hand entered or was that like that in the pg_dumpall_out.sql file? > >> >> Is this a bug or am I missing something ? > > I could not replicate: You are absolutely right, I apologize for the noise :( I had forgotten that we had to tweak src/backend/utils/misc/guc.c in order for search_path to work with pgbouncer in transaction mode. --- /usr/local/src/postgresql-10.4/src/backend/utils/misc/guc.c.orig 2018-05-07 23:51:40.000000000 +0300 +++ /usr/local/src/postgresql-10.4/src/backend/utils/misc/guc.c 2018-06-14 16:07:29.832476000 +0300 @@ -3266,7 +3266,7 @@                 {"search_path", PGC_USERSET, CLIENT_CONN_STATEMENT,                         gettext_noop("Sets the schema search order for names that are not schema-qualified."),                         NULL, -                       GUC_LIST_INPUT | GUC_LIST_QUOTE +                       GUC_LIST_INPUT | GUC_REPORT                 },                 &namespace_search_path,                 "\"$user\", public", With GUC_LIST_QUOTE it kept re-quoting and it broke the app. Without GUC_REPORT it was losing the search_path. > > create role sp_test; > > alter role sp_test SET search_path TO "$user", public; > > pg_dumpall -g -U postgres > sp_test.sql > > In sp_test.sql > > CREATE ROLE sp_test; > > ALTER ROLE sp_test SET search_path TO "$user", public; > > drop role sp_test ; > > psql -d test -U postgres  -f sp_test.sql > > > \du > > sp_test        | Cannot login    | {} > > > \drds >                  List of settings >   Role   | Database |          Settings > ---------+----------+----------------------------- >  sp_test |          | search_path="$user", public > > >> > > -- Achilleas Mantzios IT DEV Lead IT DEPT Dynacom Tankers Mgmt