Lists: | pgsql-hackers |
---|
From: | Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Validation in to_date() |
Date: | 2013-01-12 06:28:15 |
Message-ID: | CAP7QgmkvW6KeogQnNJHno1pyb7ifqQGShGoygN=fxsuv+36hdQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
to_date() doesn't check the date range, which results in unreadable
data like this.
foo=# create table t as select to_date('9999-12-10 BC', 'YYYY-MM-DD
BC')::timestamp;
SELECT 1
foo=# table t;
ERROR: timestamp out of range
Attached is to add IS_VALID_JULIAN() as we do like in date_in(). I
think to_date() should follow it because it is the entrance place to
check sanity.
Thanks,
--
Hitoshi Harada
Attachment | Content-Type | Size |
---|---|---|
to_date_check.patch | application/octet-stream | 614 bytes |
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Validation in to_date() |
Date: | 2013-01-14 20:14:41 |
Message-ID: | 28727.1358194481@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> writes:
> to_date() doesn't check the date range, which results in unreadable
> data like this.
> foo=# create table t as select to_date('9999-12-10 BC', 'YYYY-MM-DD
> BC')::timestamp;
> SELECT 1
> foo=# table t;
> ERROR: timestamp out of range
> Attached is to add IS_VALID_JULIAN() as we do like in date_in(). I
> think to_date() should follow it because it is the entrance place to
> check sanity.
This looks like a good idea, will commit.
regards, tom lane