Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6441288

Browse files
committed
Add 'output file' option for pg_dumpall, especially useful for Win32,
where output redirection of child processes (pg_dump) doesn't work.Dave Page
1 parent1b7d863 commit6441288

File tree

7 files changed

+155
-60
lines changed

7 files changed

+155
-60
lines changed

‎doc/src/sgml/ref/pg_dumpall.sgml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.61 2007/01/2502:46:33 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dumpall.sgml,v 1.62 2007/01/2503:30:43 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -128,6 +128,18 @@ PostgreSQL documentation
128128
</para>
129129
</listitem>
130130
</varlistentry>
131+
132+
<varlistentry>
133+
<term><option>-f <replaceable class="parameter">filename</replaceable></option></term>
134+
<term><option>--file=<replaceable class="parameter">filename</replaceable></option></term>
135+
<listitem>
136+
<para>
137+
Write the output to the specified file. This is particularly useful
138+
on Windows because output redirection does not work for child
139+
processes.
140+
</para>
141+
</listitem>
142+
</varlistentry>
131143

132144
<varlistentry>
133145
<term><option>-g</option></term>

‎src/bin/pg_dump/pg_backup.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.44 2006/10/14 23:07:22 tgl Exp $
18+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.45 2007/01/25 03:30:43 momjian Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -46,6 +46,13 @@ typedef enum _archiveFormat
4646
archNull=4
4747
}ArchiveFormat;
4848

49+
typedefenum_archiveMode
50+
{
51+
archModeAppend,
52+
archModeWrite,
53+
archModeRead
54+
}ArchiveMode;
55+
4956
/*
5057
*We may want to have some more user-readable data, but in the mean
5158
*time this gives us some abstraction and type checking.
@@ -166,7 +173,7 @@ extern Archive *OpenArchive(const char *FileSpec, const ArchiveFormat fmt);
166173

167174
/* Create a new archive */
168175
externArchive*CreateArchive(constchar*FileSpec,constArchiveFormatfmt,
169-
constintcompression);
176+
constintcompression,ArchiveModemode);
170177

171178
/* The --list option */
172179
externvoidPrintTOCSummary(Archive*AH,RestoreOptions*ropt);

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.139 2007/01/23 17:54:50 tgl Exp $
18+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.140 2007/01/25 03:30:43 momjian Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -86,10 +86,10 @@ static void ResetOutput(ArchiveHandle *AH, OutputContext savedContext);
8686
/* Public */
8787
Archive*
8888
CreateArchive(constchar*FileSpec,constArchiveFormatfmt,
89-
constintcompression)
89+
constintcompression,ArchiveModemode)
9090

9191
{
92-
ArchiveHandle*AH=_allocAH(FileSpec,fmt,compression,archModeWrite);
92+
ArchiveHandle*AH=_allocAH(FileSpec,fmt,compression,mode);
9393

9494
return (Archive*)AH;
9595
}
@@ -203,7 +203,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
203203

204204
/*
205205
* Setup the output file if necessary.
206-
*/
206+
*/
207207
if (ropt->filename||ropt->compression)
208208
sav=SetOutput(AH,ropt->filename,ropt->compression);
209209

@@ -940,10 +940,20 @@ SetOutput(ArchiveHandle *AH, char *filename, int compression)
940940
else
941941
#endif
942942
{/* Use fopen */
943-
if (fn >=0)
944-
AH->OF=fdopen(dup(fn),PG_BINARY_W);
943+
if (AH->mode==archModeAppend)
944+
{
945+
if (fn >=0)
946+
AH->OF=fdopen(dup(fn),PG_BINARY_A);
947+
else
948+
AH->OF=fopen(filename,PG_BINARY_A);
949+
}
945950
else
946-
AH->OF=fopen(filename,PG_BINARY_W);
951+
{
952+
if (fn >=0)
953+
AH->OF=fdopen(dup(fn),PG_BINARY_W);
954+
else
955+
AH->OF=fopen(filename,PG_BINARY_W);
956+
}
947957
AH->gzOut=0;
948958
}
949959

‎src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*
1919
* IDENTIFICATION
20-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.73 2006/10/04 00:30:05 momjian Exp $
20+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.74 2007/01/25 03:30:43 momjian Exp $
2121
*
2222
*-------------------------------------------------------------------------
2323
*/
@@ -122,12 +122,6 @@ typedef void (*PrintTocDataPtr) (struct _archiveHandle * AH, struct _tocEntry *
122122

123123
typedefsize_t (*CustomOutPtr) (struct_archiveHandle*AH,constvoid*buf,size_tlen);
124124

125-
typedefenum_archiveMode
126-
{
127-
archModeWrite,
128-
archModeRead
129-
}ArchiveMode;
130-
131125
typedefstruct_outputContext
132126
{
133127
void*OF;

‎src/bin/pg_dump/pg_dump.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.458 2007/01/23 17:54:50 tgl Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.459 2007/01/25 03:30:43 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -478,25 +478,31 @@ main(int argc, char **argv)
478478
/* open the output file */
479479
switch (format[0])
480480
{
481+
case'a':
482+
case'A':
483+
plainText=1;
484+
g_fout=CreateArchive(filename,archNull,0,archModeAppend);
485+
break;
486+
481487
case'c':
482488
case'C':
483-
g_fout=CreateArchive(filename,archCustom,compressLevel);
489+
g_fout=CreateArchive(filename,archCustom,compressLevel,archModeWrite);
484490
break;
485491

486492
case'f':
487493
case'F':
488-
g_fout=CreateArchive(filename,archFiles,compressLevel);
494+
g_fout=CreateArchive(filename,archFiles,compressLevel,archModeWrite);
489495
break;
490496

491497
case'p':
492498
case'P':
493499
plainText=1;
494-
g_fout=CreateArchive(filename,archNull,0);
500+
g_fout=CreateArchive(filename,archNull,0,archModeWrite);
495501
break;
496502

497503
case't':
498504
case'T':
499-
g_fout=CreateArchive(filename,archTar,compressLevel);
505+
g_fout=CreateArchive(filename,archTar,compressLevel,archModeWrite);
500506
break;
501507

502508
default:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp