Skip to content
Snippets Groups Projects
  1. Jul 28, 2016
  2. Jul 26, 2016
    • Tom Lane's avatar
      Fix constant-folding of ROW(...) IS [NOT] NULL with composite fields. · bcdd8a19
      Tom Lane authored
      The SQL standard appears to specify that IS [NOT] NULL's tests of field
      nullness are non-recursive, ie, we shouldn't consider that a composite
      field with value ROW(NULL,NULL) is null for this purpose.
      ExecEvalNullTest got this right, but eval_const_expressions did not,
      leading to weird inconsistencies depending on whether the expression
      was such that the planner could apply constant folding.
      
      Also, adjust the docs to mention that IS [NOT] DISTINCT FROM NULL can be
      used as a substitute test if a simple null check is wanted for a rowtype
      argument.  That motivated reordering things so that IS [NOT] DISTINCT FROM
      is described before IS [NOT] NULL.  In HEAD, I went a bit further and added
      a table showing all the comparison-related predicates.
      
      Per bug #14235.  Back-patch to all supported branches, since it's certainly
      undesirable that constant-folding should change the semantics.
      
      Report and patch by Andrew Gierth; assorted wordsmithing and revised
      regression test cases by me.
      
      Report: <20160708024746.1410.57282@wrigleys.postgresql.org>
      bcdd8a19
  3. Jul 24, 2016
  4. Jul 21, 2016
    • Tom Lane's avatar
      Make contrib regression tests safe for Danish locale. · a1e75055
      Tom Lane authored
      In btree_gin and citext, avoid some not-particularly-interesting
      dependencies on the sorting of 'aa'.  In tsearch2, use COLLATE "C" to
      remove an uninteresting dependency on locale sort order (and thereby
      allow removal of a variant expected-file).
      
      Also, in citext, avoid assuming that lower('I') = 'i'.  This isn't relevant
      to Danish but it does fail in Turkish.
      a1e75055
    • Tom Lane's avatar
      Make pltcl regression tests safe for Danish locale. · 52502e7a
      Tom Lane authored
      Another peculiarity of Danish locale is that it has an unusual idea
      of how to sort upper vs. lower case.  One of the pltcl test cases has
      an issue with that.  Now that COLLATE works in all supported branches,
      we can just change the test to be locale-independent, and get rid of
      the variant expected file that used to support non-C locales.
      52502e7a
  5. Jul 19, 2016
    • Tom Lane's avatar
      Fix MSVC build for changes in zic. · 4d37b7cf
      Tom Lane authored
      Ooops, I missed back-patching commit f5f15ea6 along with the other stuff.
      4d37b7cf
    • Tom Lane's avatar
      Sync back-branch copies of the timezone code with IANA release tzcode2016c. · cd951aa6
      Tom Lane authored
      Back-patch commit 1c1a7cbd, along with subsequent portability
      fixes, into all active branches.  Also, back-patch commits 69602772 and
      59685704 (addition of zic -P option) into 9.1 and 9.2, just to reduce
      differences between the branches.  src/timezone/ is now largely identical
      in all active branches, except that in 9.1, pgtz.c retains the
      initial-timezone-selection code that was moved over to initdb in 9.2.
      
      Ordinarily we wouldn't risk this much code churn in back branches, but it
      seems necessary in this case, because among the changes are two feature
      additions in the "zic" zone data file compiler (a larger limit on the
      number of allowed DST transitions, and addition of a "%z" escape in zone
      abbreviations).  IANA have not yet started to use those features in their
      tzdata files, but presumably they will before too long.  If we don't update
      then we'll be unable to adopt new timezone data.  Also, installations built
      with --with-system-tzdata (which includes most distro-supplied builds, I
      believe) might fail even if we don't update our copies of the data files.
      There are assorted bug fixes too, mostly affecting obscure timezones or
      post-2037 dates.
      
      Discussion: <13601.1468868947@sss.pgh.pa.us>
      cd951aa6
  6. Jul 17, 2016
    • Peter Eisentraut's avatar
      Use correct symbol for minimum int64 value · 6c0be49b
      Peter Eisentraut authored
      The old code used SEQ_MINVALUE to get the smallest int64 value.  This
      was done as a convenience to avoid having to deal with INT64_IS_BUSTED,
      but that is obsolete now.  Also, it is incorrect because the smallest
      int64 value is actually SEQ_MINVALUE-1.  Fix by writing out the constant
      the long way, as it is done elsewhere in the code.
      6c0be49b
  7. Jul 16, 2016
    • Tom Lane's avatar
      Fix crash in close_ps() for NaN input coordinates. · 89b30110
      Tom Lane authored
      The Assert() here seems unreasonably optimistic.  Andreas Seltenreich
      found that it could fail with NaNs in the input geometries, and it
      seems likely to me that it might fail in corner cases due to roundoff
      error, even for ordinary input values.  As a band-aid, make the function
      return SQL NULL instead of crashing.
      
      Report: <87d1md1xji.fsf@credativ.de>
      89b30110
    • Andres Freund's avatar
      Fix torn-page, unlogged xid and further risks from heap_update(). · 941557f1
      Andres Freund authored
      When heap_update needs to look for a page for the new tuple version,
      because the current one doesn't have sufficient free space, or when
      columns have to be processed by the tuple toaster, it has to release the
      lock on the old page during that. Otherwise there'd be lock ordering and
      lock nesting issues.
      
      To avoid concurrent sessions from trying to update / delete / lock the
      tuple while the page's content lock is released, the tuple's xmax is set
      to the current session's xid.
      
      That unfortunately was done without any WAL logging, thereby violating
      the rule that no XIDs may appear on disk, without an according WAL
      record.  If the database were to crash / fail over when the page level
      lock is released, and some activity lead to the page being written out
      to disk, the xid could end up being reused; potentially leading to the
      row becoming invisible.
      
      There might be additional risks by not having t_ctid point at the tuple
      itself, without having set the appropriate lock infomask fields.
      
      To fix, compute the appropriate xmax/infomask combination for locking
      the tuple, and perform WAL logging using the existing XLOG_HEAP_LOCK
      record. That allows the fix to be backpatched.
      
      This issue has existed for a long time. There appears to have been
      partial attempts at preventing dangers, but these never have fully been
      implemented, and were removed a long time ago, in
      11919160 (cf. HEAP_XMAX_UNLOGGED).
      
      In master / 9.6, there's an additional issue, namely that the
      visibilitymap's freeze bit isn't reset at that point yet. Since that's a
      new issue, introduced only in a892234f, that'll be fixed in a
      separate commit.
      
      Author: Masahiko Sawada and Andres Freund
      Reported-By: Different aspects by Thomas Munro, Noah Misch, and others
      Discussion: CAEepm=3fWAbWryVW9swHyLTY4sXVf0xbLvXqOwUoDiNCx9mBjQ@mail.gmail.com
      Backpatch: 9.1/all supported versions
      941557f1
  8. Jul 15, 2016
    • Peter Eisentraut's avatar
      doc: Fix typos · 544ea9d7
      Peter Eisentraut authored
      From: Alexander Law <exclusion@gmail.com>
      544ea9d7
    • Tom Lane's avatar
      Fix GiST index build for NaN values in geometric types. · 042009f2
      Tom Lane authored
      GiST index build could go into an infinite loop when presented with boxes
      (or points, circles or polygons) containing NaN component values.  This
      happened essentially because the code assumed that x == x is true for any
      "double" value x; but it's not true for NaNs.  The looping behavior was not
      the only problem though: we also attempted to sort the items using simple
      double comparisons.  Since NaNs violate the trichotomy law, qsort could
      (in principle at least) get arbitrarily confused and mess up the sorting of
      ordinary values as well as NaNs.  And we based splitting choices on box size
      calculations that could produce NaNs, again resulting in undesirable
      behavior.
      
      To fix, replace all comparisons of doubles in this logic with
      float8_cmp_internal, which is NaN-aware and is careful to sort NaNs
      consistently, higher than any non-NaN.  Also rearrange the box size
      calculation to not produce NaNs; instead it should produce an infinity
      for a box with NaN on one side and not-NaN on the other.
      
      I don't by any means claim that this solves all problems with NaNs in
      geometric values, but it should at least make GiST index insertion work
      reliably with such data.  It's likely that the index search side of things
      still needs some work, and probably regular geometric operations too.
      But with this patch we're laying down a convention for how such cases
      ought to behave.
      
      Per bug #14238 from Guang-Dih Lei.  Back-patch to 9.2; the code used before
      commit 7f3bd868 is quite different and doesn't lock up on my simple
      test case, nor on the submitter's dataset.
      
      Report: <20160708151747.1426.60150@wrigleys.postgresql.org>
      Discussion: <28685.1468246504@sss.pgh.pa.us>
      042009f2
  9. Jul 11, 2016
  10. Jul 02, 2016
    • Bruce Momjian's avatar
      doc: mention dependency on collation libraries · cfb33bc3
      Bruce Momjian authored
      Document that index storage is dependent on the operating system's
      collation library ordering, and any change in that ordering can create
      invalid indexes.
      
      Discussion: 20160617154311.GB19359@momjian.us
      
      Backpatch-through: 9.1
      cfb33bc3
  11. Jun 22, 2016
    • Tom Lane's avatar
      Make "postgres -C guc" print "" not "(null)" for null-valued GUCs. · dd41661d
      Tom Lane authored
      Commit 0b0baf26 et al made this case print "(null)" on the grounds that
      that's what happened on platforms that didn't crash.  But neither behavior
      was actually intentional.  What we should print is just an empty string,
      for compatibility with the behavior of SHOW and other ways of examining
      string GUCs.  Those code paths don't distinguish NULL from empty strings,
      so we should not here either.  Per gripe from Alain Radix.
      
      Like the previous patch, back-patch to 9.2 where -C option was introduced.
      
      Discussion: <CA+YdpwxPUADrmxSD7+Td=uOshMB1KkDN7G7cf+FGmNjjxMhjbw@mail.gmail.com>
      dd41661d
    • Tom Lane's avatar
      Document that dependency tracking doesn't consider function bodies. · 85743887
      Tom Lane authored
      If there's anyplace in our SGML docs that explains this behavior, I can't
      find it right at the moment.  Add an explanation in "Dependency Tracking"
      which seems like the authoritative place for such a discussion.  Per
      gripe from Michelle Schwan.
      
      While at it, update this section's example of a dependency-related
      error message: they last looked like that in 8.3.  And remove the
      explanation of dependency updates from pre-7.3 installations, which
      is probably no longer worth anybody's brain cells to read.
      
      The bogus error message example seems like an actual documentation bug,
      so back-patch to all supported branches.
      
      Discussion: <20160620160047.5792.49827@wrigleys.postgresql.org>
      85743887
  12. Jun 19, 2016
    • Tom Lane's avatar
      Docs: improve description of psql's %R prompt escape sequence. · 09e592b3
      Tom Lane authored
      Dilian Palauzov pointed out in bug #14201 that the docs failed to mention
      the possibility of %R producing '(' due to an unmatched parenthesis.
      
      He proposed just adding that in the same style as the other options were
      listed; but it seemed to me that the sentence was already nearly
      unintelligible, so I rewrote it a bit more extensively.
      
      Report: <20160619121113.5789.68274@wrigleys.postgresql.org>
      09e592b3
  13. Jun 16, 2016
    • Tom Lane's avatar
      Fix validation of overly-long IPv6 addresses. · f66e0fec
      Tom Lane authored
      The inet/cidr types sometimes failed to reject IPv6 inputs with too many
      colon-separated fields, instead translating them to '::/0'.  This is the
      result of a thinko in the original ISC code that seems to be as yet
      unreported elsewhere.  Per bug #14198 from Stefan Kaltenbrunner.
      
      Report: <20160616182222.5798.959@wrigleys.postgresql.org>
      f66e0fec
    • Tom Lane's avatar
      Avoid crash in "postgres -C guc" for a GUC with a null string value. · 23ed284a
      Tom Lane authored
      Emit "(null)" instead, which was the behavior all along on platforms
      that don't crash, eg OS X.  Per report from Jehan-Guillaume de Rorthais.
      Back-patch to 9.2 where -C option was introduced.
      
      Michael Paquier
      
      Report: <20160615204036.2d35d86a@firost>
      23ed284a
  14. Jun 13, 2016
    • Tom Lane's avatar
      Fix multiple minor infelicities in aclchk.c error reports. · cd05539e
      Tom Lane authored
      pg_type_aclmask reported the wrong type's OID when complaining that
      it could not find a type's typelem.  It also failed to provide a
      suitable errcode when the initially given OID doesn't exist (which
      is a user-facing error, since that OID can be user-specified).
      pg_foreign_data_wrapper_aclmask and pg_foreign_server_aclmask likewise
      lacked errcode specifications.  Trivial cosmetic adjustments too.
      
      The wrong-type-OID problem was reported by Petru-Florin Mihancea in
      bug #14186; the other issues noted by me while reading the code.
      These errors all seem to be aboriginal in the respective routines, so
      back-patch as necessary.
      
      Report: <20160613163159.5798.52928@wrigleys.postgresql.org>
      cd05539e
  15. Jun 09, 2016
    • Tom Lane's avatar
      Clarify documentation of ceil/ceiling/floor functions. · a36c8219
      Tom Lane authored
      Document these as "nearest integer >= argument" and "nearest integer <=
      argument", which will hopefully be less confusing than the old formulation.
      New wording is from Matlab via Dean Rasheed.
      
      I changed the pg_description entries as well as the SGML docs.  In the
      back branches, this will only affect installations initdb'd in the future,
      but it should be harmless otherwise.
      
      Discussion: <CAEZATCW3yzJo-NMSiQs5jXNFbTsCEftZS-Og8=FvFdiU+kYuSA@mail.gmail.com>
      a36c8219
  16. Jun 08, 2016
    • Alvaro Herrera's avatar
      nls-global.mk: search build dir for source files, too · 3dcdf980
      Alvaro Herrera authored
      In VPATH builds, the build directory was not being searched for files in
      GETTEXT_FILES, leading to failure to construct the .pot files.  This has
      bit me all along, but never hard enough to get it fixed; I suppose not a
      lot of people uses VPATH and NLS-enabled builds, and those that do,
      don't do "make update-po" often.
      
      This is a longstanding problem, so backpatch all the way back.
      3dcdf980
  17. Jun 06, 2016
    • Tom Lane's avatar
      Don't reset changes_since_analyze after a selective-columns ANALYZE. · 3201709d
      Tom Lane authored
      If we ANALYZE only selected columns of a table, we should not postpone
      auto-analyze because of that; other columns may well still need stats
      updates.  As committed, the counter is left alone if a column list is
      given, whether or not it includes all analyzable columns of the table.
      Per complaint from Tomasz Ostrowski.
      
      It's been like this a long time, so back-patch to all supported branches.
      
      Report: <ef99c1bd-ff60-5f32-2733-c7b504eb960c@ato.waw.pl>
      3201709d
  18. May 26, 2016
    • Alvaro Herrera's avatar
      Avoid hot standby cancels from VAC FREEZE · 294509ea
      Alvaro Herrera authored
      VACUUM FREEZE generated false cancelations of standby queries on an
      otherwise idle master. Caused by an off-by-one error on cutoff_xid
      which goes back to original commit.
      
      Analysis and report by Marco Nenciarini
      
      Bug fix by Simon Riggs
      
      This is a correct backpatch of commit 66fbcb0d to branches 9.1 through
      9.4.  That commit was backpatched to 9.0 originally, but it was
      immediately reverted in 9.0-9.4 because it didn't compile.
      294509ea
  19. May 24, 2016
    • Tom Lane's avatar
      Fetch XIDs atomically during vac_truncate_clog(). · 4cf0978e
      Tom Lane authored
      Because vac_update_datfrozenxid() updates datfrozenxid and datminmxid
      in-place, it's unsafe to assume that successive reads of those values will
      give consistent results.  Fetch each one just once to ensure sane behavior
      in the minimum calculation.  Noted while reviewing Alexander Korotkov's
      patch in the same area.
      
      Discussion: <8564.1464116473@sss.pgh.pa.us>
      4cf0978e
    • Tom Lane's avatar
      Avoid consuming an XID during vac_truncate_clog(). · 2e7f0c34
      Tom Lane authored
      vac_truncate_clog() uses its own transaction ID as the comparison point in
      a sanity check that no database's datfrozenxid has already wrapped around
      "into the future".  That was probably fine when written, but in a lazy
      vacuum we won't have assigned an XID, so calling GetCurrentTransactionId()
      causes an XID to be assigned when otherwise one would not be.  Most of the
      time that's not a big problem ... but if we are hard up against the
      wraparound limit, consuming XIDs during antiwraparound vacuums is a very
      bad thing.
      
      Instead, use ReadNewTransactionId(), which not only avoids this problem
      but is in itself a better comparison point to test whether wraparound
      has already occurred.
      
      Report and patch by Alexander Korotkov.  Back-patch to all versions.
      
      Report: <CAPpHfdspOkmiQsxh-UZw2chM6dRMwXAJGEmmbmqYR=yvM7-s6A@mail.gmail.com>
      2e7f0c34
  20. May 23, 2016
    • Tom Lane's avatar
      Fix latent crash in do_text_output_multiline(). · fca2eb3d
      Tom Lane authored
      do_text_output_multiline() would fail (typically with a null pointer
      dereference crash) if its input string did not end with a newline.  Such
      cases do not arise in our current sources; but it certainly could happen
      in future, or in extension code's usage of the function, so we should fix
      it.  To fix, replace "eol += len" with "eol = text + len".
      
      While at it, make two cosmetic improvements: mark the input string const,
      and rename the argument from "text" to "txt" to dodge pgindent strangeness
      (since "text" is a typedef name).
      
      Even though this problem is only latent at present, it seems like a good
      idea to back-patch the fix, since it's a very simple/safe patch and it's
      not out of the realm of possibility that we might in future back-patch
      something that expects sane behavior from do_text_output_multiline().
      
      Per report from Hao Lee.
      
      Report: <CAGoxFiFPAGyPAJLcFxTB5cGhTW2yOVBDYeqDugYwV4dEd1L_Ag@mail.gmail.com>
      fca2eb3d
  21. May 20, 2016
  22. May 14, 2016
  23. May 13, 2016
    • Tom Lane's avatar
      Ensure plan stability in contrib/btree_gist regression test. · b15ab18e
      Tom Lane authored
      Buildfarm member skink failed with symptoms suggesting that an
      auto-analyze had happened and changed the plan displayed for a
      test query.  Although this is evidently of low probability,
      regression tests that sometimes fail are no fun, so add commands
      to force a bitmap scan to be chosen.
      b15ab18e
  24. May 10, 2016
  25. May 09, 2016
  26. May 07, 2016
    • Tom Lane's avatar
      fded7669
    • Peter Eisentraut's avatar
      Distrust external OpenSSL clients; clear err queue · e3a493ac
      Peter Eisentraut authored
      OpenSSL has an unfortunate tendency to mix per-session state error
      handling with per-thread error handling.  This can cause problems when
      programs that link to libpq with OpenSSL enabled have some other use of
      OpenSSL; without care, one caller of OpenSSL may cause problems for the
      other caller.  Backend code might similarly be affected, for example
      when a third party extension independently uses OpenSSL without taking
      the appropriate precautions.
      
      To fix, don't trust other users of OpenSSL to clear the per-thread error
      queue.  Instead, clear the entire per-thread queue ahead of certain I/O
      operations when it appears that there might be trouble (these I/O
      operations mostly need to call SSL_get_error() to check for success,
      which relies on the queue being empty).  This is slightly aggressive,
      but it's pretty clear that the other callers have a very dubious claim
      to ownership of the per-thread queue.  Do this is both frontend and
      backend code.
      
      Finally, be more careful about clearing our own error queue, so as to
      not cause these problems ourself.  It's possibly that control previously
      did not always reach SSLerrmessage(), where ERR_get_error() was supposed
      to be called to clear the queue's earliest code.  Make sure
      ERR_get_error() is always called, so as to spare other users of OpenSSL
      the possibility of similar problems caused by libpq (as opposed to
      problems caused by a third party OpenSSL library like PHP's OpenSSL
      extension).  Again, do this is both frontend and backend code.
      
      See bug #12799 and https://bugs.php.net/bug.php?id=68276
      
      Based on patches by Dave Vitek and Peter Eisentraut.
      
      From: Peter Geoghegan <pg@bowt.ie>
      e3a493ac
  27. May 06, 2016
    • Tom Lane's avatar
      Fix possible read past end of string in to_timestamp(). · 11247dd9
      Tom Lane authored
      to_timestamp() handles the TH/th format codes by advancing over two input
      characters, whatever those are.  It failed to notice whether there were
      two characters available to be skipped, making it possible to advance
      the pointer past the end of the input string and keep on parsing.
      A similar risk existed in the handling of "Y,YYY" format: it would advance
      over three characters after the "," whether or not three characters were
      available.
      
      In principle this might be exploitable to disclose contents of server
      memory.  But the security team concluded that it would be very hard to use
      that way, because the parsing loop would stop upon hitting any zero byte,
      and TH/th format codes can't be consecutive --- they have to follow some
      other format code, which would have to match whatever data is there.
      So it seems impractical to examine memory very much beyond the end of the
      input string via this bug; and the input string will always be in local
      memory not in disk buffers, making it unlikely that anything very
      interesting is close to it in a predictable way.  So this doesn't quite
      rise to the level of needing a CVE.
      
      Thanks to Wolf Roediger for reporting this bug.
      11247dd9
    • Tom Lane's avatar
      Update time zone data files to tzdata release 2016d. · 29d154e3
      Tom Lane authored
      DST law changes in Russia (Magadan, Tomsk regions) and Venezuela.
      Historical corrections for Russia.  There are new zone names Europe/Kirov
      and Asia/Tomsk reflecting the fact that these regions now have different
      time zone histories from adjacent regions.
      29d154e3
  28. May 04, 2016
Loading