Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8XWy-00056f-DH for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Sep 2019 22:25:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i8XWx-0005bS-6j for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Sep 2019 22:25:35 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8XWv-0005bC-EC for pgsql-bugs@lists.postgresql.org; Thu, 12 Sep 2019 22:25:34 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8XWr-00026u-Ah for pgsql-bugs@lists.postgresql.org; Thu, 12 Sep 2019 22:25:33 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id BCCC7B74; Thu, 12 Sep 2019 18:25:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 12 Sep 2019 18:25:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=lll55ia5n6YFSDgKTQk8HQ9/Hv2 JzJO4yX6IjrcdogM=; b=pwbTBXH7ViYUKcPRY7+BH5nHyM9ETC8xC615H69HYYg JxtvoDkry9D/6+KOTugVfl5QZi7OZQBcX5pzQ2ImGmFAIIfxCEXxszmATisetdBK XVCW9UyWy6fF2/tjoS4g5tTokBoFe5UGgash14/Gq3xHrj361EPbP58ARTBfw8X9 S/0TPJcGKHZO3S03q11e7NCxRLzoe1xdUnc13D0jDYg2m9c5QJudZON8UDbFhD+D Tq9a0Tz25SM2cr/mw0z2H0JrGRuhXYjqDhPRWPMLDr7b9pDCv7NrsfeZmWtMBXwt u20X0bvgRweGvQHuDyGQB55rJ43hSt0Vz6UQh/CBfkQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=lll55i a5n6YFSDgKTQk8HQ9/Hv2JzJO4yX6IjrcdogM=; b=X5qbfBhRisK8JgggeKtcbV rQ2YEbKC2Wj/OPYzcuJyRCBmVjGb7zJuoQy/ZN9mdqNesMYx+LQskwavrwyI4ZLd +RMAAOY5SiMh/Fgaklu9NX2S+PVm3MrH09z5WnAiM/9/1gMbdSS6vE1zdITztGB5 rCqAmJtfM8/VBPC3sA5o0Z8DMqViWEMMCyH99jxTPgtiE4C+Gpcze9q3FPv/s2Fv +QbcE/hGAyG3VfQj23uhXJ7Mn3eFTe8IvmezhvjbGfGuQ/SM6vL6OA1ofDdPlvOr vK6IqD+T/cR9OS3bcxv3jfQFq5V028CuaexyDT+MIaoV5bt7cOlmey0cNaSrIObA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrtdeigddtlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehttdertd dttddvnecuhfhrohhmpeetnhgurhgvshcuhfhrvghunhguuceorghnughrvghssegrnhgr rhgriigvlhdruggvqeenucfkphepudejvddrheekrddujeehrddukeenucfrrghrrghmpe hmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdruggvnecuvehluhhsthgv rhfuihiivgeptd X-ME-Proxy: Received: from intern.anarazel.de (unknown [172.58.175.18]) by mail.messagingengine.com (Postfix) with ESMTPA id D7A05D6005B; Thu, 12 Sep 2019 18:25:24 -0400 (EDT) Date: Thu, 12 Sep 2019 14:10:47 -0700 From: Andres Freund To: Tom Lane Cc: vinay.s.banakar@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16006: Update queries fail on a table having any policy with a function that takes a whole-row var as arg Message-ID: <20190912211047.kr7e4pn7iof76jfx@alap3.anarazel.de> References: <16006-99290d2e4642cbd5@postgresql.org> <28076.1568320435@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <28076.1568320435@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-09-12 16:33:55 -0400, Tom Lane wrote: > PG Bug reporting form writes: > > Update queries fail on a table having any policy with a function that takes > > a whole-row var as argument. > > Hm. You really should have shown the failure you were seeing, but > for the archives' sake: I can reproduce this on 9.5 and 9.6 (if I > run the queries as non-superuser!), and it looks like > > regression=> insert into usertable values('key','field0','field1','field2','field3','field4','field5','field6','field7','field8','field9'); > INFO: log: (key,field0,field1,field2,field3,field4,field5,field6,field7,field8,field9,"2019-09-12 16:29:37.511329") > INSERT 0 1 > regression=> update usertable set field0 = 'f0'; > INFO: log: (key,field0,field1,field2,field3,field4,field5,field6,field7,field8,field9,"2019-09-12 16:29:37.511329") > ERROR: table row type and query-specified row type do not match > DETAIL: Table has type tid at ordinal position 1, but query expects character varying. > > Digging into this, it seems the short answer is "Andres should have > back-patched 148e632c0". The plan shape in 9.6.x is Heh :/. I was wondering (and asking for input) at the time... The whole business with parent nodes is somewhat fragile (cf 2abd7ae9b2 / 5f32b29c1819), which makes me generally a bit hesitant to backpatch. But obviously it's needed here. > Update on usertable usertable_1 (cost=0.00..66.00 rows=70 width=366) > -> Subquery Scan on usertable (cost=0.00..66.00 rows=70 width=366) > -> LockRows (cost=0.00..65.30 rows=70 width=340) > -> Seq Scan on usertable usertable_2 (cost=0.00..64.60 rows=70 width=340) > Filter: log_record(usertable_2.*) > > and because ExecInitModifyTable incorrectly passes the SubqueryScan > as parent of the WCO expressions, the horrible examine-the-parent > kluge in ExecEvalWholeRowVar fires, causing it to apply a completely > inappropriate junkfilter to the scan tuple. After which, of course, > the tuple rowtype is wrong. I don't quite understand how this "visibly" broke between 9.5.15 and 9.5.19 as the op reports? Haven't dug into it yet though. Greetings, Andres Freund