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 1k5Ybj-0004h0-75 for pgsql-bugs@arkaria.postgresql.org; Tue, 11 Aug 2020 18:02:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k5Ybh-0005fE-R5 for pgsql-bugs@arkaria.postgresql.org; Tue, 11 Aug 2020 18:02:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k5Ybh-0005f7-0U for pgsql-bugs@lists.postgresql.org; Tue, 11 Aug 2020 18:02:41 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k5Yba-0000dL-Kv for pgsql-bugs@lists.postgresql.org; Tue, 11 Aug 2020 18:02:40 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id EBDE05C0153; Tue, 11 Aug 2020 14:02:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 11 Aug 2020 14:02:33 -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=SCZGIAmtw6iFnyTKahOlbq/tEYr P+ekQNSDxToVRvqE=; b=bxQq0uYSg0sAFXZAKLX5N58ZRhyPpoyCpj+PUleFEE3 uTQotjBESBvm7WaVgsPx2wfWF0uRTPpkBc0Oufl+xBl2Wbqm5XI0eZcMurgwrOMr IvhPEl+JkBvKxBZ7aLMvPw71w753o7i9P6VEcrC7+6hzzNhMPcXtrr9VMS6hJdPl elhApxRNYPn+CB27d1mfsahY9I/tzKJ5e/SELeZppJybVt0YMXP+v+gjXfWdQN5N Q2RdgD+wOXVMlOuuPm/xVe3/HiDr8QTf/VdzdEIkwBEsJwplcywby4NaRFkZHnWb a1ZMIVSAAtquOoNaRp4zp2Bri3zZlt5eh1a67j8VF5g== 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=SCZGIA mtw6iFnyTKahOlbq/tEYrP+ekQNSDxToVRvqE=; b=aaAR5xcQsRXVHXwNprGMTU 6gfX5Yjla2FwzpkGrtKFOdW8b+EF3R8NUw57K9fl0isnP55fmBL9A7b/NUp6US+s QcXRnkSh4kTvnm7BPX5CxEqU+fmnkZh4at6+bYDBXs9ziXRKj6GrEpdibazZwG3b dfw4ukVtud8EgRFvOocokj9cBRNbW3QYhr0Plm/vb5yhw70knM0eH4OmtJK0Rlro Q1uHZZNzbMMILTA05H9yRXgJxHNQ/dHbkHAUyWRRPf/WXh8OSIhbZAquglHOY70F 6Rss+bJ8Z0m899Qp5Z8Bu2WpOyeV2dKMSD4dX5E47H2vA57TWwqB3R1WYmESqIwQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrledtgdduvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesthdtre dttddtvdenucfhrhhomheptehnughrvghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghn rghrrgiivghlrdguvgeqnecuggftrfgrthhtvghrnhepudekhfekleeugeevteehleffff ejgeelueduleeffeeutdelffeujeffhfeuffdunecukfhppeeijedrudeitddrvddujedr vdehtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-217-250.hsd1.ca.comcast.net [67.160.217.250]) by mail.messagingengine.com (Postfix) with ESMTPA id 4739630600A9; Tue, 11 Aug 2020 14:02:33 -0400 (EDT) Date: Tue, 11 Aug 2020 11:02:31 -0700 From: Andres Freund To: Tom Lane Cc: Pavel Biryukov <79166341370@yandex.ru>, pgsql-bugs@lists.postgresql.org Subject: Re: posgres 12 bug (partitioned table) Message-ID: <20200811180231.fcssvhelqpnydnx7@alap3.anarazel.de> References: <141051591267657@mail.yandex.ru> <1251598.1591289850@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1251598.1591289850@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2020-06-04 12:57:30 -0400, Tom Lane wrote: > Pavel Biryukov <79166341370@yandex.ru> writes: > > Hello. I'm catch error "virtual tuple table slot does not have system > > attributes" when inserting row into partitioned table with RETURNING > > xmin > > Reproduced here. The example works in v11, and in v10 if you remove > the unnecessary-to-the-example primary key, so it seems like a clear > regression. I didn't dig for the cause but I suppose it's related > to Andres' slot-related changes. The reason we're getting the failure is that nodeModifyTable.c only is dealing with virtual tuple slots, which don't carry visibility information. Despite actually having infrastructure for creating a partition specific slot. If I force check_attrmap_match() to return false, the example starts working. I don't really know how to best fix this in the partitioning infrastructure. Currently the determination whether there needs to be any conversion between subplan slot and the slot used for insertion is solely based on comparing tuple descriptors. But for better or worse, we don't represent system column accesses in tuple descriptors. It's not that hard to force the slot creation & use whenever there's returning, but somehow that feels hackish (but so does plenty other things in execPartition.c). See attached. But I'm worried that that's not enough: What if somebody in a trigger wants to access system columns besides tableoid and tid (which are handled in a generic manner)? Currently - only for partitioned table DML going through the root table - we'll not have valid values for the trigger. It's pretty dubious imo to use xmin/xmax in triggers, but ... I suspect we should just unconditionally use partrouteinfo->pi_PartitionTupleSlot. Going through partrouteinfo->pi_RootToPartitionMap if present, and ExecCopySlot() otherwise. Medium term I think we should just plain out forbid references to system columns in partioned tables Or at least insist that all partitions have that column. There's no meaningful way for some AMs to have xmin / xmax in a compatible way with heap. Greetings, Andres Freund