Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBvv8-0000uD-8R for pgsql-general@arkaria.postgresql.org; Tue, 16 Feb 2021 08:41:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lBvv6-00037d-EM for pgsql-general@arkaria.postgresql.org; Tue, 16 Feb 2021 08:41:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBvv6-00035j-5b for pgsql-general@lists.postgresql.org; Tue, 16 Feb 2021 08:41:20 +0000 Received: from dd27502.kasserver.com ([85.13.146.49]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBvuz-0006kD-RT for pgsql-general@lists.postgresql.org; Tue, 16 Feb 2021 08:41:19 +0000 Received: from [192.168.0.24] (ip-37-201-154-176.hsi13.unitymediagroup.de [37.201.154.176]) by dd27502.kasserver.com (Postfix) with ESMTPSA id B931060C44B5; Tue, 16 Feb 2021 09:41:10 +0100 (CET) From: Wolfgang Walther Subject: Re: ALTER ROLE ... SET in current database only To: Abdul Qoyyuum Cc: pgsql-general@lists.postgresql.org References: <2b2fc152-63cb-1d4a-93c2-f57f28a98fce@technowledgy.de> Message-ID: <260e6e0d-acf7-40be-601e-9dd2c7ce2add@technowledgy.de> Date: Tue, 16 Feb 2021 09:41:07 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Abdul Qoyyuum: > Wouldnt you need to connect to the database first before you can ALTER > ROLE anything? Of course, otherwise the notion of "current database" wouldn't make sense at all. But that's only before executing the code. I am not writing and executing this code at the same time. In my case I'm seeding a postgres docker container with settings and data on first launch. The database name is passed to the container via environment variable. But, I'm sure there are other use-cases where code should be written once, but be executed in different databases. Best, Wolfgang