Обсуждение: Re: $PGDATA/base/???

Поиск
Список
Период
Сортировка

Re: $PGDATA/base/???

От
Bruce Momjian
Дата:
Wow, this looks great, and it worked the first time too.  I will commit
if no one makes objects.


> > > > Is there a way to relate this to the names of the databases?  Why the
> > > > change?  Or am I missing something key here..
> > >
> > > See the thread on the renaming in the archives.  In short, this is part
> > > of Vadim's work on WAL -- the new naming makes certain things easier for
> > > WAL.
> > >
> > > Utilities to relate the new names to the actual database/table names
> > > _do_ need to be written, however.  The information exists in one of the
> > > system catalogs now -- it just has to be made accessible.
> >
> > Yes, I am hoping to write this utility before 7.1 final.  Maybe it will
> > have to be in /contrib.
> 
> I just finished writing such an app.  Take a look.  It's in a format
> that can be put in /contrib.  Let me know if you want any changes made,
> etc.  Feel free to use any of the code you wish.
> 
> http://www.crimelabs.net/postgresql.shtml
> 
> - Brandon
> 
> b. palmer,  bpalmer@crimelabs.net
> pgp:  www.crimelabs.net/bpalmer.pgp5
> 
> 


--  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
 


Re: $PGDATA/base/???

От
"Ross J. Reedstrom"
Дата:
On Wed, Jan 17, 2001 at 05:49:36PM -0500, Bruce Momjian wrote:
> Wow, this looks great, and it worked the first time too.  I will commit
> if no one makes objects.
> 

I object. The code displays oids and tablenames or relnames. Oid is just
the initial, default filename for tables, and may change to something other
than the oid. Currently, the reindex code is the only place that could change
the relfilenode without changing the oid, but I think there may be more
in the future.

Here's a patch to Brandon's code (completely untested, BTW):

Ross


Re: $PGDATA/base/???

От
bpalmer
Дата:
> I object. The code displays oids and tablenames or relnames. Oid is just
> the initial, default filename for tables, and may change to something other
> than the oid. Currently, the reindex code is the only place that could change
> the relfilenode without changing the oid, but I think there may be more
> in the future.

Looks great,  and I agree.  Did not know that little piece of information.
I have made the changed to my code,  here's the new version.  I have
tested this one and updated the web page.

- brandon


b. palmer,  bpalmer@crimelabs.net
pgp:  www.crimelabs.net/bpalmer.pgp5


Re: $PGDATA/base/???

От
Tom Lane
Дата:
"Ross J. Reedstrom" <reedstrm@rice.edu> writes:
> I object. The code displays oids and tablenames or relnames. Oid is just
> the initial, default filename for tables, and may change to something other
> than the oid. Currently, the reindex code is the only place that could change
> the relfilenode without changing the oid, but I think there may be more
> in the future.

Right, relfilenode is the thing to look at, not OID.  I believe we are
thinking of using relfilenode updates for a number of things in the
future --- CLUSTER and faster index rebuilds in VACUUM are two thoughts
that come to mind ...
        regards, tom lane


Re: $PGDATA/base/???

От
Bruce Momjian
Дата:
I have added this to /contrib for 7.1.

> > I object. The code displays oids and tablenames or relnames. Oid is just
> > the initial, default filename for tables, and may change to something other
> > than the oid. Currently, the reindex code is the only place that could change
> > the relfilenode without changing the oid, but I think there may be more
> > in the future.
> 
> Looks great,  and I agree.  Did not know that little piece of information.
> I have made the changed to my code,  here's the new version.  I have
> tested this one and updated the web page.
> 
> - brandon
> 
> 
> b. palmer,  bpalmer@crimelabs.net
> pgp:  www.crimelabs.net/bpalmer.pgp5
> 
Content-Description: 

[ Attachment, skipping... ]


--  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
 


Re: $PGDATA/base/???

От
Bruce Momjian
Дата:
> > 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
 


Re: $PGDATA/base/???

От
bpalmer
Дата:
On Tue, 23 Jan 2001, Bruce Momjian wrote:

> I have added this to /contrib for 7.1.
>
Not sure if you know this,  but you checked in the code compiled and w/
the .o file...

FYI.

b. palmer,  bpalmer@crimelabs.net
pgp:  www.crimelabs.net/bpalmer.pgp5



Re: $PGDATA/base/???

От
Bruce Momjian
Дата:
Thanks.  Removed.

> On Tue, 23 Jan 2001, Bruce Momjian wrote:
> 
> > I have added this to /contrib for 7.1.
> >
> Not sure if you know this,  but you checked in the code compiled and w/
> the .o file...
> 
> FYI.
> 
> b. palmer,  bpalmer@crimelabs.net
> pgp:  www.crimelabs.net/bpalmer.pgp5
> 
> 


--  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