20
20
*
21
21
*
22
22
* IDENTIFICATION
23
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.33 2007/08/06 01:38:15 tgl Exp $
23
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.34 2007/10/28 21:55:52 tgl Exp $
24
24
*
25
25
*-------------------------------------------------------------------------
26
26
*/
@@ -121,12 +121,19 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
121
121
" normal use. Files will be written in the current working directory.\n" );
122
122
123
123
if (AH -> fSpec && strcmp (AH -> fSpec , "" ) != 0 )
124
+ {
124
125
AH -> FH = fopen (AH -> fSpec , PG_BINARY_W );
126
+ if (AH -> FH == NULL )
127
+ die_horribly (NULL , modulename , "could not open output file \"%s\": %s\n" ,
128
+ AH -> fSpec , strerror (errno ));
129
+ }
125
130
else
131
+ {
126
132
AH -> FH = stdout ;
127
-
128
- if (AH -> FH == NULL )
129
- die_horribly (NULL , modulename , "could not open output file: %s\n" , strerror (errno ));
133
+ if (AH -> FH == NULL )
134
+ die_horribly (NULL , modulename , "could not open output file: %s\n" ,
135
+ strerror (errno ));
136
+ }
130
137
131
138
ctx -> hasSeek = checkSeek (AH -> FH );
132
139
@@ -139,12 +146,19 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
139
146
{ /* Read Mode */
140
147
141
148
if (AH -> fSpec && strcmp (AH -> fSpec , "" ) != 0 )
149
+ {
142
150
AH -> FH = fopen (AH -> fSpec , PG_BINARY_R );
151
+ if (AH -> FH == NULL )
152
+ die_horribly (NULL , modulename , "could not open input file \"%s\": %s\n" ,
153
+ AH -> fSpec , strerror (errno ));
154
+ }
143
155
else
156
+ {
144
157
AH -> FH = stdin ;
145
-
146
- if (AH -> FH == NULL )
147
- die_horribly (NULL , modulename , "could not open input file: %s\n" , strerror (errno ));
158
+ if (AH -> FH == NULL )
159
+ die_horribly (NULL , modulename , "could not open input file: %s\n" ,
160
+ strerror (errno ));
161
+ }
148
162
149
163
ctx -> hasSeek = checkSeek (AH -> FH );
150
164
@@ -242,7 +256,8 @@ _StartData(ArchiveHandle *AH, TocEntry *te)
242
256
#endif
243
257
244
258
if (tctx -> FH == NULL )
245
- die_horribly (AH , modulename , "could not open output file: %s\n" , strerror (errno ));
259
+ die_horribly (AH , modulename , "could not open output file \"%s\": %s\n" ,
260
+ tctx -> filename , strerror (errno ));
246
261
}
247
262
248
263
static size_t
@@ -286,7 +301,8 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
286
301
#endif
287
302
288
303
if (AH -> FH == NULL )
289
- die_horribly (AH , modulename , "could not open input file: %s\n" , strerror (errno ));
304
+ die_horribly (AH , modulename , "could not open input file \"%s\": %s\n" ,
305
+ filename , strerror (errno ));
290
306
291
307
while ((cnt = GZREAD (buf , 1 , 4095 , AH -> FH )) > 0 )
292
308
{
@@ -507,7 +523,8 @@ _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
507
523
#endif
508
524
509
525
if (tctx -> FH == NULL )
510
- die_horribly (AH , modulename , "could not open large object file for input: %s\n" , strerror (errno ));
526
+ die_horribly (AH , modulename , "could not open large object file \"%s\" for input: %s\n" ,
527
+ fname , strerror (errno ));
511
528
}
512
529
513
530
/*
0 commit comments