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 1iuSzx-0000q4-TB for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jan 2020 03:17:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iuSzv-0004Vn-4k for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jan 2020 03:17:35 +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 1iuSzu-0004Tg-Pf for pgsql-hackers@lists.postgresql.org; Thu, 23 Jan 2020 03:17:34 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iuSzo-0005ph-60 for pgsql-hackers@lists.postgresql.org; Thu, 23 Jan 2020 03:17:34 +0000 Received: by mail-pl1-x643.google.com with SMTP id c23so717837plz.4 for ; Wed, 22 Jan 2020 19:17:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=JX/Z9s2zEwF5uDzZh0DSZZ9hV3f0rWw6Z9TIzRzPH2w=; b=Uf/4amIcwfvbHrfble8oB4mWDw6k41mdmWrOJaZAeTpNElEhaHNsPDaEMjqY2ZSKEI giXGQl5hyq69PkYjDOlFskM0g81YXvwToJjwfk+TwYSZHkbiic1bUC9yy+cvh2wUBfoH GwiomvsaN/L/pIath7jMrexz+Na7DBWmEnm2qRq08JlTEmidt0iwVVNDhyehjvEPMUKo Kexp9MSNPfTWFyZtdJHT4+BDKRkiDBmgpwzAEwmjbeY5j/1uHUqILu6lAFYb1wA3FNIQ owSr8VLB8sFX4qE9/FxG7GMMF1sLtSOGpyMkgSSw3hjZRnSAuBrlGqrMRvLjy6cul5R6 ZYaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=JX/Z9s2zEwF5uDzZh0DSZZ9hV3f0rWw6Z9TIzRzPH2w=; b=kCVWUepvpcBxQRmi7kKpXcUhXEJTGZI5/J6juhF5+78NlV4540/HCGx9i4ePPZuVt9 prilRDFt6cRnxXnAtrZgqkVDQuLMLkbVoJhFPMGpD06PvUhyw6QBKKmNeT0ymXGH5DVK +HCyX5erXjU2BrTEHIjyqERoUIsN7yMZb1j2+1d0IKEobN/9ldlUsI1WIEXKRQ7/G/ql NxRBI96lOaihmltclHMckkRFfjrXKwTtk3pE3F9iv8++RA1+//QjZdmZlSAaT6JgX+on NZ8MGCB9tAKr/DdTASZrMUIf3h816l8+rJpgPFBBSVFhtbXnSzww9TG5oTPwt6RqsT82 MZYQ== X-Gm-Message-State: APjAAAVVfM+glwzhM0lMuZ5FC6W7+M+F2SMugO7tOkba6ukNQa0vE2wz 8sPHiBeZnCqy4C3xsdB16ageHMVmyT3EvQ== X-Google-Smtp-Source: APXvYqy7UGBxPR3bN0ghKd4moOFxTKMewpG7SIM0WQKpISRfYbweztuAv/+2lVOhQz7P1togykEfHQ== X-Received: by 2002:a17:902:aa04:: with SMTP id be4mr14811131plb.41.1579749445921; Wed, 22 Jan 2020 19:17:25 -0800 (PST) Received: from [192.168.2.111] (113x32x180x194.ap113.ftth.ucom.ne.jp. [113.32.180.194]) by smtp.gmail.com with ESMTPSA id h3sm348132pfr.15.2020.01.22.19.17.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jan 2020 19:17:24 -0800 (PST) Subject: Re: Allow to_date() and to_timestamp() to accept localized names To: Tom Lane , =?UTF-8?Q?Juan_Jos=c3=a9_Santamar=c3=ada_Flecha?= Cc: Tomas Vondra , Alvaro Herrera , PostgreSQL Hackers References: <20190925195745.GA21894@alvherre.pgsql> <20200111160602.4wwvyl7lo3oxoewf@development> <31691.1579648824@sss.pgh.pa.us> <29432.1579731087@sss.pgh.pa.us> From: Arthur Zakirov Message-ID: Date: Thu, 23 Jan 2020 12:17:22 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <29432.1579731087@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------F6655A3B03F7D9891EBAC015" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------F6655A3B03F7D9891EBAC015 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2020/01/23 7:11, Tom Lane wrote: > Closer examination shows that the "max" argument is pretty bogus as > well. It doesn't do anything except confuse the reader, because there > are no cases where the value passed is less than the maximum array entry > length, so it never acts to change seq_search's behavior. So we should > just drop that behavior from seq_search, too, and redefine "max" as > having no purpose except to specify how much of the string to show in > error messages. There's still a question of what that should be for > non-English cases, but at least we now have a clear idea of what we > need the value to do. Shouldn't we just show all remaining string instead of truncating it? For example I get the following output: =# select to_timestamp('3 ЯНВАРЯ 1999', 'DD MONTH YYYY'); ERROR: invalid value "ЯНВА" for "MONTH" DETAIL: The given value did not match any of the allowed values for this field. This behavior is reproduced without the patch though (on Postgres 12). And the English case might confuse too I think: =# select to_date('3 JANUZRY 1999', 'DD MONTH YYYY'); ERROR: invalid value "JANUZRY 1" for "MONTH" DETAIL: The given value did not match any of the allowed values for this field. Users might think what means "1" in "JANUZRY 1" string. I attached the draft patch, which shows all remaining string. So the query above will show the following: =# select to_timestamp('3 ЯНВАРЯ 1999', 'DD MONTH YYYY'); ERROR: invalid value "ЯНВАРЯ 1999" for "MONTH" DETAIL: The remaining value did not match any of the allowed values for this field. > The 0001 patch attached cleans up all the above complaints. I felt > that given the business about scribbling on strings we shouldn't, > it would also be wise to const-ify the string pointers if possible. > That seems not too painful, per 0002 attached. +1 on the patch. -- Arthur --------------F6655A3B03F7D9891EBAC015 Content-Type: text/plain; charset=UTF-8; name="0003-formatting-show-remaining.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="0003-formatting-show-remaining.patch" ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL3V0aWxzL2FkdC9mb3JtYXR0aW5nLmMgYi9zcmMv YmFja2VuZC91dGlscy9hZHQvZm9ybWF0dGluZy5jCmluZGV4IGVmMjFiN2U0MjYuLjYzZTc3 M2M0YzEgMTAwNjQ0Ci0tLSBhL3NyYy9iYWNrZW5kL3V0aWxzL2FkdC9mb3JtYXR0aW5nLmMK KysrIGIvc3JjL2JhY2tlbmQvdXRpbHMvYWR0L2Zvcm1hdHRpbmcuYwpAQCAtMjUzOSwxNyAr MjUzOSwxMSBAQCBmcm9tX2NoYXJfc2VxX3NlYXJjaChpbnQgKmRlc3QsIGNvbnN0IGNoYXIg KipzcmMsIGNvbnN0IGNoYXIgKmNvbnN0ICphcnJheSwKIAogCWlmIChsZW4gPD0gMCkKIAl7 Ci0JCWNoYXIJCWNvcHlbRENIX01BWF9JVEVNX1NJWiArIDFdOwotCi0JCS8qIFVzZSBtdWx0 aWJ5dGUtYXdhcmUgdHJ1bmNhdGlvbiB0byBhdm9pZCBnZW5lcmF0aW5nIGEgYm9ndXMgc3Ry aW5nICovCi0JCW1heCA9IHBnX21iY2xpcGxlbigqc3JjLCBzdHJsZW4oKnNyYyksIG1heCk7 Ci0JCXN0cmxjcHkoY29weSwgKnNyYywgbWF4ICsgMSk7Ci0KIAkJUkVUVVJOX0VSUk9SKGVy ZXBvcnQoRVJST1IsCiAJCQkJCQkJIChlcnJjb2RlKEVSUkNPREVfSU5WQUxJRF9E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