Re: Allow to_date() and to_timestamp() to accept localized names
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Arthur Zakirov <zaartur@gmail.com>, Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>, Tomas Vondra <tomas.vondra@2ndquadrant.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-01-23T22:00:53Z
Lists: pgsql-hackers
Attachments
- 0001-Allow-localized-month-names-to_date-v7.patch (text/x-diff) patch v7-0001
Here's a v7 patch, rebased over my recent hacking, and addressing most of the complaints I raised in <31691.1579648824@sss.pgh.pa.us>. However, I've got some new complaints now that I've looked harder at the code: * It's not exactly apparent to me why this code should be concerned about non-normalized characters when noplace else in the backend is. I think we should either rip that out entirely, or move the logic into str_tolower (and hence also str_toupper etc). I'd tend to favor the former, but of course I don't speak any languages where this would be an issue. Perhaps a better idea is to invent a new SQL function that normalizes a given string, and expect users to call that first if they'd like to_date() to match unnormalized text. * I have no faith in this calculation that decides how long the match length was: *len = element_len + name_len - norm_len; I seriously doubt that this does the right thing if either the normalization or the downcasing changed the byte length of the string. I'm not actually sure how we can do that correctly. There's no good way to know whether the changes happened within the part of the "name" string that we matched, or the part beyond what we matched, but we only want to count the former. So this seems like a pretty hard problem, and even if this logic is somehow correct as it stands, it needs a comment explaining why. * I'm still concerned about the risk of integer overflow in the string allocations in seq_search_localized(). Those need to be adjusted to be more paranoid, similar to the code in e.g. str_tolower. regards, tom lane
Commits
-
Allow to_date/to_timestamp to recognize non-English month/day names.
- d67755049388 13.0 landed
-
Clean up formatting.c's logic for matching constant strings.
- fb12aefaafce 11.7 landed
- be13f227febc 12.2 landed
- a576f2a8f2e8 9.5.21 landed
- 9e24575f6f1b 9.6.17 landed
- 600b953d73ca 9.4.26 landed
- 212b870d6743 10.12 landed
- 4c70098ffa8c 13.0 landed
-
Implement standard datetime parsing mode
- 1a950f37d0a2 13.0 cited
-
Repair assorted issues in locale data extraction.
- 7ad1cd31bfcb 12.0 cited