Skip to content
Snippets Groups Projects
  1. Nov 20, 2012
    • Tom Lane's avatar
      Improve handling of INT_MIN / -1 and related cases. · 278b6059
      Tom Lane authored
      Some platforms throw an exception for this division, rather than returning
      a necessarily-overflowed result.  Since we were testing for overflow after
      the fact, an exception isn't nice.  We can avoid the problem by treating
      division by -1 as negation.
      
      Add some regression tests so that we'll find out if any compilers try to
      optimize away the overflow check conditions.
      
      Back-patch of commit 1f7cb5c3.
      
      Per discussion with Xi Wang, though this is different from the patch he
      submitted.
      278b6059
  2. Nov 14, 2012
    • Tom Lane's avatar
      Fix the int8 and int2 cases of (minimum possible integer) % (-1). · 3b4db79e
      Tom Lane authored
      The correct answer for this (or any other case with arg2 = -1) is zero,
      but some machines throw a floating-point exception instead of behaving
      sanely.  Commit f9ac414c dealt with this
      in int4mod, but overlooked the fact that it also happens in int8mod
      (at least on my Linux x86_64 machine).  Protect int2mod as well; it's
      not clear whether any machines fail there (mine does not) but since the
      test is so cheap it seems better safe than sorry.  While at it, simplify
      the original guard in int4mod: we need only check for arg2 == -1, we
      don't need to check arg1 explicitly.
      
      Xi Wang, with some editing by me.
      3b4db79e
  3. Jan 02, 2012
  4. Sep 04, 2011
    • Tom Lane's avatar
      Clean up the #include mess a little. · 1609797c
      Tom Lane authored
      walsender.h should depend on xlog.h, not vice versa.  (Actually, the
      inclusion was circular until a couple hours ago, which was even sillier;
      but Bruce broke it in the expedient rather than logically correct
      direction.)  Because of that poor decision, plus blind application of
      pgrminclude, we had a situation where half the system was depending on
      xlog.h to include such unrelated stuff as array.h and guc.h.  Clean up
      the header inclusion, and manually revert a lot of what pgrminclude had
      done so things build again.
      
      This episode reinforces my feeling that pgrminclude should not be run
      without adult supervision.  Inclusion changes in header files in particular
      need to be reviewed with great care.  More generally, it'd be good if we
      had a clearer notion of module layering to dictate which headers can sanely
      include which others ... but that's a big task for another day.
      1609797c
  5. Sep 01, 2011
  6. Jun 17, 2011
  7. Apr 13, 2011
    • Tom Lane's avatar
      Pass collations to functions in FunctionCallInfoData, not FmgrInfo. · d64713df
      Tom Lane authored
      Since collation is effectively an argument, not a property of the function,
      FmgrInfo is really the wrong place for it; and this becomes critical in
      cases where a cached FmgrInfo is used for varying purposes that might need
      different collation settings.  Fix by passing it in FunctionCallInfoData
      instead.  In particular this allows a clean fix for bug #5970 (record_cmp
      not working).  This requires touching a bit more code than the original
      method, but nobody ever thought that collations would not be an invasive
      patch...
      d64713df
  8. Mar 12, 2011
  9. Jan 01, 2011
  10. Sep 20, 2010
  11. Feb 26, 2010
  12. Jan 02, 2010
  13. Dec 30, 2009
    • Robert Haas's avatar
      Reject invalid input in int2vectorin. · 3d4b0ab2
      Robert Haas authored
      Since the int2vector type is intended only for internal use, this patch doesn't
      worry about prettifying the error messages, which has the fringe benefit of
      avoiding creating additional translatable strings.  For a type intended to be
      used by end-users, we would want to do better, but the approach taken here
      seems like the correct trade-off for this case.
      
      Caleb Welton
      3d4b0ab2
  14. Sep 04, 2009
  15. Sep 03, 2009
    • Tom Lane's avatar
      Install a workaround for a longstanding gcc bug that allows SIGFPE traps · d0a368c6
      Tom Lane authored
      to occur for division by zero, even though the code is carefully avoiding
      that.  All available evidence is that the only functions affected are
      int24div, int48div, and int28div, so patch just those three functions to
      include a "return" after the ereport() call.
      
      Backpatch to 8.4 so that the fix can be tested in production builds.
      For older branches our recommendation will continue to be to use -O1
      on affected platforms (which are mostly non-mainstream anyway).
      d0a368c6
  16. Jan 01, 2009
  17. Oct 06, 2008
    • Tom Lane's avatar
      Tweak the overflow checks in integer division functions to complain if the · 8acfc759
      Tom Lane authored
      machine produces zero (rather than the more usual minimum-possible-integer)
      for the only possible overflow case.  This has been seen to occur for at least
      some word widths on some hardware, and it's cheap enough to check for
      everywhere.  Per Peter's analysis of buildfarm reports.
      
      This could be back-patched, but in the absence of any gripes from the field
      I doubt it's worth the trouble.
      8acfc759
  18. Jun 17, 2008
    • Tom Lane's avatar
      Clean up some problems with redundant cross-type arithmetic operators. Add · b163baa8
      Tom Lane authored
      int2-and-int8 implementations of the basic arithmetic operators +, -, *, /.
      This doesn't really add any new functionality, but it avoids "operator is not
      unique" failures that formerly occurred in these cases because the parser
      couldn't decide whether to promote the int2 to int4 or int8.  We could
      alternatively have removed the existing cross-type operators, but
      experimentation shows that the cost of an additional type coercion expression
      node is noticeable compared to such cheap operators; so let's not give up any
      performance here.  On the other hand, I removed the int2-and-int4 modulo (%)
      operators since they didn't seem as important from a performance standpoint.
      Per a complaint last January from ykhuang.
      b163baa8
  19. Jan 01, 2008
  20. Jun 05, 2007
    • Tom Lane's avatar
      Downgrade implicit casts to text to be assignment-only, except for the ones · 31edbadf
      Tom Lane authored
      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
      31edbadf
  21. Feb 28, 2007
    • Tom Lane's avatar
      Replace direct assignments to VARATT_SIZEP(x) with SET_VARSIZE(x, len). · 234a02b2
      Tom Lane authored
      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
      234a02b2
  22. Feb 01, 2007
    • Bruce Momjian's avatar
      Wording cleanup for error messages. Also change can't -> cannot. · 8b4ff8b6
      Bruce Momjian authored
      Standard English uses "may", "can", and "might" in different ways:
      
              may - permission, "You may borrow my rake."
      
              can - ability, "I can lift that log."
      
              might - possibility, "It might rain today."
      
      Unfortunately, in conversational English, their use is often mixed, as
      in, "You may use this variable to do X", when in fact, "can" is a better
      choice.  Similarly, "It may crash" is better stated, "It might crash".
      8b4ff8b6
  23. Jan 05, 2007
  24. Jan 02, 2007
    • Bruce Momjian's avatar
      Fix float4/8 to handle Infinity and Nan consistently, e.g. Infinity is a · f9ac414c
      Bruce Momjian authored
      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.
      f9ac414c
  25. Oct 04, 2006
  26. Jun 12, 2006
  27. Mar 11, 2006
  28. Mar 05, 2006
  29. Mar 02, 2006
  30. Nov 17, 2005
    • Tom Lane's avatar
      Make SQL arrays support null elements. This commit fixes the core array · cecb6075
      Tom Lane authored
      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.
      cecb6075
  31. Oct 15, 2005
  32. Jul 10, 2005
  33. Mar 29, 2005
    • Tom Lane's avatar
      Convert oidvector and int2vector into variable-length arrays. This · 70c9763d
      Tom Lane authored
      change saves a great deal of space in pg_proc and its primary index,
      and it eliminates the former requirement that INDEX_MAX_KEYS and
      FUNC_MAX_ARGS have the same value.  INDEX_MAX_KEYS is still embedded
      in the on-disk representation (because it affects index tuple header
      size), but FUNC_MAX_ARGS is not.  I believe it would now be possible
      to increase FUNC_MAX_ARGS at little cost, but haven't experimented yet.
      There are still a lot of vestigial references to FUNC_MAX_ARGS, which
      I will clean up in a separate pass.  However, getting rid of it
      altogether would require changing the FunctionCallInfoData struct,
      and I'm not sure I want to buy into that.
      70c9763d
  34. Feb 27, 2005
  35. Dec 31, 2004
    • PostgreSQL Daemon's avatar
      · 2ff50159
      PostgreSQL Daemon authored
      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 ...
      2ff50159
  36. Oct 04, 2004
    • Tom Lane's avatar
      Detect overflow in integer arithmetic operators (integer, smallint, and · 4171bb86
      Tom Lane authored
      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.
      4171bb86
  37. Aug 29, 2004
  38. Feb 03, 2004
    • Joe Conway's avatar
      Add function (actually an int4 and an int8 version) that generates · 12661642
      Joe Conway authored
      a series of numbers, optionally using an explicit step size other
      than the default value (one). Use function in the information_schema
      to replace hard-wired knowledge of INDEX_MAX_KEYS. initdb forced due
      to pg_proc change. Documentation update still needed -- will be
      committed separately.
      12661642
Loading