Re: $PGDATA/base/??? - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: $PGDATA/base/???
Date
Msg-id 200101240410.XAA02636@candle.pha.pa.us
Whole thread Raw
In response to $PGDATA/base/???  (bpalmer <bpalmer@crimelabs.net>)
List pgsql-hackers
> > What I will probably do is make a wrapper around it so it I can do:
> >
> >     ls | oidmapper
> >
> > and see the files as table names.
> 
> Hmmm.... I think I can add that to the code..
> 
> will try..
> 

It has to be pretty smart.  Consider this:
$ pwd/u/pg/data/base/18720$ ls -l

It has to read the directories above, looking for a directory name that
is all numbers.  It needs to then use that to find the database name. 
Of course, if you are not in the directory, you may have a problem with
the database and require them to specify it on the command line.

It then has to process the the contents of ls -l and find the oids in
there and map them:
total 2083-rw-------  1 postgres  postgres    8192 Jan 15 23:43 1215-rw-------  1 postgres  postgres    8192 Jan 15
23:431216-rw-------  1 postgres  postgres    8192 Jan 15 23:43 1219-rw-------  1 postgres  postgres   24576 Jan 15
23:431247-rw-------  1 postgres  postgres  114688 Jan 19 21:43 1249-rw-------  1 postgres  postgres  229376 Jan 15
23:431255-rw-------  1 postgres  postgres   24576 Jan 15 23:59 1259-rw-------  1 postgres  postgres    8192 Jan 15
23:4316567-rw-------  1 postgres  postgres   16384 Jan 16 00:04 16579
 

The numbers <16k are system tables so you probably need code to lookup
stuff <16k, and if it doesn't begin with pg_, it is not an oid.

It also should handle 'du':
$ du1517    ./11517    ./187192085    ./187201517    ./2759220561   ./2759327198   .
As you can see, this could be tricky.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_shadow.usecatupd attribute
Next
From: bpalmer
Date:
Subject: Re: $PGDATA/base/???