Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bK6hM-0000pk-8r for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Jul 2016 16:26:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bK6hL-0007X9-B5 for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Jul 2016 16:26:15 +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 1bK6g0-0005yv-DV for pgsql-hackers@postgresql.org; Mon, 04 Jul 2016 16:24:52 +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 1bK6fs-0007pY-4S for pgsql-hackers@postgresql.org; Mon, 04 Jul 2016 16:24:51 +0000 Received: from localhost (localhost [127.0.0.1]) by polonium.wars-nicht.de (Postfix) with ESMTP id 135A8114037; Mon, 4 Jul 2016 18:24:43 +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 WFrOC8qBp0yA; Mon, 4 Jul 2016 18:24:42 +0200 (CEST) Received: from diamond.wars-nicht.de (unknown [213.220.158.64]) by polonium.wars-nicht.de (Postfix) with ESMTPSA id 0C7A6114035; Mon, 4 Jul 2016 18:24:42 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by diamond.wars-nicht.de (Postfix) with ESMTP id DC9091BE4A1B; Mon, 4 Jul 2016 18:24:40 +0200 (CEST) Subject: Re: to_date_valid() To: Pavel Stehule , Craig Ringer References: <57786490.9010201@wars-nicht.de> Cc: Euler Taveira , PostgreSQL mailing lists From: Andreas 'ads' Scherbaum Message-ID: <577A8DC8.2040505@wars-nicht.de> Date: Mon, 4 Jul 2016 18:24:40 +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 05:51, Pavel Stehule wrote: > > > 2016-07-04 5:19 GMT+02:00 Pavel Stehule >: > > > > 2016-07-04 4:25 GMT+02:00 Craig Ringer >: > > On 3 July 2016 at 09:32, Euler Taveira > wrote: > > On 02-07-2016 22 :04, Andreas 'ads' > Scherbaum wrote: > > 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. > > > Why don't you add a third parameter (say, validate = true | > false) > instead of creating another function? The new parameter > could default to > false to not break compatibility. > > > because > > > SELECT to_date('blah', 'pattern', true) > > is less clear to read than > > SELECT to_date_valid('blah', 'pattern') > > and offers no advantage. It's likely faster to use a separate > function too. > > > personally I prefer first variant - this is same function with > stronger check. > > > Currently probably we have not two similar function - one fault > tolerant and second stricter. There is only one example of similar > behave - parse_ident with "strict" option. > > The three parameters are ok still - so I don't see a reason why we have > to implement new function. If you need to emphasize the fact so behave > should be strict, you can use named parameters > > select to_date('blah', 'patter', strict => true) The new function is not "strict", it just adds a validation step: postgres=# select to_date_valid(NULL, NULL); to_date_valid --------------- (1 row) -- 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