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

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Why is it not sane to pass ExecStoreTuple(shouldFree=true) for tuples point into buffers
Date: 2014-04-08 08:49:04
Message-ID: 20140408084904.GR4161@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2014-04-07 21:47:38 -0400, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2014-04-08 09:05:32 Minor improvements in alter_table.sgml
Previous Message Michael Paquier 2014-04-08 07:08:20 Re: Including replication slot data in base backups