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 1uhU0p-000UKF-5I for pgsql-general@arkaria.postgresql.org; Thu, 31 Jul 2025 14:12:03 +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 1uhU0m-001AbY-Ep for pgsql-general@arkaria.postgresql.org; Thu, 31 Jul 2025 14:12:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uhU0m-001AbO-43 for pgsql-general@lists.postgresql.org; Thu, 31 Jul 2025 14:12:00 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uhU0j-000264-2l for pgsql-general@lists.postgresql.org; Thu, 31 Jul 2025 14:11:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 56VEBrCO2071881; Thu, 31 Jul 2025 10:11:53 -0400 From: Tom Lane To: Dominique Devienne cc: Guillaume Lelarge , pgsql-general@lists.postgresql.org Subject: Re: SET LOCAL ROLE inside SECURITY INVOKER (LANGUAGE plpgsql) function In-reply-to: References: <508f71c4-f1b1-4685-921d-bec8b361be10@aklaver.com> <662792ed-810d-46f1-a0c3-d4b55e5469fc@aklaver.com> <693d1252-89e4-498d-a5a6-5de6524bbb34@dalibo.com> Comments: In-reply-to Dominique Devienne message dated "Thu, 31 Jul 2025 13:37:37 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2071879.1753971113.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Thu, 31 Jul 2025 10:11:53 -0400 Message-ID: <2071880.1753971113@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dominique Devienne writes: > On Thu, Jul 31, 2025 at 11:35 AM Guillaume Lelarge > wrote: >> It doesn't lie. The role has DELETE privilege. I guess what it lacks is >> the SELECT privilege. If you do a "DELETE FROM ... WHERE ...", you need >> the SELECT privilege to perform the WHERE. Without "WHERE ...", it would >> work without the SELECT privilege. > Right on the money! Merci Guillaume!!! --DD So the real problem here is that the "permission denied" error message doesn't tell you which permission you lack. I think we've had prior discussions about improving that, but it never got done. In some cases it's a bit complicated -- for example, here either whole-table SELECT or SELECT on the specific column would do. But even pointing you in the direction of "you need SELECT" would likely have led to the correct line of thought, so maybe giving 100% of the details isn't necessary. regards, tom lane