Reading deleted records - PageHeader v3

Поиск
Список
Период
Сортировка
От Jonathan Bond-Caron
Тема Reading deleted records - PageHeader v3
Дата
Msg-id 002201caa668$9c5583a0$d5008ae0$@com
обсуждение исходный текст
Ответы Re: Reading deleted records - PageHeader v3
Список pgsql-hackers

Hi,

 

So first I’m a pgsql hacker newbie and I’ve been reading up on the storage structure:

http://www.postgresql.org/docs/8.2/interactive/storage-page-layout.html

 

I’m trying to recover deleted records from a page file (postgresql 8.2) : i.e. base/dbId/20132

 

I am able to successfully read all the header data I need (PageHeaderData, ItemIdData , HeapTupleHeaderData)

but I hit a wall when I try to start reading user data.

 

This has helped:

http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/postgres.h?rev=1.77;content-type=text%2Fplain

 

I’ve read and understood fairly well how varlena structures are stored (plain, compressed, external/toast) but so far I can’t seem to read a plain inline value.

I think part of my problem is I haven’t really understood what ‘Then make sure you have the right alignment’ means.

 

My approach currently is:

After reading HeapTupleHeaderData (23 bytes), I advance another 4 bytes (hoff) and try to read a 32 bit integer (first attribute).

 

I am expecting to get an integer value 1 but I get 512 .

 

Am I doing this wrong?

Could someone point me to the pgsql code pieces I should be looking at?

 

If useful, this is the information I have before reading the ‘user data’:

 

object(PostgreSQL_HeapTupleHeaderData)#14 (7) {

  ["xmin"]=>

  string(5) "13824"

  ["xmax"]=>

  string(1) "0"

  ["cid"]=>

  string(1) "0"

  ["ctid"]=>

  object(PostgreSQL_ItemPointerData)#16 (2) {

    ["blockId"]=>

    string(1) "0"

    ["posId"]=>

    int(0)

  }

  ["infomask2"]=>

  int(0)

  ["infomask"]=>

  int(2)

  ["hoff"]=>

  int(4)

}

object(PostgreSQL_Attribute)#7 (6) {

  ["name"]=>

  string(7) "book_id"

  ["relid"]=>

  int(20132)

  ["len"]=>

  int(4)

  ["num"]=>

  int(1)

  ["ndims"]=>

  int(0)

  ["align"]=>

  string(1) "i"

}

array(1) {

  ["book_id"]=>

  int(512)

}

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