Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aZ6gc-00006h-DG for pgsql-bugs@arkaria.postgresql.org; Fri, 26 Feb 2016 00:55:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aZ6gb-0003w3-RC for pgsql-bugs@arkaria.postgresql.org; Fri, 26 Feb 2016 00:55:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aZ6gb-0003vb-5Q for pgsql-bugs@postgresql.org; Fri, 26 Feb 2016 00:55:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aZ6gY-0004HB-Tm for pgsql-bugs@postgresql.org; Fri, 26 Feb 2016 00:55:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u1Q0t83E025224; Thu, 25 Feb 2016 19:55:08 -0500 From: Tom Lane To: Dean Rasheed cc: Alvaro Herrera , asguthrie@gmail.com, "pgsql-bugs@postgresql.org" Subject: Re: BUG #13988: "plan should not reference subplan's variable" whilst using row level security In-reply-to: References: <20160224210507.2568.85774@wrigleys.postgresql.org> <20160224214214.GA449452@alvherre.pgsql> Comments: In-reply-to Dean Rasheed message dated "Thu, 25 Feb 2016 23:32:12 +0000" Date: Thu, 25 Feb 2016 19:55:08 -0500 Message-ID: <25223.1456448108@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Dean Rasheed writes: > Debugging it, I have a theory as to the cause of the problem, which I > think is in security_barrier_replace_vars() --- when it finds a > matching Var that needs to be added to the targetlist that it is > building, it copies the existing Var and modifies it: > /* New variable for subquery targetlist */ > newvar = copyObject(var); > newvar->varno = newvar->varnoold = 1; > ... > However, the Var found comes from a sublink subquery in the outer > query, and so has varlevelsup = 1, but newvar is for the new subquery > being built, so it needs to have varlevelsup set to 0, which that code > fails to do. Offhand, I'd think it more likely that this code should not be touching outer-level vars at all? There are few if any situations where it makes sense to suppose that a Var of one level should be transformed into a Var of a different level. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs