Commit Graph

149 Commits

Author SHA1 Message Date
Tom Lane 557faa4fb3 Random speculation about the reason for PPC64 buildfarm failures:
maybe isalnum is returning a value with the low-order byte all zero?
2008-10-06 05:03:27 +00:00
Tom Lane b1e929f295 Fix pointer-advancement bugs in MS and US cases of new to_timestamp() code.
Alex Hunsaker
2008-09-26 15:35:28 +00:00
Tom Lane 06edce4c3f Tighten up to_date/to_timestamp so that they are more likely to reject
erroneous input, rather than silently producing bizarre results as formerly
happened.

Brendan Jurd
2008-09-11 17:32:34 +00:00
Bruce Momjian 6152de97d3 Minor patch on pgbench
1. -i option should run vacuum analyze only on pgbench tables, not *all*
tables in database.

2. pre-run cleanup step was DELETE FROM HISTORY then VACUUM HISTORY.
This is just a slow version of TRUNCATE HISTORY.

Simon Riggs
2008-08-22 17:57:34 +00:00
Tom Lane 960af47efd Const-ify the arguments of str_tolower() and friends to suppress compile
warnings.  Clean up various unneeded cruft that was left behind after
creating those routines.  Introduce some convenience functions str_tolower_z
etc to eliminate tedious and error-prone double arguments in formatting.c.
(Currently there seems no need to export the latter, but maybe reconsider
this later.)
2008-07-12 00:44:38 +00:00
Teodor Sigaev 5ff9899933 Fix bug "select lower('asd') = 'asd'" returns false with multibyte encoding
and non-C locale. Fix is just to use correct source's length for char2wchar
call.
2008-06-26 16:06:37 +00:00
Bruce Momjian f6ec7430f9 Merge duplicate upper/lower/initcap() routines in oracle_compat.c and
formatting.c to use common code;  remove duplicate functions and support
routines that are no longer needed.
2008-06-23 19:27:19 +00:00
Bruce Momjian dc69c0362f Move USE_WIDE_UPPER_LOWER define to c.h, and remove TS_USE_WIDE and use
USE_WIDE_UPPER_LOWER instead.
2008-06-17 16:09:06 +00:00
Bruce Momjian 9f19470966 Simplify code in formatting.c now that to upper/lower/initcase do not
modify the passed string.
2008-05-20 01:41:02 +00:00
Tom Lane 07a5606735 Make to_char()'s localized month/day names depend on LC_TIME, not LC_MESSAGES.
Euler Taveira de Oliveira
2008-05-19 18:08:16 +00:00
Tom Lane 220db7ccd8 Simplify and standardize conversions between TEXT datums and ordinary C
strings.  This patch introduces four support functions cstring_to_text,
cstring_to_text_with_len, text_to_cstring, and text_to_cstring_buffer, and
two macros CStringGetTextDatum and TextDatumGetCString.  A number of
existing macros that provided variants on these themes were removed.

Most of the places that need to make such conversions now require just one
function or macro call, in place of the multiple notational layers that used
to be needed.  There are no longer any direct calls of textout or textin,
and we got most of the places that were using handmade conversions via
memcpy (there may be a few still lurking, though).

This commit doesn't make any serious effort to eliminate transient memory
leaks caused by detoasting toasted text objects before they reach
text_to_cstring.  We changed PG_GETARG_TEXT_P to PG_GETARG_TEXT_PP in a few
places where it was easy, but much more could be done.

Brendan Jurd and Tom Lane
2008-03-25 22:42:46 +00:00
Tom Lane 19595835c3 Refactor to_char/to_date formatting code; primarily, replace DCH_processor
with two new functions DCH_to_char and DCH_from_char that have less confusing
APIs.  Brendan Jurd
2008-03-22 22:32:19 +00:00
Bruce Momjian 9098ab9e32 Update copyrights in source tree to 2008. 2008-01-01 19:46:01 +00:00
Bruce Momjian b85cf684f7 Add more comments about thousands separator handling. 2007-11-22 17:51:39 +00:00
Bruce Momjian d9bc7a3946 Add comments about thousands separator logic. 2007-11-22 15:10:05 +00:00
Bruce Momjian 3894e7cc55 When setting default thousands separator when locale has "", use logic
so new thousands separator doesn't match decimal symbol.
2007-11-21 22:28:18 +00:00
Bruce Momjian 6f3149e464 Fix typo in comment. 2007-11-21 21:49:22 +00:00
Bruce Momjian fdf5a5efb7 pgindent run for 8.3. 2007-11-15 21:14:46 +00:00
Tom Lane bdd6b62245 Switch over to using the src/timezone functions for formatting timestamps
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.
2007-08-04 01:26:54 +00:00
Tom Lane 6faf795662 Fix a passel of ancient bugs in to_char(), including two distinct buffer
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.
2007-06-29 01:51:35 +00:00
Tom Lane 234a02b2a8 Replace direct assignments to VARATT_SIZEP(x) with SET_VARSIZE(x, len).
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
2007-02-27 23:48:10 +00:00
Bruce Momjian 4fe1a12c54 Remove rint() for to_char MS and US output. We can't us rint() because
we can't overflow to the next higher units, and we might print the lower
units for MS.
2007-02-17 03:11:32 +00:00
Bruce Momjian f7a51b7a0d Cleanup of to_char() patch.
Brendan Jurd
2007-02-17 01:51:42 +00:00
Peter Eisentraut 89b18bdd2a Fix // comment 2007-02-16 10:55:47 +00:00
Bruce Momjian 4ebb0cf9c3 Add two new format fields for use with to_char(), to_date() and
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
2007-02-16 03:39:46 +00:00
Bruce Momjian 764122471a Fix to_date()/to_timestamp() 'D' field for day of week, was off by one.
Converting from char using 'D' doesn't make lots of sense, of course.

