aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/formatting.c
Commit message (Collapse)AuthorAge
...
* Switch over to using the src/timezone functions for formatting timestampsTom Lane2007-08-04
| | | | | | | | | | | | | | displayed in the postmaster log. This avoids Windows-specific problems with localized time zone names that are in the wrong encoding, and generally seems like a good idea to forestall other potential platform-dependent issues. To preserve the existing behavior that all backends will log in the same time zone, create a new GUC variable log_timezone that can only be changed on a system-wide basis, and reference log-related calculations to that zone instead of the TimeZone variable. This fixes the issue reported by Hiroshi Saito that timestamps printed by xlog.c startup could be improperly localized on Windows. We still need a simpler patch for that problem in the back branches, however.
* Fix a passel of ancient bugs in to_char(), including two distinct bufferTom Lane2007-06-29
| | | | | | | | | | | overruns (neither of which seem likely to be exploitable as security holes, fortunately, since the provoker can't control the data written). One of these is due to choosing to stomp on the output of a called function, which is bad news in any case; make it treat the called functions' results as read-only. Avoid some unnecessary palloc/pfree traffic too; it's not really helpful to free small temporary objects, and again this is presuming more than it ought to about the nature of the results of called functions. Per report from Patrick Welche and additional code-reading by Imad.
* Replace direct assignments to VARATT_SIZEP(x) with SET_VARSIZE(x, len).Tom Lane2007-02-27
| | | | | | | | | | | Get rid of VARATT_SIZE and VARATT_DATA, which were simply redundant with VARSIZE and VARDATA, and as a consequence almost no code was using the longer names. Rename the length fields of struct varlena and various derived structures to catch anyplace that was accessing them directly; and clean up various places so caught. In itself this patch doesn't change any behavior at all, but it is necessary infrastructure if we hope to play any games with the representation of varlena headers. Greg Stark and Tom Lane
* Remove rint() for to_char MS and US output. We can't us rint() becauseBruce Momjian2007-02-17
| | | | | we can't overflow to the next higher units, and we might print the lower units for MS.
* Cleanup of to_char() patch.Bruce Momjian2007-02-17
| | | | Brendan Jurd
* Fix // commentPeter Eisentraut2007-02-16
|
* Add two new format fields for use with to_char(), to_date() andBruce Momjian2007-02-16
| | | | | | | | | | | | | | to_timestamp(): - ID for day-of-week - IDDD for day-of-year This makes it possible to convert ISO week dates to and from text fully represented in either week ('IYYY-IW-ID') or day-of-year ('IYYY-IDDD') format. I have also added an 'isoyear' field for use with extract / date_part. Brendan Jurd
* Fix to_date()/to_timestamp() 'D' field for day of week, was off by one.Bruce Momjian2007-02-14
| | | | | | Converting from char using 'D' doesn't make lots of sense, of course. Report from Brendan Jurd.
* Add comment that to_char() for broken glibc pt_BR might cause a problem.Bruce Momjian2007-02-13
|
* Remove blank lines in code.Bruce Momjian2007-02-09
|
* Remove blank line from C code.Bruce Momjian2007-02-09
|
* Fix bug when localized to_char() day or month names were incorectlyBruce Momjian2007-02-08
| | | | | | trnasformed to lower or upper string. Pavel Stehule
* Fix bug in our code when using to_timestamp() or to_date() without "TM".Bruce Momjian2007-02-08
| | | | | Assume "TM" when input fields are variable-length, like month or day names. This matches Oracle behavior.
* Fix handling of CC (century) format spec in to_date/to_char. According toTom Lane2007-01-12
| | | | | | | | standard convention the 21st century runs from 2001-2100, not 2000-2099, so make it work like that. Per bug #2885 from Akio Iwaasa. Backpatch to 8.2, but no further, since this is really a definitional change; users of older branches are probably more interested in stability.
* Update CVS HEAD for 2007 copyright. Back branches are typically notBruce Momjian2007-01-05
| | | | back-stamped for this.
* Add workaround for localizing May and abbreviated May differently. IdeaPeter Eisentraut2006-11-28
| | | | of Dennis Björklund.
* Revert (too late in beta):Bruce Momjian2006-11-24
| | | | | | Fix to_char() locale handling to honor LC_TIME, not LC_MESSAGES. Euler Taveira de Oliveira
* Fix to_char() locale handling to honor LC_TIME, not LC_MESSAGES.Bruce Momjian2006-11-24
| | | | Euler Taveira de Oliveira
* pgindent run for 8.2.Bruce Momjian2006-10-04
|
* Back out patch added during 8.2.X development:Bruce Momjian2006-09-10
| | | | | | | Allow to_char() "D" format specifiers for interval/time. It doesn't work, and I doubt it is useful enough to fix ("D" = day of week).
* Fix case where "PM" to_timestamp() mask was eating too many characters.Bruce Momjian2006-09-03
| | | | Report from Josh Tolley.
* Fix problem that sscanf(buf, "%d", &val) eats leading white space, butBruce Momjian2006-04-19
| | | | our to_* functions were not handling that.
* C code whitespace inprovement for formatting.c.Bruce Momjian2006-04-19
|
* Update copyright for 2006. Update scripts.Bruce Momjian2006-03-05
|
* Add comment about localized month names for to_date and to_timestamp.Bruce Momjian2006-03-03
|
* Revert because C locale uses "" for thousands_sep, meaning "n/a", whileBruce Momjian2006-02-12
| | | | | French uses "" for "don't want". Seems we have to keep the existing behavior.
* Support "" for thousands separator and plus sign in to_char(), perBruce Momjian2006-02-12
| | | | report from French Debian user. psql already handles "" fine.
* Allow to_char() to print localized month and day names.Bruce Momjian2006-02-12
| | | | Euler Taveira de Oliveira
* Allow to_char(interval) and to_char(time) to use AM/PM specifications.Bruce Momjian2005-12-03
| | | | | | | | | | | Map them to a single day, so '30 hours' is 'AM'. Have to_char(interval) and to_char(time) use "HH", "HH12" as 12-hour intervals, rather than bypass and print the full interval hours. This is neeeded because to_char(time) is mapped to interval in this function. Intervals should use "HH24", and document suggestion. Allow "D" format specifiers for interval/time.
* Re-run pgindent, fixing a problem where comment lines after a blankBruce Momjian2005-11-22
| | | | | | | | | 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.
* Adjust not-too-sane calculation of DDD value for to_char(interval).Tom Lane2005-10-20
| | | | Per gripe from Chris Matheson.
* Standard pgindent run for 8.1.Bruce Momjian2005-10-15
|
* Add hint for to_char(interval) invalid format specifications.Bruce Momjian2005-08-18
|
* Fix to_char(interval) to return proper year and century values.Bruce Momjian2005-08-18
| | | | | | | | 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.
* More formatting.c cleanups.Bruce Momjian2005-08-17
|
* Small cleanup.Bruce Momjian2005-08-17
|
* Adjust to_char/from_char code to use boolean "is_to_char" rather thanBruce Momjian2005-08-17
| | | | integer with flags.
* Fix a few macro definitions to ensure that unary minus is enclosed inNeil Conway2005-07-27
| | | | | parentheses. This avoids possible operator precedence problems, and is consistent with most of the macro definitions in the tree.
* Andrew pointed out that the current fix didn't handle dates that wereBruce Momjian2005-07-23
| | | | | | | | | | | 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)
* Add time/date macros for code clarity:Bruce Momjian2005-07-21
| | | | | | | #define DAYS_PER_YEAR 365.25 #define MONTHS_PER_YEAR 12 #define DAYS_PER_MONTH 30 #define HOURS_PER_DAY 24
* Add 'day' field to INTERVAL so 1 day interval can be distinguished fromBruce Momjian2005-07-20
| | | | | | | | | | | | | | | | 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
* Code cleanup: remove 3 duplicate static function declarations.Neil Conway2005-06-24
|
* More trivial dead code removal: in int_to_roman(), checking for "num == -1"Neil Conway2005-06-22
| | | | | | | | 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.
* This patch makes it possible to use the full set of timezones when doingBruce Momjian2005-06-15
| | | | | | | | | | | | | | | | | | "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
* Add parentheses to macros when args are used in computations. WithoutBruce Momjian2005-05-25
| | | | them, the executation behavior could be unexpected.
* Prevent to_char(interval) from dumping core on month-related formatsTom Lane2005-03-26
| | | | | | 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.
* Fix to_date to behave reasonably when CC and YY fields are both used.Tom Lane2005-03-25
| | | | Karel Zak
* Remove unportable assumption that it's okay to use the target bufferTom Lane2005-01-13
| | | | | of an sprintf() as a source string. Demonstrably does not work with recent gcc and/or glibc on some platforms.
* Update copyrights that were missed.Bruce Momjian2005-01-01
|
* Fix unportable isdigit() call --- must cast arg to unsigned char.Tom Lane2004-11-20
|