Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bK6Z6-0000Sg-Hz for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Jul 2016 16:17:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bK6Z6-0003aa-4l for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Jul 2016 16:17:44 +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 1bK6Z5-0003YL-72 for pgsql-hackers@postgresql.org; Mon, 04 Jul 2016 16:17:43 +0000 Received: from palladium.wars-nicht.de ([89.238.64.91] helo=polonium.wars-nicht.de) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bK6Z2-0002Xj-0U for pgsql-hackers@postgresql.org; Mon, 04 Jul 2016 16:17:42 +0000 Received: from localhost (localhost [127.0.0.1]) by polonium.wars-nicht.de (Postfix) with ESMTP id B1450114037; Mon, 4 Jul 2016 18:17:36 +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 mnP4HkNmelt2; Mon, 4 Jul 2016 18:17:35 +0200 (CEST) Received: from diamond.wars-nicht.de (unknown [213.220.158.64]) by polonium.wars-nicht.de (Postfix) with ESMTPSA id B3497114035; Mon, 4 Jul 2016 18:17:35 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by diamond.wars-nicht.de (Postfix) with ESMTP id 2A18E1BE49C5; Mon, 4 Jul 2016 18:17:35 +0200 (CEST) Subject: Re: to_date_valid() To: Amit Kapila References: <57786490.9010201@wars-nicht.de> Cc: PostgreSQL mailing lists From: Andreas 'ads' Scherbaum Message-ID: <577A8C1E.7080606@wars-nicht.de> Date: Mon, 4 Jul 2016 18:17:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -3.2 (---) 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 04.07.2016 16:33, Amit Kapila wrote: > On Sun, Jul 3, 2016 at 6:34 AM, Andreas 'ads' Scherbaum > wrote: >> >> Hello, >> >> we have customers complaining that to_date() accepts invalid dates, and >> returns a different date instead. This is a known issue: >> >> http://sql-info.de/postgresql/notes/to_date-to_timestamp-gotchas.html >> >> On the other hand this leads to wrong dates when loading dates into the >> database, because the database happily accepts invalid dates and ends up >> writing something completely different into the table. >> >> The attached patch adds a new function "to_date_valid()" which will validate >> the date and return an error if the input and output date do not match. >> Tests included, documentation update as well. >> > > It seems that you are calling many additional function calls > (date_out, timestamp_in, etc.) to validate the date. Won't the > additional function calls make to_date much costlier than its current > implementation? I don't know if there is a better way, but I think it > is worth to consider, if we can find a cheaper way to detect validity > of date. It certainly is costlier, and I'm open to suggestions how to improve the performance. That is one of the reasons why I considered a separate function, instead of adding this to to_date() and add even more overhead there. > Note - Your patch is small (~13KB) enough that it doesn't need to zipped. It's not about the small size, it's about websites like Gmail which mingle up the linebreaks and then git fails. Ran into this problem on the pgAdminIII list a while ago, ever since I just zip it and avoid the trouble. -- 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