Retrieving the original table of a tuple stored in a tuplestore?

Started by Spencer Pearsonalmost 15 years ago2 messagesgeneral
Jump to latest
#1Spencer Pearson
crzybggr@gmail.com

Hi,
I'm pretty new to postgres, but I'm currently working on a project to
extend some of the code. For what we're doing, we need to sometimes store
tuples from multiple tables into the same tuplestore.
The way I understand the code, tuples stored in tuplestores do not also
store the TupleDesc or a way to access the original table the tuple came
from. This - again, as I understand the code - would make it impossible to
know what types of attributes are stored in the tuple.
Is there any way to find out which table a tuple that was previously
stored inside a tuplestore came from?

Thank you,
Spencer Pearson

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Spencer Pearson (#1)
Re: Retrieving the original table of a tuple stored in a tuplestore?

Spencer Pearson <crzybggr@gmail.com> writes:

The way I understand the code, tuples stored in tuplestores do not also
store the TupleDesc or a way to access the original table the tuple came
from. This - again, as I understand the code - would make it impossible to
know what types of attributes are stored in the tuple.

I think there are two different questions there.

1. A tuplestore has an associated TupleDesc, which must describe all
tuples stored into the tuplestore. The individual tuples aren't
individually self-describing, but the information as to what columns
they contain is certainly available.

2. While the TupleDesc only explicitly describes the "user" columns,
actual practice is that we store MinimalTuples, which don't include any
system columns and particularly not tableoid.

So no, there's no automatic solution for what you want. But perhaps you
could carry the tableoid as a "user" column that's explicitly present in
the stored tuples.

regards, tom lane