pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mattia <mattia@p2pforum.it>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Subject: Re: Allow to_date() and to_timestamp() to accept localized month names
Date: Sat, 10 Sep 2016 11:41:18 -0400
Message-ID: <19809.1473522078@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+heTbrDQ6b0Am_mk0dJEcwNxwQz+r=az_=zHTva+5BDnfOKjA@mail.gmail.com>
References: <CA+heTbrDQ6b0Am_mk0dJEcwNxwQz+r=az_=zHTva+5BDnfOKjA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Mattia <mattia@p2pforum.it> writes:
> attached is a patch which adds support to localized month names in
> to_date() and to_timestamp() functions.

Seems like a fine goal.

> I thought about reusing from_char_seq_search() but localized month
> names use different capitalization according to the language grammar,
> so I used pg_strncasecmp to do the match.

pg_str(n)casecmp is really only meant to handle comparisons of ASCII
strings; it will definitely not succeed in case-folding multibyte
characters.  That's not a big problem for to_date's existing usages
but I'm afraid it will be for non-English month names.  I think you'll
need another solution there.  You might have to resort to what citext
does, namely apply the full lower() transformation, at least whenever
the data string actually contains MB characters.

> Regression tests with TM modifier are difficult since one should have
> the locale used for the test installed on his system.

I suspect you'll have to give up on putting much about this into the
standard regression tests.  We've used not-run-by-default test scripts
in some similar cases (eg collate.linux.utf8.sql), but personally I think
those are 99% a waste of time, precisely because they never actually
get run by anyone but the author.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (66+ messages)  latest in thread

Message-ID: <19809.1473522078@sss.pgh.pa.us>
Permalink:  ../19809.1473522078@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/19809.1473522078@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mattia@p2pforum.it
  Subject: Re: Allow to_date() and to_timestamp() to accept localized month names
  In-Reply-To: <19809.1473522078@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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