Commit Graph

102 Commits

Author SHA1 Message Date
Bruce Momjian 436a2956d8 Re-run pgindent, fixing a problem where comment lines after a blank
comment line where output as too long, and update typedefs for /lib
directory.  Also fix case where identifiers were used as variable names
in the backend, but as typedefs in ecpg (favor the backend for
indenting).

Backpatch to 8.1.X.
2005-11-22 18:17:34 +00:00
Tom Lane 7218aab7a2 Adjust not-too-sane calculation of DDD value for to_char(interval).
Per gripe from Chris Matheson.
2005-10-20 15:59:46 +00:00
Bruce Momjian 1dc3498251 Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
Bruce Momjian 7be1b3ba74 Add hint for to_char(interval) invalid format specifications. 2005-08-18 13:43:08 +00:00
Bruce Momjian e20261128d Fix to_char(interval) to return proper year and century values.
Fix to_char(interval) to return large year/month/day/hour values that
are larger than possible timestamp values.
Prevent to_char(interval) format specifications that make no sense, like
Month.
Clean up formatting.c code to more logically handle return lengths.
2005-08-18 04:37:08 +00:00
Bruce Momjian 63f850cd4d More formatting.c cleanups. 2005-08-17 22:06:53 +00:00
Bruce Momjian 9cd3fb172d Small cleanup. 2005-08-17 21:54:50 +00:00
Bruce Momjian 420fc28ac5 Adjust to_char/from_char code to use boolean "is_to_char" rather than
integer with flags.
2005-08-17 21:47:55 +00:00
Neil Conway a4c75ece82 Fix a few macro definitions to ensure that unary minus is enclosed in
parentheses. This avoids possible operator precedence problems, and
is consistent with most of the macro definitions in the tree.
2005-07-27 12:44:10 +00:00
Bruce Momjian 3dbbbbf8e9 Andrew pointed out that the current fix didn't handle dates that were
near daylight savings time boudaries.  This handles it properly, e.g.

        test=> select '2005-04-03 04:00:00'::timestamp at time zone
        'America/Los_Angeles';
                timezone
        ------------------------
         2005-04-03 07:00:00-04
        (1 row)
2005-07-23 14:25:34 +00:00
Bruce Momjian a536b2dd80 Add time/date macros for code clarity:
#define DAYS_PER_YEAR   365.25
	#define MONTHS_PER_YEAR 12
	#define DAYS_PER_MONTH  30
	#define HOURS_PER_DAY   24
2005-07-21 03:56:25 +00:00
Bruce Momjian db05f4a7eb Add 'day' field to INTERVAL so 1 day interval can be distinguished from
24 hours. This is very helpful for daylight savings time:

	select '2005-05-03 00:00:00 EST'::timestamp with time zone + '24 hours';
	      ?column?
	----------------------
	2005-05-04 01:00:00-04

	select '2005-05-03 00:00:00 EST'::timestamp with time zone + '1 day';
	      ?column?
	----------------------
	2005-05-04 01:00:00-04

Michael Glaesemann
2005-07-20 16:42:32 +00:00
Neil Conway 76aa6d29cf Code cleanup: remove 3 duplicate static function declarations. 2005-06-24 01:10:11 +00:00
Neil Conway 06ecacded6 More trivial dead code removal: in int_to_roman(), checking for "num == -1"
is redundant after a check has already been made for "num < 0". The "set"
variable can also be removed, as it is now no longer used. Per checking
with Karel, this is the right fix.

Per Coverity static analysis performed by EnterpriseDB.
2005-06-22 01:43:05 +00:00
Bruce Momjian 0851a6fbc7 This patch makes it possible to use the full set of timezones when doing
"AT TIME ZONE", and not just the shorlist previously available. For
example:

SELECT CURRENT_TIMESTAMP AT TIME ZONE 'Europe/London';

works fine now. It will also obey whatever DST rules were in effect at
just that date, which the previous implementation did not.

It also supports the AT TIME ZONE on the timetz datatype. The whole
handling of DST is a bit bogus there, so I chose to make it use whatever
DST rules are in effect at the time of executig the query. not sure if
anybody is actuallyi *using* timetz though, it seems pretty
unpredictable just because of this...

