pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14984: function "heap_tuple_from_minimal_tuple" lost HeapTupleHeader->t_len value
3+ messages / 3 participants
[nested] [flat]

* BUG #14984: function "heap_tuple_from_minimal_tuple" lost HeapTupleHeader->t_len value
@ 2017-12-20 09:49  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 2 replies; 3+ messages in thread

From: PG Bug reporting form @ 2017-12-20 09:49 UTC (permalink / raw)
  To: pgsql-bugs; +Cc: bucoo@sohu.com

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:        

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);
*/
	return result;
}



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #14984: function "heap_tuple_from_minimal_tuple" lost HeapTupleHeader->t_len value
@ 2017-12-20 15:25  Andres Freund <andres@anarazel.de>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 0 replies; 3+ messages in thread

From: Andres Freund @ 2017-12-20 15:25 UTC (permalink / raw)
  To: bucoo@sohu.com; pgsql-bugs

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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #14984: function "heap_tuple_from_minimal_tuple" lost HeapTupleHeader->t_len value
@ 2017-12-20 15:39  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2017-12-20 15:39 UTC (permalink / raw)
  To: bucoo@sohu.com; +Cc: pgsql-bugs

=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> 	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);
> */

As with #14985, you haven't shown any reason why this is a good change
to make.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2017-12-20 15:39 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-12-20 09:49 BUG #14984: function "heap_tuple_from_minimal_tuple" lost HeapTupleHeader->t_len value PG Bug reporting form <noreply@postgresql.org>
2017-12-20 15:25 ` Andres Freund <andres@anarazel.de>
2017-12-20 15:39 ` Tom Lane <tgl@sss.pgh.pa.us>

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