summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/cash.c
AgeCommit message (Collapse)Author
2012-06-10Run pgindent on 9.2 source tree in preparation for first 9.3Bruce Momjian
commit-fest.
2011-10-30Support more locale-specific formatting options in cash_out().Tom Lane
The POSIX spec defines locale fields for controlling the ordering of the value, sign, and currency symbol in monetary output, but cash_out only supported a small subset of these options. Fully implement p/n_sign_posn, p/n_cs_precedes, and p/n_sep_by_space per spec. Fix up cash_in so that it will accept all these format variants. Also, make sure that thousands_sep is only inserted to the left of the decimal point, as required by spec. Per bug #6144 from Eduard Kracmar and discussion of bug #6277. This patch includes some ideas from Alexander Lakhin's proposed patch, though it is very different in detail.
2011-10-29Fix assorted bogosities in cash_in() and cash_out().Tom Lane
cash_out failed to handle multiple-byte thousands separators, as per bug #6277 from Alexander Law. In addition, cash_in didn't handle that either, nor could it handle multiple-byte positive_sign. Both routines failed to support multiple-byte mon_decimal_point, which I did not think was worth changing, but at least now they check for the possibility and fall back to using '.' rather than emitting invalid output. Also, make cash_in handle trailing negative signs, which formerly it would reject. Since cash_out generates trailing negative signs whenever the locale tells it to, this last omission represents a fail-to-reload-dumped-data bug. IMO that justifies patching this all the way back.
2011-04-10pgindent run before PG 9.1 beta 1.Bruce Momjian
2011-04-05Add casts from int4 and int8 to numeric.Robert Haas
Joey Adams, per gripe from Ramanujam. Review by myself and Tom Lane.
2010-09-20Remove cvs keywords from all files.Magnus Hagander
2010-07-16Add support for dividing money by money (yielding a float8 result) and forTom Lane
casting between money and numeric. Andy Balholm, reviewed by Kevin Grittner
2009-06-118.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef listBruce Momjian
provided by Andrew.
2009-06-10Fix cash_in() to behave properly in locales where frac_digits is zero,Tom Lane
eg Japan. Report and fix by Itagaki Takahiro. Also fix CASHDEBUG printout format for branches with 64-bit money type, and some minor comment cleanup. Back-patch to 7.4, because it's broken all the way back.
2008-06-09Fix unportable (and incorrect anyway) usage of LL constant suffix thatTom Lane
recently snuck into cash.c. Per report from Edmundo Robles Lopez.
2008-04-21Allow float8, int8, and related datatypes to be passed by value on machinesTom Lane
where Datum is 8 bytes wide. Since this will break old-style C functions (those still using version 0 calling convention) that have arguments or results of these types, provide a configure option to disable it and retain the old pass-by-reference behavior. Likewise, provide a configure option to disable the recently-committed float4 pass-by-value change. Zoltan Boszormenyi, plus configurability stuff by me.
2008-03-25Simplify and standardize conversions between TEXT datums and ordinary CTom Lane
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
2007-11-24Clarify how MONEY trims off trailing thousands separator.Bruce Momjian
2007-11-24Make the MONEY data type have a thousands separator != decimal symbol,Bruce Momjian
if the locale has the thousands separator as "". This now matches the to_char and psql numericlocale behavior. (Previously this data type was basically useless for such setups.)
2007-11-23Fix white space in MONEY type code. Rename 'comma' to more genericBruce Momjian
'ssymbol' as used in previous function.
2007-11-15pgindent run for 8.3.Bruce Momjian
2007-08-21Fix cash_mul_int4 and cash_div_int4 for overenthusiastic substitutionTom Lane
of int64 for int32. Per reports from Merlin Moncure and Andrew Chernow.
2007-08-21Fix money type's send/receive functions to conform to recent wideningTom Lane
of the datatype to int64. Per Andrew Chernow.
2007-07-12Fix a portability bug (ye olde not casting a <ctype.h> argument toTom Lane
unsigned char). Fortunately we still have buildfarm machines that will flag this. Seems to be new in CVS HEAD, so no backpatch.
2007-02-27Replace direct assignments to VARATT_SIZEP(x) with SET_VARSIZE(x, len).Tom Lane
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-01-03Widen the money type to 64 bits.D'Arcy J.M. Cain
2006-07-14Remove 576 references of include files that were not needed.Bruce Momjian
2006-03-19Fix a few places that were checking for the return value of palloc() to beNeil Conway
non-NULL: palloc() ereports on OOM, so we can safely assume it returns a valid pointer.
2005-10-15Standard pgindent run for 8.1.Bruce Momjian
2005-07-21Remove unnecessary parentheses in assignments.Bruce Momjian
Add spaces where needed. Reference time interval variables as tinterval.
2004-08-29Pgindent run for 8.0.Bruce Momjian
2004-05-07Solve the 'Turkish problem' with undesirable locale behavior for caseTom Lane
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.
2003-11-29$Header: -> $PostgreSQL Changes ...PostgreSQL Daemon
2003-09-25Message editing: remove gratuitous variations in message wording, standardizePeter Eisentraut
terms, add some clarifications, fix some untranslatable attempts at dynamic message building.
2003-08-17Create a 'type cache' that keeps track of the data needed for any particularTom Lane
datatype by array_eq and array_cmp; use this to solve problems with memory leaks in array indexing support. The parser's equality_oper and ordering_oper routines also use the cache. Change the operator search algorithms to look for appropriate btree or hash index opclasses, instead of assuming operators named '<' or '=' have the right semantics. (ORDER BY ASC/DESC now also look at opclasses, instead of assuming '<' and '>' are the right things.) Add several more index opclasses so that there is no regression in functionality for base datatypes. initdb forced due to catalog additions.
2003-07-27Error message editing in utils/adt. Again thanks to Joe Conway for doingTom Lane
the bulk of the heavy lifting ...
2003-05-13More binary I/O routines.Tom Lane
2003-03-11Add explicit tests for division by zero to all user-accessible integerTom Lane
division and modulo functions, to avoid problems on OS X (which fails to trap 0 divide at all) and Windows (which traps it in some bizarre nonstandard fashion). Standardize on 'division by zero' as the one true spelling of this error message. Add regression tests as suggested by Neil Conway.
2002-09-04pgindent run.Bruce Momjian
2002-09-03Remove all traces of multibyte and locale options. Clean up commentsPeter Eisentraut
referring to "multibyte" where it really means character encoding.
2002-08-20Increase buffer size in cash_words(). Pure paranoia; I don't think theTom Lane
code is broken, but any small change in the output format might overrun the buffer with the old size.
2002-04-03Locale support is on by default. The choice of locale is done in initdbPeter Eisentraut
and/or with GUC variables.
2002-02-19Avoid failures in cash_out and cash_words for INT_MIN.Tom Lane
Also, 'fourty' -> 'forty'.
2001-10-25pgindent run on all C files. Java run to follow. initdb/regressionBruce Momjian
tests pass.
2001-03-22pgindent run. Make it all clean.Bruce Momjian
2000-12-03Ensure that all uses of <ctype.h> functions are applied to unsigned-charTom Lane
values, whether the local char type is signed or not. This is necessary for portability. Per discussion on pghackers around 9/16/00.
2000-11-25Make PGLC_setlocale() static, and document that it can't be used safelyTom Lane
for any other purpose than PGLC_localeconv()'s internal save/restore of locale settings. Fix cash.c to call PGLC_localeconv() rather than making a direct call to localeconv() --- the old way, if PGLC_localeconv() had already cached a locale result, it would be overwritten by the first cash_in or cash_out operation, leading to wrong-locale results later. Probably no demonstrable bug today, since we only appear to be looking at the LC_MONETARY results which should be the same anyway, but definitely a gotcha waiting to strike.
2000-11-25Store current LC_COLLATE and LC_CTYPE settings in pg_control during initdb;Tom Lane
re-adopt these settings at every postmaster or standalone-backend startup. This should fix problems with indexes becoming corrupt due to failure to provide consistent locale environment for postmaster at all times. Also, refuse to start up a non-locale-enabled compilation in a database originally initdb'd with a non-C locale. Suppress LIKE index optimization if locale is not "C" or "POSIX" (are there any other locales where it's safe?). Issue NOTICE during initdb if selected locale disables LIKE optimization.
2000-11-18Modify locale code to defend against possibility that it was compiledTom Lane
with an -fsigned-char/-funsigned-char setting opposite to that of libc, thus breaking the convention that 'undefined' values returned by localeconv() are represented by CHAR_MAX. It is sheer stupidity that gcc even has such a switch --- it's just as bad as the structure-packing control switches offered by the more brain-dead PC compilers --- and as for the behavior of Linux distribution vendors who set RPM_OPT_FLAGS differently from the way they built libc, well, words fail me...
2000-08-03More functions updated to new fmgr style --- money, name, tid datatypes.Tom Lane
We're reaching the mopup stage here (good thing too, this is getting tedious).
2000-08-01Convert all remaining float4 and float8 functions to new fmgr style.Tom Lane
At this point I think it'd be possible to make float4 be pass-by-value without too much work --- and float8 too on machines where Datum is 8 bytes. Something to try when the mood strikes, anyway.
2000-07-07Rename cash_words_out to cash_words.Bruce Momjian
2000-07-06Functions on 'text' type updated to new fmgr style. 'text' isTom Lane
now TOAST-able.
2000-07-03TOASTJan Wieck
WARNING: This is actually broken - we have self-deadlocks due to concurrent changes in buffer management. Vadim and me are working on it. Jan
2000-06-15Clean up #include's.Bruce Momjian