ERROR: invalid input syntax for type timestamp with time zone

From: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org
Cc: Rushabh Lathia <rushabh(dot)lathia(at)enterprisedb(dot)com>
Subject: ERROR: invalid input syntax for type timestamp with time zone
Date: 2013-03-11 06:00:16
Message-ID: CAGPqQf2J=kP_EcDKCiRKa4CPfMv8sSVaszhJXfGkbXuySO4XhQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi All,

Consider the following test:

postgres=# select version();

version
------------------------------------------------------------
-----------------------------------------------------
PostgreSQL 9.3devel on x86_64-unknown-linux-gnu, compiled by gcc (GCC)
4.4.6 20120305 (Red Hat 4.4.6-4), 64-bit
(1 row)

postgres=# create table test ( a timestamptz);
CREATE TABLE
postgres=# insert into test values ( 'Sat Mar 11 23:58:48 1000 IST');
INSERT 0 1
postgres=# select * from test;
a
------------------------------
1000-03-12 03:52:16+05:53:28
(1 row)

postgres=# insert into test values ( 'Sat Mar 11 23:58:48 10000 IST');
ERROR: invalid input syntax for type timestamp with time zone: "Sat Mar 11
23:58:48 10000 IST"
LINE 1: insert into test values ( 'Sat Mar 11 23:58:48 10000 IST');

So, if you see while trying to insert date 'Sat Mar 11 23:58:48 *10000* IST'
, its returns with invalid input syntax. Error coming from the stack
(timestamptz_in() -> DecodeDateTime()).

But when I tried to enter same date with other format then it does work.

postgres=# insert into test values ( '*10000*-03-11 23:58:48');
INSERT 0 1
postgres=# select * from test;
a
-------------------------------
Sat Mar 11 23:58:48 *10000* IST
(1 row)

Looking at the code, it seems like for Postgres,MDY datestyle DecodeDateTime()
doesn't handle date properly if year is greater then 4 digits (greater then
9999). Do you see this as bug or expected output ?

Regards,
Rushabh Lathia
www.EnterpriseDB.com

Browse pgsql-bugs by date

  From Date Subject
Next Message sivakumar.og 2013-03-11 07:01:19 BUG #7927: MEDIAN FUNCTION IN POSTGRE REQUIRED
Previous Message Alvaro Herrera 2013-03-11 01:22:40 Re: New kind of crash?

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2013-03-11 06:48:10 Re: Re: Proposal for Allow postgresql.conf values to be changed via SQL [review]
Previous Message Daniel Farina 2013-03-11 04:53:39 Re: postgres_fdw vs data formatting GUCs (was Re: [v9.3] writable foreign tables)