Thread: Difference between HeapTupleData and TupleTableSlot structures
Hi,
I am pretty new to the Postgres code base. I would like to know the difference between HeapTupleData and TupleTableSlot structures.
Basically I am trying to understand some of the table access methods like heap_insert, heap_getnext, heap_getnextslot etc where some accepts Heaptuple as input and some accepts TupleTableSlot.
Could anyone please help me to understand this? Any example would also be helpful.
Best,
Ajay
I am pretty new to the Postgres code base. I would like to know the difference between HeapTupleData and TupleTableSlot structures.
Basically I am trying to understand some of the table access methods like heap_insert, heap_getnext, heap_getnextslot etc where some accepts Heaptuple as input and some accepts TupleTableSlot.
Could anyone please help me to understand this? Any example would also be helpful.
Best,
Ajay
Ajay P S <ajayps547@gmail.com> writes: > I am pretty new to the Postgres code base. I would like to know the > difference between HeapTupleData and TupleTableSlot structures. HeapTupleData is just a pointer to a concrete tuple. It exists mainly because it's often convenient to pass around the tuple's logical location (table OID and t_self) along with the tuple. The comments about it in htup.h tell you about all you need to know. TupleTableSlot is a more abstract concept, being a container for a tuple that can be present in several different forms. It can contain a concrete tuple (HeapTupleData), or a "virtual" tuple that is just an array of Datum+isnull values. The executor usually uses tuple slots to return tuples out of plan nodes; they're not very common elsewhere. regards, tom lane
Hi hackers, > TupleTableSlot is a more abstract concept, being a container > for a tuple that can be present in several different forms. > It can contain a concrete tuple (HeapTupleData), or a "virtual" > tuple that is just an array of Datum+isnull values. The executor > usually uses tuple slots to return tuples out of plan nodes; > they're not very common elsewhere. I came across another little piece of information about TupleTableSlots [1] and recalled this thread: """ To implement an access method, an implementer will typically need to implement an AM-specific type of tuple table slot (see src/include/executor/tuptable.h), which allows code outside the access method to hold references to tuples of the AM, and to access the columns of the tuple. """ Hopefully this is helpful. [1] https://www.postgresql.org/docs/current/tableam.html -- Best regards, Aleksander Alekseev