Magnus Hagander
2005-06-15 00:34:11 +00:00
Bruce Momjian b492c3accc Add parentheses to macros when args are used in computations. Without
them, the executation behavior could be unexpected.
2005-05-25 21:40:43 +00:00
Tom Lane fccde77ecb Prevent to_char(interval) from dumping core on month-related formats
when a zero-month interval is given.  Per discussion with Karel.
Also, some desultory const-labeling of constant tables.  More could be
done along that line.
2005-03-26 00:41:31 +00:00
Tom Lane 6e26c00297 Fix to_date to behave reasonably when CC and YY fields are both used.
Karel Zak
2005-03-25 16:08:40 +00:00
Tom Lane cbd8913245 Remove unportable assumption that it's okay to use the target buffer
of an sprintf() as a source string.  Demonstrably does not work with
recent gcc and/or glibc on some platforms.
2005-01-13 01:40:13 +00:00
Bruce Momjian 2daed8c5b3 Update copyrights that were missed. 2005-01-01 05:43:09 +00:00
Tom Lane 83fea34b5b Fix unportable isdigit() call --- must cast arg to unsigned char. 2004-11-20 02:09:47 +00:00
Bruce Momjian 9c3d654a16 Update comment to point to proper file. 2004-11-01 14:33:10 +00:00
Tom Lane 319902dc8c Fix to_number for the case of a trailing S.
Karel Zak
2004-10-28 18:55:08 +00:00
Neil Conway 7069dbcc31 More minor cosmetic improvements:
- remove another senseless "extern" keyword that was applied to a
function definition
- change a foo more function signatures from "some_type foo()" to
"some_type foo(void)"
- rewrite another K&R style function definition
- make the type of the "action" function pointer in the KeyWord struct
in src/backend/utils/adt/formatting.c more precise
2004-10-13 01:25:13 +00:00
Bruce Momjian 15d3f9f6b7 Another pgindent run with lib typedefs added. 2004-08-30 02:54:42 +00:00
Bruce Momjian b6b71b85bc Pgindent run for 8.0. 2004-08-29 05:07:03 +00:00
Bruce Momjian da9a8649d8 Update copyright to 2004. 2004-08-29 04:13:13 +00:00
Tom Lane 63bd0db121 Integrate src/timezone library for all platforms. There is more we can
and should do now that we control our own destiny for timezone handling,
but this commit gets the bulk of the picayune diffs in place.
Magnus Hagander and Tom Lane.
2004-05-21 05:08:06 +00:00
Tom Lane 0bd61548ab Solve the 'Turkish problem' with undesirable locale behavior for case
conversion of basic ASCII letters.  Remove all uses of strcasecmp and
strncasecmp in favor of new functions pg_strcasecmp and pg_strncasecmp;
remove most but not all direct uses of toupper and tolower in favor of
pg_toupper and pg_tolower.  These functions use the same notions of
case folding already developed for identifier case conversion.  I left
the straight locale-based folding in place for situations where we are
just manipulating user data and not trying to match it to built-in
strings --- for example, the SQL upper() function is still locale
dependent.  Perhaps this will prove not to be what's wanted, but at
the moment we can initdb and pass regression tests in Turkish locale.
2004-05-07 00:24:59 +00:00
Bruce Momjian fd071bd478 Fix to_char for 1 BC. Previously it returned 1 AD.
Fix to_char(year) for BC dates.  Previously it returned one less than
the current year.

Add documentation mentioning that there is no 0 AD.
2004-03-30 15:53:18 +00:00
Neil Conway 192ad63bd7 More janitorial work: remove the explicit casting of NULL literals to a
pointer type when it is not necessary to do so.

For future reference, casting NULL to a pointer type is only necessary
when (a) invoking a function AND either (b) the function has no prototype
OR (c) the function is a varargs function.
2004-01-07 18:56:30 +00:00
Bruce Momjian 1c757c49fa > > I have no idea if this in Oracle or not. But it's something I
> > needed, and other people in the past asked about it too.
>
> It is in Oracle, but you aren't exactly on the spot.  It should be
>
> IYYY - 4 digits  ('2003')
> IYY  - 3 digits  ('003')
> IY   - 2 digits  ('03')
> I    - 1 digit   ('3')

Here is an updated patch that does that.

