Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRgFx-00064J-Ec for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Dec 2017 15:26:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRgFw-0004Qt-Qp for pgsql-bugs@arkaria.postgresql.org; Wed, 20 Dec 2017 15:26:04 +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_2) (envelope-from ) id 1eRgFw-0004Qj-Hm for pgsql-bugs@lists.postgresql.org; Wed, 20 Dec 2017 15:26:04 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eRgFs-0003Sc-PR for pgsql-bugs@postgresql.org; Wed, 20 Dec 2017 15:26:03 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E2AA52089C; Wed, 20 Dec 2017 10:25:58 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Wed, 20 Dec 2017 10:25:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=ebMBzny7bNzbL/E2tVEGYUFg8+2Vt TxHZZb1gghpylo=; b=AEiLwJdYBQqHf7dSzqbED550F1TxC5y2hm/S1T2iAkDtK GJLRJrYYAbz18LilRTbardLDwSz+SLUmxsIPvEsD+2L4KvA3/JNxYSl2Ow6jseBC 38SXxnCRTaIh9DW+fu/0zoeS/clPgaAtnerhDdlWFout2NUPANIx0Cj1zH+e/fmc 6FXFqHiYtaby9KJTIn8u9Aq9V1N5zkLlZ05ogOSeCBh9fQT0jmsOvAPGjPSdF48l DCkJkZu1qKkkPtPnkU5gUpg0AlsRgGDdzzyCuNRFMSqMTVjxkDtcfFYAPxR//ja+ GDcmOBVjNRFSCDhUl6E+V5Jiun/wDAZXUOLRCet6g== X-ME-Sender: Received: from intern.anarazel.de (unknown [172.56.30.31]) by mail.messagingengine.com (Postfix) with ESMTPA id 1AA7924772; Wed, 20 Dec 2017 10:25:58 -0500 (EST) Date: Wed, 20 Dec 2017 07:25:54 -0800 From: Andres Freund To: bucoo@sohu.com, pgsql-bugs@postgresql.org Subject: Re: BUG #14984: function "heap_tuple_from_minimal_tuple" lost HeapTupleHeader->t_len value Message-ID: <20171220152554.rmfjlhhdhno2drau@alap3.anarazel.de> References: <20171220094958.25744.94506@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171220094958.25744.94506@wrigleys.postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2017-12-20 09:49:58 +0000, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 14984 > Logged by: bucoo hsiao > Email address: bucoo@sohu.com > PostgreSQL version: 10.1 > Operating system: all > Description: This isn't really a complete bug report. How did you arrive at this being a problem? What triggers it? > HeapTuple > heap_tuple_from_minimal_tuple(MinimalTuple mtup) > { > HeapTuple result; > uint32 len = mtup->t_len + MINIMAL_TUPLE_OFFSET; > > result = (HeapTuple) palloc(HEAPTUPLESIZE + len); > result->t_len = len; > ItemPointerSetInvalid(&(result->t_self)); > result->t_tableOid = InvalidOid; > result->t_data = (HeapTupleHeader) ((char *) result + HEAPTUPLESIZE); > memcpy((char *) result->t_data + MINIMAL_TUPLE_OFFSET, mtup, > mtup->t_len); > memset(result->t_data, 0, offsetof(HeapTupleHeaderData, t_infomask2)); > /* when memset return, result->t_data->t_len value lost > should append code: > HeapTupleHeaderSetDatumLength(result->t_data, len); > */ There is no result->t_data->t_len. It's result->t_len. And calling HeapTupleHeaderSetDatumLength() wouldn't be right, because the returned value is an actual tuple, not a datum. Use heap_copy_tuple_as_datum() if you want that. Greetings, Andres Freund