1. 06 May, 2016 9 commits
    • Tom Lane's avatar
      Fix possible read past end of string in to_timestamp(). · d136d600
      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.
      d136d600
    • Tom Lane's avatar
      Fix pgbench's parsing of double values to notice trailing garbage. · 6b8b4e4d
      Tom Lane authored
      Noted by Fabien Coelho, though this isn't exactly his proposed patch.
      (The technique used here is borrowed from the zic sources.)
      6b8b4e4d
    • Tom Lane's avatar
      Improve handling of numeric-valued variables in pgbench. · 95152994
      Tom Lane authored
      The previous coding always stored variable values as strings, doing
      conversion on-the-fly when a numeric value was needed or a number was to be
      assigned.  This was a bit inefficient and risked loss of precision for
      floating-point values.  The precision aspect had been hacked around by
      printing doubles in "%.18e" format, which is ugly and has machine-dependent
      results.  Instead, arrange to preserve an assigned numeric value in the
      original binary numeric format, converting to string only when and if
      needed.  When we do need to convert a double to string, convert in "%g"
      format with DBL_DIG precision, which is the standard way to do it and
      produces the least surprising results in most cases.
      
      The implementation supports storing both a string value and a numeric
      value for any one variable, with lazy conversion between them.  I also
      arranged for lazy re-sorting of the variable array when new variables are
      added.  That was mainly to allow a clean refactoring of putVariable()
      into two levels of subroutine, but it may allow us to save a few sorts.
      
      Discussion: <9188.1462475559@sss.pgh.pa.us>
      95152994
    • Tom Lane's avatar
      Docs: fix \crosstabview example. · daa9856f
      Tom Lane authored
      This example missed being updated when we redefined \crosstabview's
      argument processing.
      
      Daniel Vérité
      daa9856f
    • Kevin Grittner's avatar
      Fix hash index vs "snapshot too old" problemms · 2cc41acd
      Kevin Grittner authored
      Hash indexes are not WAL-logged, and so do not maintain the LSN of
      index pages.  Since the "snapshot too old" feature counts on
      detecting error conditions using the LSN of a table and all indexes
      on it, this makes it impossible to safely do early vacuuming on any
      table with a hash index, so add this to the tests for whether the
      xid used to vacuum a table can be adjusted based on
      old_snapshot_threshold.
      
      While at it, add a paragraph to the docs for old_snapshot_threshold
      which specifically mentions this and other aspects of the feature
      which may otherwise surprise users.
      
      Problem reported and patch reviewed by Amit Kapila
      2cc41acd
    • Dean Rasheed's avatar
      Fix psql's \ev and \sv commands so that they handle view reloptions. · 9b66aa00
      Dean Rasheed authored
      Commit 8eb6407a added support for
      editing and showing view definitions, but neglected to account for
      view options such as security_barrier and WITH CHECK OPTION which are
      not returned by pg_get_viewdef() and so need special handling.
      
      Author: Dean Rasheed
      Reviewed-by: Peter Eisentraut
      Discussion: http://www.postgresql.org/message-id/CAEZATCWZjCgKRyM-agE0p8ax15j9uyQoF=qew7D2xB6cF76T8A@mail.gmail.com
      9b66aa00
    • Dean Rasheed's avatar
      Move and rename fmtReloptionsArray(). · 93a8c6fd
      Dean Rasheed authored
      Move fmtReloptionsArray() from pg_dump.c to string_utils.c so that it
      is available to other frontend code. In particular psql's \ev and \sv
      commands need it to handle view reloptions. Also rename the function
      to appendReloptionsArray(), which is a more accurate description of
      what it does.
      
      Author: Dean Rasheed
      Reviewed-by: Peter Eisentraut
      Discussion: http://www.postgresql.org/message-id/CAEZATCWZjCgKRyM-agE0p8ax15j9uyQoF=qew7D2xB6cF76T8A@mail.gmail.com
      93a8c6fd
    • Tom Lane's avatar
      Further 9.6 release note improvements. · 306ff0aa
      Tom Lane authored
      Call out the major enhancements in this release as identified by
      pgsql-advocacy discussion, and rearrange some of the entries to
      make those items more prominent.  Other minor improvements per
      advice from Vitaly Burovoy, Masahiko Sawada, Peter Geoghegan,
      and Andres Freund.
      306ff0aa
    • Tom Lane's avatar
      Update time zone data files to tzdata release 2016d. · 98f158e4
      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.
      98f158e4
  2. 05 May, 2016 6 commits
    • Tom Lane's avatar
      Rename tsvector delete() to ts_delete(), and filter() to ts_filter(). · 0b9a2344
      Tom Lane authored
      The similarity of the original names to SQL keywords seems like a bad
      idea.  Rename them before we're stuck with 'em forever.
      
      In passing, minor code and docs cleanup.
      
      Discussion: <4875.1462210058@sss.pgh.pa.us>
      0b9a2344
    • Tom Lane's avatar
      Small 9.6 release note improvements. · 2f38b986
      Tom Lane authored
      Sync release notes through today, and incorporate some suggestions
      from Robert Haas.
      2f38b986
    • Tom Lane's avatar
      Rename pgbench min/max to least/greatest, and fix handling of double args. · 7a622b27
      Tom Lane authored
      These functions behave like the backend's least/greatest functions,
      not like min/max, so the originally-chosen names invite confusion.
      Per discussion, rename to least/greatest.
      
      I also took it upon myself to make them return double if any input is
      double.  The previous behavior of silently coercing all inputs to int
      surely does not meet the principle of least astonishment.
      
      Copy-edit some of the other new functions' documentation, too.
      7a622b27
    • Tom Lane's avatar
      First-draft release notes for Postgres 9.6. · c311f788
      Tom Lane authored
      These are just of beta quality, but we're only at beta ... the section
      about parallel query, in particular, could doubtless use more work.
      c311f788
    • Tom Lane's avatar
      Fix ordering/categorization of some recently-added system views. · a9ba6195
      Tom Lane authored
      Somebody added pg_replication_origin, pg_replication_origin_status and
      pg_replication_slots to catalogs.sgml without a whole lot of concern for
      either alphabetical order or the difference between a table and a view.
      Clean up the mess.
      
      Back-patch to 9.5, not so much because this is critical as because if
      I don't it will result in a cross-branch divergence in release-9.5.sgml,
      which would be a maintenance hazard.
      a9ba6195
    • Dean Rasheed's avatar
      Fix corner-case loss of precision in numeric pow() calculation · 18a02ad2
      Dean Rasheed authored
      Commit 7d9a4737 greatly improved the
      accuracy of the numeric transcendental functions, however it failed to
      consider the case where the result from pow() is close to the overflow
      threshold, for example 0.12 ^ -2345.6. For such inputs, where the
      result has more than 2000 digits before the decimal point, the decimal
      result weight estimate was being clamped to 2000, leading to a loss of
      precision in the final calculation.
      
      Fix this by replacing the clamping code with an overflow test that
      aborts the calculation early if the final result is sure to overflow,
      based on the overflow limit in exp_var(). This provides the same
      protection against integer overflow in the subsequent result scale
      computation as the original clamping code, but it also ensures that
      precision is never lost and saves compute cycles in cases that are
      sure to overflow.
      
      The new early overflow test works with the initial low-precision
      result (expected to be accurate to around 8 significant digits) and
      includes a small fuzz factor to ensure that it doesn't kick in for
      values that would not overflow exp_var(), so the overall overflow
      threshold of pow() is unchanged and consistent for all inputs with
      non-integer exponents.
      
      Author: Dean Rasheed
      Reviewed-by: Tom Lane
      Discussion: http://www.postgresql.org/message-id/CAEZATCUj3U-cQj0jjoia=qgs0SjE3auroxh8swvNKvZWUqegrg@mail.gmail.com
      See-also: http://www.postgresql.org/message-id/CAEZATCV7w+8iB=07dJ8Q0zihXQT1semcQuTeK+4_rogC_zq5Hw@mail.gmail.com
      18a02ad2
  3. 04 May, 2016 5 commits
    • Alvaro Herrera's avatar
      Revert timeline following in replication slots · c1543a81
      Alvaro Herrera authored
      This reverts commits f07d18b6, 82c83b33, 3a3b3090, and
      24c5f1a1.
      
      This feature has shown enough immaturity that it was deemed better to
      rip it out before rushing some more fixes at the last minute.  There are
      discussions on larger changes in this area for the next release.
      c1543a81
    • Peter Eisentraut's avatar
      doc: Fix more typos · 6535bf39
      Peter Eisentraut authored
      From: Alexander Law <exclusion@gmail.com>
      6535bf39
    • Teodor Sigaev's avatar
      Fix crash of filter(tsvector) · 4bbc1a7e
      Teodor Sigaev authored
      Variable storing a position of lexeme, had a wrong type: char, it's
      obviously not enough to store 2^14 possible positions.
      
      Stas Kelvich
      4bbc1a7e
    • Andres Freund's avatar
      Fix transient mdsync() errors of truncated relations due to 72a98a63. · a7124870
      Andres Freund authored
      Unfortunately the segment size checks from 72a98a63 had the negative
      side-effect of breaking a corner case in mdsync(): When processing a
      fsync request for a truncated away segment mdsync() could fail with
      "could not fsync file" (if previous segment < RELSEG_SIZE) because
      _mdfd_getseg() now wouldn't return the relevant segment anymore.
      
      The cleanest fix seems to be to allow the caller of _mdfd_getseg() to
      specify whether checks for RELSEG_SIZE are performed. To allow doing so,
      change the ExtensionBehavior enum into a bitmask. Besides allowing for
      the addition of EXTENSION_DONT_CHECK_SIZE, this makes for a nicer
      implementation of EXTENSION_REALLY_RETURN_NULL.
      
      Besides mdsync() the only callsite that should change behaviour due to
      this is mdprefetch() which now doesn't create segments anymore, even in
      recovery. Given the uses of mdprefetch() that seems better.
      
      Reported-By: Thom Brown
      Discussion: CAA-aLv72QazLvPdKZYpVn4a_Eh+i4_cxuB03k+iCuZM_xjc+6Q@mail.gmail.com
      a7124870
    • Peter Eisentraut's avatar
      doc: Fix typos · 613fb29a
      Peter Eisentraut authored
      From: Alexander Law <exclusion@gmail.com>
      613fb29a
  4. 03 May, 2016 3 commits
    • Robert Haas's avatar
      Fix more things to be parallel-safe. · 9888b34f
      Robert Haas authored
      Conversion functions were previously marked as parallel-unsafe, since
      that is the default, but in fact they are safe.  Parallel-safe
      functions defined in pg_proc.h and redefined in system_views.sql were
      ending up as parallel-unsafe because the redeclarations were not
      marked PARALLEL SAFE.  While editing system_views.sql, mark ts_debug()
      parallel safe also.
      
      Andreas Karlsson
      9888b34f
    • Robert Haas's avatar
      Tweak a few more things in preparation for upcoming pgindent run. · 8826d850
      Robert Haas authored
      These adjustments adjust code and comments in minor ways to prevent
      pgindent from mangling them.  Among other things, I tried to avoid
      situations where pgindent would emit "a +b" instead of "a + b", and I
      tried to avoid having it break up inline comments across multiple
      lines.
      8826d850
    • Robert Haas's avatar
      Note that max_worker_processes requires restart. · 1e77949e
      Robert Haas authored
      Since this is a minor issue, no back-patch.
      
      Julien Rouhaud
      1e77949e
  5. 02 May, 2016 8 commits
    • Alvaro Herrera's avatar
      Fix thinko in comment · 6b609168
      Alvaro Herrera authored
      Pointed out by Andres Freund
      6b609168
    • Alvaro Herrera's avatar
      Fix code comments regarding logical decoding · 234a2660
      Alvaro Herrera authored
      Back in 3b02ea4f I added some comments in various places to explain
      how logical decoding and other things worked.  Not all of the changes
      were welcome, because they were misleading or wrong.  This changes them
      a little bit to make them more accurate.
      
      Some other comments are also changed to be more accurate.  Also, fix a
      bunch of typos.
      
      Author: Álvaro Herrera, Craig Ringer
      
      Andres Freund reviewed some parts of this.
      234a2660
    • Tom Lane's avatar
      Docs: improve index entries for new tsvector functions. · 21c2b1c6
      Tom Lane authored
      Fix typos, reword some overly general index entries.
      21c2b1c6
    • Tom Lane's avatar
      Fix configure's incorrect version tests for flex and perl. · 7d7b1292
      Tom Lane authored
      awk's equality-comparison operator is "==" not "=".  We got this right
      in many places, but not in configure's checks for supported version
      numbers of flex and perl.  It hadn't been noticed because unsupported
      versions are so old as to be basically extinct in the wild, and because
      the only consequence is whether or not a WARNING flies by during
      configure.
      
      Daniel Gustafsson noted the problem with respect to the test for flex,
      I found the other by reviewing other awk calls.
      7d7b1292
    • Robert Haas's avatar
      Fix parallel safety markings for pg_start_backup. · 37d0c2cb
      Robert Haas authored
      Commit 71176854 made pg_start_backup
      parallel-restricted rather than parallel-safe, because it now relies
      on backend-private state that won't be synchronized with the parallel
      worker.  However, it didn't update pg_proc.h.  Separately, Andreas
      Karlsson observed that system_views.sql neglected to reiterate the
      parallel-safety markings whe redefining various functions, including
      this one; so add a PARALLEL RESTRICTED declaration there to match
      the new value in pg_proc.h.
      37d0c2cb
    • Robert Haas's avatar
      Again update typedefs.list file in preparation for pgindent run · f2f5e7e7
      Robert Haas authored
      This time, use the buildfarm-supplied contents for this file, instead
      of trying to update it by eyeballing the pgindent output.
      
      Per discussion with Tom and Bruce.
      f2f5e7e7
    • Heikki Linnakangas's avatar
      Remove unused macros. · d22b85fb
      Heikki Linnakangas authored
      CHECK_PAGE_OFFSET_RANGE() has been unused forever.
      CHECK_RELATION_BLOCK_RANGE() has been unused in pgstatindex.c ever since
      bt_page_stats() and bt_page_items() functions were moved from pgstattuple
      to pageinspect module. It still exists in pageinspect/btreefuncs.c.
      
      Daniel Gustafsson
      d22b85fb
    • Peter Eisentraut's avatar
      doc: Fix typo · a956bf43
      Peter Eisentraut authored
      From: Guillaume Lelarge <guillaume@lelarge.info>
      a956bf43
  6. 01 May, 2016 1 commit
    • Tom Lane's avatar
      Add a --non-master-only option to git_changelog. · 8473b7f9
      Tom Lane authored
      This has the inverse effect of --master-only.  It's needed to help find
      cases where a commit should not be described in major release notes
      because it was back-patched into older branches, though not at the same
      time as the HEAD commit.
      8473b7f9
  7. 30 Apr, 2016 5 commits
    • Tom Lane's avatar
      Update contrib/unaccent documentation about its unaccent.rules file. · 6376a16b
      Tom Lane authored
      Commit 1bbd52cb didn't bother with such niceties.
      6376a16b
    • Tom Lane's avatar
      Small improvements to OPTIMIZER_DEBUG code. · 2a2435e6
      Tom Lane authored
      Now that Paths have their own rows field, print that rather than
      the parent relation's rowcount.
      
      Show the relid sets associated with Paths using table names rather
      than numbers; since this code is able to print simple Var references
      using table names, it seems a bit silly that print_relids can't.
      
      Print the cheapest_parameterized_paths list for a RelOptInfo, and
      include information about a parameterized path's required_outer rels.
      
      Noted while trying to use this feature to debug Alexander Kirkouski's
      recent bug report.
      2a2435e6
    • Tom Lane's avatar
      Fix planner crash from pfree'ing a partial path that a GatherPath uses. · c45bf575
      Tom Lane authored
      We mustn't run generate_gather_paths() during add_paths_to_joinrel(),
      because that function can be invoked multiple times for the same target
      joinrel.  Not only is it wasteful to build GatherPaths repeatedly, but
      a later add_partial_path() could delete the partial path that a previously
      created GatherPath depends on.  Instead establish the convention that we
      do generate_gather_paths() for a rel only just before set_cheapest().
      
      The code was accidentally not broken for baserels, because as of today there
      never is more than one partial path for a baserel.  But that assumption
      obviously has a pretty short half-life, so move the generate_gather_paths()
      calls for those cases as well.
      
      Also add some generic comments explaining how and why this all works.
      
      Per fuzz testing by Andreas Seltenreich.
      
      Report: <871t5pgwdt.fsf@credativ.de>
      c45bf575
    • Tom Lane's avatar
      Remove warning about num_sync being too large in synchronous_standby_names. · 17d5db35
      Tom Lane authored
      If we're not going to reject such setups entirely, throwing a WARNING in
      check_synchronous_standby_names() is unhelpful, because it will cause the
      warning to be logged again every time the postmaster receives SIGHUP.
      Per discussion, just remove the warning.
      
      In passing, improve the documentation for synchronous_commit, which had not
      gotten the word that now there can be more than one synchronous standby.
      17d5db35
    • Tom Lane's avatar
      Fix mishandling of equivalence-class tests in parameterized plans. · 207d5a65
      Tom Lane authored
      Given a three-or-more-way equivalence class, such as X.Y = Y.Y = Z.Z,
      it was possible for the planner to omit one of the quals needed to
      enforce that all members of the equivalence class are actually equal.
      This only happened in the case of a parameterized join node for two
      of the relations, that is a plan tree like
      
      	Nested Loop
      	  ->  Scan X
      	  ->  Nested Loop
      	    ->  Scan Y
      	    ->  Scan Z
      	          Filter: Z.Z = X.X
      
      The eclass machinery normally expects to apply X.X = Y.Y when those
      two relations are joined, but in this shape of plan tree they aren't
      joined until the top node --- and, if the lower nested loop is marked
      as parameterized by X, the top node will assume that the relevant eclass
      condition(s) got pushed down into the lower node.  On the other hand,
      the scan of Z assumes that it's only responsible for constraining Z.Z
      to match any one of the other eclass members.  So one or another of
      the required quals sometimes fell between the cracks, depending on
      whether consideration of the eclass in get_joinrel_parampathinfo()
      for the lower nested loop chanced to generate X.X = Y.Y or X.X = Z.Z
      as the appropriate constraint there.  If it generated the latter,
      it'd erroneously suppose that the Z scan would take care of matters.
      To fix, force X.X = Y.Y to be generated and applied at that join node
      when this case occurs.
      
      This is *extremely* hard to hit in practice, because various planner
      behaviors conspire to mask the problem; starting with the fact that the
      planner doesn't really like to generate a parameterized plan of the
      above shape.  (It might have been impossible to hit it before we
      tweaked things to allow this plan shape for star-schema cases.)  Many
      thanks to Alexander Kirkouski for submitting a reproducible test case.
      
      The bug can be demonstrated in all branches back to 9.2 where parameterized
      paths were introduced, so back-patch that far.
      207d5a65
  8. 29 Apr, 2016 3 commits
    • Kevin Grittner's avatar
      Add a few entries to the tail of time mapping, to see old values. · 7c3e8039
      Kevin Grittner authored
      Without a few entries beyond old_snapshot_threshold, the lookup
      would often fail, resulting in the more aggressive pruning or
      vacuum being skipped often enough to matter.  This was very clearly
      shown by a python test script posted by Ants Aasma, and was likely
      a factor in an earlier but somewhat less clear-cut test case posted
      by Jeff Janes.
      
      This patch makes no change to the logic, per se -- it just makes
      the array of mapping entries big enough to make lookup misses based
      on timing much less likely.  An occasional miss is still possible
      if a thread stalls for more than 10 minutes, but that does not
      create any problem with correctness of behavior.  Besides, if
      things are so busy that a thread is stalling for more than 10
      minutes, it is probably OK to skip the more aggressive cleanup at
      that particular point in time.
      7c3e8039
    • Andrew Dunstan's avatar
      Fix comment whitespace in VS2105 patch · d34e7b28
      Andrew Dunstan authored
      per gripe from Michael Paquier.
      d34e7b28
    • Peter Eisentraut's avatar
      doc: Minor wording changes · 82881b2b
      Peter Eisentraut authored
      From: Dmitry Igrishin <dmitigr@gmail.com>
      82881b2b