Skip to content
Snippets Groups Projects
  1. Apr 02, 2015
    • Alvaro Herrera's avatar
      psql: fix \connect with URIs and conninfo strings · d4bacdcb
      Alvaro Herrera authored
      psql was already accepting conninfo strings as the first parameter in
      \connect, but the way it worked wasn't sane; some of the other
      parameters would get the previous connection's values, causing it to
      connect to a completely unexpected server or, more likely, not finding
      any server at all because of completely wrong combinations of
      parameters.
      
      Fix by explicitely checking for a conninfo-looking parameter in the
      dbname position; if one is found, use its complete specification rather
      than mix with the other arguments.  Also, change tab-completion to not
      try to complete conninfo/URI-looking "dbnames" and document that
      conninfos are accepted as first argument.
      
      There was a weak consensus to backpatch this, because while the behavior
      of using the dbname as a conninfo is nowhere documented for \connect, it
      is reasonable to expect that it works because it does work in many other
      contexts.  Therefore this is backpatched all the way back to 9.0.
      
      To implement this, routines previously private to libpq have been
      duplicated so that psql can decide what looks like a conninfo/URI
      string.  In back branches, just duplicate the same code all the way back
      to 9.2, where URIs where introduced; 9.0 and 9.1 have a simpler version.
      In master, the routines are moved to src/common and renamed.
      
      Author: David Fetter, Andrew Dunstan.  Some editorialization by me
      (probably earning a Gierth's "Sloppy" badge in the process.)
      Reviewers: Andrew Gierth, Erik Rijkers, Pavel Stěhule, Stephen Frost,
      Robert Haas, Andrew Dunstan.
      d4bacdcb
  2. Apr 01, 2015
  3. Mar 08, 2015
    • Tom Lane's avatar
      Fix documentation for libpq's PQfn(). · ae67e81e
      Tom Lane authored
      The SGML docs claimed that 1-byte integers could be sent or received with
      the "isint" options, but no such behavior has ever been implemented in
      pqGetInt() or pqPutInt().  The in-code documentation header for PQfn() was
      even less in tune with reality, and the code itself used parameter names
      matching neither the SGML docs nor its libpq-fe.h declaration.  Do a bit
      of additional wordsmithing on the SGML docs while at it.
      
      Since the business about 1-byte integers is a clear documentation bug,
      back-patch to all supported branches.
      ae67e81e
  4. Mar 02, 2015
    • Stephen Frost's avatar
      Fix pg_dump handling of extension config tables · d13bbfab
      Stephen Frost authored
      Since 9.1, we've provided extensions with a way to denote
      "configuration" tables- tables created by an extension which the user
      may modify.  By marking these as "configuration" tables, the extension
      is asking for the data in these tables to be pg_dump'd (tables which
      are not marked in this way are assumed to be entirely handled during
      CREATE EXTENSION and are not included at all in a pg_dump).
      
      Unfortunately, pg_dump neglected to consider foreign key relationships
      between extension configuration tables and therefore could end up
      trying to reload the data in an order which would cause FK violations.
      
      This patch teaches pg_dump about these dependencies, so that the data
      dumped out is done so in the best order possible.  Note that there's no
      way to handle circular dependencies, but those have yet to be seen in
      the wild.
      
      The release notes for this should include a caution to users that
      existing pg_dump-based backups may be invalid due to this issue.  The
      data is all there, but restoring from it will require extracting the
      data for the configuration tables and then loading them in the correct
      order by hand.
      
      Discussed initially back in bug #6738, more recently brought up by
      Gilles Darold, who provided an initial patch which was further reworked
      by Michael Paquier.  Further modifications and documentation updates
      by me.
      
      Back-patch to 9.1 where we added the concept of extension configuration
      tables.
      d13bbfab
  5. Feb 23, 2015
    • Heikki Linnakangas's avatar
      Fix potential deadlock with libpq non-blocking mode. · 22c9c8a7
      Heikki Linnakangas authored
      If libpq output buffer is full, pqSendSome() function tries to drain any
      incoming data. This avoids deadlock, if the server e.g. sends a lot of
      NOTICE messages, and blocks until we read them. However, pqSendSome() only
      did that in blocking mode. In non-blocking mode, the deadlock could still
      happen.
      
      To fix, take a two-pronged approach:
      
      1. Change the documentation to instruct that when PQflush() returns 1, you
      should wait for both read- and write-ready, and call PQconsumeInput() if it
      becomes read-ready. That fixes the deadlock, but applications are not going
      to change overnight.
      
      2. In pqSendSome(), drain the input buffer before returning 1. This
      alleviates the problem for applications that only wait for write-ready. In
      particular, a slow but steady stream of NOTICE messages during COPY FROM
      STDIN will no longer cause a deadlock. The risk remains that the server
      attempts to send a large burst of data and fills its output buffer, and at
      the same time the client also sends enough data to fill its output buffer.
      The application will deadlock if it goes to sleep, waiting for the socket
      to become write-ready, before the server's data arrives. In practice,
      NOTICE messages and such that the server might be sending are usually
      short, so it's highly unlikely that the server would fill its output buffer
      so quickly.
      
      Backpatch to all supported versions.
      22c9c8a7
  6. Feb 17, 2015
    • Tom Lane's avatar
      Remove code to match IPv4 pg_hba.conf entries to IPv4-in-IPv6 addresses. · d068609b
      Tom Lane authored
      In investigating yesterday's crash report from Hugo Osvaldo Barrera, I only
      looked back as far as commit f3aec2c7 where the breakage occurred
      (which is why I thought the IPv4-in-IPv6 business was undocumented).  But
      actually the logic dates back to commit 3c9bb888 and was simply
      broken by erroneous refactoring in the later commit.  A bit of archives
      excavation shows that we added the whole business in response to a report
      that some 2003-era Linux kernels would report IPv4 connections as having
      IPv4-in-IPv6 addresses.  The fact that we've had no complaints since 9.0
      seems to be sufficient confirmation that no modern kernels do that, so
      let's just rip it all out rather than trying to fix it.
      
      Do this in the back branches too, thus essentially deciding that our
      effective behavior since 9.0 is correct.  If there are any platforms on
      which the kernel reports IPv4-in-IPv6 addresses as such, yesterday's fix
      would have made for a subtle and potentially security-sensitive change in
      the effective meaning of IPv4 pg_hba.conf entries, which does not seem like
      a good thing to do in minor releases.  So let's let the post-9.0 behavior
      stand, and change the documentation to match it.
      
      In passing, I failed to resist the temptation to wordsmith the description
      of pg_hba.conf IPv4 and IPv6 address entries a bit.  A lot of this text
      hasn't been touched since we were IPv4-only.
      d068609b
  7. Feb 11, 2015
    • Michael Meskes's avatar
      Fixed array handling in ecpg. · 9be9ac42
      Michael Meskes authored
      When ecpg was rewritten to the new protocol version not all variable types
      were corrected. This patch rewrites the code for these types to fix that. It
      also fixes the documentation to correctly tell the status of array handling.
      9be9ac42
  8. Feb 06, 2015
    • Heikki Linnakangas's avatar
      Report WAL flush, not insert, position in replication IDENTIFY_SYSTEM · 2af568c6
      Heikki Linnakangas authored
      When beginning streaming replication, the client usually issues the
      IDENTIFY_SYSTEM command, which used to return the current WAL insert
      position. That's not suitable for the intended purpose of that field,
      however. pg_receivexlog uses it to start replication from the reported
      point, but if it hasn't been flushed to disk yet, it will fail. Change
      IDENTIFY_SYSTEM to report the flush position instead.
      
      Backpatch to 9.1 and above. 9.0 doesn't report any WAL position.
      2af568c6
  9. Feb 02, 2015
  10. Feb 01, 2015
    • Tom Lane's avatar
      9eadf637
    • Tom Lane's avatar
      Fix documentation of psql's ECHO all mode. · ad48256b
      Tom Lane authored
      "ECHO all" is ignored for interactive input, and has been for a very long
      time, though possibly not for as long as the documentation has claimed the
      opposite.  Fix that, and also note that empty lines aren't echoed, which
      while dubious is another longstanding behavior (it's embedded in our
      regression test files for one thing).  Per bug #12721 from Hans Ginzel.
      
      In HEAD, also improve the code comments in this area, and suppress an
      unnecessary fflush(stdout) when we're not echoing.  That would likely
      be safe to back-patch, but I'll not risk it mere hours before a release
      wrap.
      ad48256b
  11. Jan 21, 2015
    • Tom Lane's avatar
      Improve documentation of random() function. · bdde191c
      Tom Lane authored
      Move random() and setseed() to a separate table, to have them grouped
      together. Also add a notice that random() is not cryptographically secure.
      
      Back-patch of commit 75fdcec1 into
      all supported versions, per discussion of the need to document that
      random() is just a wrapper around random(3).
      bdde191c
  12. Jan 06, 2015
  13. Jan 03, 2015
  14. Dec 31, 2014
    • Tom Lane's avatar
      Docs: improve descriptions of ISO week-numbering date features. · daa63068
      Tom Lane authored
      Use the phraseology "ISO 8601 week-numbering year" in place of just
      "ISO year", and make related adjustments to other terminology.
      
      The point of this change is that it seems some people see "ISO year"
      and think "standard year", whereupon they're surprised when constructs
      like to_char(..., "IYYY-MM-DD") produce nonsensical results.  Perhaps
      hanging a few more adjectives on it will discourage them from jumping
      to false conclusions.  I put in an explicit warning against that
      specific usage, too, though the main point is to discourage people
      who haven't read this far down the page.
      
      In passing fix some nearby markup and terminology inconsistencies.
      daa63068
    • Tom Lane's avatar
      Improve consistency of parsing of psql's magic variables. · 64c50653
      Tom Lane authored
      For simple boolean variables such as ON_ERROR_STOP, psql has for a long
      time recognized variant spellings of "on" and "off" (such as "1"/"0"),
      and it also made a point of warning you if you'd misspelled the setting.
      But these conveniences did not exist for other keyword-valued variables.
      In particular, though ECHO_HIDDEN and ON_ERROR_ROLLBACK include "on" and
      "off" as possible values, none of the alternative spellings for those were
      recognized; and to make matters worse the code would just silently assume
      "on" was meant for any unrecognized spelling.  Several people have reported
      getting bitten by this, so let's fix it.  In detail, this patch:
      
      * Allows all spellings recognized by ParseVariableBool() for ECHO_HIDDEN
      and ON_ERROR_ROLLBACK.
      
      * Reports a warning for unrecognized values for COMP_KEYWORD_CASE, ECHO,
      ECHO_HIDDEN, HISTCONTROL, ON_ERROR_ROLLBACK, and VERBOSITY.
      
      * Recognizes all values for all these variables case-insensitively;
      previously there was a mishmash of case-sensitive and case-insensitive
      behaviors.
      
      Back-patch to all supported branches.  There is a small risk of breaking
      existing scripts that were accidentally failing to malfunction; but the
      consensus is that the chance of detecting real problems and preventing
      future mistakes outweighs this.
      64c50653
  15. Dec 29, 2014
    • Tom Lane's avatar
      Assorted minor fixes for psql metacommand docs. · c61e471a
      Tom Lane authored
      Document the long forms of \H \i \ir \o \p \r \w ... apparently, we have
      a long and dishonorable history of leaving out the unabbreviated names of
      psql backslash commands.
      
      Avoid saying "Unix shell"; we can just say "shell" with equal clarity,
      and not leave Windows users wondering whether the feature works for them.
      
      Improve consistency of documentation of \g \o \w metacommands.  There's
      no reason to use slightly different wording or markup for each one.
      c61e471a
  16. Dec 21, 2014
    • Tom Lane's avatar
      Docs: clarify treatment of variadic functions with zero variadic arguments. · ee56e14b
      Tom Lane authored
      Explain that you have to use "VARIADIC ARRAY[]" to pass an empty array
      to a variadic parameter position.  This was already implicit in the text
      but it seems better to spell it out.
      
      Per a suggestion from David Johnston, though I didn't use his proposed
      wording.  Back-patch to all supported branches.
      ee56e14b
  17. Dec 18, 2014
    • Tom Lane's avatar
      Improve documentation about CASE and constant subexpressions. · 3dd740b3
      Tom Lane authored
      The possibility that constant subexpressions of a CASE might be evaluated
      at planning time was touched on in 9.17.1 (CASE expressions), but it really
      ought to be explained in 4.2.14 (Expression Evaluation Rules) which is the
      primary discussion of such topics.  Add text and an example there, and
      revise the <note> under CASE to link there.
      
      Back-patch to all supported branches, since it's acted like this for a
      long time (though 9.2+ is probably worse because of its more aggressive
      use of constant-folding via replanning of nominally-prepared statements).
      Pre-9.4, also back-patch text added in commit 0ce627d4 about CASE versus
      aggregate functions.
      
      Tom Lane and David Johnston, per discussion of bug #12273.
      3dd740b3
    • Noah Misch's avatar
      Lock down regression testing temporary clusters on Windows. · 0046f651
      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
      0046f651
  18. Nov 25, 2014
    • Heikki Linnakangas's avatar
      Allow "dbname" from connection string to be overridden in PQconnectDBParams · 9b468bce
      Heikki Linnakangas authored
      If the "dbname" attribute in PQconnectDBParams contained a connection string
      or URI (and expand_dbname = TRUE), the database name from the connection
      string could not be overridden by a subsequent "dbname" keyword in the
      array. That was not intentional; all other options can be overridden.
      Furthermore, any subsequent "dbname" caused the connection string from the
      first dbname value to be processed again, overriding any values for the same
      options that were given between the connection string and the second dbname
      option.
      
      In the passing, clarify in the docs that only the first dbname option in the
      array is parsed as a connection string.
      
      Alex Shulgin. Backpatch to all supported versions.
      9b468bce
  19. Nov 19, 2014
    • Tom Lane's avatar
      Improve documentation's description of JOIN clauses. · d767aa51
      Tom Lane authored
      In bug #12000, Andreas Kunert complained that the documentation was
      misleading in saying "FROM T1 CROSS JOIN T2 is equivalent to FROM T1, T2".
      That's correct as far as it goes, but the equivalence doesn't hold when
      you consider three or more tables, since JOIN binds more tightly than
      comma.  I added a <note> to explain this, and ended up rearranging some
      of the existing text so that the note would make sense in context.
      
      In passing, rewrite the description of JOIN USING, which was unnecessarily
      vague, and hadn't been helped any by somebody's reliance on markup as a
      substitute for clear writing.  (Mostly this involved reintroducing a
      concrete example that was unaccountably removed by commit 032f3b7e.)
      
      Back-patch to all supported branches.
      d767aa51
  20. Nov 03, 2014
    • Tom Lane's avatar
      Docs: fix incorrect spelling of contrib/pgcrypto option. · 2c2c1e8b
      Tom Lane authored
      pgp_sym_encrypt's option is spelled "sess-key", not "enable-session-key".
      Spotted by Jeff Janes.
      
      In passing, improve a comment in pgp-pgsql.c to make it clearer that
      the debugging options are intentionally undocumented.
      2c2c1e8b
  21. Nov 01, 2014
  22. Oct 16, 2014
    • Tom Lane's avatar
      Support timezone abbreviations that sometimes change. · 7c67b936
      Tom Lane authored
      Up to now, PG has assumed that any given timezone abbreviation (such as
      "EDT") represents a constant GMT offset in the usage of any particular
      region; we had a way to configure what that offset was, but not for it
      to be changeable over time.  But, as with most things horological, this
      view of the world is too simplistic: there are numerous regions that have
      at one time or another switched to a different GMT offset but kept using
      the same timezone abbreviation.  Almost the entire Russian Federation did
      that a few years ago, and later this month they're going to do it again.
      And there are similar examples all over the world.
      
      To cope with this, invent the notion of a "dynamic timezone abbreviation",
      which is one that is referenced to a particular underlying timezone
      (as defined in the IANA timezone database) and means whatever it currently
      means in that zone.  For zones that use or have used daylight-savings time,
      the standard and DST abbreviations continue to have the property that you
      can specify standard or DST time and get that time offset whether or not
      DST was theoretically in effect at the time.  However, the abbreviations
      mean what they meant at the time in question (or most recently before that
      time) rather than being absolutely fixed.
      
      The standard abbreviation-list files have been changed to use this behavior
      for abbreviations that have actually varied in meaning since 1970.  The
      old simple-numeric definitions are kept for abbreviations that have not
      changed, since they are a bit faster to resolve.
      
      While this is clearly a new feature, it seems necessary to back-patch it
      into all active branches, because otherwise use of Russian zone
      abbreviations is going to become even more problematic than it already was.
      This change supersedes the changes in commit 513d06de et al to modify the
      fixed meanings of the Russian abbreviations; since we've not shipped that
      yet, this will avoid an undesirably incompatible (not to mention incorrect)
      change in behavior for timestamps between 2011 and 2014.
      
      This patch makes some cosmetic changes in ecpglib to keep its usage of
      datetime lookup tables as similar as possible to the backend code, but
      doesn't do anything about the increasingly obsolete set of timezone
      abbreviation definitions that are hard-wired into ecpglib.  Whatever we
      do about that will likely not be appropriate material for back-patching.
      Also, a potential free() of a garbage pointer after an out-of-memory
      failure in ecpglib has been fixed.
      
      This patch also fixes pre-existing bugs in DetermineTimeZoneOffset() that
      caused it to produce unexpected results near a timezone transition, if
      both the "before" and "after" states are marked as standard time.  We'd
      only ever thought about or tested transitions between standard and DST
      time, but that's not what's happening when a zone simply redefines their
      base GMT offset.
      
      In passing, update the SGML documentation to refer to the Olson/zoneinfo/
      zic timezone database as the "IANA" database, since it's now being
      maintained under the auspices of IANA.
      7c67b936
  23. Oct 09, 2014
  24. Oct 03, 2014
    • Alvaro Herrera's avatar
      Don't balance vacuum cost delay when per-table settings are in effect · 769d6815
      Alvaro Herrera authored
      When there are cost-delay-related storage options set for a table,
      trying to make that table participate in the autovacuum cost-limit
      balancing algorithm produces undesirable results: instead of using the
      configured values, the global values are always used,
      as illustrated by Mark Kirkwood in
      http://www.postgresql.org/message-id/52FACF15.8020507@catalyst.net.nz
      
      Since the mechanism is already complicated, just disable it for those
      cases rather than trying to make it cope.  There are undesirable
      side-effects from this too, namely that the total I/O impact on the
      system will be higher whenever such tables are vacuumed.  However, this
      is seen as less harmful than slowing down vacuum, because that would
      cause bloat to accumulate.  Anyway, in the new system it is possible to
      tweak options to get the precise behavior one wants, whereas with the
      previous system one was simply hosed.
      
      This has been broken forever, so backpatch to all supported branches.
      This might affect systems where cost_limit and cost_delay have been set
      for individual tables.
      769d6815
  25. Sep 19, 2014
    • Tom Lane's avatar
      Fix failure of contrib/auto_explain to print per-node timing information. · 5ff8c2d7
      Tom Lane authored
      This has been broken since commit af7914c6,
      which added the EXPLAIN (TIMING) option.  Although that commit included
      updates to auto_explain, they evidently weren't tested very carefully,
      because the code failed to print node timings even when it should, due to
      failure to set es.timing in the ExplainState struct.  Reported off-list by
      Neelakanth Nadgir of Salesforce.
      
      In passing, clean up the documentation for auto_explain's options a
      little bit, including re-ordering them into what seems to me a more
      logical order.
      5ff8c2d7
  26. Sep 14, 2014
  27. Sep 08, 2014
    • Tom Lane's avatar
      Fix psql \s to work with recent libedit, and add pager support. · 886b58b4
      Tom Lane authored
      psql's \s (print command history) doesn't work at all with recent libedit
      versions when printing to the terminal, because libedit tries to do an
      fchmod() on the target file which will fail if the target is /dev/tty.
      (We'd already noted this in the context of the target being /dev/null.)
      Even before that, it didn't work pleasantly, because libedit likes to
      encode the command history file (to ensure successful reloading), which
      renders it nigh unreadable, not to mention significantly different-looking
      depending on exactly which libedit version you have.  So let's forget using
      write_history() for this purpose, and instead print the data ourselves,
      using logic similar to that used to iterate over the history for newline
      encoding/decoding purposes.
      
      While we're at it, insert the ability to use the pager when \s is printing
      to the terminal.  This has been an acknowledged shortcoming of \s for many
      years, so while you could argue it's not exactly a back-patchable bug fix
      it still seems like a good improvement.  Anyone who's seriously annoyed
      at this can use "\s /dev/tty" or local equivalent to get the old behavior.
      
      Experimentation with this showed that the history iteration logic was
      actually rather broken when used with libedit.  It turns out that with
      libedit you have to use previous_history() not next_history() to advance
      to more recent history entries.  The easiest and most robust fix for this
      seems to be to make a run-time test to verify which function to call.
      We had not noticed this because libedit doesn't really need the newline
      encoding logic: its own encoding ensures that command entries containing
      newlines are reloaded correctly (unlike libreadline).  So the effective
      behavior with recent libedits was that only the oldest history entry got
      newline-encoded or newline-decoded.  However, because of yet other bugs in
      history_set_pos(), some old versions of libedit allowed the existing loop
      logic to reach entries besides the oldest, which means there may be libedit
      ~/.psql_history files out there containing encoded newlines in more than
      just the oldest entry.  To ensure we can reload such files, it seems
      appropriate to back-patch this fix, even though that will result in some
      incompatibility with older psql versions (ie, multiline history entries
      written by a psql with this fix will look corrupted to a psql without it,
      if its libedit is reasonably up to date).
      
      Stepan Rutz and Tom Lane
      886b58b4
    • Tom Lane's avatar
      Documentation fix: sum(float4) returns float4, not float8. · 4cadb8a5
      Tom Lane authored
      The old claim is from my commit d06ebdb8 of
      2000-07-17, but it seems to have been a plain old thinko; sum(float4) has
      been distinct from sum(float8) since Berkeley days.  Noted by KaiGai Kohei.
      
      While at it, mention the existence of sum(money), which is also of
      embarrassingly ancient vintage.
      4cadb8a5
  28. Aug 30, 2014
  29. Aug 18, 2014
  30. Aug 14, 2014
    • Tom Lane's avatar
      Update SysV parameter configuration documentation for FreeBSD. · c5e2333a
      Tom Lane authored
      FreeBSD hasn't made any use of kern.ipc.semmap since 1.1, and newer
      releases reject attempts to set it altogether; so stop recommending
      that it be adjusted.  Per bug #11161.
      
      Back-patch to all supported branches.  Before 9.3, also incorporate
      commit 7a42dff4, which touches the same text and for some reason
      was not back-patched at the time.
      c5e2333a
  31. Aug 11, 2014
    • Fujii Masao's avatar
      Fix failure to follow the directions when "init" fork was added. · 054fc309
      Fujii Masao authored
      Specifically this commit updates forkname_to_number() so that the HINT
      message includes "init" fork, and also adds the description of "init" fork
      into pg_relation_size() document.
      
      This is a part of the commit 2d001904
      which has fixed the same oversight in master and 9.4. Back-patch to
      9.1 where "init" fork was added.
      054fc309
    • Fujii Masao's avatar
      Fix documentation oversights about pageinspect and initialization fork. · 84317b07
      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
      84317b07
  32. Aug 10, 2014
    • Tom Lane's avatar
      Clarify type resolution behavior for domain types. · 6079e5d4
      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.
      6079e5d4
Loading