postgresql/src
Michael Paquier 8722c4dacc Fix error handling of readdir() port implementation on first file lookup
The implementation of readdir() in src/port/ which gets used by MSVC has
been added in 399a36a, and since the beginning it considers all errors
on the first file lookup as ENOENT, setting errno accordingly and
letting the routine caller think that the directory is empty.  While
this is normally enough for the case of the backend, this can confuse
callers of this routine on Windows as all errors would map to the same
behavior.  So, for example, even permission errors would be thought as
having an empty directory, while there could be contents in it.

This commit changes the error handling so as readdir() gets a behavior
similar to native implementations: force errno=0 when seeing
ERROR_FILE_NOT_FOUND as error and consider other errors as plain
failures.

While looking at the patch, I noticed that MinGW does not enforce
errno=0 when looking at the first file, but it gets enforced on the next
file lookups.  A comment related to that was incorrect in the code.

Reported-by: Yuri Kurenkov
Diagnosed-by: Yuri Kurenkov, Grigory Smolkin
Author:	Konstantin Knizhnik
Reviewed-by: Andrew Dunstan, Michael Paquier
Discussion: https://postgr.es/m/2cad7829-8d66-e39c-b937-ac825db5203d@postgrespro.ru
Backpatch-through: 9.4
2019-03-04 09:50:02 +09:00
..
backend Further fixing for multi-row VALUES lists for updatable views. 2019-03-03 10:52:54 +00:00
bin Fix some issues with TAP tests of pg_basebackup 2019-02-18 14:23:44 +09:00
common Tolerate EINVAL when calling fsync() on a directory. 2019-02-24 23:51:54 +13:00
fe_utils Fix translation of special characters in psql's LaTeX output modes. 2018-11-26 17:32:51 -05:00
include Stamp 11.2. 2019-02-11 16:17:27 -05:00
interfaces Fix SCRAM authentication via SSL when mixing versions of OpenSSL 2019-02-28 09:40:39 +09:00
makefiles Move port-specific parts of with_temp_install to port makefile. 2019-02-04 18:56:17 +00:00
pl Translation updates 2019-02-11 14:31:57 +01:00
port Fix error handling of readdir() port implementation on first file lookup 2019-03-04 09:50:02 +09:00
template Yet further rethinking of build changes for macOS Mojave. 2018-11-02 18:54:00 -04:00
test Further fixing for multi-row VALUES lists for updatable views. 2019-03-03 10:52:54 +00:00
timezone Update time zone data files to tzdata release 2018i. 2019-02-05 10:59:06 -05:00
tools Unify searchpath and do file logic in MSVC build scripts. 2019-02-06 07:49:07 -05:00
tutorial Update copyright for 2018 2018-01-02 23:30:12 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Move port-specific parts of with_temp_install to port makefile. 2019-02-04 18:56:17 +00:00
Makefile.shlib Ensure static libraries have correct mod time even if ranlib messes it up. 2018-11-29 15:53:44 -05:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00