pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Technical Doubts <online.technicaldoubts@gmail.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: to_timestamp error between postgres version 8.3 and 9.2
Date: Sat, 31 Aug 2013 01:47:00 -0400
Message-ID: <14883.1377928020@sss.pgh.pa.us> (raw)
In-Reply-To: <CAJyuQsEP6af-MzxS=utG_4AN9ziHyDEOLSmecTiRt-fD7i+jCg@mail.gmail.com>
References: <CAJyuQsEP6af-MzxS=utG_4AN9ziHyDEOLSmecTiRt-fD7i+jCg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>

Technical Doubts <online.technicaldoubts@gmail.com> writes:
> insert into registers_info (regid,transid,regdate,canceldate) values
> ('reg1',1,to_timestamp('2013-07-24','yyyy-MM-dd
> hh24:mi:ss')::TIMESTAMP,to_timestamp('null','yyyy-MM-dd
> hh24:mi:ss')::TIMESTAMP);

> The above query works fine in Postgres 8.3 version.

> But the same query when executed in postgres 9.2 its throwing below error

> ERROR: invalid value "null" for "yyyy"
> Detail: Value must be an integer.

Yup.  It was never intended that 'null' would be valid input for
to_timestamp, and that's thrown an error since 8.4.  See thread here:
http://www.postgresql.org/message-id/37ed240d0808291839t21e19956mdfbdc80aeb1b3c19@mail.gmail.com

A quick test says that 8.3 and older did this:

regression=# select to_timestamp('null','yyyy-MM-dd hh24:mi:ss');
       to_timestamp        
---------------------------
 0001-01-01 00:00:00-05 BC
(1 row)

which can hardly be considered a sane interpretation of 'null', even
if we wanted to accept that input.

			regards, tom lane


-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



view thread (3+ messages)  latest in thread

Message-ID: <14883.1377928020@sss.pgh.pa.us>
Permalink:  ../14883.1377928020@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/14883.1377928020@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, online.technicaldoubts@gmail.com
  Subject: Re: to_timestamp error between postgres version 8.3 and 9.2
  In-Reply-To: <14883.1377928020@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox