Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZG9X-0005jA-Jh for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Aug 2016 11:33:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bZG9W-0002lv-TK for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Aug 2016 11:33:58 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bZG9U-0002kc-5l for pgsql-hackers@postgresql.org; Mon, 15 Aug 2016 11:33:56 +0000 Received: from palladium.wars-nicht.de ([89.238.64.91] helo=polonium.wars-nicht.de) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bZG9L-0000z1-3K for pgsql-hackers@postgresql.org; Mon, 15 Aug 2016 11:33:55 +0000 Received: from localhost (localhost [127.0.0.1]) by polonium.wars-nicht.de (Postfix) with ESMTP id A17F5114037; Mon, 15 Aug 2016 13:33:45 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at polonium X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9] autolearn=ham autolearn_force=no Received: from polonium.wars-nicht.de ([127.0.0.1]) by localhost (polonium.wars-nicht.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CN_t8Jko7ySG; Mon, 15 Aug 2016 13:33:44 +0200 (CEST) Received: from diamond.wars-nicht.de (unknown [212.86.42.85]) by polonium.wars-nicht.de (Postfix) with ESMTPSA id 2A1B3114035; Mon, 15 Aug 2016 13:33:44 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by diamond.wars-nicht.de (Postfix) with ESMTP id 80A2D1BE0B29; Mon, 15 Aug 2016 13:33:43 +0200 (CEST) Subject: Re: to_date_valid() To: Artur Zakirov , "Joshua D. Drake" , Peter Eisentraut , Albe Laurenz , 'Andreas Karlsson *EXTERN*' , Pavel Stehule References: <57786490.9010201@wars-nicht.de> <5778EA94.1020706@wars-nicht.de> <2bc6bcef-cada-1ac7-f9a2-2f6128ca4c3c@proxel.se> <579823DF.3080903@commandprompt.com> <95738e12-6ed6-daf5-9dcf-6336072e6b15@postgrespro.ru> Cc: Jaime Casanova , Euler Taveira , Pg Hackers From: Andreas 'ads' Scherbaum Message-ID: <81ed5480-9bca-361b-9aa0-cbafc2ec2f63@wars-nicht.de> Date: Mon, 15 Aug 2016 13:33:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <95738e12-6ed6-daf5-9dcf-6336072e6b15@postgrespro.ru> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 15.08.2016 10:24, Artur Zakirov wrote: > On 14.08.2016 01:52, Andreas 'ads' Scherbaum wrote: >> >> Attached is a patch to "do the right thing". The verification is in >> "to_date()" now, the extra function is removed. Regression tests are >> updated - two or three of them returned a wrong date before, and still >> passed. They fail now. Documentation is also updated. >> >> >> Regards, >> > > Is it right and "true" way to validate date by extra transforming and > comparison? > > Maybe validate date by using ValidateDate(). Attached sample patch. This does not solve the problem at hand, and let's wrong dates/formats slip through: ./buildclient.py -v -c demo-config-pg.yaml --run-configure --run-make --run-install --no-clean-at-all --patch 'https://www.postgresql.org/message-id/95738e12-6ed6-daf5-9dcf-6336072e6b15%40postgrespro.ru' postgres=# SELECT to_date('2011 12 18', 'YYYY MM DD'); to_date ------------ 2011-12-08 (1 row) That is from the regression tests, and obviously handles the date transformation wrong. My attempt catches this, because I compare the date with the input date, and do not rely on a valid date only. -- Andreas 'ads' Scherbaum German PostgreSQL User Group European PostgreSQL User Group - Board of Directors Volunteer Regional Contact, Germany - PostgreSQL Project -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers