Re: Q: extract database name from directory dump - Mailing list pgsql-general

From Karsten Hilbert
Subject Re: Q: extract database name from directory dump
Date
Msg-id 20160312211949.GG1688@hermes.hilbert.loc
Whole thread Raw
In response to Re: Q: extract database name from directory dump  (John R Pierce <pierce@hogranch.com>)
List pgsql-general
On Sat, Mar 12, 2016 at 01:12:52PM -0800, John R Pierce wrote:

>> Constraints of the question:
>>
>> - existing dump in directory format
>> - dump was taken of only one particular database
>
> I know of no documentation on the format of the toc.dat file contained in
> that directory format pg_dump output (short of reading the source to
> pg_dump/restore?) but I tried a hexdump...
>
> $ hexdump -C junky/toc.dat
> 00000000  50 47 44 4d 50 01 0c 00  04 08 03 01 01 00 00 00
> |PGDMP...........|
> 00000010  00 24 00 00 00 00 2d 00  00 00 00 0c 00 00 00 00
> |.$....-.........|
> 00000020  0c 00 00 00 00 02 00 00  00 00 74 00 00 00 00 00
> |..........t.....|
> 00000030  00 00 00 00 04 00 00 00  6a 75 6e 6b 00 06 00 00
> |........junk....|
> 00000040  00 39 2e 33 2e 31 31 00  06 00 00 00 39 2e 33 2e
> |.9.3.11.....9.3.|
> (tons more deleted)
>
> and note that 'junk' is in fact the name of the database.   But I doubt the
> format of this toc.dat file is guaranteed to be immutable

I looked at that, too, but was quite worried that this
solution would be very fragile.

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


pgsql-general by date:

Previous
From: Melvin Davidson
Date:
Subject: Re: Q: extract database name from directory dump
Next
From: Karsten Hilbert
Date:
Subject: Re: Q: extract database name from directory dump