Re: [PATCHES] sound extract century/millennium date_part

2004-04-10 Thread Bruce Momjian

Patch applied.  Thanks.

---


Fabien COELHO wrote:
 
 Dear patchers,
 
 Please find a small patch to fix the brain damage century and
 millennium date part implementation in postgresql, both in the code and
 the documentation, so that it conforms to the official definition. If you
 do not agree with the official definition, please send your complaint to
 [EMAIL PROTECTED]. I'm not responsible for them;-)
 
 With the previous version, the centuries and millenniums had a wrong
 number and started the wrong year. Moreover century number 0, which does
 not exist in reality, lasted 200 years. Also, millennium number 0 lasted
 2000 years.
 
 If you want postgresql to have it's own definition of century and
 millennium that does not conform to the one of the society, just give
 them another name. I would suggest pgCENTURY and pgMILLENNIUM;-)
 
 IMO, if someone may use the options, it means that postgresql is used for
 historical data, so it make sense to have an historical definition. Also,
 I just want to divide the year by 100 or 1000, I can do that quite easily.
 
 Have a nice day,
 
 -- 
 Fabien Coelho - [EMAIL PROTECTED]

Content-Description: 

[ Attachment, skipping... ]

 
 ---(end of broadcast)---
 TIP 3: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (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 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


[PATCHES] sound extract century/millennium date_part

2004-04-05 Thread Fabien COELHO

Dear patchers,

Please find a small patch to fix the brain damage century and
millennium date part implementation in postgresql, both in the code and
the documentation, so that it conforms to the official definition. If you
do not agree with the official definition, please send your complaint to
[EMAIL PROTECTED]. I'm not responsible for them;-)

With the previous version, the centuries and millenniums had a wrong
number and started the wrong year. Moreover century number 0, which does
not exist in reality, lasted 200 years. Also, millennium number 0 lasted
2000 years.

If you want postgresql to have it's own definition of century and
millennium that does not conform to the one of the society, just give
them another name. I would suggest pgCENTURY and pgMILLENNIUM;-)

IMO, if someone may use the options, it means that postgresql is used for
historical data, so it make sense to have an historical definition. Also,
I just want to divide the year by 100 or 1000, I can do that quite easily.

Have a nice day,

-- 
Fabien Coelho - [EMAIL PROTECTED]*** ./doc/src/sgml/func.sgml.orig   Wed Mar 31 08:58:31 2004
--- ./doc/src/sgml/func.sgmlSun Apr  4 10:23:00 2004
***
*** 4948,4965 
termliteralcentury/literal/term
listitem
 para
! The year field divided by 100
 /para
  
  screen
! SELECT EXTRACT(CENTURY FROM TIMESTAMP '2001-02-16 20:38:40');
  lineannotationResult: /lineannotationcomputeroutput20/computeroutput
  /screen
  
 para
! Note that the result for the century field is simply the year field
! divided by 100, and not the conventional definition which puts most
! years in the 1900's in the twentieth century.
 /para
/listitem
   /varlistentry
--- 4948,4978 
termliteralcentury/literal/term
listitem
 para
! The historical definition of a century.
 /para
  
  screen
! SELECT EXTRACT(CENTURY FROM TIMESTAMP '2000-12-16 12:21:13');
  lineannotationResult: /lineannotationcomputeroutput20/computeroutput
+ SELECT EXTRACT(CENTURY FROM TIMESTAMP '2001-02-16 20:38:40');
+ lineannotationResult: /lineannotationcomputeroutput21/computeroutput
  /screen
  
 para
! An historical century is a period of 100 years.
!   The first century starts at 0001-01-01 00:00:00 AD, although
!   they did not know at the time. This definition applies to all
!   Gregorian calendar countries. There is no number 0 century, 
!   you go from -1 to 1.
! 
!   If you disagree with this, please write your complaint to:
!   Pope, Cathedral Saint-Peter of Roma, Vatican.
!/para
! 
!para
!   Compatibility: if you want the previous postgres version of century,
!   just divide the year by 100. Note that with this definition, 
!   century number 0 lasts 200 years.
 /para
/listitem
   /varlistentry
***
*** 5083,5100 
termliteralmillennium/literal/term
listitem
 para
! The year field divided by 1000
 /para
  
  screen
  SELECT EXTRACT(MILLENNIUM FROM TIMESTAMP '2001-02-16 20:38:40');
! lineannotationResult: /lineannotationcomputeroutput2/computeroutput
  /screen
  
 para
! Note that the result for the millennium field is simply the year field
! divided by 1000, and not the conventional definition which puts
! years in the 1900's in the second millennium.
 /para
/listitem
   /varlistentry
--- 5096,5112 
termliteralmillennium/literal/term
listitem
 para
! The conventional historical millennium.
 /para
  
  screen
  SELECT EXTRACT(MILLENNIUM FROM TIMESTAMP '2001-02-16 20:38:40');
! lineannotationResult: /lineannotationcomputeroutput3/computeroutput
  /screen
  
 para
! Years in the 1900's are in the second millennium.
!   The third millennium starts January 1, 2001.
 /para
/listitem
   /varlistentry
*** ./src/backend/utils/adt/timestamp.c.origWed Mar 31 08:58:40 2004
--- ./src/backend/utils/adt/timestamp.c Sun Apr  4 10:45:59 2004
***
*** 3273,3283 
break;
  
case DTK_CENTURY:
!   result = (tm-tm_year / 100);
break;
  
case DTK_MILLENNIUM:
!   result = (tm-tm_year / 1000);
break;
  
case DTK_JULIAN:
--- 3273,3295 
break;
  
case DTK_CENTURY:
!   /* centuries AD, c0: year in [ (c-1)*100+1 : 
c*100   ]
!* centuries BC, c0: year in [ c*100   : 
(c+1)*100-1 ]
!* there is no number 0 century.
!*/
!