Go to file
Bruce Momjian 46be0c18f1 > 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.

Fabien Coelho
2004-08-20 03:45:14 +00:00
config Fix agressive collection of thread flags. 2004-08-17 15:19:09 +00:00
contrib dbsize modification to support tablespaces 2004-08-12 19:18:05 +00:00
doc Add: 2004-08-20 03:06:00 +00:00
src > After all that about numbering centuries and millenia correctly, 2004-08-20 03:45:14 +00:00
aclocal.m4 Add new auto-detection of thread flags. 2004-04-23 18:15:55 +00:00
configure Fix agressive collection of thread flags. 2004-08-17 15:19:09 +00:00
configure.in tag her configure 8.0.0beta1 ... 2004-08-08 23:27:11 +00:00
COPYRIGHT Fix some copyright notices that weren't updated. Improve copyright tool 2003-08-04 23:59:41 +00:00
GNUmakefile.in PostgreSQL extension makefile framework ("pgxs"), by Fabien Coelho, with 2004-07-30 12:26:40 +00:00
Makefile Restructure the key include files per recent pghackers discussion: there 2001-02-10 02:31:31 +00:00
README Remove JDBC from the build system and documentation, too. 2004-01-19 21:20:06 +00:00
README.CVS Some further editorializing on README.CVS. 2004-03-28 06:09:08 +00:00

PostgreSQL Database Management System
=====================================
  
This directory contains the source code distribution of the PostgreSQL
database management system.

PostgreSQL is an advanced object-relational database management system
that supports an extended subset of the SQL standard, including
transactions, foreign keys, subqueries, triggers, user-defined types
and functions.  This distribution also contains several language
bindings, including C and Tcl.

The JDBC, ODBC, C++, and Python interfaces have been moved to the PostgreSQL
Projects Web Site at http://gborg.postgresql.org for separate maintenance.
A Perl DBI/DBD driver is available from CPAN.

See the file INSTALL for instructions on how to build and install
PostgreSQL.  That file also lists supported operating systems and
hardware platforms and contains information regarding any other
software packages that are required to build or run the PostgreSQL
system.  Changes between all PostgreSQL releases are recorded in the
file HISTORY.  Copyright and license information can be found in the
file COPYRIGHT.  A comprehensive documentation set is included in this
distribution; it can be read as described in the installation
instructions.

The latest version of this software may be obtained at
ftp://ftp.postgresql.org/pub/.  For more information look at our web
site located at http://www.postgresql.org/.