1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-27 07:42:10 +03:00

Change pg_restore -f- to dump to stdout instead of to ./-

Starting with PostgreSQL 12, pg_restore refuses to run when neither -d
nor -f are specified (c.f. commit 413ccaa74d), and it also makes "-f -"
mean the old implicit behavior of dumping to stdout.  However, older
branches write to a file called ./- when invoked like that, making it
impossible to write pg_restore scripts that work across versions.  This
is a partial backpatch of the aforementioned commit to all older
supported branches, providing an upgrade path.

Discussion: https://postgr.es/m/20191006190839.GE18030@telsasoft.com
This commit is contained in:
Alvaro Herrera
2019-11-04 15:50:57 -03:00
parent 74d32ee704
commit d38635725c
3 changed files with 9 additions and 4 deletions

View File

@@ -1500,7 +1500,12 @@ SetOutput(ArchiveHandle *AH, const char *filename, int compression)
int fn;
if (filename)
fn = -1;
{
if (strcmp(filename, "-") == 0)
fn = fileno(stdout);
else
fn = -1;
}
else if (AH->FH)
fn = fileno(AH->FH);
else if (AH->fSpec)