Re: Why is it not sane to pass ExecStoreTuple(shouldFree=true) for tuples point into buffers - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Why is it not sane to pass ExecStoreTuple(shouldFree=true) for tuples point into buffers
Date
Msg-id 20140408084904.GR4161@awork2.anarazel.de
Whole thread Raw
In response to Re: Why is it not sane to pass ExecStoreTuple(shouldFree=true) for tuples point into buffers  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Why is it not sane to pass ExecStoreTuple(shouldFree=true) for tuples point into buffers  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2014-04-07 21:47:38 -0400, Tom Lane wrote:
> Andres Freund <andres@2ndquadrant.com> writes:
> > So what I now do is essentially:
> > while ((scantuple = index_getnext(scan, ForwardScanDirection)) != NULL)
> > {
> > ...
> >         ht = palloc(sizeof(HeapTupleData)); /* in the right context */
> >         memcpy(ht, scantuple, sizeof(HeapTupleData));
> >         ExecStoreTuple(ht, slot, scan->xs_cbuf, false);
> >         slot->tts_shouldFree = true;
> > ...
> > }
> 
> Well, that is certainly messy.  I think you could just use a local
> HeapTupleData variable instead of palloc'ing every time, where "local"
> means "has lifespan similar to the slot pointer".

Doesn't work nicely in this specific situation, but it's obviously an
alternative.

> There's some vaguely similar hacking near the end of ExecDelete.

Yea, and some other places. I wonder if a ExecShallowMaterializeSlot()
or something would be useful for me, that callsite and others?

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Including replication slot data in base backups
Next
From: Etsuro Fujita
Date:
Subject: Minor improvements in alter_table.sgml