Re: Recovering data via raw table and field separators

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: John Wells <jb(at)sourceillustrated(dot)com>
Cc: General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Recovering data via raw table and field separators
Date: 2007-12-04 19:28:55
Message-ID: 20071204192855.GJ18214@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

John Wells wrote:
> On 12/4/07, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> > John Wells wrote:
> > > On 12/4/07, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> > > > There are no field separators. Perhaps you could extract some useful
> > > > info with pg_filedump, which you can grab at
> > > > http://sources.redhat.com/rhdb
> > >
> > > So is it simply field width? Can one count the number of bytes based
> > > on native datatype length and determine field start/end?
> >
> > Yes. For variable length types, there is a 4-byte length word at the
> > start of the field (unless you are using 8.3 which introduces more
> > compact representations in some cases).
>
> Oh fun...what about record separators? I think I could live with doing
> it by name and id. Since name is the last field in the table, and id
> is the first, one could assume that it looks something like this:
>
> 1rst record name | record separator | 2nd record id | etc, etc
>
> If I could split on that record separator I might be able to get what I'm after.

There are no record separators either. Records are stored following
offsets which are stored in a fixed-size array at the start of each
page, called "line pointers". Have a look at what pg_filedump shows you
for interpreted output.

Maybe you can get away with your idea, keeping in mind that record
separators are just not there.

--
Alvaro Herrera http://www.flickr.com/photos/alvherre/
"Aprender sin pensar es inútil; pensar sin aprender, peligroso" (Confucio)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message SHARMILA JOTHIRAJAH 2007-12-04 19:35:06 Re: WAL shipping question
Previous Message John Wells 2007-12-04 19:26:21 Re: Recovering data via raw table and field separators