Fix parsing mode tracking when recycling datetime format cache entries JSONPath datetime() could accept invalid format strings depending on earlier datetime formatting operations in the same session. For example, a format containing an unquoted "z" separator could be accepted after to_char() had used it, although SQL/JSON standard mode prohibited it.
The cause was that DCH_cache_getnew() did not update the std flag when recycling a cache entry. Since cache lookups matched both the format string and std, a format parsed in one mode could be reused in the other. Fix this by setting std when recycling an entry, as already done when allocating a new one. Backpatch to all supported versions. Reported-by: Michael Malis <[email protected]> Author: Andrey Rachitskiy <[email protected]> Reviewed-by: Aleksander Alekseev <[email protected]> Reviewed-by: Fujii Masao <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: 15 Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/80cf6847aa7ead14de4d9bce23b00a394c79cf99 Modified Files -------------- src/backend/utils/adt/formatting.c | 1 + src/test/regress/expected/jsonb_jsonpath.out | 22 ++++++++++++++++++++++ src/test/regress/sql/jsonb_jsonpath.sql | 12 ++++++++++++ 3 files changed, 35 insertions(+)
