1. 13 Oct, 2015 4 commits
    • Bruce Momjian's avatar
      -- email subject limit ----------------------------------------- · aa7f9493
      Bruce Momjian authored
      -- gitweb summary limit --------------------------
      pg_upgrade:  reorder controldata checks to match program output
      
      Also improve comment for how float8_pass_by_value is used.
      
      Backpatch through 9.5
      aa7f9493
    • Robert Haas's avatar
      Have dtrace depend on object files directly, not objfiles.txt · 73537828
      Robert Haas authored
      Per Mark Johnston, this resolves a build error on FreeBSD related
      to the fact that dtrace is modifying the generated object files
      under the hood.  Consequently, without this, dtrace gets reinvoked
      at install time because the object files have been updated.  This
      is a pretty hacky fix, but it shouldn't hurt anything, and it's
      not clear that it's worth expending any more effort for a feature
      that not too many people are using.
      
      Patch by Mark Johnston.  This is arguably back-patchable as a bug
      fix to the build system, but I'm not certain enough of the
      consequences to try that.  Let's see what the buildfarm (and
      our packagers) think of this change on master first.
      73537828
    • Robert Haas's avatar
      Improve INSERT .. ON CONFLICT error message. · b8dd19af
      Robert Haas authored
      Peter Geoghegan, reviewed by me.
      b8dd19af
    • Tom Lane's avatar
      On Windows, ensure shared memory handle gets closed if not being used. · 869f693a
      Tom Lane authored
      Postmaster child processes that aren't supposed to be attached to shared
      memory were not bothering to close the shared memory mapping handle they
      inherit from the postmaster process.  That's mostly harmless, since the
      handle vanishes anyway when the child process exits -- but the syslogger
      process, if used, doesn't get killed and restarted during recovery from a
      backend crash.  That meant that Windows doesn't see the shared memory
      mapping as becoming free, so it doesn't delete it and the postmaster is
      unable to create a new one, resulting in failure to recover from crashes
      whenever logging_collector is turned on.
      
      Per report from Dmitry Vasilyev.  It's a bit astonishing that we'd not
      figured this out long ago, since it's been broken from the very beginnings
      of out native Windows support; probably some previously-unexplained trouble
      reports trace to this.
      
      A secondary problem is that on Cygwin (perhaps only in older versions?),
      exec() may not detach from the shared memory segment after all, in which
      case these child processes did remain attached to shared memory, posing
      the risk of an unexpected shared memory clobber if they went off the rails
      somehow.  That may be a long-gone bug, but we can deal with it now if it's
      still live, by detaching within the infrastructure introduced here to deal
      with closing the handle.
      
      Back-patch to all supported branches.
      
      Tom Lane and Amit Kapila
      869f693a
  2. 12 Oct, 2015 5 commits
    • Tom Lane's avatar
      Fix "pg_ctl start -w" to test child process status directly. · 6bcce258
      Tom Lane authored
      pg_ctl start with -w previously relied on a heuristic that the postmaster
      would surely always manage to create postmaster.pid within five seconds.
      Unfortunately, that fails much more often than we would like on some of the
      slower, more heavily loaded buildfarm members.
      
      We have known for quite some time that we could remove the need for that
      heuristic on Unix by using fork/exec instead of system() to launch the
      postmaster.  This allows us to know the exact PID of the postmaster, which
      allows near-certain verification that the postmaster.pid file is the one
      we want and not a leftover, and it also lets us use waitpid() to detect
      reliably whether the child postmaster has exited or not.
      
      What was blocking this change was not wanting to rewrite the Windows
      version of start_postmaster() to avoid use of CMD.EXE.  That's doable
      in theory but would require fooling about with stdout/stderr redirection,
      and getting the handling of quote-containing postmaster switches to
      stay the same might be rather ticklish.  However, we realized that
      we don't have to do that to fix the problem, because we can test
      whether the shell process has exited as a proxy for whether the
      postmaster is still alive.  That doesn't allow an exact check of the
      PID in postmaster.pid, but we're no worse off than before in that
      respect; and we do get to get rid of the heuristic about how long the
      postmaster might take to create postmaster.pid.
      
      On Unix, this change means that a second "pg_ctl start -w" immediately
      after another such command will now reliably fail, whereas previously
      it would succeed if done within two seconds of the earlier command.
      Since that's a saner behavior anyway, it's fine.  On Windows, the case can
      still succeed within the same time window, since pg_ctl can't tell that the
      earlier postmaster's postmaster.pid isn't the pidfile it is looking for.
      To ensure stable test results on Windows, we can insert a short sleep into
      the test script for pg_ctl, ensuring that the existing pidfile looks stale.
      This hack can be removed if we ever do rewrite start_postmaster(), but that
      no longer seems like a high-priority thing to do.
      
      Back-patch to all supported versions, both because the current behavior
      is buggy and because we must do that if we want the buildfarm failures
      to go away.
      
      Tom Lane and Michael Paquier
      6bcce258
    • Noah Misch's avatar
      Use JsonbIteratorToken consistently in automatic variable declarations. · 7732d49c
      Noah Misch authored
      Many functions stored JsonbIteratorToken values in variables of other
      integer types.  Also, standardize order relative to other declarations.
      Expect compilers to generate the same code before and after this change.
      7732d49c
    • Peter Eisentraut's avatar
      Fix whitespace · f20b2696
      Peter Eisentraut authored
      f20b2696
    • Noah Misch's avatar
      Avoid scan-build warning about uninitialized htonl() arguments. · dfa1cddc
      Noah Misch authored
      Josh Kupershmidt
      dfa1cddc
    • Noah Misch's avatar
      Make prove_installcheck remove the old log directory, if any. · 03a22f8b
      Noah Misch authored
      prove_check already has been doing this.  Back-patch to 9.4, like the
      commit that introduced this logging.
      03a22f8b
  3. 09 Oct, 2015 5 commits
    • Robert Haas's avatar
      Speed up text sorts where the same strings occur multiple times. · 0e57b4d8
      Robert Haas authored
      Cache strxfrm() blobs across calls made to the text SortSupport
      abbreviation routine.  This can speed up sorting if the same string
      needs to be abbreviated many times in a row.
      
      Also, cache the result of the previous strcoll() comparison, so that
      if we're asked to compare the same strings agin, we do need to call
      strcoll() again.
      
      Perhaps surprisingly, these optimizations don't seem to hurt even when
      they don't help.  memcmp() is really cheap compared to strcoll() or
      strxfrm().
      
      Peter Geoghegan, reviewed by me.
      0e57b4d8
    • Robert Haas's avatar
      Make abbreviated key comparisons for text a bit cheaper. · bfb54ff1
      Robert Haas authored
      If we do some byte-swapping while abbreviating, we can do comparisons
      using integer arithmetic rather than memcmp.
      
      Peter Geoghegan, reviewed and slightly revised by me.
      bfb54ff1
    • Robert Haas's avatar
      Remove set_latch_on_sigusr1 flag. · db0f6cad
      Robert Haas authored
      This flag has proven to be a recipe for bugs, and it doesn't seem like
      it can really buy anything in terms of performance.  So let's just
      *always* set the process latch when we receive SIGUSR1 instead of
      trying to do it only when needed.
      
      Per my recent proposal on pgsql-hackers.
      db0f6cad
    • Stephen Frost's avatar
      Handle append_rel_list in expand_security_qual · b7aac362
      Stephen Frost authored
      During expand_security_quals, we take the security barrier quals on an
      RTE and create a subquery which evaluates the quals.  During this, we
      have to replace any variables in the outer query which refer to the
      original RTE with references to the columns from the subquery.
      
      We need to also perform that replacement for any Vars in the
      append_rel_list.
      
      Only backpatching to 9.5 as we only go through this process in 9.4 for
      auto-updatable security barrier views, which UNION ALL queries aren't.
      
      Discovered by Haribabu Kommi
      
      Patch by Dean Rasheed
      b7aac362
    • Tom Lane's avatar
      Fix uninitialized-variable bug. · 94f5246c
      Tom Lane authored
      For some reason, neither of the compilers I usually use noticed the
      uninitialized-variable problem I introduced in commit 7e2a18a9.
      That's hardly a good enough excuse though.  Committing with brown paper bag
      on head.
      
      In addition to putting the operations in the right order, move the
      declaration of "now" inside the loop; there's no need for it to be
      outside, and that does wake up older gcc enough to notice any similar
      future problem.
      
      Back-patch to 9.4; earlier versions lack the time-to-SIGKILL stanza
      so there's no bug.
      94f5246c
  4. 08 Oct, 2015 5 commits
  5. 07 Oct, 2015 4 commits
  6. 06 Oct, 2015 6 commits
    • Tom Lane's avatar
      Perform an immediate shutdown if the postmaster.pid file is removed. · 7e2a18a9
      Tom Lane authored
      The postmaster now checks every minute or so (worst case, at most two
      minutes) that postmaster.pid is still there and still contains its own PID.
      If not, it performs an immediate shutdown, as though it had received
      SIGQUIT.
      
      The original goal behind this change was to ensure that failed buildfarm
      runs would get fully cleaned up, even if the test scripts had left a
      postmaster running, which is not an infrequent occurrence.  When the
      buildfarm script removes a test postmaster's $PGDATA directory, its next
      check on postmaster.pid will fail and cause it to exit.  Previously, manual
      intervention was often needed to get rid of such orphaned postmasters,
      since they'd block new test postmasters from obtaining the expected socket
      address.
      
      However, by checking postmaster.pid and not something else, we can provide
      additional robustness: manual removal of postmaster.pid is a frequent DBA
      mistake, and now we can at least limit the damage that will ensue if a new
      postmaster is started while the old one is still alive.
      
      Back-patch to all supported branches, since we won't get the desired
      improvement in buildfarm reliability otherwise.
      7e2a18a9
    • Robert Haas's avatar
      Remove more volatile qualifiers. · 8f6bb851
      Robert Haas authored
      Prior to commit 0709b7ee, access to
      variables within a spinlock-protected critical section had to be done
      through a volatile pointer, but that should no longer be necessary.
      This continues work begun in df4077cd
      and 6ba4ecbf.
      
      Thomas Munro and Michael Paquier
      8f6bb851
    • Bruce Momjian's avatar
      Have CREATE TABLE LIKE add OID column if any LIKEd table has one · b943f502
      Bruce Momjian authored
      Also, process constraints for LIKEd tables at the end so an OID column
      can be referenced in a constraint.
      
      Report by Tom Lane
      b943f502
    • Bruce Momjian's avatar
      to_number(): allow 'V' to divide by 10^(the number of digits) · 28b3a3d4
      Bruce Momjian authored
      to_char('V') already multiplied in a similar manner.
      
      Report by Jeremy Lowery
      28b3a3d4
    • Bruce Momjian's avatar
      psql: allow \pset C in setting the title, matches \C · 2145a766
      Bruce Momjian authored
      Report by David G. Johnston
      2145a766
    • Bruce Momjian's avatar
      to_char(): Do not count negative sign as a digit for time values · 2d87eedc
      Bruce Momjian authored
      For time masks, like HH24, MI, SS, CC, MM, do not count the negative
      sign as part of the zero-padding length specified by the mask, e.g. have
      to_char('-4 years'::interval, 'YY') return '-04', not '-4'.
      
      Report by Craig Ringer
      2d87eedc
  7. 05 Oct, 2015 11 commits
    • Bruce Momjian's avatar
      docs: update guidelines on when to use GIN and GiST indexes · 6d8b2aa8
      Bruce Momjian authored
      Report by Tomas Vondra
      
      Backpatch through 9.5
      6d8b2aa8
    • Tom Lane's avatar
      Docs: explain contrib/pg_stat_statements' handling of GC failure. · f8a5e579
      Tom Lane authored
      Failure to perform garbage collection now has a user-visible effect, so
      explain that and explain that reducing pgss_max is the way to prevent it.
      Per gripe from Andrew Dunstan.
      f8a5e579
    • Tom Lane's avatar
      Fix insufficiently-portable regression test case. · 9e36c91b
      Tom Lane authored
      Some of the buildfarm members are evidently miserly enough of stack space
      to pass the originally-committed form of this test.  Increase the
      requirement 10X to hopefully ensure that it fails as-expected everywhere.
      
      Security: CVE-2015-5289
      9e36c91b
    • Tom Lane's avatar
      Last-minute updates for release notes. · 272ede71
      Tom Lane authored
      Add entries for security and not-quite-security issues.
      
      Security: CVE-2015-5288, CVE-2015-5289
      272ede71
    • Andres Freund's avatar
      Remove outdated comment about relation level autovacuum freeze limits. · 10cfd6f8
      Andres Freund authored
      The documentation for the autovacuum_multixact_freeze_max_age and
      autovacuum_freeze_max_age relation level parameters contained:
      "Note that while you can set autovacuum_multixact_freeze_max_age very
      small, or even zero, this is usually unwise since it will force frequent
      vacuuming."
      which hasn't been true since these options were made relation options,
      instead of residing in the pg_autovacuum table (834a6da4).
      
      Remove the outdated sentence. Even the lowered limits from 2596d705 are
      high enough that this doesn't warrant calling out the risk in the CREATE
      TABLE docs.
      
      Per discussion with Tom Lane and Alvaro Herrera
      
      Discussion: 26377.1443105453@sss.pgh.pa.us
      Backpatch: 9.0- (in parts)
      10cfd6f8
    • Stephen Frost's avatar
      Add regression tests for INSERT/UPDATE+RETURNING · be400cd2
      Stephen Frost authored
      This adds regressions tests which are specific to INSERT+RETURNING and
      UPDATE+RETURNING to ensure that the SELECT policies are added as
      WithCheckOptions (and should therefore throw an error when the policy is
      violated).
      
      Per suggestion from Andres.
      
      Back-patch to 9.5 as the prior commit was.
      be400cd2
    • Noah Misch's avatar
      Prevent stack overflow in query-type functions. · 5976097c
      Noah Misch authored
      The tsquery, ltxtquery and query_int data types have a common ancestor.
      Having acquired check_stack_depth() calls independently, each was
      missing at least one call.  Back-patch to 9.0 (all supported versions).
      5976097c
    • Noah Misch's avatar
      Prevent stack overflow in container-type functions. · 30cb1288
      Noah Misch authored
      A range type can name another range type as its subtype, and a record
      type can bear a column of another record type.  Consequently, functions
      like range_cmp() and record_recv() are recursive.  Functions at risk
      include operator family members and referents of pg_type regproc
      columns.  Treat as recursive any such function that looks up and calls
      the same-purpose function for a record column type or the range subtype.
      Back-patch to 9.0 (all supported versions).
      
      An array type's element type is never itself an array type, so array
      functions are unaffected.  Recursion depth proportional to array
      dimensionality, found in array_dim_to_jsonb(), is fine thanks to MAXDIM.
      30cb1288
    • Noah Misch's avatar
      Prevent stack overflow in json-related functions. · 08fa47c4
      Noah Misch authored
      Sufficiently-deep recursion heretofore elicited a SIGSEGV.  If an
      application constructs PostgreSQL json or jsonb values from arbitrary
      user input, application users could have exploited this to terminate all
      active database connections.  That applies to 9.3, where the json parser
      adopted recursive descent, and later versions.  Only row_to_json() and
      array_to_json() were at risk in 9.2, both in a non-security capacity.
      Back-patch to 9.2, where the json type was introduced.
      
      Oskari Saarenmaa, reviewed by Michael Paquier.
      
      Security: CVE-2015-5289
      08fa47c4
    • Noah Misch's avatar
      pgcrypto: Detect and report too-short crypt() salts. · 1d812c8b
      Noah Misch authored
      Certain short salts crashed the backend or disclosed a few bytes of
      backend memory.  For existing salt-induced error conditions, emit a
      message saying as much.  Back-patch to 9.0 (all supported versions).
      
      Josh Kupershmidt
      
      Security: CVE-2015-5288
      1d812c8b
    • Stephen Frost's avatar
      Apply SELECT policies in INSERT/UPDATE+RETURNING · 2ca9d544
      Stephen Frost authored
      Similar to 7d8db3e8, given that INSERT+RETURNING requires SELECT rights
      on the table, apply the SELECT policies as WCOs to the tuples being
      inserted.  Apply the same logic to UPDATE+RETURNING.
      
      Back-patch to 9.5 where RLS was added.
      2ca9d544