summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/timestamp.c
AgeCommit message (Collapse)Author
2008-07-07Fix AT TIME ZONE (in all three variants) so that we first try to interpretTom Lane
the timezone argument as a timezone abbreviation, and only try it as a full timezone name if that fails. The zic database has four zones (CET, EET, MET, WET) that are full daylight-savings zones and yet have names that are the same as their abbreviations for standard time, resulting in ambiguity. In the timestamp input functions we resolve the ambiguity by preferring the abbreviation, and AT TIME ZONE should work the same way. (No functionality is lost because the zic database also has other names for these zones, eg Europe/Zurich.) Per gripe from Jaromir Talir. Backpatch to 8.1. Older releases did not have the issue because AT TIME ZONE only accepted abbreviations not zone names. (Thus, this patch also arguably fixes a compatibility botch introduced at 8.1: in ambiguous cases we now behave the same as 8.0 did.)
2007-09-16Fix overflow in extract(epoch from interval) for intervals exceeding 68 years.Tom Lane
Seems to have been introduced in 8.1 by careless SECS_PER_DAY search-and-replace.
2006-11-11Suppress a few 'uninitialized variable' warnings that gcc emits only atTom Lane
-O3 or higher (presumably because it inlines more things). Per gripe from Mark Mielke.
2006-10-04pgindent run for 8.2.Bruce Momjian
2006-09-05Fix imprecision from interval rounding of multiplication/division.Bruce Momjian
Bruce, Michael Glaesemann
2006-09-03Properly round months into days and into seconds for intervalBruce Momjian
multiplication/division queries like select '41 mon 10:00:00'::interval / 10 as "pos". Report from Michael Glaesemann
2006-07-13Allow include files to compile own their own.Bruce Momjian
Strip unused include files out unused include files, and add needed includes to C files. The next step is to remove unused include files in C files.
2006-06-20Remove redundant gettimeofday() calls to the extent practical withoutTom Lane
changing semantics too much. statement_timestamp is now set immediately upon receipt of a client command message, and the various places that used to do their own gettimeofday() calls to mark command startup are referenced to that instead. I have also made stats_command_string use that same value for pg_stat_activity.query_start for both the command itself and its eventual replacement by <IDLE> or <idle in transaction>. There was some debate about that, but no argument that seemed convincing enough to justify an extra gettimeofday() call.
2006-04-25Add statement_timestamp(), clock_timestamp(), andBruce Momjian
transaction_timestamp() (just like now()). Also update statement_timeout() to mention it is statement arrival time that is measured. Catalog version updated.
2006-03-06Attached is the new patch. To summarize:Bruce Momjian
- new function justify_interval(interval) - modified function justify_hours(interval) - modified function justify_days(interval) These functions are defined to meet the requirements as discussed in this thread. Specifically: - justify_hours makes certain the sign bit on the hours matches the sign bit on the days. It only checks the sign bit on the days, and not the months, when determining if the hours should be positive or negative. After the call, -24 < hours < 24. - justify_days makes certain the sign bit on the days matches the sign bit on the months. It's behavior does not depend on the hours, nor does it modify the hours. After the call, -30 < days < 30. - justify_interval makes sure the sign bits on all three fields months, days, and hours are all the same. After the call, -24 < hours < 24 AND -30 < days < 30. Mark Dilger
2006-03-05Update copyright for 2006. Update scripts.Bruce Momjian
2005-11-22Fix up comment munged by pg_indent. (Not pg_indent's fault; should haveTom Lane
protected comment with dashes the first time round.)
2005-11-22Re-run pgindent, fixing a problem where comment lines after a blankBruce Momjian
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-17Make SQL arrays support null elements. This commit fixes the core arrayTom Lane
functionality, but I still need to make another pass looking at places that incidentally use arrays (such as ACL manipulation) to make sure they are null-safe. Contrib needs work too. I have not changed the behaviors that are still under discussion about array comparison and what to do with lower bounds.
2005-10-27Add comment documenting actual failure case of usingBruce Momjian
interval_justify_hours in timestamp subtraction. TODO already has text description.
2005-10-25Remove justify_hours call from interval_mul and interval_div, and makeTom Lane
some small stylistic improvements in these functions. Also fix several places where TMODULO() was being used with wrong-sized quotient argument, creating a risk of overflow --- interval2tm was actually capable of going into an infinite loop because of this.
2005-10-15Standard pgindent run for 8.1.Bruce Momjian
2005-10-09Fix (hopefully for the last time) problems with datetime values displayingTom Lane
like '23:59:60' because of fractional-second roundoff problems. Trying to control this upstream of the actual display code was hopeless; the right way is to explicitly round fractional seconds in the display code and then refigure the results if the fraction rounds up to 1. Per bug #1927.
2005-09-09timestamptz_izone should return the input, not NULL, when the inputTom Lane
is a non-finite timestamp, for consistency with related functions. In other words: +infinity rotated to a different timezone is still +infinity.
2005-09-09Fix the various forms of AT TIME ZONE to accept either timezones foundTom Lane
in the zic database or zone names found in the date token table. This preserves the old ability to do AT TIME ZONE 'PST' along with the new ability to do AT TIME ZONE 'PST8PDT'. Per gripe from Bricklen Anderson. Also, fix some inconsistencies in usage of TZ_STRLEN_MAX --- the old code had the potential for one-byte buffer overruns, though given alignment considerations it's unlikely there was any real risk.
2005-08-25Factor out the common subexpression month_remainder * DAYS_PER_MONTHTom Lane
in interval_mul and interval_div. This avoids an optimization bug in A Certain Company's compiler (and given their explanation, I wouldn't be surprised if other compilers blow it too). Besides the code seems more clear this way --- in the original formulation, you had to mentally recognize the common subexpression in order to understand what was going on.
2005-08-25Back out pfrees for justify_hour function calls.Bruce Momjian
2005-08-25Fix memory leak when using justify_hours.Bruce Momjian
2005-08-12Code & docs review for server instrumentation patch. File timestampsTom Lane
should surely be timestamptz not timestamp; fix some but not all of the holes in check_and_make_absolute(); other minor cleanup. Also put in the missed catversion bump.
2005-07-30Fix justify_days() for integer datestamp, clean up code.Bruce Momjian
2005-07-24Fix rounding problem in interval_div by using rint(), and improveBruce Momjian
interval_mul function.
2005-07-23Improve computations of interval_div to prevent rounding problem on AIX.Bruce Momjian
2005-07-23Andrew pointed out that the current fix didn't handle dates that wereBruce Momjian
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-23Fix AT TIME ZONE for timestamps without time zones:Bruce Momjian
test=> select (CURRENT_DATE + '05:00'::time)::timestamp at time zone 'Canada/Pacific'; timezone ------------------------ 2005-07-22 08:00:00-04 (1 row)
2005-07-22Fix AT TIME ZONE for timestamps without time zones:Bruce Momjian
test=> select ('2005-07-20 00:00:00'::timestamp without time zone) at time zone 'Europe/Paris'; timezone ------------------------ 2005-07-19 22:00:00-04 Udpate documentation.
2005-07-22More removal of unneeded parentheses.Bruce Momjian
2005-07-22More spacing adjustmentsBruce Momjian
2005-07-22Code spacing improvement, particularly *tm spacing.Bruce Momjian
2005-07-21Update DAYS_PER_MONTH comment.Bruce Momjian
Add SECS_PER_YEAR and MINS_PER_HOUR macros.
2005-07-21Fix integer timestamp build for macro changes.Bruce Momjian
2005-07-21Remove unnecessary parentheses in assignments.Bruce Momjian
Add spaces where needed. Reference time interval variables as tinterval.
2005-07-21Add time/date macros for code clarity:Bruce Momjian
#define DAYS_PER_YEAR 365.25 #define MONTHS_PER_YEAR 12 #define DAYS_PER_MONTH 30 #define HOURS_PER_DAY 24
2005-07-20Add 'day' field to INTERVAL so 1 day interval can be distinguished fromBruce Momjian
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-20Fix interval division and multiplication, before:Bruce Momjian
test=> select '4 months'::interval / 5; ?column? --------------- 1 mon -6 days (1 row) after: test=> select '4 months'::interval / 5; ?column? ---------- 24 days (1 row) The problem was the use of rint() to round, and then find the remainder, causing the negative values.
2005-07-12Improve comments for AdjustIntervalForTypmod.Bruce Momjian
Blank line adjustments.
2005-07-12Change 5e0 to 5.0, for consistency.Bruce Momjian
2005-07-10Change typreceive function API so that receive functions get the sameTom Lane
optional arguments as text input functions, ie, typioparam OID and atttypmod. Make all the datatypes that use typmod enforce it the same way in typreceive as they do in typinput. This fixes a problem with failure to enforce length restrictions during COPY FROM BINARY.
2005-07-04Fix date_trunct for December dates that are in the next year, e.g.:Bruce Momjian
SELECT date_trunc('week', '2002-12-31'::date); Backpatch to 8.0.X. Per report from Nick Johnson.
2005-06-30Fix build break on BSD, OSX, and other systems: add missing <sys/time.h>Neil Conway
include.
2005-06-29Clean up the rather historically encumbered interface to now() andTom Lane
current time: provide a GetCurrentTimestamp() function that returns current time in the form of a TimestampTz, instead of separate time_t and microseconds fields. This is what all the callers really want anyway, and it eliminates low-level dependencies on AbsoluteTime, which is a deprecated datatype that will have to disappear eventually.
2005-06-15This patch makes it possible to use the full set of timezones when doingBruce Momjian
"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-14Add pg_postmaster_start_time() function.Bruce Momjian
Euler Taveira de Oliveira Matthias Schmidt
2005-05-26Adjust datetime parsing to be more robust. We now pass the length of theNeil Conway
working buffer into ParseDateTime() and reject too-long input there, rather than checking the length of the input string before calling ParseDateTime(). The old method was bogus because ParseDateTime() can use a variable amount of working space, depending on the content of the input string (e.g. how many fields need to be NUL terminated). This fixes a minor stack overrun -- I don't _think_ it's exploitable, although I won't claim to be an expert. Along the way, fix a bug reported by Mark Dilger: the working buffer allocated by interval_in() was too short, which resulted in rejecting some perfectly valid interval input values. I added a regression test for this fix.
2005-05-24Remove more extraneous parentheses in date/time functions.Bruce Momjian
2005-05-23More macro cleanups for date/time.Bruce Momjian