Обсуждение: Re: [GENERAL] You are really hosed.
--- Michael Plump <plumpy@skylab.org> wrote: > On Wed, 6 Oct 1999, Mike Mascari wrote: > > > You show yourself attempting to dump a database > > called "darwin", while connecting to and > displaying > > tables in the "template1" database. If the data > you > > wish to dump is in template1, you should issue the > > command: > > But, as his message indicated, the error says: > > > pg_dump: couldn't find the template1 database. > You > > > are really hosed. > > Hence, he was showing you that template1 really does > exist. > > I see. I guess I wasn't convinced darwin existed. Knowing that they both do, the source to pg_dump shows the error after the following select: SELECT oid from pg_database where datname = 'template1' in the routine which attempts to determine the maximum OID. Nikos should see the template1 database when performing the select in "darwin". If he does not, something is seriously wrong. However, he may still be able to dump the darwin database if he does not use the -o switch to dump OIDs, or he may wish to manually INSERT the missing records into pg_database: INSERT INTO pg_database VALUES ('template1', uid, 0, 'template1'); where uid is the usesysid from pg_user of the owner of the database (usually, 'postgres'). It would be interesting if he could list the details on the file: /usr/local/pgsql/data/pg_database Of course, if he's dumping OIDs for a reason (say he's using them as pk/fk) then he may be forced, if the above fails, to attempt to dump the schema, and then dump the data by using COPY :-( Hope that helps, Mike Mascari (mascarim@yahoo.com) ===== __________________________________________________ Do You Yahoo!? Bid and sell for free at http://auctions.yahoo.com
> > SELECT oid from pg_database where datname = > 'template1' > it turns out there was multiple template1's in the pg_database table: template1=> select * from pg_database;l datname |datdba|encoding|datpath ---------+------+--------+--------- template1| 100| 0|template1 template1| 100| 0|template1 darwin | 100| 0|darwin template1| 100| 0|template1 (4 rows) pg_dump works fine now (I deleted two of the three template1's) nm
> > > > SELECT oid from pg_database where datname = > > 'template1' > > > > it turns out there was multiple template1's in the pg_database table: > > template1=> select * from pg_database;l > datname |datdba|encoding|datpath > ---------+------+--------+--------- > template1| 100| 0|template1 > template1| 100| 0|template1 > darwin | 100| 0|darwin > template1| 100| 0|template1 > (4 rows) > > > pg_dump works fine now (I deleted two of the three template1's) I have no idea how this happens, but when it does, things are bad. I have improved the error message in pg_dump, saying: pg_dump: couldn't find the template1 database. Check the table pg_database for a problem. There should be exactly one 'template1' entry. -- Bruce Momjian | http://www.op.net/~candle maillist@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
Would it be unreasonable to make datname a primary key in pg_database ? nm > > it turns out there was multiple template1's in the pg_database table: > > I have no idea how this happens, but when it does, things are bad. > > I have improved the error message in pg_dump, saying: > > pg_dump: couldn't find the template1 database. > Check the table pg_database for a problem. > There should be exactly one 'template1' entry.
> > Would it be unreasonable to make datname a primary key in pg_database ? > That would help the having more than one, but not having none. Also, we don't know what is causing it. -- Bruce Momjian | http://www.op.net/~candle maillist@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