Обсуждение: BUG #5384: pg_dump hard-codes use of /tmp

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

BUG #5384: pg_dump hard-codes use of /tmp

От
"Jon Nelson"
Дата:
The following bug has been logged online:

Bug reference:      5384
Logged by:          Jon Nelson
Email address:      jnelson@jamponi.net
PostgreSQL version: 8.4.2
Operating system:   openSUSE 11.2
Description:        pg_dump hard-codes use of /tmp
Details:

I was trying to dump a database (with --format=tar).
I noticed I kept running out of space, but that should not have been - I was
dumping to a filesystem with plenty of space.

strace to the rescue!

strace shows me that pg_dump is using /tmp - hardcoded because my TMPDIR
environment variable does *not* point to /tmp.

So, there are two issues:

1. why is pg_dump using a temporary directory (other than the $CWD) anyway?

2. More importantly, why is pg_dump ignoring TMPDIR ?

Re: BUG #5384: pg_dump hard-codes use of /tmp

От
Tom Lane
Дата:
"Jon Nelson" <jnelson@jamponi.net> writes:
> I was trying to dump a database (with --format=tar).

Do you have a really good reason to be using tar rather than custom
format?  If so what is it?

> 1. why is pg_dump using a temporary directory (other than the $CWD) anyway?

Tar format is sufficiently weird that we have to dump data into a temp
file and then append it to the archive after we know its exact size.
This means double copying of data, as well as problems if your temp
directory is in an undersized filesystem.  On the whole, custom format
is a lot better bet from a performance standpoint --- so we only
recommend tar format if you have a clear need to be able to disassemble
the archive with non-Postgres tools.

> 2. More importantly, why is pg_dump ignoring TMPDIR ?

The temp files are created with the standard library function tmpfile().
If you think that's behaving improperly, take it up with your OS vendor.
I suspect they'll tell you it would be a security risk for that function
to respond to environment variables.

            regards, tom lane