Re: PATCH: pg_basebackup (missing exit on error) - Mailing list pgsql-hackers

From Robert Haas
Subject Re: PATCH: pg_basebackup (missing exit on error)
Date
Msg-id CA+TgmoZTVdHQVS3HksoOVmAY44C49mxv+K166vWgZrJ0Gavyjg@mail.gmail.com
Whole thread Raw
In response to Re: PATCH: pg_basebackup (missing exit on error)  (Fujii Masao <masao.fujii@gmail.com>)
Responses Re: PATCH: pg_basebackup (missing exit on error)  (Fujii Masao <masao.fujii@gmail.com>)
List pgsql-hackers
On Tue, Mar 27, 2012 at 7:13 AM, Fujii Masao <masao.fujii@gmail.com> wrote:
> Attached patch removes the fflush() part, changes the log message and removes
> the check of tarfile, as above.

With this patch applied, we end up with:
           if (strcmp(basedir, "-") == 0)           {
#ifdef HAVE_LIBZ               if (ztarfile != NULL)                   gzclose(ztarfile);
#endif           }           else           {
#ifdef HAVE_LIBZ               if (ztarfile != NULL)                   gzclose(ztarfile);               else
#endif               {                   if (fclose(tarfile) != 0)                   {
fprintf(stderr,_("%s: could not close file
 
\"%s\": %s\n"),                               progname, filename, strerror (errno));
disconnect_and_exit(1);                  }               }           }
 

I think it would make sense to rearrange that so that we don't have
two tests for ztarfile != NULL; do that test first, and then if it
fails, do the strcmp after that.

Also, if we're going to test the return value of fclose(), shouldn't
we also be checking the return value of gzclose()?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Shigeru HANADA
Date:
Subject: Re: pgsql_fdw, FDW for PostgreSQL server
Next
From: Robert Haas
Date:
Subject: Re: Improvement of log messages in pg_basebackup