Re: Thanks, naming conventions, and count()
Bruce Momjian <pgman@candle.pha.pa.us>
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: The Hermit Hacker <scrappy@hub.org>
Cc: Casey Lyon <casey@earthcars.com>, pgsql-hackers@postgresql.org
Date: 2001-04-30T03:46:38Z
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@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026