Kurt Roeckx
2003-12-25 03:36:24 +00:00
PostgreSQL Daemon 969685ad44 $Header: -> $PostgreSQL Changes ... 2003-11-29 19:52:15 +00:00
Peter Eisentraut 7438af96fa More message editing, some suggested by Alvaro Herrera 2003-09-29 00:05:25 +00:00
Tom Lane 5840b89373 Repair problems with to_char() overrunning its input string.
From Karel Zak.
2003-09-03 14:59:41 +00:00
Tom Lane a17f2d76cc Refactor code so that to_date() does not call to_timestamp() and then
perform a timestamp-to-date coercion.  Instead both routines share a
subroutine that delivers the parsing result as a struct tm.  This avoids
problems with timezone dependency of to_date's result, and should be
at least marginally faster too.
2003-08-25 16:13:27 +00:00
Tom Lane 2f9c859ea1 Fix some copyright notices that weren't updated. Improve copyright tool
so it won't miss 'em again.
2003-08-04 23:59:41 +00:00
Bruce Momjian 089003fb46 pgindent run. 2003-08-04 00:43:34 +00:00
Tom Lane b6a1d25b0a Error message editing in utils/adt. Again thanks to Joe Conway for doing
the bulk of the heavy lifting ...
2003-07-27 04:53:12 +00:00
Tom Lane d6f1aa9760 Fix platform-dependent failure introduced by recent to_char changes
(ye good olde uninitialized-local-variable).
2003-04-02 02:33:52 +00:00
Bruce Momjian 6f2d02d306 Fix syntax error in to_char fixes --- was defining variable in main code
block, ala C++.
2003-03-27 17:10:55 +00:00
Bruce Momjian 7a3e7b64ac to_char fixes, Karel Zak 2003-03-27 16:35:31 +00:00
Bruce Momjian aaf11b931f Back out to_char fixes until regression tests are fixed. 2003-03-22 02:12:24 +00:00
Bruce Momjian 94701fb24b Peter found bug in the to_char() routine for PL/MI options. This
patch fix it -- but this patch doesn't contains tests or docs fixes. I
 will send it later.

 Fixed outputs:

select  to_char(x, '9999.999')  as x,
        to_char(x, 'S9999.999') as s,
        to_char(x, 'SG9999.999') as sg,
        to_char(x, 'MI9999.999') as mi,
        to_char(x, 'PL9999.999') as pl,
        to_char(x, 'PLMI9999.999') as plmi,
        to_char(x, '9999.999SG') as sg2,
        to_char(x, '9999.999PL') as pl2,
        to_char(x, '9999.999MI') as mi2 from num;

Karel Zak
2003-03-20 05:19:26 +00:00
Tom Lane e4704001ea This patch fixes a bunch of spelling mistakes in comments throughout the
PostgreSQL source code.

Neil Conway
2003-03-10 22:28:22 +00:00
Bruce Momjian bea4792125 This patch removes a bunch of superfluous #include directives: if
postgres.h or c.h includes a system header (such as stdio.h or
stdlib.h), there's no need to specifically include it in any of the .c
files in the backend.

Neil Conway
2002-11-08 20:23:57 +00:00
Bruce Momjian c27d95e25d The patch fix bug described in TODO:
* to_char(0,'FM999.99') returns a period, to_char(1,'FM999.99') does not

Karel Zak
2002-09-20 03:57:09 +00:00
Bruce Momjian 192b0c94f2 This patch cleans up some of the code in src/util/adt/formatting.c,
fixes a few minor bugs (typos, potential buffer overruns, etc.), and
fixes some spelling/grammar mistakes.

Neil Conway
2002-09-20 03:54:57 +00:00
Bruce Momjian e50f52a074 pgindent run. 2002-09-04 20:31:48 +00:00
Thomas G. Lockhart 547df0cc85 Support alternate storage scheme of 64-bit integer for date/time types.
Use "--enable-integer-datetimes" in configuration to use this rather
 than the original float8 storage. I would recommend the integer-based
 storage for any platform on which it is available. We perhaps should
 make this the default for the production release.
Change timezone(timestamptz) results to return timestamp rather than
 a character string. Formerly, we didn't have a way to represent
 timestamps with an explicit time zone other than freezing the info into
 a string. Now, we can reasonably omit the explicit time zone from the
 result and return a timestamp with values appropriate for the specified
 time zone. Much cleaner, and if you need the time zone in the result
 you can put it into a character string pretty easily anyway.
Allow fractional seconds in date/time types even for dates prior to 1BC.
Limit timestamp data types to 6 decimal places of precision. Just right
 for a micro-second storage of int8 date/time types, and reduces the
 number of places ad-hoc rounding was occuring for the float8-based types.
Use lookup tables for precision/rounding calculations for timestamp and
 interval types.  Formerly used pow() to calculate the desired value but
 with a more limited range there is no reason to not type in a lookup
 table. Should be *much* better performance, though formerly there were
 some optimizations to help minimize the number of times pow() was called.
Define a HAVE_INT64_TIMESTAMP variable. Based on the configure option
 "--enable-integer-datetimes" and the existing internal INT64_IS_BUSTED.
Add explicit date/interval operators and functions for addition and
 subtraction. Formerly relied on implicit type promotion from date to
 timestamp with time zone.
Change timezone conversion functions for the timetz type from "timetz()"
 to "timezone()". This is consistant with other time zone coersion
 functions for other types.
Bump the catalog version to 200204201.
Fix up regression tests to reflect changes in fractional seconds
 representation for date/times in BC eras.
All regression tests pass on my Linux box.
2002-04-21 19:52:18 +00:00