Tighten tid input parsing with strtoul() to reject empty fields strtoul() informs that in the case of no conversion, "endptr" is set equal to the location of the input pointer, which is something that tidin() has never checked.
This allowed inputs like "(,)", "(1,)" or "(,1)" to be accepted on some platforms, like Linux where "(1,)" implied "(1,0)", but rejected on others like macos where "(1,)" is rejected, due to the fact that errno may not be set. This change may cause some issues as some tid values will now be rejected, but at least we get the consistent strtoul() experience. If it proves to be a pain for some, it could always be reverted. Another point of this change is that we get one step closer to a possible common strtoul() where the error handling could be unified in core, with all the errors handled the same way for errno and no input parsed, at least. Reported-by: Michael Malis <[email protected]> Author: Tristan Partin <[email protected]> Discussion: https://postgr.es/m/[email protected] Discussion: https://postgr.es/m/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/58ff4a0a08679356e502dfcbbc50e9bec94b77b1 Modified Files -------------- src/backend/utils/adt/tid.c | 5 ++--- src/test/regress/expected/tid.out | 8 ++++++++ src/test/regress/sql/tid.sql | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-)
