1. 02 Aug, 2014 2 commits
  2. 01 Aug, 2014 1 commit
  3. 31 Jul, 2014 1 commit
    • Heikki Linnakangas's avatar
      Move log_newpage and log_newpage_buffer to xlog.c. · 54685338
      Heikki Linnakangas authored
      log_newpage is used by many indexams, in addition to heap, but for
      historical reasons it's always been part of the heapam rmgr. Starting with
      9.3, we have another WAL record type for logging an image of a page,
      XLOG_FPI. Simplify things by moving log_newpage and log_newpage_buffer to
      xlog.c, and switch to using the XLOG_FPI record type.
      
      Bump the WAL version number because the code to replay the old HEAP_NEWPAGE
      records is removed.
      54685338
  4. 30 Jul, 2014 5 commits
    • Tom Lane's avatar
      Avoid wholesale autovacuuming when autovacuum is nominally off. · f51ead09
      Tom Lane authored
      When autovacuum is nominally off, we will still launch autovac workers
      to vacuum tables that are at risk of XID wraparound.  But after we'd done
      that, an autovac worker would proceed to autovacuum every table in the
      targeted database, if they meet the usual thresholds for autovacuuming.
      This is at best pretty unexpected; at worst it delays response to the
      wraparound threat.  Fix it so that if autovacuum is nominally off, we
      *only* do forced vacuums and not any other work.
      
      Per gripe from Andrey Zhidenkov.  This has been like this all along,
      so back-patch to all supported branches.
      f51ead09
    • Robert Haas's avatar
      pgbench: Allow \setrandom to generate Gaussian/exponential distributions. · ed802e7d
      Robert Haas authored
      Mitsumasa KONDO and Fabien COELHO, with further wordsmithing by me.
      ed802e7d
    • Robert Haas's avatar
      Fix mishandling of background worker PGPROCs in EXEC_BACKEND builds. · e280c630
      Robert Haas authored
      InitProcess() relies on IsBackgroundWorker to decide whether the PGPROC
      for a new backend should be taken from ProcGlobal's freeProcs or from
      bgworkerFreeProcs.  In EXEC_BACKEND builds, InitProcess() is called
      sooner than in non-EXEC_BACKEND builds, and IsBackgroundWorker wasn't
      getting initialized soon enough.
      
      Report by Noah Misch.  Diagnosis and fix by me.
      e280c630
    • Peter Eisentraut's avatar
      doc: Clean up some recently added PL/pgSQL documentation · 232f1475
      Peter Eisentraut authored
      - Capitalize titles consistently.
      - Fix some grammar.
      - Group "Obtaining Information About an Error" under "Trapping Errors",
        but make "Obtaining the Call Stack Context Information" its own
        section, since it's not about errors.
      232f1475
    • Bruce Momjian's avatar
      pg_upgrade: improve C comment wording · d826d8ec
      Bruce Momjian authored
      d826d8ec
  5. 29 Jul, 2014 5 commits
    • Alvaro Herrera's avatar
      Avoid uselessly looking up old LOCK_ONLY multixacts · 05315498
      Alvaro Herrera authored
      Commit 0ac5ad51 removed an optimization in multixact.c that skipped
      fetching members of MultiXactId that were older than our
      OldestVisibleMXactId value.  The reason this was removed is that it is
      possible for multixacts that contain updates to be older than that
      value.  However, if the caller is certain that the multi does not
      contain an update (because the infomask bits say so), it can pass this
      info down to GetMultiXactIdMembers, enabling it to use the old
      optimization.
      
      Pointed out by Andres Freund in 20131121200517.GM7240@alap2.anarazel.de
      05315498
    • Alvaro Herrera's avatar
      Simplify multixact freezing a bit · c2581794
      Alvaro Herrera authored
      Testing for abortedness of a multixact member that's being frozen is
      unnecessary: we only need to know whether the transaction is still in
      progress or committed to determine whether it must be kept or not.  This
      let us simplify the code a bit and avoid a useless TransactionIdDidAbort
      test.
      
      Suggested by Andres Freund awhile back.
      c2581794
    • Heikki Linnakangas's avatar
      Oops, fix recoveryStopsBefore functions for regular commits. · 60d93182
      Heikki Linnakangas authored
      Pointed out by Tom Lane. Backpatch to 9.4, the code was structured
      differently in earlier branches and didn't have this mistake.
      60d93182
    • Heikki Linnakangas's avatar
      Treat 2PC commit/abort the same as regular xacts in recovery. · e74e0906
      Heikki Linnakangas authored
      There were several oversights in recovery code where COMMIT/ABORT PREPARED
      records were ignored:
      
      * pg_last_xact_replay_timestamp() (wasn't updated for 2PC commits)
      * recovery_min_apply_delay (2PC commits were applied immediately)
      * recovery_target_xid (recovery would not stop if the XID used 2PC)
      
      The first of those was reported by Sergiy Zuban in bug #11032, analyzed by
      Tom Lane and Andres Freund. The bug was always there, but was masked before
      commit d19bd29f, because COMMIT PREPARED
      always created an extra regular transaction that was WAL-logged.
      
      Backpatch to all supported versions (older versions didn't have all the
      features and therefore didn't have all of the above bugs).
      e74e0906
    • Fujii Masao's avatar
      Reword the sentence for pg_logical_slot_peek_changes function. · 61e48efb
      Fujii Masao authored
      Previously the duplicated paragraphs were used next to each other
      in the document to demonstrate that the changes in the stream
      were not consumed by pg_logical_slot_peek_changes function.
      But some users misunderstood that the duplication of the same
      paragraph was just typo. So this commit rewords the sentence in
      the latter paragraph for less confusing.
      
      Christoph Moench-Tegeder
      61e48efb
  6. 28 Jul, 2014 1 commit
  7. 27 Jul, 2014 1 commit
  8. 25 Jul, 2014 3 commits
    • Tom Lane's avatar
      Fix a performance problem in pg_dump's dump order selection logic. · c8e2e0e7
      Tom Lane authored
      findDependencyLoops() was not bright about cases where there are multiple
      dependency paths between the same two dumpable objects.  In most scenarios
      this did not hurt us too badly; but since the introduction of section
      boundary pseudo-objects in commit a1ef01fe,
      it was possible for this code to take unreasonable amounts of time (tens
      of seconds on a database with a couple thousand objects), as reported in
      bug #11033 from Joe Van Dyk.  Joe's particular problem scenario involved
      "pg_dump -a" mode with long chains of foreign key constraints, but I think
      that similar problems could arise with other situations as long as there
      were enough objects.  To fix, add a flag array that lets us notice when we
      arrive at the same object again while searching from a given start object.
      This simple change seems to be enough to eliminate the performance problem.
      
      Back-patch to 9.1, like the patch that introduced section boundary objects.
      c8e2e0e7
    • Noah Misch's avatar
      Handle WAIT_IO_COMPLETION return from WaitForMultipleObjectsEx(). · de35a977
      Noah Misch authored
      This return code is possible wherever we pass bAlertable = TRUE; it
      arises when Windows caused the current thread to run an "I/O completion
      routine" or an "asynchronous procedure call".  PostgreSQL does not
      provoke either of those Windows facilities, hence this bug remaining
      largely unnoticed, but other local code might do so.  Due to a shortage
      of complaints, no back-patch for now.
      
      Per report from Shiv Shivaraju Gowda, this bug can cause
      PGSemaphoreLock() to PANIC.  The bug can also cause select() to report
      timeout expiration too early, which might confuse pgstat_init() and
      CheckRADIUSAuth().
      de35a977
    • Noah Misch's avatar
      Move PGAC_LDAP_SAFE to config/programs.m4. · e565ff75
      Noah Misch authored
      This restores the style of keeping configure.in free of AC_DEFUN.  Per
      gripe from Tom Lane.
      e565ff75
  9. 24 Jul, 2014 7 commits
    • Robert Haas's avatar
      Prevent shm_mq_send from reading uninitialized memory. · 1144ea34
      Robert Haas authored
      shm_mq_send_bytes didn't invariably initialize *bytes_written before
      returning, which would cause shm_mq_send to read from uninitialized
      memory and add the value it found there to mqh->mqh_partial_bytes.
      This could cause the next attempt to send a message via the queue to
      fail an assertion (if the queue was detached) or copy data from a
      garbage pointer value into the queue (if non-blocking mode was in use).
      1144ea34
    • Robert Haas's avatar
      Fix checkpointer crash in EXEC_BACKEND builds. · 250c26ba
      Robert Haas authored
      Nothing in the checkpointer calls InitXLOGAccess(), so WALInsertLocks
      never got initialized there.  Without EXEC_BACKEND, it works anyway
      because the correct value is inherited from the postmaster, but
      with EXEC_BACKEND we've got a problem.  The problem appears to have
      been introduced by commit 68a2e52b.
      
      To fix, move the relevant initialization steps from InitXLOGAccess()
      to XLOGShmemInit(), making this more parallel to what we do
      elsewhere.
      
      Amit Kapila
      250c26ba
    • Andres Freund's avatar
      Properly remove ephemeral replication slots after a crash restart. · 93a028f5
      Andres Freund authored
      Ephemeral slots - slots that shouldn't survive database restarts -
      weren't properly cleaned up after a immediate/crash restart. They were
      ignored in the sense that they weren't restored into memory and thus
      didn't cause unwanted resource retention; but they prevented a new
      slot with the same name from being created.
      
      Now ephemeral slots are fully removed during startup.
      
      Backpatch to 9.4 where replication slots where added.
      93a028f5
    • Robert Haas's avatar
      Avoid access to already-released lock in LockRefindAndRelease. · 32d78894
      Robert Haas authored
      Spotted by Tom Lane.
      32d78894
    • Robert Haas's avatar
      docs: Improve documentation of \pset without arguments. · 967a4e7f
      Robert Haas authored
      The syntax summary previously failed to clarify that the first
      argument is also optional.  The textual description did mention it,
      but all the way at the bottom.  It fits better with the command
      overview, so move it there, and fix the summary also.
      
      Dilip Kumar, reviewed by Fabien Coelho
      967a4e7f
    • Fujii Masao's avatar
      Fix bug where pg_receivexlog goes into busy loop if -s option is set to 0. · 78493b71
      Fujii Masao authored
      The problem is that pg_receivexlog calls select(2) with timeout=0 and
      goes into busy loop when --status-interval option is set to 0. This bug
      was introduced by the commit,
      74cbe966.
      
      Per report from Sawada Masahiko
      78493b71
    • Peter Eisentraut's avatar
      Fix TAP installcheck tests when current directory name contains spaces · 455044d5
      Peter Eisentraut authored
      This fixes the installcheck part.  The check part has additional
      problems that will be addressed in a separate commit.
      455044d5
  10. 23 Jul, 2014 3 commits
    • Tom Lane's avatar
      Rearrange documentation paragraph describing pg_relation_size(). · 4fd9e6ff
      Tom Lane authored
      Break the list of available options into an <itemizedlist> instead of
      inline sentences.  This is mostly motivated by wanting to ensure that the
      cross-references to the FSM and VM docs don't cross page boundaries in PDF
      format; but it seems to me to read more easily this way anyway.  I took the
      liberty of editorializing a bit further while at it.
      
      Per complaint from Magnus about 9.0.18 docs not building in A4 format.
      Patch all active branches so we don't get blind-sided by this particular
      issue again in future.
      4fd9e6ff
    • Noah Misch's avatar
      Report success when Windows kill() emulation signals an exiting process. · 0ea1f2a3
      Noah Misch authored
      This is consistent with the POSIX verdict that kill() shall not report
      ESRCH for a zombie process.  Back-patch to 9.0 (all supported versions).
      Test code from commit d7cdf6ee depends
      on it, and log messages about kill() reporting "Invalid argument" will
      cease to appear for this not-unexpected condition.
      0ea1f2a3
    • Noah Misch's avatar
      MSVC: Substitute $(top_builddir) in REGRESS_OPTS. · 31f9bbf0
      Noah Misch authored
      Commit d7cdf6ee introduced a usage
      thereof.  Back-patch to 9.0, like that commit.
      31f9bbf0
  11. 22 Jul, 2014 7 commits
    • Tom Lane's avatar
      Re-enable error for "SELECT ... OFFSET -1". · 27048980
      Tom Lane authored
      The executor has thrown errors for negative OFFSET values since 8.4 (see
      commit bfce56ee), but in a moment of brain
      fade I taught the planner that OFFSET with a constant negative value was a
      no-op (commit 1a1832eb).  Reinstate the
      former behavior by only discarding OFFSET with a value of exactly 0.  In
      passing, adjust a planner comment that referenced the ancient behavior.
      
      Back-patch to 9.3 where the mistake was introduced.
      27048980
    • Tom Lane's avatar
      Check block number against the correct fork in get_raw_page(). · 27cef0a5
      Tom Lane authored
      get_raw_page tried to validate the supplied block number against
      RelationGetNumberOfBlocks(), which of course is only right when
      accessing the main fork.  In most cases, the main fork is longer
      than the others, so that the check was too weak (allowing a
      lower-level error to be reported, but no real harm to be done).
      However, very small tables could have an FSM larger than their heap,
      in which case the mistake prevented access to some FSM pages.
      Per report from Torsten Foertsch.
      
      In passing, make the bad-block-number error into an ereport not elog
      (since it's certainly not an internal error); and fix sloppily
      maintained comment for RelationGetNumberOfBlocksInFork.
      
      This has been wrong since we invented relation forks, so back-patch
      to all supported branches.
      27cef0a5
    • Andrew Dunstan's avatar
      Allow empty string object keys in json_object(). · 4ebe3519
      Andrew Dunstan authored
      This makes the behaviour consistent with the json parser, other
      json-generating functions, and the JSON standards.
      4ebe3519
    • Noah Misch's avatar
      Diagnose incompatible OpenLDAP versions during build and test. · d7cdf6ee
      Noah Misch authored
      With OpenLDAP versions 2.4.24 through 2.4.31, inclusive, PostgreSQL
      backends can crash at exit.  Raise a warning during "configure" based on
      the compile-time OpenLDAP version number, and test the crash scenario in
      the dblink test suite.  Back-patch to 9.0 (all supported versions).
      d7cdf6ee
    • Peter Eisentraut's avatar
      Unset some local environment variables in TAP tests · 24e786f0
      Peter Eisentraut authored
      Unset environment variables that control message language, so that we
      can compare some program output with expected strings.  This is very
      similar to what pg_regress does.
      24e786f0
    • Peter Eisentraut's avatar
      gitattributes: Ignore time zone data files for whitespace checks · 8195e9e9
      Peter Eisentraut authored
      The latest update introduced some funny whitespace, but since they are
      externally maintained files, we add them to the list of files to ignore.
      8195e9e9
    • Tom Lane's avatar
      Reject out-of-range numeric timezone specifications. · 6412f3e2
      Tom Lane authored
      In commit 631dc390, we started to handle
      simple numeric timezone offsets via the zic library instead of the old
      CTimeZone/HasCTZSet kluge.  However, we overlooked the fact that the zic
      code will reject UTC offsets exceeding a week (which seems a bit arbitrary,
      but not because it's too tight ...).  This led to possibly setting
      session_timezone to NULL, which results in crashes in most timezone-related
      operations as of 9.4, and crashes in a small number of places even before
      that.  So check for NULL return from pg_tzset_offset() and report an
      appropriate error message.  Per bug #11014 from Duncan Gillis.
      
      Back-patch to all supported branches, like the previous patch.
      (Unfortunately, as of today that no longer includes 8.4.)
      6412f3e2
  12. 21 Jul, 2014 4 commits
    • Tom Lane's avatar
      212825f8
    • Tom Lane's avatar
      Adjust cutoff points in newly-added sanity tests. · 87f830e0
      Tom Lane authored
      Per recommendation from Andres.
      87f830e0
    • Tom Lane's avatar
      Defend against bad relfrozenxid/relminmxid/datfrozenxid/datminmxid values. · 78db307b
      Tom Lane authored
      In commit a61daa14, we fixed pg_upgrade so
      that it would install sane relminmxid and datminmxid values, but that does
      not cure the problem for installations that were already pg_upgraded to
      9.3; they'll initially have "1" in those fields.  This is not a big problem
      so long as 1 is "in the past" compared to the current nextMultiXact
      counter.  But if an installation were more than halfway to the MXID wrap
      point at the time of upgrade, 1 would appear to be "in the future" and
      that would effectively disable tracking of oldest MXIDs in those
      tables/databases, until such time as the counter wrapped around.
      
      While in itself this isn't worse than the situation pre-9.3, where we did
      not manage MXID wraparound risk at all, the consequences of premature
      truncation of pg_multixact are worse now; so we ought to make some effort
      to cope with this.  We discussed advising users to fix the tracking values
      manually, but that seems both very tedious and very error-prone.
      
      Instead, this patch adopts two amelioration rules.  First, a relminmxid
      value that is "in the future" is allowed to be overwritten with a
      full-table VACUUM's actual freeze cutoff, ignoring the normal rule that
      relminmxid should never go backwards.  (This essentially assumes that we
      have enough defenses in place that wraparound can never occur anymore,
      and thus that a value "in the future" must be corrupt.)  Second, if we see
      any "in the future" values then we refrain from truncating pg_clog and
      pg_multixact.  This prevents loss of clog data until we have cleaned up
      all the broken tracking data.  In the worst case that could result in
      considerable clog bloat, but in practice we expect that relfrozenxid-driven
      freezing will happen soon enough to fix the problem before clog bloat
      becomes intolerable.  (Users could do manual VACUUM FREEZEs if not.)
      
      Note that this mechanism cannot save us if there are already-wrapped or
      already-truncated-away MXIDs in the table; it's only capable of dealing
      with corrupt tracking values.  But that's the situation we have with the
      pg_upgrade bug.
      
      For consistency, apply the same rules to relfrozenxid/datfrozenxid.  There
      are not known mechanisms for these to get messed up, but if they were, the
      same tactics seem appropriate for fixing them.
      78db307b
    • Magnus Hagander's avatar
      Properly use DEFAULT_EVENT_SOURCE in pgevent.c · 4c3c911d
      Magnus Hagander authored
      This was broken and reverted in a previous commit. The (this time verified)
      fix is to simly add postgres_fe.h.
      
      MauMau, review by Amit Kapila
      4c3c911d