Timestamp data type problems

Started by Olivier PRENANTover 25 years ago4 messages
#1Olivier PRENANT
ohp@pyrenet.fr

Please help!

I'm having troubles with the timestamp type:
here's a psql output :

Script started on Mon May 29 13:32:08 2000
~ 13:32:08: psql pyrenet
Welcome to psql, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

pyrenet=# select 'today'::date;
?column?
------------
29-05-2000
(1 row)

pyrenet=# select 'today'::timestamp
?column?
-------------------------------------------
Mon 29 May 00:00:00 2000 MET DST(���^A
(1 row)

script done on Mon May 29 13:44:30 2000

As you can see, there's no \0 after TZ.

Checking to code led me to EncodeTimeSpan that does strcpy and strncpy and
never puts a null character.

Could this be a bug?

That's breaking all my scripts because if I add a timespan value to it,
then the backend complains about bad formated external timestamp.

Please help!

This is V7.0 on Unixware 7.0.1 compiled with cc.

--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
Quartier d'Harraud Turrou +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Olivier PRENANT (#1)
Re: Timestamp data type problems

Olivier PRENANT <ohp@pyrenet.fr> writes:

pyrenet=# select 'today'::timestamp
?column?
-------------------------------------------
Mon 29 May 00:00:00 2000 MET DST(���^A
(1 row)

script done on Mon May 29 13:44:30 2000

As you can see, there's no \0 after TZ.

OK, patched for 7.0.1 (I increased MAXTZLEN as well as made the code
more careful about overrun of the allowed length).

regards, tom lane

#3Olivier PRENANT
ohp@pyrenet.fr
In reply to: Tom Lane (#2)
Re: Timestamp data type problems

I made a patch against 7.0. Do you need it?

Actually it's quite simple and only ocurs and datetime.c.

afterline 2156, I added : *(str + 28 + MAXSTZLEN) = '\0';

and after line 2166, I added : *(str + 25 + MAXTZLEN) = '\0';

It works for me !!

Regards,
On Mon, 29 May 2000, Tom Lane wrote:

Olivier PRENANT <ohp@pyrenet.fr> writes:

pyrenet=# select 'today'::timestamp
?column?
-------------------------------------------
Mon 29 May 00:00:00 2000 MET DST(���^A
(1 row)

script done on Mon May 29 13:44:30 2000

As you can see, there's no \0 after TZ.

OK, patched for 7.0.1 (I increased MAXTZLEN as well as made the code
more careful about overrun of the allowed length).

regards, tom lane

--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
Quartier d'Harraud Turrou +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Olivier PRENANT (#3)
Re: Timestamp data type problems

Olivier PRENANT <ohp@pyrenet.fr> writes:

I made a patch against 7.0. Do you need it?
Actually it's quite simple and only ocurs and datetime.c.
afterline 2156, I added : *(str + 28 + MAXSTZLEN) = '\0';
and after line 2166, I added : *(str + 25 + MAXTZLEN) = '\0';
It works for me !!

I used StrNCpy instead, but thanks for confirming that that fixes it
for you.

regards, tom lane