Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8sDu-0007Nv-3m for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Sep 2019 20:31:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i8sDt-0000X2-0c for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Sep 2019 20:31:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8sDs-0000Wj-NB for pgsql-hackers@lists.postgresql.org; Fri, 13 Sep 2019 20:31:16 +0000 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8sDp-0007Ip-Tr for pgsql-hackers@lists.postgresql.org; Fri, 13 Sep 2019 20:31:16 +0000 Received: by mail-qk1-x744.google.com with SMTP id x134so29492256qkb.0 for ; Fri, 13 Sep 2019 13:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=k8qerhQmt7o1xbakncgzLxOoJZF1xhzMZoWjKOMwcEg=; b=MwLOcT14OclkqhgiHIMs6Dyhc4SrgTa0pBrAN1USyLTO+BPJjBqaD5EBCrFlfZXLNi rpIUIizemB/0PkgqgKiSGt0pBazSM0dNbadOEYz8OBpvIulJbJhdXqgD0SPtxoR+rfTB 4eDqH8W0Q/i133exYDTV0UebO70F1dnXrei6l4Hc6KVg9GKhxdhRI69MJ/O1PnaCRoIP CuMy34LVZrqVVcu2v4CPl98XAqxw2juVRrzre6DGd3VvtfiMyWbmghWF3wkeyE8j2eDi 5d4UvIyoj8fLFXPR3J5nA+Y5BWPxaxmwwRgVwId+AP2dG9SriRyBilbcXy9DhBvebQ7X yd5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=k8qerhQmt7o1xbakncgzLxOoJZF1xhzMZoWjKOMwcEg=; b=p1lwADwFYufJuTo0Mo2mR3i1gJZ0qSEW2E6NhpKlpPSQLfBv+FZpDVVAbeV6q/dhKB /ByhceZ75Y03eWf9A8/xWvbhsn0me0T3Evi0iQ+fove7SN4pEDIKL8RDgiYuVMZKNydL /mAn3+LBlc8a4EFTIs0z6qEvnfCy/GaVUVeobbg5NLnR6jaM7LMvwKvERhPZX658seev HlYw8qlp+mpfVXr16HkdgCHFT74bjN6hWArVXz+Kr2b2/NqMTsCvF7GaPP7Hg+uuNxIt aWwA1S1L7fql2byeLeaHB68y5fnRpv5ZUWFy6bX644hn4Z76NfN/foqxsNZqKfuriVsA JvVg== X-Gm-Message-State: APjAAAU1Cbn2LYSBEh6ZUHePsR9Xx94qXL0O3/3/+TUS5zgEGnS3wraH Cb9pUHZcEXWNLhBNgnjiF9xAdw== X-Google-Smtp-Source: APXvYqxiN92UAgRVNvvr2L7aP5AS9xgGvXF+1R995MvwT4rqHnAn+fd0PSipkJeZYOl68Z1mishS3A== X-Received: by 2002:a37:b303:: with SMTP id c3mr48154849qkf.253.1568406672394; Fri, 13 Sep 2019 13:31:12 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([179.56.30.174]) by smtp.gmail.com with ESMTPSA id b4sm13591736qkd.121.2019.09.13.13.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 13:31:11 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id D3D2912068B; Fri, 13 Sep 2019 17:31:09 -0300 (-03) Date: Fri, 13 Sep 2019 17:31:09 -0300 From: Alvaro Herrera To: Juan =?iso-8859-1?Q?Jos=E9_Santamar=EDa?= Flecha Cc: PostgreSQL Hackers Subject: Re: Allow to_date() and to_timestamp() to accept localized names Message-ID: <20190913203109.GA12141@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Aug-22, Juan José Santamaría Flecha wrote: > On Sun, Aug 18, 2019 at 10:42 AM Juan José Santamaría Flecha > wrote: > > > > Going through the current items in the wiki's todo list, I have been > > looking into: "Allow to_date () and to_timestamp () to accept > > localized month names". > > I have gone through a second take on this, trying to give it a better > shape but it would surely benefit from some review, so I will open an > item in the commitfest. I'm confused why we acquire the MONTH_DIM / etc definitions. Can't we just use lengthof() of the corresponding array? AFAICS it should work just as well. I wonder if the "compare first char" thing (seq_search_localized) really works when there are multibyte chars in the day/month names. I think the code compares just the first char ... but what if the original string uses those funny Unicode non-normalized letters and the locale translation uses normalized letters? My guess is that the first-char comparison will fail, but surely you'll want the name to match. (There's no month/day name in Spanish that doesn't start with an ASCII letter, but I bet there are some in other languages.) I think the localized comparison should avoid the first-char optimization, just compare the whole string all the time, and avoid possible weird issues. But then, I'm not 100% sure of this code. formatting.c is madness distilled. Thanks, -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services