summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/date.c
AgeCommit message (Collapse)Author
2003-07-17Make EXTRACT(TIMEZONE) and SET/SHOW TIMEZONE follow the SQL conventionTom Lane
for the sign of timezone offsets, ie, positive is east from UTC. These were previously out of step with other operations that accept or show timezones, such as I/O of timestamptz values.
2003-06-16Fix bugs in interval-to-time conversion: HAVE_INT64_TIMESTAMP case did notTom Lane
work at all, and neither case behaved sanely for negative intervals.
2003-05-12Add binary I/O routines for a bunch more datatypes. Still a few to go,Tom Lane
but that was enough tedium for one day. Along the way, move the few support routines for types xid and cid into a more logical place.
2003-04-08Mark TimeScales constants as double to avoid integer overflow in some compilers.Tom Lane
2003-04-04Avoid repeated computation of the constants date2j(1970, 1, 1) andTom Lane
date2j(2000, 1, 1). Should make for some marginal speed improvement in date/time operations.
2003-02-13Prevent timetz2tm() from scribbling on its input in HAVE_INT64_TIMESTAMP case.Tom Lane
2003-01-31Allow a time zone to be specified (and silently ignored) in the inputTom Lane
for type 'time without time zone', as we already did for type 'timestamp without time zone'. This patch was proposed by Tom Lockhart on 7-Nov-02, but he never got around to applying it. Adjust regression tests and documentation to match.
2003-01-29Repair array subscript overrun identified by Yichen Xie. Reduce theTom Lane
value of MAX_TIME_PRECISION in floating-point-timestamp-storage case from 13 to 10, which is as much as time_out is actually willing to print. (The alternative of increasing the number of digits we are willing to print looks risky; we might find ourselves printing roundoff garbage.)
2003-01-22Fix sloppy comment.Tom Lane
2003-01-09Repair inconsistent rounding behavior for timestamp, time, interval,Tom Lane
per gripe from Csaba Nagy. There is still potential for platform-specific behavior for values that are exactly halfway between integers, but at least we now get the expected answer for all other cases.
2002-11-21Fix breakage in new-in-7.3 timetz_zone() function: was giving randomTom Lane
results due to doing arithmetic on uninitialized values. Add some documentation about the AT TIME ZONE construct. Update some other date/time documentation that seemed out of date for 7.3.
2002-09-21Add last-ditch defense against attempts to compile datetime code withTom Lane
-ffast-math.
2002-09-04pgindent run.Bruce Momjian
2002-09-03Eliminate unnecessary dependency on mktime(), and consequent 'Unable toTom Lane
convert date to tm' failures, by using DetermineLocalTimeZone() instead.
2002-08-04Add guard code to protect from buffer overruns on long date/time inputThomas G. Lockhart
strings. Should go back in and look at doing this a bit more elegantly and (hopefully) cheaper. Probably not too bad anyway, but it seems a shame to scan the strings twice: once for length for this buffer overrun protection, and once to parse the line. Remove use of pow() in date/time handling; was already gone from everything *but* the time data types. Define macros for handling typmod manipulation for date/time types. Should be more robust than all of that brute-force inline code. Rename macros for masking and typmod manipulation to put TIMESTAMP_ or INTERVAL_ in front of the macro name, to reduce the possibility of name space collisions.
2002-06-20Update copyright to 2002.Bruce Momjian
2002-06-11Katherine Ward wrote:Jan Wieck
> Changes to avoid collisions with WIN32 & MFC names... > 1. Renamed: > a. PROC => PGPROC > b. GetUserName() => GetUserNameFromId() > c. GetCurrentTime() => GetCurrentDateTime() > d. IGNORE => IGNORE_DTF in include/utils/datetime.h & utils/adt/datetim > > 2. Added _P to some lex/yacc tokens: > CONST, CHAR, DELETE, FLOAT, GROUP, IN, OUT Jan
2002-06-01Fix timestamp to date conversion for the case where timestamp uses a doubleThomas G. Lockhart
precision storage format. Previously applied the same math as used for the 64-bit integer storage format case, which was wrong. Problem introduced recently when the 64-bit storage format was implemented.
2002-04-21Support alternate storage scheme of 64-bit integer for date/time types.Thomas G. Lockhart
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-03-09Code review for improved-hashing patch. Fix some portability issuesTom Lane
(char != unsigned char, Datum != uint32); make use of new hash code in dynahash hash tables and hash joins.
2001-11-21Repair swapped sign for time minus time routine (time_mi_time()).Thomas G. Lockhart
Problem reported by Manuel Sugawara (masm@fciencias.unam.mx).
2001-10-25pgindent run on all C files. Java run to follow. initdb/regressionBruce Momjian
tests pass.
2001-10-18Accept an INTERVAL argument for SET TIME ZONE per SQL99.Thomas G. Lockhart
Modified the parser and the SET handlers to use full Node structures rather than simply a character string argument. Implement INTERVAL() YEAR TO MONTH (etc) syntax per SQL99. Does not yet accept the goofy string format that goes along with, but this should be fairly straight forward to fix now as a bug or later as a feature. Implement precision for the INTERVAL() type. Use the typmod mechanism for both of INTERVAL features. Fix the INTERVAL syntax in the parser: opt_interval was in the wrong place. INTERVAL is now a reserved word, otherwise we get reduce/reduce errors. Implement an explicit date_part() function for TIMETZ. Should fix coersion problem with INTERVAL reported by Peter E. Fix up some error messages for date/time types. Use all caps for type names within message. Fix recently introduced side-effect bug disabling 'epoch' as a recognized field for date_part() etc. Reported by Peter E. (??) Bump catalog version number. Rename "microseconds" current transaction time field from ...Msec to ...Usec. Duh! date/time regression tests updated for reference platform, but a few changes will be necessary for others.
2001-10-04AdjustTimeForTypmod has the same bug ...Tom Lane
2001-10-04Fix some problems in new variable-resolution-timestamp code.Tom Lane
2001-10-03Implement precision support for timestamp and time, both with and withoutThomas G. Lockhart
time zones. SQL99 spec requires a default of zero (round to seconds) which is set in gram.y as typmod is set in the parse tree. We *could* change to a default of either 6 (for internal compatibility with previous versions) or 2 (for external compatibility with previous versions). Evaluate entries in pg_proc wrt the iscachable attribute for timestamp and other date/time types. Try to recognize cases where side effects like the current time zone setting may have an effect on results to decide whether something is cachable or not.
2001-09-28Measure the current transaction time to milliseconds.Thomas G. Lockhart
Define a new function, GetCurrentTransactionStartTimeUsec() to get the time to this precision. Allow now() and timestamp 'now' to use this higher precision result so we now have fractional seconds in this "constant". Add timestamp without time zone type. Move previous timestamp type to timestamp with time zone. Accept another ISO variant for date/time values: yyyy-mm-ddThh:mm:ss (note the "T" separating the day from hours information). Remove 'current' from date/time types; convert to 'now' in input. Separate time and timetz regression tests. Separate timestamp and timestamptz regression test.
2001-05-03Ensure that btree sort ordering functions and boolean comparison operatorsTom Lane
give consistent results for all datatypes. Types float4, float8, and numeric were broken for NaN values; abstime, timestamp, and interval were broken for INVALID values; timetz was just plain broken (some possible pairs of values were neither < nor = nor >). Also clean up text, bpchar, varchar, and bit/varbit to eliminate duplicate code and thereby reduce the probability of similar inconsistencies arising in the future.
2001-03-22pgindent run. Make it all clean.Bruce Momjian
2001-01-24Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group.Bruce Momjian
2000-12-07Make OVERLAPS operators conform to SQL92 spec regarding NULL handling.Tom Lane
As I read it, the spec requires a non-null result in some cases where one of the inputs is NULL: specifically, if the other endpoint of that interval is between the endpoints of the other interval, then the result is known TRUE despite the missing endpoint. The spec could've been a lot simpler if they did not intend this behavior. I did not force an initdb for this change, but if you don't do one you'll still see the old strict-function behavior.
2000-12-03Repair usage of the OVERLAPS operator.Thomas G. Lockhart
Allow some operator-like tokens to be used as function names. Flesh out support for time, timetz, and interval operators and interactions. Regression tests pass, but non-reference-platform horology test results will need to be updated.
2000-11-11Allow interpretation of INTERVALs with more timezone-like syntax.Thomas G. Lockhart
Define conversions to and from text for date, time, and timetz. Have millisecond and microsecond return full # of seconds in those units. Previously, only returned full fractional part in those units.
2000-10-29USE_POSIX_TIME replaced by HAVE_TM_ZONE || HAVE_INT_TIMEZONE, which arePeter Eisentraut
equivalent. In linux.h there were some #undef HAVE_INT_TIMEZONE, which are useless because HAVE_TM_ZONE overrides it anyway, and messing with configure results isn't cool.
2000-09-12Modify date->timestamp conversion to use mktime().Thomas G. Lockhart
This should do better than before around Daylight Savings Time transitions.
2000-07-12Remove a bunch of unused configure tests, in particular cases wherePeter Eisentraut
* the result is not recorded anywhere * the result is not used anywhere * the result is only used in some places, whereas others have been getting away with it * the result is used improperly Also make command line options handling a little better (e.g., --disable-locale, while redundant, should really still *dis*able).
2000-06-19Clean up bogosities in pg_opclass, pg_amop, pg_amproc. There are amprocTom Lane
entries now for int8 and network hash indexes. int24_ops and int42_ops are gone. pg_opclass no longer contains multiple entries claiming to be the default opclass for the same datatype. opr_sanity regress test extended to catch errors like these in the future.
2000-06-15Final #include cleanup.Bruce Momjian
2000-06-15Clean up #include's.Bruce Momjian
2000-06-09Another round of updates for new fmgr, mostly in the datetime code.Tom Lane
2000-04-12Ye-old pgindent run. Same 4-space tabs.Bruce Momjian
2000-03-14Implement column aliases on views "CREATE VIEW name (collist)".Thomas G. Lockhart
Implement TIME WITH TIME ZONE type (timetz internal type). Remap length() for character strings to CHAR_LENGTH() for SQL92 and to remove the ambiguity with geometric length() functions. Keep length() for character strings for backward compatibility. Shrink stored views by removing internal column name list from visible rte. Implement min(), max() for time and timetz data types. Implement conversion of TIME to INTERVAL. Implement abs(), mod(), fac() for the int8 data type. Rename some math functions to generic names: round(), sqrt(), cbrt(), pow(), etc. Rename NUMERIC power() function to pow(). Fix int2 factorial to calculate result in int4. Enhance the Oracle compatibility function translate() to work with string arguments (from Edwin Ramirez). Modify pg_proc system table to remove OID holes.
2000-02-16All regression tests pass except for rules.sql (unrelated).Thomas G. Lockhart
Implement "date/time grand unification". Transform datetime and timespan into timestamp and interval. Deprecate datetime and timespan, though translate to new types in gram.y. Transform all datetime and timespan catalog entries into new types. Make "INTERVAL" reserved word allowed as a column identifier in gram.y. Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility routines for all date/time types. date.{h,c} now deals with date, time types. timestamp.{h,c} now deals with timestamp, interval types. nabstime.{h,c} now deals with abstime, reltime, tinterval types. Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-01-26Add:Bruce Momjian
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc to all files copyright Regents of Berkeley. Man, that's a lot of files.
2000-01-15Fixed all elog related warnings, as well as a few others.Peter Eisentraut
2000-01-02Remove DATEDEBUG because it didn't look Y2K safe, and fix timestamp elogBruce Momjian
to be Y2K safe.
1999-09-21values.h patch from Alex HowanskyBruce Momjian
1999-07-17 Move some system includes into c.h, and remove duplicates.Bruce Momjian
1999-07-16Final cleanup.Bruce Momjian
1999-07-16Update #include cleanupsBruce Momjian