1. 18 Dec, 2014 10 commits
    • Heikki Linnakangas's avatar
      Change how first WAL segment on new timeline after promotion is created. · ba94518a
      Heikki Linnakangas authored
      Two changes:
      
      1. When copying a WAL segment from old timeline to create the first segment
      on the new timeline, only copy up to the point where the timeline switch
      happens, and zero-fill the rest. This avoids corner cases where we might
      think that the copied WAL from the previous timeline belong to the new
      timeline.
      
      2. If the timeline switch happens at a segment boundary, don't copy the
      whole old segment to the new timeline. It's pointless, because it's 100%
      identical to the old segment.
      ba94518a
    • Fujii Masao's avatar
      Add memory barriers for PgBackendStatus.st_changecount protocol. · 38628db8
      Fujii Masao authored
      st_changecount protocol needs the memory barriers to ensure that
      the apparent order of execution is as it desires. Otherwise,
      for example, the CPU might rearrange the code so that st_changecount
      is incremented twice before the modification on a machine with
      weak memory ordering. This surprising result can lead to bugs.
      
      This commit introduces the macros to load and store st_changecount
      with the memory barriers. These are called before and after
      PgBackendStatus entries are modified or copied into private memory,
      in order to prevent CPU from reordering PgBackendStatus access.
      
      Per discussion on pgsql-hackers, we decided not to back-patch this
      to 9.4 or before until we get an actual bug report about this.
      
      Patch by me. Review by Robert Haas.
      38628db8
    • Fujii Masao's avatar
      Ensure variables live across calls in generate_series(numeric, numeric). · 19e065c0
      Fujii Masao authored
      In generate_series_step_numeric(), the variables "start_num"
      and "stop_num" may be potentially freed until the next call.
      So they should be put in the location which can survive across calls.
      But previously they were not, and which could cause incorrect
      behavior of generate_series(numeric, numeric). This commit fixes
      this problem by copying them on multi_call_memory_ctx.
      
      Andrew Gierth
      19e065c0
    • Fujii Masao's avatar
      Update .gitignore for config.cache. · ccf292cd
      Fujii Masao authored
      Also add a comment about why regreesion.* aren't listed in .gitignore.
      
      Jim Nasby
      ccf292cd
    • Andres Freund's avatar
      Adjust valgrind suppression to the changes in 2c03216d. · 72950dc1
      Andres Freund authored
      CRC computation is now done in XLogRecordAssemble.
      72950dc1
    • Noah Misch's avatar
      Recognize Makefile line continuations in fetchRegressOpts(). · 43b56171
      Noah Misch authored
      Back-patch to 9.0 (all supported versions).  This is mere
      future-proofing in the context of the master branch, but commit
      f6dc6dd5 requires it of older branches.
      43b56171
    • Fujii Masao's avatar
      Remove odd blank line in comment. · 26674c92
      Fujii Masao authored
      Etsuro Fujita
      26674c92
    • Andres Freund's avatar
      Fix (re-)starting from a basebackup taken off a standby after a failure. · c303e9e7
      Andres Freund authored
      When starting up from a basebackup taken off a standby extra logic has
      to be applied to compute the point where the data directory is
      consistent. Normal base backups use a WAL record for that purpose, but
      that isn't possible on a standby.
      
      That logic had a error check ensuring that the cluster's control file
      indicates being in recovery. Unfortunately that check was too strict,
      disregarding the fact that the control file could also indicate that
      the cluster was shut down while in recovery.
      
      That's possible when the a cluster starting from a basebackup is shut
      down before the backup label has been removed. When everything goes
      well that's a short window, but when either restore_command or
      primary_conninfo isn't configured correctly the window can get much
      wider. That's because inbetween reading and unlinking the label we
      restore the last checkpoint from WAL which can need additional WAL.
      
      To fix simply also allow starting when the control file indicates
      "shutdown in recovery". There's nicer fixes imaginable, but they'd be
      more invasive.
      
      Backpatch to 9.2 where support for taking basebackups from standbys
      was added.
      c303e9e7
    • Noah Misch's avatar
      Fix previous commit for TAP test suites in VPATH builds. · 40c598fa
      Noah Misch authored
      Per buildfarm member crake.  Back-patch to 9.4, where the TAP suites
      were introduced.
      40c598fa
    • Noah Misch's avatar
      Lock down regression testing temporary clusters on Windows. · f6dc6dd5
      Noah Misch authored
      Use SSPI authentication to allow connections exclusively from the OS
      user that launched the test suite.  This closes on Windows the
      vulnerability that commit be76a6d3
      closed on other platforms.  Users of "make installcheck" or custom test
      harnesses can run "pg_regress --config-auth=DATADIR" to activate the
      same authentication configuration that "make check" would use.
      Back-patch to 9.0 (all supported versions).
      
      Security: CVE-2014-0067
      f6dc6dd5
  2. 17 Dec, 2014 7 commits
  3. 16 Dec, 2014 7 commits
    • Tom Lane's avatar
      Fix off-by-one loop count in MapArrayTypeName, and get rid of static array. · 66709133
      Tom Lane authored
      MapArrayTypeName would copy up to NAMEDATALEN-1 bytes of the base type
      name, which of course is wrong: after prepending '_' there is only room for
      NAMEDATALEN-2 bytes.  Aside from being the wrong result, this case would
      lead to overrunning the statically allocated work buffer.  This would be a
      security bug if the function were ever used outside bootstrap mode, but it
      isn't, at least not in any currently supported branches.
      
      Aside from fixing the off-by-one loop logic, this patch gets rid of the
      static work buffer by having MapArrayTypeName pstrdup its result; the sole
      caller was already doing that, so this just requires moving the pstrdup
      call.  This saves a few bytes but mainly it makes the API a lot cleaner.
      
      Back-patch on the off chance that there is some third-party code using
      MapArrayTypeName with less-secure input.  Pushing pstrdup into the function
      should not cause any serious problems for such hypothetical code; at worst
      there might be a short term memory leak.
      
      Per Coverity scanning.
      66709133
    • Tom Lane's avatar
      Suppress bogus statistics when pgbench failed to complete any transactions. · de8e46f5
      Tom Lane authored
      Code added in 9.4 would attempt to divide by zero in such cases.
      Noted while testing fix for missing-pclose problem.
      de8e46f5
    • Tom Lane's avatar
      Fix file descriptor leak after failure of a \setshell command in pgbench. · d38e8d30
      Tom Lane authored
      If the called command fails to return data, runShellCommand forgot to
      pclose() the pipe before returning.  This is fairly harmless in the current
      code, because pgbench would then abandon further processing of that client
      thread; so no more than nclients descriptors could be leaked this way.  But
      it's not hard to imagine future improvements whereby that wouldn't be true.
      In any case, it's sloppy coding, so patch all branches.  Found by Coverity.
      d38e8d30
    • Andrew Dunstan's avatar
      Fix some jsonb issues found by Coverity in recent commits. · c8315930
      Andrew Dunstan authored
      Mostly these issues concern the non-use of function results. These
      have been changed to use (void) pushJsonbValue(...) instead of assigning
      the result to a variable that gets overwritten before it is used.
      
      There is a larger issue that we should possibly examine the API for
      pushJsonbValue(), so that instead of returning a value it modifies a
      state argument. The current idiom is rather clumsy. However, changing
      that requires quite a bit more work, so this change should do for the
      moment.
      c8315930
    • Heikki Linnakangas's avatar
      Misc comment typo fixes. · 4d65e16a
      Heikki Linnakangas authored
      Backpatch the applicable parts, just to make backpatching future patches
      easier.
      4d65e16a
    • Heikki Linnakangas's avatar
      Fix incorrect comment about XLogRecordBlockHeader.data_length field. · da9f6a78
      Heikki Linnakangas authored
      It does not include the possible full-page image. While at it, reformat the
      comment slightly to make it more readable.
      
      Reported by Rahila Syed
      da9f6a78
    • Noah Misch's avatar
      Fix commit_ts test suite for systems with coarse timestamp granularity. · 0916eba1
      Noah Misch authored
      Noticed on a couple of Windows configurations.
      
      Petr Jelinek, reviewed by Michael Paquier.
      0916eba1
  4. 15 Dec, 2014 6 commits
  5. 14 Dec, 2014 2 commits
    • Tom Lane's avatar
      Improve documentation around parameter-setting and ALTER SYSTEM. · af06aa82
      Tom Lane authored
      The ALTER SYSTEM ref page hadn't been held to a very high standard, nor
      was the feature well integrated into section 18.1 (parameter setting).
      Also, though commit 4c4654af had improved the structure of 18.1, it also
      introduced a lot of poor wording, imprecision, and outright falsehoods.
      Try to clean that up.
      af06aa82
    • Tom Lane's avatar
      Update 9.4 release notes. · 0923b01e
      Tom Lane authored
      Set release date, do a final pass of wordsmithing, improve some other
      new-in-9.4 documentation.
      0923b01e
  6. 13 Dec, 2014 5 commits
  7. 12 Dec, 2014 3 commits
    • Tom Lane's avatar
      Avoid instability in output of new REINDEX SCHEMA test. · 1c5c70df
      Tom Lane authored
      The planner seems to like to do this join query as a hash join, making
      the output ordering machine-dependent; worse, it's a hash on OIDs, so
      that it's a bit astonishing that the result doesn't change from run to
      run even on one machine.  Add an ORDER BY to get consistent results.
      Per buildfarm.
      
      I also suppressed output from the final DROP SCHEMA CASCADE, to avoid
      occasional failures similar to those fixed in commit 81d815dc.
      That hasn't been observed in the buildfarm yet, but it seems likely
      to happen in future if we leave it as-is.
      1c5c70df
    • Andrew Dunstan's avatar
      Add several generator functions for jsonb that exist for json. · 7e354ab9
      Andrew Dunstan authored
      The functions are:
          to_jsonb()
          jsonb_object()
          jsonb_build_object()
          jsonb_build_array()
          jsonb_agg()
          jsonb_object_agg()
      
      Also along the way some better logic is implemented in
      json_categorize_type() to match that in the newly implemented
      jsonb_categorize_type().
      
      Andrew Dunstan, reviewed by Pavel Stehule and Alvaro Herrera.
      7e354ab9
    • Tom Lane's avatar
      Revert misguided change to postgres_fdw FOR UPDATE/SHARE code. · 8ec8760f
      Tom Lane authored
      In commit 462bd957, I changed postgres_fdw
      to rely on get_plan_rowmark() instead of get_parse_rowmark().  I still
      think that's a good idea in the long run, but as Etsuro Fujita pointed out,
      it doesn't work today because planner.c forces PlanRowMarks to have
      markType = ROW_MARK_COPY for all foreign tables.  There's no urgent reason
      to change this in the back branches, so let's just revert that part of
      yesterday's commit rather than trying to design a better solution under
      time pressure.
      
      Also, add a regression test case showing what postgres_fdw does with FOR
      UPDATE/SHARE.  I'd blithely assumed there was one already, else I'd have
      realized yesterday that this code didn't work.
      8ec8760f