Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1suZBB-007lUD-0b for pgsql-general@arkaria.postgresql.org; Sat, 28 Sep 2024 15:16:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1suZB9-009SQL-Nw for pgsql-general@arkaria.postgresql.org; Sat, 28 Sep 2024 15:16:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1suZB7-009SQC-Rc for pgsql-general@lists.postgresql.org; Sat, 28 Sep 2024 15:16:15 +0000 Received: from fhigh-a6-smtp.messagingengine.com ([103.168.172.157]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1suZB4-001Ui5-Fw for pgsql-general@lists.postgresql.org; Sat, 28 Sep 2024 15:16:12 +0000 Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfhigh.phl.internal (Postfix) with ESMTP id 8FDE4114013B; Sat, 28 Sep 2024 11:16:08 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-07.internal (MEProxy); Sat, 28 Sep 2024 11:16:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1727536568; x=1727622968; bh=c+ajdSEeQtXgz+mu0EnwaVlLxMq28fqMG++/zDnSe80=; b= FFU7LBJ1vg2DtBVR5azHBz5gQ2NL3fE5b75iKaJLYAexOSDgMsdJgVoLDYGPSrPJ 1yn7ksup4+PPxo684tIYaTwGFegyuI6ygt1/UZXCcXoiUIRT+JETErqe51lJB1TA f+qkwF5xoOR4IAT7/mQuJLXrSrkuxMefY1msMRehMh9DoP+dUxGNAeAYgHjvl6qi 3VNBXCcK/6b9wGCwK2UEmYNl27NXZzDBtRbU39crS4bELSILWPUYgY0Q+sofEs88 GtIPEUlOHDvHxLEYikyPACqr9Fi9oJMCVPNEE8ZgMRs5dZe0fwLHWUL0p37aY+sm nIBUYp7lDpvsecHn6irjbw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1727536568; x= 1727622968; bh=c+ajdSEeQtXgz+mu0EnwaVlLxMq28fqMG++/zDnSe80=; b=c +vcfExXKOkBhp54Bt9oMt+0b5NQVmG+pUbI8e1ciYF6ms6QAxfsKXO2IyNJZehb1 YVkmVUzCm/TI5YpYQp4dydIGJWb6JxMIW9sM2kaAo01EwoJcudiC+wsupQ5iB9vH 4Hqv1v8iu57zwBElnSF6q2iRaBp5rGA3PiIJPI7tpxgwJfYx+BlOCHV3J+zViOms bfJVpfLNz28NIwPzyiPxZyQxlunYCzGEyCV15m1mNcTCGOYJezgDWH/skmDwGzGV 4XkMDlLRuB2N7xSVp5Re2WDdOOqdJDmucyGW0RXEDYAY0+XoqIQfM3CnRCKKXknk xR/ZPeaztogJGNOPU48Mg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdduuddgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfg fuvfhfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghr uceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrth htvghrnhephfekvdeghfetheevgfeghfekjeehheetgeejieelleekgfefieekjedugfeu keffnecuffhomhgrihhnpehgihhthhhusgdrtghomhdpphhgpghprghrthhmrghnrdhmug enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughr ihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmpdhnsggprhgtphhtthhopedvpd hmohguvgepshhmthhpohhuthdprhgtphhtthhopehlohhknhgrthhhrdejfeesghhmrghi lhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpoh hsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 28 Sep 2024 11:16:07 -0400 (EDT) Message-ID: <4a17cf81-3fdd-4661-a0b4-1ad135f85511@aklaver.com> Date: Sat, 28 Sep 2024 08:16:06 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Grants not working on partitions To: Lok P , pgsql-general References: Content-Language: en-US From: Adrian Klaver 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: Archived-At: Precedence: bulk On 9/28/24 04:02, Lok P wrote: > Hi, > While we are creating any new tables, we used to give SELECT privilege > on the newly created tables using the below command. But we are seeing > now , in case of partitioned tables even if we had given the privileges > in the same fashion, the user is not able to query specific partitions > but only the table. Commands like "select * from > schema1. " are erroring out with the "insufficient > privilege" error , even if the partition belongs to the same table. > > Grant SELECT ON to ; > > Grant was seen as a one time command which needed while creating the > table and then subsequent partition creation for that table was handled > by the pg_partman extension. But that extension is not creating or > copying any grants on the table to the users. We were expecting , once > the base table is given a grant , all the inherited partitions will be > automatically applied to those grants. but it seems it's not working > that way. So is there any other way to handle this situation? The docs are there for a reason: https://github.com/pgpartman/pg_partman/blob/master/doc/pg_partman.md#child-table-property-inheritance "Privileges & ownership are NOT inherited by default. If enabled by pg_partman, note that this inheritance is only at child table creation and isn't automatically retroactive when changed (see reapply_privileges()). Unless you need direct access to the child tables, this should not be needed. You can set the inherit_privileges option if this is needed (see config table information below)." And: "reapply_privileges( p_parent_table text ) RETURNS void This function is used to reapply ownership & grants on all child tables based on what the parent table has set. Privileges that the parent table has will be granted to all child tables and privileges that the parent does not have will be revoked (with CASCADE). Privileges that are checked for are SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, & TRIGGER. Be aware that for large partition sets, this can be a very long running operation and is why it was made into a separate function to run independently. Only privileges that are different between the parent & child are applied, but it still has to do system catalog lookups and comparisons for every single child partition and all individual privileges on each. p_parent_table - parent table of the partition set. Must be schema qualified and match a parent table name already configured in pg_partman. " > > In other databases(say like Oracle) we use to create standard > "roles"(Read_role, Write_role etc..) and then provide grants to the user > through those roles. And the objects were given direct grants to those > roles. Similarly here in postgres we were granting "read" or "write" > privileges on objects to the roles and letting the users login to the > database using those roles and thus getting all the read/write > privileges assigned to those roles. Are we doing anything wrong? > > Regards > Lok -- Adrian Klaver adrian.klaver@aklaver.com