Re: ParseDateTime in src/backend/utils/adt/datetime.c

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Vladimir Svedov <vodevsh(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: ParseDateTime in src/backend/utils/adt/datetime.c
Date: 2018-05-25 00:24:23
Message-ID: 20180525002423.GA2347@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, May 3, 2018 at 12:21:45PM +0100, Vladimir Svedov wrote:
> Hi guys,
> https://stackoverflow.com/questions/50153122/
> how-come-this-postgres-query-is-working
> Above guys are surprised by "ignore other punctuation but use as delimiter"
> part.
> Do you think this should be mentioned in docs?
> E.g. https://www.postgresql.org/docs/current/static/functions-formatting.html
> docs have very thorough explanation on what is skipped and what parsed.
>
> I believe at least interval '1^minute' equality to interval '1 minute' or other
> short comment would make it clear.
>
> Sorry if Iwrote to a wrong list. Maybe I should write to 
> pgsql-docs(at)lists(dot)postgresql(dot)org instead? please point me If I should.

Hmm, that's interesting:

SELECT interval '1^minute';
interval
----------
00:01:00

to_number() was just changed in Postgres 11 to properly ignore
puntuation:

Prevent to_number() from consuming characters when the template
separator does not match (Oliver Ford)

Specifically, SELECT to_number('1234', '9,999') used to return 134.
It will now return 1234. L and TH now only consume characters
that are not digits, positive/negative signs, decimal points,
and commas.

so I think we are consistent in ignoring invalid input characters so I
would we would change it.

I am not sure adding documentation would really help much.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2018-05-25 01:00:25 add default parallel query to v10 release notes? (Re: [PERFORM] performance drop after upgrade (9.6 > 10))
Previous Message Mike Palmiotto 2018-05-24 23:10:23 Re: contrib/sepgsql fails on Fedora 28