1. 14 Aug, 2014 2 commits
  2. 13 Aug, 2014 3 commits
    • Tom Lane's avatar
      Prevent memory leaks in parseRelOptions(). · a844c299
      Tom Lane authored
      parseRelOptions() tended to leak memory in the caller's context.  Most
      of the time this doesn't really matter since the caller's context is
      at most query-lifespan, and the function won't be invoked very many times.
      However, when testing with CLOBBER_CACHE_RECURSIVELY, the same relcache
      entry can get rebuilt a *lot* of times in one query, leading to significant
      intraquery memory bloat if it has any reloptions.  Noted while
      investigating a related report from Tomas Vondra.
      
      In passing, get rid of some Asserts that are redundant with the one
      done by deconstruct_array().
      
      As with other patches to avoid leaks in CLOBBER_CACHE testing, it doesn't
      really seem worth back-patching this.
      a844c299
    • Tom Lane's avatar
      Prevent memory leaks in RelationGetIndexList, RelationGetIndexAttrBitmap. · ab8c84db
      Tom Lane authored
      When replacing rd_indexlist, rd_indexattr, etc, we neglected to pfree any
      old value of these fields.  Under ordinary circumstances, the old value
      would always be NULL, so this seemed reasonable enough.  However, in cases
      where we're rebuilding a system catalog's relcache entry and another cache
      flush occurs on that same catalog meanwhile, it's possible for the field to
      not be NULL when we return to the outer level, because we already refilled
      it while recovering from the inner flush.  This leads to a fairly small
      session-lifespan leak in CacheMemoryContext.  In real-world usage the leak
      would be too small to notice; but in testing with CLOBBER_CACHE_RECURSIVELY
      the leakage can add up to the point of causing OOM failures, as reported by
      Tomas Vondra.
      
      The issue has been there a long time, but it only seems worth fixing in
      HEAD, like the previous fix in this area (commit 078b2ed2).
      ab8c84db
    • Fujii Masao's avatar
      Expose -S option in pg_receivexlog. · 52bffe34
      Fujii Masao authored
      This option is equivalent to --slot option which pg_receivexlog has
      already supported, which specifies the replication slot to use for
      WAL streaming. pg_recvlogical has already supported both options,
      and this commit makes pg_receivexlog consistent with pg_recvlogical
      regarding the slot option.
      
      Back-patch to 9.4 where the slot option was added.
      
      Michael Paquier
      52bffe34
  3. 12 Aug, 2014 6 commits
    • Andres Freund's avatar
      pg_recvlogical message and code improvements. · 596385be
      Andres Freund authored
      Some error messages complained about --init and --stop being used
      whereas the --create and --drop are the correct verbs. Fix that.
      
      Also a XLogRecPtr was tested in a boolean fashion instead of being
      compared to InvalidXLogRecPtr.
      
      Backpatch to 9.4 where pg_recvlogical was introduced.
      
      Michael Paquier
      596385be
    • Fujii Masao's avatar
      Fix typo in \setrandom document. · d6ded369
      Fujii Masao authored
      Fabien COELHO
      d6ded369
    • Andres Freund's avatar
      Be less aggressive in asking for feedback of logical walsender clients. · 41d5f8ad
      Andres Freund authored
      When doing logical decoding using START_LOGICAL_REPLICATION in a
      walsender process the walsender sometimes was sending out keepalive
      messages too frequently. Asking for feedback every time.
      
      WalSndWaitForWal() sends out keepalive messages when it's waiting for
      new WAL to be generated locally when it sees that the remote side
      hasn't yet flushed WAL up to the local position. That generally is
      good but causes problems if the remote side only writes but doesn't
      flush changes yet. So check for both remote write and flush position.
      
      Additionally we've asked for feedback to the keepalive message which
      isn't warranted when waiting for WAL in contrast to preventing
      timeouts because of wal_sender_timeout.
      
      Complaint and patch by Steve Singer.
      41d5f8ad
    • Tatsuo Ishii's avatar
      Enhance pgbench's option checking. · 51222a17
      Tatsuo Ishii authored
      Now benchmarking options such as -c cannot be used if initializing
      option (-i) is specified.  Also initializing options such as -F cannot
      be used if initializing option is not specified.
      
      Tatsuo Ishii and Fabien COELHO.
      51222a17
    • Fujii Masao's avatar
      Change first call of ProcessConfigFile so as to process only data_directory. · 3e3f6597
      Fujii Masao authored
      When both postgresql.conf and postgresql.auto.conf have their own entry of
      the same parameter, PostgreSQL uses the entry in postgresql.auto.conf because
      it appears last in the configuration scan. IOW, the other entries which appear
      earlier are ignored. But, previously, ProcessConfigFile() detected the invalid
      settings of even those unused entries and emitted the error messages
      complaining about them, at postmaster startup. Complaining about the entries
      to ignore is basically useless.
      
      This problem happened because ProcessConfigFile() was called twice at
      postmaster startup and the first call read only postgresql.conf. That is, the
      first call could check the entry which might be ignored eventually by
      the second call which read both postgresql.conf and postgresql.auto.conf.
      To work around the problem, this commit changes ProcessConfigFile so that
      its first call processes only data_directory and the second one does all the
      entries. It's OK to process data_directory in the first call because it's
      ensured that data_directory doesn't exist in postgresql.auto.conf.
      
      Back-patch to 9.4 where postgresql.auto.conf was added.
      
      Patch by me. Review by Amit Kapila
      3e3f6597
    • Fujii Masao's avatar
      Add tab-completion for \unset and valid setting values of psql variables. · e15c4ab5
      Fujii Masao authored
      This commit also changes tab-completion for \set so that it displays
      all the special variables like COMP_KEYWORD_CASE. Previously it displayed
      only variables having the set values. Which was not user-friendly for
      those who want to set the unset variables.
      
      This commit also changes tab-completion for :variable so that only the
      variables having the set values are displayed. Previously even unset
      variables were displayed.
      
      Pavel Stehule, modified by me.
      e15c4ab5
  4. 11 Aug, 2014 2 commits
    • Fujii Masao's avatar
      Fix documentation oversights about pageinspect and initialization fork. · 7d835ff4
      Fujii Masao authored
      The initialization fork was added in 9.1, but has not been taken into
      consideration in documents of get_raw_page function in pageinspect and
      storage layout. This commit fixes those oversights.
      
      get_raw_page can read not only a table but also an index, etc. So it
      should be documented that the function can read any relation. This commit
      also fixes the document of pageinspect that way.
      
      Back-patch to 9.1 where those oversights existed.
      
      Vik Fearing, review by MauMau
      7d835ff4
    • 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 05 Aug, 2014 2 commits
  11. 04 Aug, 2014 3 commits
  12. 02 Aug, 2014 2 commits
  13. 01 Aug, 2014 1 commit
  14. 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
  15. 30 Jul, 2014 4 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