Re: $PGDATA/base/???

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: bpalmer <bpalmer(at)crimelabs(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: $PGDATA/base/???
Date: 2001-01-24 04:10:49
Message-ID: 200101240410.XAA02636@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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:43 1216
-rw------- 1 postgres postgres 8192 Jan 15 23:43 1219
-rw------- 1 postgres postgres 24576 Jan 15 23:43 1247
-rw------- 1 postgres postgres 114688 Jan 19 21:43 1249
-rw------- 1 postgres postgres 229376 Jan 15 23:43 1255
-rw------- 1 postgres postgres 24576 Jan 15 23:59 1259
-rw------- 1 postgres postgres 8192 Jan 15 23:43 16567
-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':

$ du
1517 ./1
1517 ./18719
2085 ./18720
1517 ./27592
20561 ./27593
27198 .

As you can see, this could be tricky.

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

Browse pgsql-hackers by date

  From Date Subject
Next Message bpalmer 2001-01-24 04:19:56 Re: $PGDATA/base/???
Previous Message Bruce Momjian 2001-01-24 03:46:51 Re: [PATCHES] Small patch to replace 'idle' by 'trans' if transactionis still open