hi,is it dangerous to only use tuple pointer through heap_getnext()?

Started by sunpengalmost 16 years ago2 messagesgeneral
Jump to latest
#1sunpeng
bluevaley@gmail.com

hi,i use these codes to store only pointer of tuple :
HeapTuple *tuple;
tuple = heap_getnext(pHeapScanDesc,ForwardScanDirection);
while(tuple){
//[1#]here i only store the pointer of tuple in an array for later
using,that means i don't retrive attribute data from this tuple ,is this ok?

myArray[i++]=tuple;
//then next tuple
tuple = heap_getnext(pHeapScanDesc,ForwardScanDirection);
}
at place [1#],i only store the pointer of current tuple in an array for
later using,that means i don't retrieve attribute data from this tuple ,is
this ok?
could these tuple pointers be invalid sometimes later if myArray still
reference these tuples? i know these tuples have been read into buffers in
shared memory, yet I am not sure wether these buffers be replaced or marked
invalid when myArray still points to these tuples in according buffers.
thanks a lot!

peng

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: sunpeng (#1)
Re: hi, is it dangerous to only use tuple pointer through heap_getnext()?

Excerpts from sunpeng's message of vie may 14 19:15:47 -0400 2010:

hi,i use these codes to store only pointer of tuple :
HeapTuple *tuple;
tuple = heap_getnext(pHeapScanDesc,ForwardScanDirection);
while(tuple){
//[1#]here i only store the pointer of tuple in an array for later
using,that means i don't retrive attribute data from this tuple ,is this ok?

No, this is not safe. The buffer is unpinned after heap_getnext walks
to the next buffer, and thus could be used for a different page.

--