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 1jz52O-00061P-1b for pgsql-general@arkaria.postgresql.org; Fri, 24 Jul 2020 21:15:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jz52M-0007R4-Mp for pgsql-general@arkaria.postgresql.org; Fri, 24 Jul 2020 21:15:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jz52K-0007Qx-R3 for pgsql-general@lists.postgresql.org; Fri, 24 Jul 2020 21:15:26 +0000 Received: from [64.147.123.24] (helo=wout1-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jz52E-0006cL-Io for pgsql-general@postgresql.org; Fri, 24 Jul 2020 21:15:22 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id C730915A7; Fri, 24 Jul 2020 17:15:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 24 Jul 2020 17:15:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=g snFOu4AxYHrRfLhdLk+NRmTw3jtCuDFZGNXPiibXrc=; b=o9mb8Dv855v95XmGd s5P/Kw7Noj9t8Xm33ycuuMbXkPj58aLklvrReKJuxfQQwVp0XyHl2RKs6Wb1BFtt zP+2xuFMZRW6YvPWyFCtKNo8Pg6VzTkvvoRhYntQYc4vIzwrQUoo4nWN3at7SyRo P29t5UjUnn77lcYdaHmSNA2Ix+n+qlBf7AcL5SFpSovlht+KFELOzYAG5+7q3iHK toFJhrVzVNZJO4fg2XkCfDC5NIQaVv5Abass5x55I1XIdsjzxrxaRpFqD115zkZV wGmXJzDLSBhBBmiCqEuVmAOde2TeBiSIcBecyewhB4cq6N6x2t4Wd/febVpR/dJu o9p9w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=gsnFOu4AxYHrRfLhdLk+NRmTw3jtCuDFZGNXPiibX rc=; b=DED1AV48GtLxWs7olIwVRCopOySn2ZW5wzkJ0tGDvtE2PsXy+QaZF6pO2 xIvbZbbsCcKJwrlxrieHwRSMBzW+3d8KvQuah84zY2uPYTChZ/+KQEpPhiOmcLqj NIp1fHc5nS4zv/ocM7+h6KnuG8kdG0ssrR99Mj0ty4/gyGQpQtRwzRR6T/f6aHMb 3rAnX31nQiupE/OTmtW9D1OvLwqrhYRjBZ6u0qxr0LYhnLX/jY/k7SYGfKocw1nP 7glKSB+rgYdN8qcvnf7tpiuPhqf8n5PGtA05mLCaUi6EDRJd7pJjKqsTXjTg6uKn Rh5aHr/yoRkMtPpM393r4n+zm+b0Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrheefgdduieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeduudefjeetveffhefgudehtdfhvdetkeeiueehfeev veduteekleeuheegudehhfenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgne cukfhppeejhedrudejvddrhedrvdefudenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrd gtohhm X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id 690813280060; Fri, 24 Jul 2020 17:15:04 -0400 (EDT) Subject: Re: when is RLS policy applied To: Ted Toth , Tom Lane Cc: pgsql-general References: <575913.1595621731@sss.pgh.pa.us> From: Adrian Klaver Message-ID: <949e1dfd-0ffc-896b-3c5e-052a99fe74c9@aklaver.com> Date: Fri, 24 Jul 2020 14:15:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.24 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/24/20 2:12 PM, Ted Toth wrote: > I've looked for information on leakproofness of operators but haven't > found anything can you direct me to a source of this information? See here: https://www.postgresql.org/docs/12/catalog-pg-proc.html "proleakproof bool The function has no side effects. No information about the arguments is conveyed except via the return value. Any function that might throw an error depending on the values of its arguments is not leak-proof." So as example: select proname from pg_proc where proleakproof = 't'; select proname from pg_proc where proleakproof = 'f'; > > On Fri, Jul 24, 2020 at 3:40 PM Ted Toth > wrote: > > > On Fri, Jul 24, 2020 at 3:15 PM Tom Lane > wrote: > > Ted Toth > writes: > > I'm trying to understand when RLS select policy is applied so > I created the > > follow to test but I don't understand why the query filter > order is > > different for the 2 queries can anyone explain? > > The core reason why not is that the ~~ operator isn't considered > leakproof.  Plain text equality is leakproof, so it's safe to > evaluate > ahead of the RLS filter --- and we'd rather do so because the > plpgsql > function is assumed to be much more expensive than a built-in > operator. > > (~~ isn't leakproof because it can throw errors that expose > information > about the pattern argument.) > >                         regards, tom lane > > > Thanks for the explanation. > > Ted > -- Adrian Klaver adrian.klaver@aklaver.com