Report from Brendan Jurd.
2007-02-14 05:10:55 +00:00
Bruce Momjian d1d3f4d015 Add comment that to_char() for broken glibc pt_BR might cause a problem. 2007-02-13 02:00:55 +00:00
Bruce Momjian d7fee591db Remove blank lines in code. 2007-02-09 04:17:58 +00:00
Bruce Momjian acb3416686 Remove blank line from C code. 2007-02-09 03:15:48 +00:00
Bruce Momjian b577aa9ebc Fix bug when localized to_char() day or month names were incorectly
trnasformed to lower or upper string.

Pavel Stehule
2007-02-08 18:19:33 +00:00
Bruce Momjian 9e9e387ecf Fix bug in our code when using to_timestamp() or to_date() without "TM".
Assume "TM" when input fields are variable-length, like month or day
names.  This matches Oracle behavior.
2007-02-08 03:22:28 +00:00
Tom Lane 9a54b76b39 Fix handling of CC (century) format spec in to_date/to_char. According to
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.
2007-01-12 23:34:55 +00:00
Bruce Momjian 29dccf5fe0 Update CVS HEAD for 2007 copyright. Back branches are typically not
back-stamped for this.
2007-01-05 22:20:05 +00:00
Peter Eisentraut b64d2d2133 Add workaround for localizing May and abbreviated May differently. Idea
of Dennis Björklund.
2006-11-28 12:53:44 +00:00
Bruce Momjian 9b15b14014 Revert (too late in beta):
Fix to_char() locale handling to honor LC_TIME, not LC_MESSAGES.

Euler Taveira de Oliveira
2006-11-24 22:25:56 +00:00
Bruce Momjian d2b694d825 Fix to_char() locale handling to honor LC_TIME, not LC_MESSAGES.
Euler Taveira de Oliveira
2006-11-24 15:26:18 +00:00
Bruce Momjian f99a569a2e pgindent run for 8.2. 2006-10-04 00:30:14 +00:00
Bruce Momjian 94cf48d72b Back out patch added during 8.2.X development:
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).
2006-09-10 22:54:47 +00:00
Bruce Momjian 1d4abf2175 Fix case where "PM" to_timestamp() mask was eating too many characters.
Report from Josh Tolley.
2006-09-03 01:22:56 +00:00
Bruce Momjian 5d096d0127 Fix problem that sscanf(buf, "%d", &val) eats leading white space, but
our to_* functions were not handling that.
2006-04-19 18:49:09 +00:00
Bruce Momjian e37a649e94 C code whitespace inprovement for formatting.c. 2006-04-19 14:48:06 +00:00
Bruce Momjian f2f5b05655 Update copyright for 2006. Update scripts. 2006-03-05 15:59:11 +00:00
Bruce Momjian 6839bc95d4 Add comment about localized month names for to_date and to_timestamp. 2006-03-03 02:17:30 +00:00
Bruce Momjian 8325be229c Revert because C locale uses "" for thousands_sep, meaning "n/a", while
French uses "" for "don't want".  Seems we have to keep the existing
behavior.
2006-02-12 23:48:23 +00:00
Bruce Momjian 2cb61220eb Support "" for thousands separator and plus sign in to_char(), per
report from French Debian user.  psql already handles "" fine.
2006-02-12 19:52:06 +00:00
Bruce Momjian f695750c43 Allow to_char() to print localized month and day names.
Euler Taveira de Oliveira
2006-02-12 04:44:15 +00:00
Bruce Momjian d20901a39b Allow to_char(interval) and to_char(time) to use AM/PM specifications.
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.
2005-12-03 16:45:06 +00:00
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