1. 11 Aug, 2014 1 commit
    • Heikki Linnakangas's avatar
      Break out OpenSSL-specific code to separate files. · 680513ab
      Heikki Linnakangas authored
      This refactoring is in preparation for adding support for other SSL
      implementations, with no user-visible effects. There are now two #defines,
      USE_OPENSSL which is defined when building with OpenSSL, and USE_SSL which
      is defined when building with any SSL implementation. Currently, OpenSSL is
      the only implementation so the two #defines go together, but USE_SSL is
      supposed to be used for implementation-independent code.
      
      The libpq SSL code is changed to use a custom BIO, which does all the raw
      I/O, like we've been doing in the backend for a long time. That makes it
      possible to use MSG_NOSIGNAL to block SIGPIPE when using SSL, which avoids
      a couple of syscall for each send(). Probably doesn't make much performance
      difference in practice - the SSL encryption is expensive enough to mask the
      effect - but it was a natural result of this refactoring.
      
      Based on a patch by Martijn van Oosterhout from 2006. Briefly reviewed by
      Alvaro Herrera, Andreas Karlsson, Jeff Janes.
      680513ab
  2. 10 Aug, 2014 1 commit
    • Tom Lane's avatar
      Clarify type resolution behavior for domain types. · 6aa61580
      Tom Lane authored
      The user documentation was vague and not entirely accurate about how
      we treat domain inputs for ambiguous operators/functions.  Clarify
      that, and add an example and some commentary.  Per a recent question
      from Adam Mackler.
      
      It's acted like this ever since we added domains, so back-patch
      to all supported branches.
      6aa61580
  3. 09 Aug, 2014 4 commits
    • Tom Lane's avatar
      Clean up handling of unknown-type inputs in json_build_object and friends. · 92f57c9a
      Tom Lane authored
      There's actually no need for any special case for unknown-type literals,
      since we only need to push the value through its output function and
      unknownout() works fine.  The code that was here was completely bizarre
      anyway, and would fail outright in cases that should work, not to mention
      suffering from some copy-and-paste bugs.
      92f57c9a
    • Tom Lane's avatar
      Further cleanup of JSON-specific error messages. · 495cadda
      Tom Lane authored
      Fix an obvious typo in json_build_object()'s complaint about invalid
      number of arguments, and make the errhint a bit more sensible too.
      
      Per discussion about how to word the improved hint, change the few places
      in the documentation that refer to JSON object field names as "names" to
      say "keys" instead, since that's what we've said in the vast majority of
      places in the docs.  Arguably "name" is more correct, since that's the
      terminology used in RFC 7159; but we're stuck with "key" in view of the
      naming of json_object_keys() so let's at least be self-consistent.
      
      I adjusted a few code comments to match this as well, and failed to
      resist the temptation to clean up some odd whitespace choices in the
      same area, as well as a useless duplicate PG_ARGISNULL() check.  There's
      still quite a bit of code that uses the phrase "field name" in non-user-
      visible ways, so I left those usages alone.
      495cadda
    • Tom Lane's avatar
      Reject duplicate column names in foreign key referenced-columns lists. · 9da86753
      Tom Lane authored
      Such cases are disallowed by the SQL spec, and even if we wanted to allow
      them, the semantics seem ambiguous: how should the FK columns be matched up
      with the columns of a unique index?  (The matching could be significant in
      the presence of opclasses with different notions of equality, so this issue
      isn't just academic.)  However, our code did not previously reject such
      cases, but instead would either fail to match to any unique index, or
      generate a bizarre opclass-lookup error because of sloppy thinking in the
      index-matching code.
      
      David Rowley
      9da86753
    • Peter Eisentraut's avatar
      Small message fixes · f25e0bf5
      Peter Eisentraut authored
      f25e0bf5
  4. 08 Aug, 2014 2 commits
    • Fujii Masao's avatar
      Add -F option to pg_receivexlog, for specifying fsync interval. · 3dad73e7
      Fujii Masao authored
      This allows us to specify the maximum time to issue fsync to ensure
      the received WAL file is safely flushed to disk. Without this,
      pg_receivexlog always flushes WAL file only when it's closed and
      which can cause WAL data to be lost at the event of a crash.
      
      Furuya Osamu, heavily modified by me.
      3dad73e7
    • Tom Lane's avatar
      Fix typo in docs. · 1add956a
      Tom Lane authored
      s/XIDs XIDs/XIDs/ in one place in maintenance.sgml.
      
      Guillaume Lelarge
      1add956a
  5. 07 Aug, 2014 2 commits
    • Bruce Momjian's avatar
      pg_upgrade: prevent oid conflicts with new-cluster TOAST tables · 4c6780fd
      Bruce Momjian authored
      Previously, TOAST tables only required in the new cluster could cause
      oid conflicts if they were auto-numbered and a later conflicting oid had
      to be assigned.
      
      Backpatch through 9.3
      4c6780fd
    • Heikki Linnakangas's avatar
      Improve comment. · ec903d20
      Heikki Linnakangas authored
      Based on the old comment, it took me a while to figure out what the
      problem was. The importnat detail is that SSL_read() can return WANT_READ
      even though some raw data was received from the socket.
      ec903d20
  6. 06 Aug, 2014 5 commits
    • Robert Haas's avatar
      Add PG_RETURN_UINT16 macro. · 73cfa37a
      Robert Haas authored
      Manuel Kniep
      73cfa37a
    • Robert Haas's avatar
      Don't require sort support functions to provide a comparator. · 1d41739e
      Robert Haas authored
      This could be useful for datatypes like text, where we might want
      to optimize for some collations but not others.  However, this patch
      doesn't introduce any new sortsupport functions that work this way;
      it merely revises the code so that future patches may do so.
      
      Patch by me.  Review by Peter Geoghegan.
      1d41739e
    • Robert Haas's avatar
      Fix alternate regression test output file. · 873de34b
      Robert Haas authored
      Commit 0ef99bdc broke this.
      
      Jeff Janes
      873de34b
    • Fujii Masao's avatar
      Refactor pg_receivexlog main loop code, for readability, take 2. · 6805e02c
      Fujii Masao authored
      Previously the source codes for processing the received data and handling
      the end of stream were included in pg_receivexlog main loop. This commit
      splits out them as separate functions. This is useful for improving the
      readability of main loop code and making the future pg_receivexlog-related
      patch simpler.
      6805e02c
    • Fujii Masao's avatar
      Change ParseConfigFp() so that it doesn't process unused entry of each parameter. · e3da0d4d
      Fujii Masao authored
      When more than one setting entries of same parameter exist in the
      configuration file, PostgreSQL uses only entry appearing last in
      configuration file scan. Since the other entries are not used,
      ParseConfigFp() doesn't need to process them, but previously it did
      that. This problematic behavior caused the configuration file scan
      to detect invalid settings of unused entries (e.g., existence of
      multiple entries of PGC_POSTMASTER parameter) and log the messages
      complaining about them.
      
      This commit changes the configuration file scan so that it processes
      only last entry of each parameter.
      
      Note that when multiple entries of same parameter exist both in
      postgresql.conf and postgresql.auto.conf, unused entries in
      postgresql.conf are still processed only at postmaster startup.
      
      The problem has existed since old version, but a user is more likely
      to encounter it since 9.4 where ALTER SYSTEM command was introduced.
      So back-patch to 9.4.
      
      Amit Kapila, slightly modified by me. Per report from Christoph Berg.
      e3da0d4d
  7. 05 Aug, 2014 2 commits
  8. 04 Aug, 2014 3 commits
  9. 02 Aug, 2014 2 commits
  10. 01 Aug, 2014 1 commit
  11. 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
  12. 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
  13. 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
  14. 28 Jul, 2014 1 commit
  15. 27 Jul, 2014 1 commit
  16. 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
  17. 24 Jul, 2014 1 commit
    • 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