Hi, > > > Where is the OID of tuple stored in a WAL record of a > tuple? If not with xl_heap_header, where is it stored? Is it > stored at all? > > It's stored in the "tuple data" portion.
I see it now. I was having alignment issues, which I resolved. Thanks for your help. I am still not sure if I understand how attributes are packed in to a buffer. In particular, according to the inline comments in code, this is how a xl_heap_insert stores data: Oid + [padding bits] + [data] Now, to unpack the data, we would have to know what type of data is stored, which is obtained from pg_type. Different types require either a "no (char) align", "short align", "int aligned" or "double align". I went over the varattrib code and I am also able to unpack varchar, text and other variable length types. The code I wrote works fine but runs into alignment issues with some of the records. So, I am still missing something even though I have spent weeks reading postgres code. I notice the following: 1. Oid starts at MAXALIGNed, which is fine. 2. The subsequent attribute starts right away. There never seems to be padding even if the subsequent tuple needs to be double aligned. Hence, I skip aligning the first attribute by default, which is bizarre but works. 3. When unpacking goes out of alignment, I print the buffer see if this is because they are externally stored. That is not the case as I can see text fields are actually stored in the buffer. 4. The alignment goes out of whack even for entries with no varattrib for certain tuples. In general, what is the best way to unpack buffers containing tuples? I came across "heap_form_tuple" but not sure if that is most optimal way to go about. Is there some documentation on how tuples are internally stored? Thanks in advance for any pointers. Jagan -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers