pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix error handling of readdir() port implementation on first fil 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix error handling of readdir() port implementation on first fil @ 2019-03-04 00:51 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2019-03-04 00:51 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/977f833772de09970da375fb68a46e33bbf397cb Modified Files -------------- src/port/dirent.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix error handling of readdir() port implementation on first fil @ 2019-03-04 00:51 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2019-03-04 00:51 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9aa59e64ba753e5392ea2711a0decb7c633d69ce Modified Files -------------- src/port/dirent.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix error handling of readdir() port implementation on first fil @ 2019-03-04 00:51 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2019-03-04 00:51 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d95133163b1b2d64a756bc4bfee0a356e3d80577 Modified Files -------------- src/port/dirent.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix error handling of readdir() port implementation on first fil @ 2019-03-04 00:51 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2019-03-04 00:51 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/754b90f657bd54b482524b73726dae4a9165031c Modified Files -------------- src/port/dirent.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix error handling of readdir() port implementation on first fil @ 2019-03-04 00:51 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2019-03-04 00:51 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8722c4daccf83411996aa5a18a3eca4ec84b7d41 Modified Files -------------- src/port/dirent.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix error handling of readdir() port implementation on first fil @ 2019-03-04 00:51 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 6+ messages in thread From: Michael Paquier @ 2019-03-04 00:51 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL9_4_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/81f5b32839ff9ab9b055538a4c55cf07d12ec450 Modified Files -------------- src/port/dirent.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2019-03-04 00:51 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-03-04 00:51 pgsql: Fix error handling of readdir() port implementation on first fil Michael Paquier <michael@paquier.xyz> 2019-03-04 00:51 pgsql: Fix error handling of readdir() port implementation on first fil Michael Paquier <michael@paquier.xyz> 2019-03-04 00:51 pgsql: Fix error handling of readdir() port implementation on first fil Michael Paquier <michael@paquier.xyz> 2019-03-04 00:51 pgsql: Fix error handling of readdir() port implementation on first fil Michael Paquier <michael@paquier.xyz> 2019-03-04 00:51 pgsql: Fix error handling of readdir() port implementation on first fil Michael Paquier <michael@paquier.xyz> 2019-03-04 00:51 pgsql: Fix error handling of readdir() port implementation on first fil Michael Paquier <michael@paquier.xyz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox