Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZGKY-0006Ty-Gj for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Aug 2016 11:45:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bZGKX-0005lj-H3 for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Aug 2016 11:45:21 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bZGKW-0005l6-DP for pgsql-hackers@postgresql.org; Mon, 15 Aug 2016 11:45:20 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZGKF-0005Uj-OP for pgsql-hackers@postgresql.org; Mon, 15 Aug 2016 11:45:19 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id D693721C2D44; Mon, 15 Aug 2016 14:45:02 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from mail.postgrespro.ru ([127.0.0.1]) by localhost (mail.postgrespro.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7qCs8mZU8vyX; Mon, 15 Aug 2016 14:45:02 +0300 (MSK) Received: from [192.168.27.153] (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id AFF7921C2D38; Mon, 15 Aug 2016 14:45:02 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1471261502; bh=elfq882W5lF028MuNBKbuDGFwDHSlvbqNGOedS1Eik8=; h=Subject:To:References:Cc:From:Date:In-Reply-To; b=COWmsKB96DZTqfAC41+1bMoFSrOuUe4dMbTfdOlVMvG7YiP5kBNfXnr+cidsvS5S6 u4XDi3MT4Ba8p1Qo9NALYuqKnhUg8+i5rBQd/5ptDHTRJkmn1oyFJa7rpRFQahthKV tHI/fCWZweMTaOjV6xhlYGgVMGja5+ZXm8OKtyWs= Subject: Re: to_date_valid() To: Andreas 'ads' Scherbaum , "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> <81ed5480-9bca-361b-9aa0-cbafc2ec2f63@wars-nicht.de> Cc: Jaime Casanova , Euler Taveira , Pg Hackers From: Artur Zakirov Message-ID: <198c569d-4bd0-7ddb-05c7-113845aec37b@postgrespro.ru> Date: Mon, 15 Aug 2016 14:44:19 +0300 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: <81ed5480-9bca-361b-9aa0-cbafc2ec2f63@wars-nicht.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.5 (--) 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 14:33, Andreas 'ads' Scherbaum wrote: >> 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. I suppose that your sample query is an another issue, not date validate task. I sent the patch to the thread https://www.postgresql.org/message-id/b2a39359-3282-b402-f4a3-057aae500ee7@postgrespro.ru . It fixes formatting issues. I thought that it is better to distinguish this issues to: - validation of input date/timestmap string and input format string - result date/timestamp validation -- Artur Zakirov Postgres Professional: http://www.postgrespro.com Russian Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers