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 1u8KkV-001L58-Va for pgsql-general@arkaria.postgresql.org; Fri, 25 Apr 2025 15:13:56 +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 1u8KkU-00CQOB-AP for pgsql-general@arkaria.postgresql.org; Fri, 25 Apr 2025 15:13:55 +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 1u8KkT-00CQNp-4S for pgsql-general@lists.postgresql.org; Fri, 25 Apr 2025 15:13:54 +0000 Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u8KkR-001uNb-0V for pgsql-general@lists.postgresql.org; Fri, 25 Apr 2025 15:13:52 +0000 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id 9F11311401C2; Fri, 25 Apr 2025 11:13:50 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 25 Apr 2025 11:13:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc: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=fm2; t=1745594030; x=1745680430; bh=jDMaL692yTCptHYotExAdi1RnR7OmvtyXlOvuMPVuDE=; b= gmhbObXTtPD/L8qF5mFl2vtqlTH5cYSVnwo8dtzDq3+SU9GKlbyUDVPPGl4fF3p6 JheYQTFbpkOiOCrI13BgNR78uA+ZafXj3/iiC3gstVvDXG+EeBwrbGqQ3zjfp2k4 Hb0fyvTpvF0o61hg74S5Dv6to5RpfR64Xx1qRCR6xea32nUwqOvgG3xX4hsYjnP1 5ljYxFeTkgPwkJs0emG78lvBW3Lzswvk0PEExPxr+wkfSpvz/7u0I5IRGxzFPMPQ g2idskz5PlwrAFCcqnSLg0kZlef4508mvShQLBdk03lG4sGONR3wpucWMTbWjAZm DViPWmKw8afF91SPFXJPbA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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-sender:x-me-sender:x-sasl-enc; s=fm3; t=1745594030; x= 1745680430; bh=jDMaL692yTCptHYotExAdi1RnR7OmvtyXlOvuMPVuDE=; b=v u3gAI4catFpvY11K2e4j2VHu16elQzVFDeeEaei4NI1vVuvkcbUikWNff9JpFKBO 4sD5u7MysKgXS5GG0ZjAvySXmZu6n4J6iim+ZT3dk7iXUhLzzrnaQZDWlTtJ5W5H PKAnntAk33IE49YGWzE8rGslGBCPbzhexnpGzTKOqO9CBYmEoY7cmZ5Jlz8vzuL/ c9I0NbOsXjdGzH+70eLW/SXdhIPbVkoofoGG5Dh1bu7NAi4s94ivf7vXpE6IeWiS L+u+A43ZAPPfrS1+a3ZbAN5I5ddPMhbFqdevq/eECAdIpWIkHShz1Sm23cYsNeS+ lFkE8wXEXfijIKP/8QMQg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvhedvieejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddt vdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvh gvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepfeegfeeiuedtgffg teeggfehkeejheetieeliefgteeikeejvdeiveeigfehvedtnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhes rghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouh htpdhrtghpthhtoheprhgrhihuughughhssehgmhgrihhlrdgtohhmpdhrtghpthhtohep ugguvghvihgvnhhnvgesghhmrghilhdrtghomhdprhgtphhtthhopehlrghurhgvnhiird grlhgsvgestgihsggvrhhtvggtrdgrthdprhgtphhtthhopehpghhsqhhlqdhgvghnvghr rghlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 25 Apr 2025 11:13:49 -0400 (EDT) Message-ID: <8b745873-f008-41ec-b58e-4b167e266b29@aklaver.com> Date: Fri, 25 Apr 2025 08:13:49 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Clarification on RLS policy To: Vydehi Ganti , Dominique Devienne Cc: Laurenz Albe , pgsql-general@lists.postgresql.org References: <88804c921b425d37a3072b5698b558a763d80d63.camel@cybertec.at> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/25/25 06:01, Vydehi Ganti wrote: > This is my Scenario: > > *Can you please guide how to achieve this?* > > CREATE OR REPLACE FUNCTION one.get_country( > powner name, > ptable_name name) >     RETURNS character varying > LANGUAGE 'plpgsql' > > For the below policy statement it created the policy but i cant call that > CREATE POLICY "Codebase_Filter" >     ON one.activity >     FOR SELECT >     TO one >     USING (one.get_country('one','activity')); The core of the issue you are getting is that this from the function: RETURNS character varying is not going to work here: USING (one.get_country('one','activity')) as what USING will see is a string not the evaluation of 1=1 hence the error you get: ERROR: invalid input syntax for type boolean: "1=1" CONTEXT: PL/pgSQL function function name(name,name) while casting return value to function's return type -- Adrian Klaver adrian.klaver@aklaver.com