Re: [HACKERS] Problem with copying abstimes - Mailing list pgsql-hackers

From Thomas G. Lockhart
Subject Re: [HACKERS] Problem with copying abstimes
Date
Msg-id 65221c592261cc989bb3aadd0143fbd1
Whole thread Raw
In response to [HACKERS] Problem with copying abstimes  (Ronald Baljeu <rjb@xs4all.nl>)
List pgsql-hackers
Ronald Baljeu wrote:
> ... I think there is a small problem with copying abstimes in v6.1.
> I noticed an increment of 1 hour to abstime fields when
> copying tables back into the database using the 'copy from'
> command.
<snip>
(table has one abstime field)
> > --------------------------------
> > Fri Apr 04 18:41:48 1997 MET DST
(copy out and back in using the copy command)
> > --------------------------------
> > Fri Apr 04 19:41:48 1997 MET DST
>               ^
> The time 18:41:48 has become 19:41:48. I just upgraded to v6.1 and this
> has never happened before.
> Platform is Linux 2.0.29. Compiler is gcc 2.7.2.1. C-library: 5.4.33
> Any ideas?

Yup. There is probably confusion in Postgres with your timezone
character strings. I have a similar installation environment, but my
US/Pacific timezone (PST8PDT) does not exhibit the behavior you see.

Please tell me your exact timezone environment and I can run some tests:
1) What is your default timezone (the character strings and the long
name)?
2) What does the link /etc/localtime point to?
3) Is there *really* a space between "MET" and "DST"? (sheesh)

In looking at the Postgres code, it appears that if there is a space
between "MET" and "DST" then that is the source of your trouble. "MET"
is Middle Europe (Standard) Time, and "DST" is ignored as a "noop" (this
behavior is inherited from previous versions of Postgres). If your
timezone is set to "MEST" or to "METDST" with no space you might get the
behavior you want.

            - Tom

> > postgres=> create table test(modtime abstime);
> > postgres=> insert into test values('Fri Apr 04 18:41:48 1997');
> > postgres=> select * from test;
> > modtime
> > --------------------------------
> > Fri Apr 04 18:41:48 1997 MET DST
> > (1 row)
> >
> > postgres=> copy test to '/tmp/test';
> > COPY
> > postgres=> ^Z
> > [1]+  Stopped                 psql
> > % cat /tmp/test
> > Fri Apr 04 18:41:48 1997 MET DST
>
> Ok. Now watch this:
>
> > % fg
> > psql
> >
> > postgres=> delete from test;
> > DELETE
> > postgres=> copy test from '/tmp/test';
> > COPY
> > postgres=> select * from test;
> > modtime
> > --------------------------------
> > Fri Apr 04 19:41:48 1997 MET DST
>               ^
> > (1 row)
>
> The time 18:41:48 has become 19:41:48. I just upgraded to v6.1 and this
> has never happened before.

------------------------------

pgsql-hackers by date:

Previous
From: Andrew Martin
Date:
Subject: [HACKERS] Array bug is still there....
Next
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] Array bug is still there....