Skip site navigation (1) Skip section navigation (2)

Bug in CAST() with time data types

From: Alvaro Herrera <alvherre(at)protecne(dot)cl>
To: <pgsql-bugs(at)postgresql(dot)org>
Subject: Bug in CAST() with time data types
Date: 2000-12-15 13:58:06
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Your name		:	Alvaro Herrera
Your email address	:	alvherre(at)protecne(dot)cl

System Configuration
  Architecture (example: Intel Pentium)  	: AMD Athlon

  Operating System (example: Linux 2.0.26 ELF) 	: Linux 2.2.17

  PostgreSQL version (example: PostgreSQL-7.0):   PostgreSQL-7.0.2

  Compiler used (example:  gcc 2.8.0)		: RPM for Mandrake Linux

Please enter a FULL description of your problem:

When inserting timestamps or interval types whose precision is one full
minute, Postgres substracts one minute from the data and add 60 seconds
(00:01:00 becomes 00:00:60). Later, when reading this data Postgres says
"Bad timestamp external representation '2000-12-14 18:25:60.00-03'" and
refuses to understand it.

I gave a look at the list of fixed bugs for 7.0.3, but it isn't listed.

(sorry, Mandrake hasn't provided upgraded packages yet, and I don't want to
 mess around with the installation).

Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:

rwatch=> CREATE TABLE test (val1 TIMESTAMP, val2 INTERVAL);
rwatch=> INSERT INTO test VALUES (CAST ('2000-12-14 18:25:00.00-03' AS
			TIMESTAMP), CAST ('00:01:00' AS INTERVAL));
INSERT 4400170 1
rwatch=> SELECT * FROM test;
           val1            |   val2
 2000-12-14 18:25:60.00-03 | 00:00:60
	    (1 row)

(cutting and pasting the text from the select above):

rwatch=> INSERT INTO test VALUES (CAST ('2000-12-14 18:25:60.00-03' AS
ERROR:  Bad timestamp external representation '2000-12-14 18:25:60.00-03'

If you know how this problem might be fixed, list the solution below:

Sorry, I don't even know where to look. It is probably a bug in the way
CAST() treats it's arguments, when dealing with time data types.

Alvaro Herrera (<alvherre[(at)]protecne(dot)cl>)


pgsql-bugs by date

Next:From: Alvaro HerreraDate: 2000-12-15 14:29:01
Subject: DON'T APPROVE PREVIOUS Re: Bug in CAST() with time data types
Previous:From: pgsql-bugsDate: 2000-12-15 12:44:47
Subject: Outer joins aren't working with views

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group