pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: bucoo@sohu.com
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #14984: function "heap_tuple_from_minimal_tuple" lost HeapTupleHeader->t_len value
Date: Wed, 20 Dec 2017 07:25:54 -0800
Message-ID: <20171220152554.rmfjlhhdhno2drau@alap3.anarazel.de> (raw)
In-Reply-To: <20171220094958.25744.94506@wrigleys.postgresql.org>
References: <20171220094958.25744.94506@wrigleys.postgresql.org>

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




view thread (3+ messages)  latest in thread

Message-ID: <20171220152554.rmfjlhhdhno2drau@alap3.anarazel.de>
Permalink:  ../20171220152554.rmfjlhhdhno2drau@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20171220152554.rmfjlhhdhno2drau@alap3.anarazel.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andres@anarazel.de, bucoo@sohu.com
  Subject: Re: BUG #14984: function "heap_tuple_from_minimal_tuple" lost HeapTupleHeader->t_len value
  In-Reply-To: <20171220152554.rmfjlhhdhno2drau@alap3.anarazel.de>
  References: <20171220094958.25744.94506@wrigleys.postgresql.org> <20171220152554.rmfjlhhdhno2drau@alap3.anarazel.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox