summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/float.c
AgeCommit message (Collapse)Author
2007-06-05Downgrade implicit casts to text to be assignment-only, except for the onesTom Lane
from the other string-category types; this eliminates a lot of surprising interpretations that the parser could formerly make when there was no directly applicable operator. Create a general mechanism that supports casts to and from the standard string types (text,varchar,bpchar) for *every* datatype, by invoking the datatype's I/O functions. These new casts are assignment-only in the to-string direction, explicit-only in the other, and therefore should create no surprising behavior. Remove a bunch of thereby-obsoleted datatype-specific casting functions. The "general mechanism" is a new expression node type CoerceViaIO that can actually convert between *any* two datatypes if their external text representations are compatible. This is more general than needed for the immediate feature, but might be useful in plpgsql or other places in future. This commit does nothing about the issue that applying the concatenation operator || to non-text types will now fail, often with strange error messages due to misinterpreting the operator as array concatenation. Since it often (not always) worked before, we should either make it succeed or at least give a more user-friendly error; but details are still under debate. Peter Eisentraut and Tom Lane
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-20Make setseed() return void, rather than an int4 without any use. PerNeil Conway
pgsql-patches discussion of September 20, 2006. Bump the catversion.
2007-01-16Implement width_bucket() for the float8 data type.Neil Conway
The implementation is somewhat ugly logic-wise, but I don't see an easy way to make it more concise. When writing this, I noticed that my previous implementation of width_bucket() doesn't handle NaN correctly: postgres=# select width_bucket('NaN', 1, 5, 5); width_bucket -------------- 6 (1 row) AFAICS SQL:2003 does not define a NaN value, so it doesn't address how width_bucket() should behave here. The patch changes width_bucket() so that ereport(ERROR) is raised if NaN is specified for the operand or the lower or upper bounds to width_bucket(). For float8, NaN is disallowed for any of the floating-point inputs, and +/- infinity is disallowed for the histogram bounds (but allowed for the operand). Update docs and regression tests, bump the catversion.
2007-01-06Apply fix so pow() and exp() ERANGE is used only if result is not 0.Bruce Momjian
2007-01-06Check for ERANGE in exp() as well.Bruce Momjian
Improve release docs for ecpg regression tests.
2007-01-06Improve dpow() check for ERANGE overflow for HPPA.Bruce Momjian
2007-01-06Put back ERANGE test in dpow(). There are platforms that need this,Tom Lane
like my HPPA ...
2007-01-05Update CVS HEAD for 2007 copyright. Back branches are typically notBruce Momjian
back-stamped for this.
2007-01-05Update float dpow() comment about whick platforms had issues with Nan.Bruce Momjian
Stefan Kaltenbrunner
2007-01-04Simplify assignment of Inf for pow Nan (don't worry about the sign).Bruce Momjian
2007-01-03Update pow() tests to check for both errno==EDOM _and_ result==Nan, andBruce Momjian
document why this happens. Remove exp() errno check because not needed.
2007-01-03Fix erroneous error tests in pow/exp.Tom Lane
2007-01-03Attempt to return proper overflow/underflow messages for platforms thatBruce Momjian
only return Nan and set errno for pow/exp overflow/underflow.
2007-01-03For float4/8, remove errno checks for pow() and exp() because only someBruce Momjian
platforms set errno, and we already have a check macro that detects under/overflow, so there is no reason for platform-specific code anymore.
2007-01-02Some platforms set errno on pow(), exp() overflow, some do not, so ifBruce Momjian
isinf(), fall through to our own infinity checks.
2007-01-02finite() no longer used; remove finite() platform-specificBruce Momjian
infrastructure.
2007-01-02Add #include <float.h> for platforms that still need it.Bruce Momjian
2007-01-02Fix float4/8 to handle Infinity and Nan consistently, e.g. Infinity is aBruce Momjian
valid result from a computation if one of the input values was infinity. The previous code assumed an operation that returned infinity was an overflow. Handle underflow/overflow consistently, and add checks for aggregate overflow. Consistently prevent Inf/Nan from being cast to integer data types. Fix INT_MIN % -1 to prevent overflow. Update regression results for new error text. Per report from Roman Kononov.
2006-12-23Remove unnecessary parentheses in if() statements.Bruce Momjian
2006-10-05Work around buggy strtod on (some versions of?) IRIX. Combination ofTom Lane
proposed patches from John Jorgensen and Steve Singer.
2006-10-04pgindent run for 8.2.Bruce Momjian
2006-07-28SQL2003-standard statistical aggregates, by Sergey Koposov. I've added onlyTom Lane
the float8 versions of the aggregates, which is all that the standard requires. Sergey's original patch also provided versions using numeric arithmetic, but given the size and slowness of the code, I doubt we ought to include those in core.
2006-07-14Remove 576 references of include files that were not needed.Bruce Momjian
2006-07-14Fix a passel of recently-committed violations of the rule 'thou shaltTom Lane
have no other gods before c.h'. Also remove some demonstrably redundant #include lines, mostly of <errno.h> which was added to c.h years ago.
2006-06-07Prepare code to be built by MSVC:Bruce Momjian
o remove many WIN32_CLIENT_ONLY defines o add WIN32_ONLY_COMPILER define o add 3rd argument to open() for portability o add include/port/win32_msvc directory for system includes Magnus Hagander
2006-04-24Improve our private implementation of cbrt() to give results of theTom Lane
accuracy expected by the regression tests. Per suggestion from Martijn van Oosterhout.
2006-03-11Remove a few places that attempted to define INT_MAX, SCHAR_MAX, andNeil Conway
similar constants if they were not previously defined. All these constants must be defined by limits.h according to C89, so we can safely assume they are present.
2006-03-10Implement 4 new aggregate functions from SQL2003. Specifically: var_pop(),Neil Conway
var_samp(), stddev_pop(), and stddev_samp(). var_samp() and stddev_samp() are just renamings of the historical Postgres aggregates variance() and stddev() -- the latter names have been kept for backward compatibility. This patch includes updates for the documentation and regression tests. The catversion has been bumped. NB: SQL2003 requires that DISTINCT not be specified for any of these aggregates. Per discussion on -patches, I have NOT implemented this restriction: if the user asks for stddev(DISTINCT x), presumably they know what they are doing.
2006-03-05Update copyright for 2006. Update scripts.Bruce Momjian
2006-02-03Update random() usage so ranges are inclusive/exclusive as required.Bruce Momjian
2005-12-02Remove comment on errno=0 lines, but add mention to port/strtol.c function.Bruce Momjian
2005-12-01Comment "errno = 0" in a more generic way.Bruce Momjian
2005-12-01Add comments about why errno is set to zero.Bruce Momjian
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-15Standard pgindent run for 8.1.Bruce Momjian
2005-04-06Apply the "nodeAgg" optimization to more of the builtin transitionNeil Conway
functions. This patch optimizes int2_sum(), int4_sum(), float4_accum() and float8_accum() to avoid needing to copy the transition function's state for each input tuple of the aggregate. In an extreme case (e.g. SELECT sum(int2_col) FROM table where table has a single column), it improves performance by about 20%. For more complex queries or tables with wider rows, the relative performance improvement will not be as significant.
2005-02-11Adjust input routines for float4, float8 and oid to reject the empty stringNeil Conway
as valid input (it was previously treated as 0). This input was deprecated in 8.0 (and a warning was emitted). Regression tests updated.
2004-12-31Tag appropriate files for rc3PostgreSQL Daemon
Also performed an initial run through of upgrading our Copyright date to extend to 2005 ... first run here was very simple ... change everything where: grep 1996-2004 && the word 'Copyright' ... scanned through the generated list with 'less' first, and after, to make sure that I only picked up the right entries ...
2004-10-04Detect overflow in integer arithmetic operators (integer, smallint, andTom Lane
bigint variants). Clean up some inconsistencies in error message wording. Fix scanint8 to allow trailing whitespace in INT64_MIN case. Update int8-exp-three-digits.out, which seems to have been ignored by the last couple of people to modify the int8 regression test, and remove int8-exp-three-digits-win32.out which is thereby exposed as redundant.
2004-09-02Cope with recent HPUX versions providing isfinite() instead of finite().Tom Lane
2004-08-29Pgindent run for 8.0.Bruce Momjian
2004-08-29Update copyright to 2004.Bruce Momjian
2004-08-11Work around broken strtod() that's present in many Solaris releases.Tom Lane
Thanks to Michael Fuhr for identifying the problem.
2004-08-04Label CVS tip as 8.0devel instead of 7.5devel. Adjust various commentsTom Lane
and documentation to reference 8.0 instead of 7.5.
2004-05-16Change ln(), log(), power(), and sqrt() to emit the correct SQLSTATENeil Conway
error codes for certain error conditions, as specified by SQL2003.
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.
2004-04-01Fix some portability issues with new float input code (didn't work onTom Lane
HPUX 11 ...)
2004-04-01Add missing casts to unsigned char in recently-added isspace() calls.Tom Lane
2004-03-15Localize our dependencies on the way to create NAN or INFINITY.Tom Lane
Per recent proposal to pghackers.