Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space - Mailing list pgsql-bugs

From Noah Misch
Subject Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space
Date
Msg-id 20151118044334.GA1410299@tornado.leadboat.com
Whole thread Raw
In response to Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space  (Bruce Momjian <bruce@momjian.us>)
Responses Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space  (Bruce Momjian <bruce@momjian.us>)
List pgsql-bugs
On Fri, Nov 13, 2015 at 08:24:02PM -0500, Bruce Momjian wrote:
> Thank you for the report.  This is embarrassing, but the code was
> testing for the wrong return value on Windows.  We used a macro to
> define the same symbol on Windows and Unix (pg_copy_file)

> *** a/src/bin/pg_upgrade/file.c
> --- b/src/bin/pg_upgrade/file.c
> *************** copyAndUpdateFile(pageCnvCtx *pageConver
> *** 34,40 ****
>   {
>       if (pageConverter == NULL)
>       {
> !         if (pg_copy_file(src, dst, force) == -1)
>               return getErrorText(errno);
>           else
>               return NULL;
> --- 34,44 ----
>   {
>       if (pageConverter == NULL)
>       {
> ! #ifndef WIN32
> !         if (copy_file(src, dst, force) == -1)
> ! #else
> !         if (CopyFile(src, dst, force) == 0)
> ! #endif
>               return getErrorText(errno);

Thanks.  This passage of code has at least two other problems on Windows.  The
third CopyFile() argument means the opposite of the third copy_file()
argument.  Next, getErrorText() is wrong on Windows:

const char *
getErrorText(int errNum)
{
#ifdef WIN32
    _dosmaperr(GetLastError());
#endif
    return pg_strdup(strerror(errNum));
}

Calling _dosmaperr() to set errno is futile, because we nonetheless proceed to
use the passed-in errNum.

pgsql-bugs by date:

Previous
From: John R Pierce
Date:
Subject: Re: BUG #13777: FKs began to no longer treat referential integrity, ie, it was as if the FKs did not exist.
Next
From: Sandeep Thakkar
Date:
Subject: Re: BUG #13763: Failed to re-install Posgresql 9.1