Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gB5z8-0008H0-VX for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Oct 2018 22:32:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gB5z6-0002pv-LB for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Oct 2018 22:32:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gB5z4-0002pP-Pt for pgsql-hackers@lists.postgresql.org; Fri, 12 Oct 2018 22:32:40 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gB5z1-00014M-1g for pgsql-hackers@postgresql.org; Fri, 12 Oct 2018 22:32:38 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id CCFB021F47; Fri, 12 Oct 2018 18:32:32 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 12 Oct 2018 18:32:32 -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=kYpzhsuQddPqW+c75xolCH0yK2P GltEVk6VPOPdUS7I=; b=ETOJbkbUt1+SnfxUS4sCw6XDDZTmVz/6scrWe+H7iCo sn8KyuEjRujWARlSdzpAbO6fR/zR7TF42eb2LyYhy5PDHdsRiUhjflIQrkFb2sQP lOgIPwFE6bSqc4L2fI15cwGGJpVVFTcDF4J0+PxBIFYjI3Qa+v+hiVTYKJqHx/7w Uf1L67cPIgH9O9ercXXe+3yP0DUgVacd9J1TIe5TJiR56cUrED1A71iMDIYc/qrb n9IVJ41xcqZhacDN2yyZ0LrC3jWR3b8gG9488RdeuNs5TEC5G7EU7TzXETN09cNh f1hFD+PMz8aZL9IDaonxPhz29G4ff/OY8V7T6vnfA6g== 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=fm1; bh=kYpzhs uQddPqW+c75xolCH0yK2PGltEVk6VPOPdUS7I=; b=Nrses0UzdYOKeyEl9i1tLM rmHThJ3NjrMf1Z69rqM5ZUDhn4GRnbVLYKr2EzJo0aqAPYpoETSYSTXDbr5s+weu +HKkoPfdfqGfC0ErYUGsXHTmtW5t+5LvJbGKzIy7gpank7ghk4J1DJO44VRx2y3p O9aAc8m5s/p93gG1bQEsOeNrQQhVcB/XvVFSDQA6XUzYSbbVDRCNqMB2C6/S8i9M ifoaA92xMLmN0+wkqgcFu+uFAnvuPNX9Jt6iWPDofV/eagapWF/825BIvsOru/gB 6s2QMd+/XxVrAGWCNXSVdIpSshaCZj0cTeieH4iNhZ9D14qL6MyNpB2JF7qs+mqg == X-ME-Sender: X-ME-Proxy: Received: from intern.anarazel.de (c-98-210-140-171.hsd1.ca.comcast.net [98.210.140.171]) by mail.messagingengine.com (Postfix) with ESMTPA id 0E126102DE; Fri, 12 Oct 2018 18:32:32 -0400 (EDT) Date: Fri, 12 Oct 2018 15:32:31 -0700 From: Andres Freund To: Amit Khandekar Cc: Ashutosh Bapat , pgsql-hackers , Robert Haas , Haribabu Kommi , Alvaro Herrera , Amit Kapila Subject: Re: TupleTableSlot abstraction Message-ID: <20181012223231.3tedn53fzosm56id@alap3.anarazel.de> References: <20180817080706.a4hh4fluilejkjdi@alap3.anarazel.de> <20180818152310.6quymlphu276mpwu@alap3.anarazel.de> <20180820122822.uag4nlmslvajaacv@alap3.anarazel.de> <20180824011634.q2lrc6b26mjwoi5s@alap3.anarazel.de> <20180926000511.ivjuepi7cqy2c3ns@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-10-09 20:46:04 +0530, Amit Khandekar wrote: > On Wed, 26 Sep 2018 at 05:35, Andres Freund wrote: > > > + > > > +/* > > > + * This is a function used by all getattr() callbacks which deal with a heap > > > + * tuple or some tuple format which can be represented as a heap tuple e.g. a > > > + * minimal tuple. > > > + * > > > + * heap_getattr considers any attnum beyond the attributes available in the > > > + * tuple as NULL. This function however returns the values of missing > > > + * attributes from the tuple descriptor in that case. Also this function does > > > + * not support extracting system attributes. > > > + * > > > + * If the attribute needs to be fetched from the tuple, the function fills in > > > + * tts_values and tts_isnull arrays upto the required attnum. > > > + */ > > > +Datum > > > +tts_heap_getattr_common(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp, > > > + int attnum, bool > > > *isnull) > > > > I'm still *vehemently* opposed to the introduction of this. > > You mean, you want to remove the att_isnull() optimization, right ? Yes. > Removed that code now. Directly deforming the tuple regardless of the > null attribute. Good, thanks. > > > @@ -2024,7 +2024,18 @@ FormIndexDatum(IndexInfo *indexInfo, > > > Datum iDatum; > > > bool isNull; > > > > > > - if (keycol != 0) > > > + if (keycol < 0) > > > + { > > > + HeapTupleTableSlot *hslot = (HeapTupleTableSlot *)slot; > > > + > > > + /* Only heap tuples have system attributes. */ > > > + Assert(TTS_IS_HEAPTUPLE(slot) || TTS_IS_BUFFERTUPLE(slot)); > > > + > > > + iDatum = heap_getsysattr(hslot->tuple, keycol, > > > + slot->tts_tupleDescriptor, > > > + &isNull); > > > + } > > > + else if (keycol != 0) > > > { > > > /* > > > * Plain index column; get the value we need directly from the > > > > This now should access the system column via the slot, right? There's > > other places like this IIRC. > > Done. In FormIndexDatum() and ExecInterpExpr(), directly calling > slot_getsysattr() now. > > In ExecInterpExpr (), I am no longer using ExecEvalSysVar() now. I am > planning to remove this definition since it would be a single line > function just calling slot_getsysattr(). > > In build_ExecEvalSysVar(), ExecEvalSysVar() is still used, so I > haven't removed the definition yet. I am planning to create a new > LLVMValueRef FuncSlotGetsysattr, and use that instead, in > build_ExecEvalSysVar(), or for that matter, I am thinking to revert > back build_ExecEvalSysVar() and instead have that code inline as in > HEAD. I'd just have ExecInterpExpr() continue calling ExecEvalSysVar. There's no reason for it to be inline. And it's simpler for JIT than the alternative. > > > @@ -185,6 +1020,7 @@ ExecResetTupleTable(List *tupleTable, /* tuple table */ > > > { > > > TupleTableSlot *slot = lfirst_node(TupleTableSlot, lc); > > > > > > + slot->tts_cb->release(slot); > > > /* Always release resources and reset the slot to empty */ > > > ExecClearTuple(slot); > > > if (slot->tts_tupleDescriptor) > > > @@ -240,6 +1076,7 @@ void > > > ExecDropSingleTupleTableSlot(TupleTableSlot *slot) > > > { > > > /* This should match ExecResetTupleTable's processing of one slot */ > > > + slot->tts_cb->release(slot); > > > Assert(IsA(slot, TupleTableSlot)); > > > ExecClearTuple(slot); > > > if (slot->tts_tupleDescriptor) > > > > ISTM that release should be called *after* clearing the slot. > > I am copying here what I discussed about this in the earlier reply: > > I am not sure what was release() designed to do. Currently all of the > implementers of this function are empty. So additional deallocations can happen in a slot. We might need this e.g. at some point for zheap which needs larger, longer-lived, buffers in slots. > Was it meant for doing > ReleaseTupleDesc(slot->tts_tupleDescriptor) ? Or > ReleaseBuffer(bslot->buffer) ? No. The former lives in generic code, the latter is in ClearTuple. > I think the purpose of keeping this *before* clearing the tuple might > be because the clear() might have already cleared some handles that > release() might need. It's just plainly wrong to call it this way round. > I went ahead and did these changes, but for now, I haven't replaced > ExecFetchSlotTuple() with ExecFetchSlotHeapTuple(). Instead, I > retained ExecFetchSlotTuple() to be called for heap tuples, and added > a new ExecFetchGenericSlotTuple() to be used with shouldFree. I don't > like these names, but until we have concluded, I don't want to go > ahead and replace all the numerous ExecFetchSlotTuple() calls with > ExecFetchSlotHeapTuple(). Why not? Greetings, Andres Freund