Skip site navigation (1) Skip section navigation (2)

Re: Thanks, naming conventions, and count()

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: The Hermit Hacker <scrappy(at)hub(dot)org>
Cc: Casey Lyon <casey(at)earthcars(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Thanks, naming conventions, and count()
Date: 2001-04-30 03:46:38
Message-ID: 200104300346.f3U3kct12404@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
> > I think parsing the file contents is too hard.  The database would have
> > to be running and I would use psql.
> 
> I don't know, I recovered someone's database using a "raw" connection ...
> wasn't that difficult once I figured out the format *shrug*
> 
> the following gets the oid,relname's for a database in the format:
> 
> echo "select oid,relname from pg_class" | postgres -L -D /usr/local/pgsql/data eceb | egrep "oid|relname"
> 
> then just parse the output using a simple perl script:
> 
>          1: oid = "163338"      (typeid = 26, len = 4, typmod = -1, byval = t)
>          2: relname = "auth_info_uid_key"       (typeid = 19, len = 32, typmod = -1, byval = f)
>          1: oid = "163341"      (typeid = 26, len = 4, typmod = -1, byval = t)
>          2: relname = "auth_info_id"    (typeid = 19, len = 32, typmod = -1, byval = f)
>          1: oid = "56082"       (typeid = 26, len = 4, typmod = -1, byval = t)
>          2: relname = "auth_info"       (typeid = 19, len = 32, typmod = -1, byval = f)

Oh, you did a direct postgres backend connect.  Yes, that will work
fine.  Good idea if the postmaster is down.  I originally thought you
meant reading the pg_class file raw.  Of course, that would be really
hard because there is no way to know what numeric file is pg_class!

Actually, seems it is always 1259.  I see this in
include/catalog/pg_class.h:

	DATA(insert OID = 1259 (  pg_class 83         PGUID 0 1259 0 0 0 0 f f r
	22 0 0 0 0 0 f f f _null_ ));

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

In response to

Responses

pgsql-hackers by date

Next:From: Casey LyonDate: 2001-04-30 03:50:04
Subject: Re: Thanks, naming conventions, and count()
Previous:From: Bruce MomjianDate: 2001-04-30 03:43:18
Subject: Re: Thanks, naming conventions, and count()

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group