Commit Graph

135 Commits

Author SHA1 Message Date
Bruce Momjian 182676ae27 Some platforms set errno on pow(), exp() overflow, some do not, so if
isinf(), fall through to our own infinity checks.
2007-01-02 22:19:42 +00:00
Bruce Momjian cac2d912d9 finite() no longer used; remove finite() platform-specific
infrastructure.
2007-01-02 21:25:50 +00:00
Bruce Momjian 7bb1cc50b2 Add #include <float.h> for platforms that still need it. 2007-01-02 20:50:35 +00:00
Bruce Momjian f9ac414c35 Fix float4/8 to handle Infinity and Nan consistently, e.g. Infinity is a
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.
2007-01-02 20:00:50 +00:00
Bruce Momjian 426030eda1 Remove unnecessary parentheses in if() statements. 2006-12-23 02:13:24 +00:00
Tom Lane b2c04d5e6b Work around buggy strtod on (some versions of?) IRIX. Combination of
proposed patches from John Jorgensen and Steve Singer.
2006-10-05 01:40:45 +00:00
Bruce Momjian f99a569a2e pgindent run for 8.2. 2006-10-04 00:30:14 +00:00
Tom Lane 1249cf8f38 SQL2003-standard statistical aggregates, by Sergey Koposov. I've added only
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-28 18:33:04 +00:00
Bruce Momjian e0522505bd Remove 576 references of include files that were not needed. 2006-07-14 14:52:27 +00:00
Tom Lane ae643747b1 Fix a passel of recently-committed violations of the rule 'thou shalt
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-07-14 05:28:29 +00:00
Bruce Momjian 399a36a75d Prepare code to be built by MSVC:
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-06-07 22:24:46 +00:00
Tom Lane 332ea60d23 Improve our private implementation of cbrt() to give results of the
accuracy expected by the regression tests.  Per suggestion from
Martijn van Oosterhout.
2006-04-24 20:36:32 +00:00
Neil Conway 7992d0fbca Remove a few places that attempted to define INT_MAX, SCHAR_MAX, and
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-11 01:19:22 +00:00
Neil Conway 0ebf1cc834 Implement 4 new aggregate functions from SQL2003. Specifically: var_pop(),
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-10 20:15:28 +00:00
Bruce Momjian f2f5b05655 Update copyright for 2006. Update scripts. 2006-03-05 15:59:11 +00:00
Bruce Momjian 59bb147353 Update random() usage so ranges are inclusive/exclusive as required. 2006-02-03 12:45:47 +00:00
Bruce Momjian cf17131767 Remove comment on errno=0 lines, but add mention to port/strtol.c function. 2005-12-02 02:49:11 +00:00
Bruce Momjian 0e6b1528b7 Comment "errno = 0" in a more generic way. 2005-12-01 21:11:58 +00:00
Bruce Momjian 277b2ea328 Add comments about why errno is set to zero. 2005-12-01 20:06:37 +00:00
Tom Lane cecb607559 Make SQL arrays support null elements. This commit fixes the core array
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-11-17 22:14:56 +00:00
Bruce Momjian 1dc3498251 Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
Neil Conway be2f825d51 Apply the "nodeAgg" optimization to more of the builtin transition
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-04-06 23:56:07 +00:00
Neil Conway 975e27377a Adjust input routines for float4, float8 and oid to reject the empty string
as valid input (it was previously treated as 0). This input was deprecated
in 8.0 (and a warning was emitted). Regression tests updated.
2005-02-11 04:09:05 +00:00
PostgreSQL Daemon 2ff501590b Tag appropriate files for rc3
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-12-31 22:04:05 +00:00
Tom Lane 4171bb869f Detect overflow in integer arithmetic operators (integer, smallint, and
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-10-04 14:42:48 +00:00
Tom Lane 3cd16475db Cope with recent HPUX versions providing isfinite() instead of finite(). 2004-09-02 17:12:50 +00:00
Bruce Momjian b6b71b85bc Pgindent run for 8.0. 2004-08-29 05:07:03 +00:00
Bruce Momjian da9a8649d8 Update copyright to 2004. 2004-08-29 04:13:13 +00:00
Tom Lane b2d9fbeef2 Work around broken strtod() that's present in many Solaris releases.
Thanks to Michael Fuhr for identifying the problem.
2004-08-11 17:20:50 +00:00
Tom Lane fcbc438727 Label CVS tip as 8.0devel instead of 7.5devel. Adjust various comments
and documentation to reference 8.0 instead of 7.5.
2004-08-04 21:34:35 +00:00
Neil Conway 2871f60f23 Change ln(), log(), power(), and sqrt() to emit the correct SQLSTATE
error codes for certain error conditions, as specified by SQL2003.
2004-05-16 23:18:55 +00:00
Tom Lane 0bd61548ab Solve the 'Turkish problem' with undesirable locale behavior for case
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-05-07 00:24:59 +00:00
Tom Lane eeaef25ad6 Fix some portability issues with new float input code (didn't work on
HPUX 11 ...)
2004-04-01 23:52:18 +00:00
Tom Lane b3fcc816ae Add missing casts to unsigned char in recently-added isspace() calls. 2004-04-01 22:51:31 +00:00
Tom Lane 1bc2d544b9 Localize our dependencies on the way to create NAN or INFINITY.
Per recent proposal to pghackers.
2004-03-15 03:29:22 +00:00
Neil Conway 80ac9b06ac Portability fixes and bug fixes for recent floating point input changes.
In particular, don't depend on strtod() to accept 'NaN' and 'Infinity'
inputs (while this is required by C99, not all platforms are compliant
with that yet). Also, don't require glibc's behavior from isinf():
it seems that on a lot of platforms isinf() does not itself distinguish
between negative and positive infinity.
2004-03-14 05:22:52 +00:00
Neil Conway bfd6f52b0e Allow 'Infinity' and '-Infinity' as input to the float4 and float8
types. Update the regression tests and the documentation to reflect
this. Remove the UNSAFE_FLOATS #ifdef.

This is only half the story: we still unconditionally reject
floating point operations that result in +/- infinity. See
recent thread on -hackers for more information.
2004-03-12 00:25:43 +00:00
Neil Conway e2ded829f6 Revise int2/int4/int8/float4/float8 input routines to allow for
any amount of leading or trailing whitespace (where "whitespace"
is defined by isspace()). This is for SQL conformance, as well
as consistency with other numeric types (e.g. oid, numeric).

Also refactor pg_atoi() to avoid looking at errno where not
necessary, and add a bunch of regression tests for the input
to these types.
2004-03-11 02:11:14 +00:00
Neil Conway 2146bfc869 Emit a warning when an empty string is input to the oid, float4, and
float8 types. This begins the deprecation of this feature: in 7.6,
this input will be rejected.

Also added a new error code for warnings about deprecated features,
and updated the regression tests.
2004-03-04 21:47:18 +00:00
PostgreSQL Daemon 969685ad44 $Header: -> $PostgreSQL Changes ... 2003-11-29 19:52:15 +00:00
Tom Lane fa5c8a055a Cross-data-type comparisons are now indexable by btrees, pursuant to my
pghackers proposal of 8-Nov.  All the existing cross-type comparison
operators (int2/int4/int8 and float4/float8) have appropriate support.
The original proposal of storing the right-hand-side datatype as part of
the primary key for pg_amop and pg_amproc got modified a bit in the event;
it is easier to store zero as the 'default' case and only store a nonzero
when the operator is actually cross-type.  Along the way, remove the
long-since-defunct bigbox_ops operator class.
2003-11-12 21:15:59 +00:00
Peter Eisentraut feb4f44d29 Message editing: remove gratuitous variations in message wording, standardize
terms, add some clarifications, fix some untranslatable attempts at dynamic
message building.
2003-09-25 06:58:07 +00:00
Bruce Momjian f3c3deb7d0 Update copyrights to 2003. 2003-08-04 02:40:20 +00:00
Bruce Momjian 089003fb46 pgindent run. 2003-08-04 00:43:34 +00:00
Tom Lane 4b1c6695f1 Fix numeric_smaller, numeric_larger, float4smaller, float4larger,
float8smaller, float8larger (and thereby the MIN/MAX aggregates on these
datatypes) to agree with the datatypes' comparison operations as
regards NaN handling.  In all these datatypes, NaN is arbitrarily
considered larger than any normal value ... but MIN/MAX had not gotten
the word.  Per recent discussion on pgsql-sql.
2003-07-30 19:48:41 +00:00
Tom Lane b6a1d25b0a Error message editing in utils/adt. Again thanks to Joe Conway for doing
the bulk of the heavy lifting ...
2003-07-27 04:53:12 +00:00
Bruce Momjian bb9f84aad7 Remove comment that cbrt() isn't being used. 2003-05-26 00:55:25 +00:00
Bruce Momjian 310049a19b Clean up our static cbrt() implementation in float.c. 2003-05-25 05:30:57 +00:00
Tom Lane b1ee615a7f COPY BINARY uses the new binary I/O routines. Update a few more datatypes
so that COPY BINARY regression test passes.
2003-05-09 21:19:50 +00:00
Bruce Momjian 3afb84cd0f Remove another old rint() replacement. 2003-05-09 16:31:24 +00:00