Re: WAL, xl_heap_insert and tuple oid mystry

Поиск
Список
Период
Сортировка
От jagan
Тема Re: WAL, xl_heap_insert and tuple oid mystry
Дата
Msg-id 343821.32394.qm@web32103.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Re: WAL, xl_heap_insert and tuple oid mystry  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Ответы Re: WAL, xl_heap_insert and tuple oid mystry  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-hackers
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
understandhow attributes are packed in to a buffer. In particular, according to the inline comments in code, this is
howa 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
typesrequire either a "no (char) align", "short align", "int aligned" or "double align". I went over the varattrib code
andI 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
eventhough 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
doublealigned. 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
notthe 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
thatis most optimal way to go about. Is there some documentation on how tuples are internally stored? 
 

Thanks in advance for any pointers.
Jagan



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Greg Smith
Дата:
Сообщение: Re: Single client performance on trivial SELECTs
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: Single client performance on trivial SELECTs