dbTalk Databases Forums  

Re: [PATCHES] [BUGS] Bug: century/millenium still broken

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [PATCHES] [BUGS] Bug: century/millenium still broken in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bruce Momjian
 
Posts: n/a

Default Re: [PATCHES] [BUGS] Bug: century/millenium still broken - 08-16-2004 , 11:01 AM







Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

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


Fabien COELHO wrote:
Quote:
Dear Tom,

After all that about numbering centuries and millenia correctly,
why does CVS tip still give me

regression=# select extract(century from now());
date_part
-----------
20
(1 row)
[ ... looks in code ... ]

Apparently it's because you fixed only timestamp_part, and not
timestamptz_part. I'm not too sure about what timestamp_trunc or
timestamptz_trunc should do, but they may be wrong as well.

Sigh... as usual, what is not tested does not work:-(


Could we have a more complete patch?

Please find a submission attached. I hope it really fixes all decade,
century and millenium issues for extract and *_trunc functions on interval
and other timestamp types. If someone could check that the results
are reasonnable, it would be great.

I indeed overlooked the fact that there were two functions. The patch
fixes the code so that both variants agree.

I added comments to interval extractions, because it relies on the C
division to have a negative remainder: -7/10 = 0 and remains -7.

As for *_trunc functions, I have chosen to put the first year of the
century or millennium: -100, 1, 101... 1001 2001 etc. Indeed, I don't
think it would make sense to put 2000 (last year of the 2nd millennium)
for rounding all years of the third millenium.

I also fixed the code so that all decades last 10 years and decade 199
means the 1990's.

I have added some tests that are relevant to deal with tricky cases. The
formula may be simplified, but all these cases must pass. Please keep
them.

Have a nice day,

--
Fabien Coelho - coelho (AT) cri (DOT) ensmp.fr
Content-Description:

[ Attachment, skipping... ]

Quote:
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
--
Bruce Momjian | http://candle.pha.pa.us
pgman (AT) candle (DOT) pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
  #2  
Old   
Bruce Momjian
 
Posts: n/a

Default Re: [PATCHES] [BUGS] Bug: century/millenium still broken - 08-19-2004 , 10:46 PM







Patch applied. Thanks.

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


Fabien COELHO wrote:
Quote:
Dear Tom,

After all that about numbering centuries and millenia correctly,
why does CVS tip still give me

regression=# select extract(century from now());
date_part
-----------
20
(1 row)
[ ... looks in code ... ]

Apparently it's because you fixed only timestamp_part, and not
timestamptz_part. I'm not too sure about what timestamp_trunc or
timestamptz_trunc should do, but they may be wrong as well.

Sigh... as usual, what is not tested does not work:-(


Could we have a more complete patch?

Please find a submission attached. I hope it really fixes all decade,
century and millenium issues for extract and *_trunc functions on interval
and other timestamp types. If someone could check that the results
are reasonnable, it would be great.

I indeed overlooked the fact that there were two functions. The patch
fixes the code so that both variants agree.

I added comments to interval extractions, because it relies on the C
division to have a negative remainder: -7/10 = 0 and remains -7.

As for *_trunc functions, I have chosen to put the first year of the
century or millennium: -100, 1, 101... 1001 2001 etc. Indeed, I don't
think it would make sense to put 2000 (last year of the 2nd millennium)
for rounding all years of the third millenium.

I also fixed the code so that all decades last 10 years and decade 199
means the 1990's.

I have added some tests that are relevant to deal with tricky cases. The
formula may be simplified, but all these cases must pass. Please keep
them.

Have a nice day,

--
Fabien Coelho - coelho (AT) cri (DOT) ensmp.fr
Content-Description:

[ Attachment, skipping... ]

Quote:
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
--
Bruce Momjian | http://candle.pha.pa.us
pgman (AT) candle (DOT) pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.