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. Feb 02, 2015
  4. Feb 01, 2015
    • 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
  5. Dec 31, 2014
    • 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
  6. 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
  7. 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
  8. Aug 30, 2014
  9. Aug 18, 2014
  10. Jul 15, 2014
  11. Jun 21, 2014
    • Kevin Grittner's avatar
      Fix documentation template for CREATE TRIGGER. · 07353de4
      Kevin Grittner authored
      By using curly braces, the template had specified that one of
      "NOT DEFERRABLE", "INITIALLY IMMEDIATE", or "INITIALLY DEFERRED"
      was required on any CREATE TRIGGER statement, which is not
      accurate.  Change to square brackets makes that optional.
      
      Backpatch to 9.1, where the error was introduced.
      07353de4
  12. Mar 25, 2014
  13. Feb 17, 2014
    • Noah Misch's avatar
      Shore up ADMIN OPTION restrictions. · 15a8f97b
      Noah Misch authored
      Granting a role without ADMIN OPTION is supposed to prevent the grantee
      from adding or removing members from the granted role.  Issuing SET ROLE
      before the GRANT bypassed that, because the role itself had an implicit
      right to add or remove members.  Plug that hole by recognizing that
      implicit right only when the session user matches the current role.
      Additionally, do not recognize it during a security-restricted operation
      or during execution of a SECURITY DEFINER function.  The restriction on
      SECURITY DEFINER is not security-critical.  However, it seems best for a
      user testing his own SECURITY DEFINER function to see the same behavior
      others will see.  Back-patch to 8.4 (all supported versions).
      
      The SQL standards do not conflate roles and users as PostgreSQL does;
      only SQL roles have members, and only SQL users initiate sessions.  An
      application using PostgreSQL users and roles as SQL users and roles will
      never attempt to grant membership in the role that is the session user,
      so the implicit right to add or remove members will never arise.
      
      The security impact was mostly that a role member could revoke access
      from others, contrary to the wishes of his own grantor.  Unapproved role
      member additions are less notable, because the member can still largely
      achieve that by creating a view or a SECURITY DEFINER function.
      
      Reviewed by Andres Freund and Tom Lane.  Reported, independently, by
      Jonas Sundman and Noah Misch.
      
      Security: CVE-2014-0060
      15a8f97b
  14. Feb 14, 2014
  15. Jan 15, 2014
    • Tom Lane's avatar
      Improve FILES section of psql reference page. · aa00af38
      Tom Lane authored
      Primarily, explain where to find the system-wide psqlrc file, per recent
      gripe from John Sutton.  Do some general wordsmithing and improve the
      markup, too.
      
      Also adjust psqlrc.sample so its comments about file location are somewhat
      trustworthy.  (Not sure why we bother with this file when it's empty,
      but whatever.)
      
      Back-patch to 9.2 where the startup file naming scheme was last changed.
      aa00af38
  16. Nov 13, 2013
  17. Jul 17, 2013
  18. Jul 05, 2013
  19. Jun 20, 2013
  20. Jun 18, 2013
    • Simon Riggs's avatar
      Fix docs on lock level for ALTER TABLE VALIDATE · 20a562f9
      Simon Riggs authored
      ALTER TABLE .. VALIDATE CONSTRAINT previously
      gave incorrect details about lock levels and
      therefore incomplete reasons to use the option.
      
      Initial bug report and fix from Marko Tiikkaja
      Reworded by me to include comments by Kevin Grittner
      20a562f9
  21. Jun 09, 2013
  22. Jun 07, 2013
    • Tom Lane's avatar
      Minor docs wordsmithing. · 58855fbf
      Tom Lane authored
      Swap the order of a couple of phrases to clarify what the adjective
      "subsequent" applies to.
      
      Joshua Tolley
      58855fbf
  23. May 27, 2013
    • Stephen Frost's avatar
      Documentation fix for ALTER TYPE .. RENAME · 02230d3c
      Stephen Frost authored
      The documentation for ALTER TYPE .. RENAME claimed to support a
      RESTRICT/CASCADE option at the 'type' level, which wasn't implemented
      and doesn't make a whole lot of sense to begin with.  What is supported,
      and previously undocumented, is
      
      ALTER TYPE .. RENAME ATTRIBUTE .. RESTRICT/CASCADE.
      
      I've updated the documentation and back-patched this to 9.1 where it was
      first introduced.
      02230d3c
  24. May 11, 2013
  25. Apr 05, 2013
  26. Mar 03, 2013
  27. Jan 28, 2013
    • Alvaro Herrera's avatar
      DROP OWNED: don't try to drop tablespaces/databases · 2d4e3387
      Alvaro Herrera authored
      My "fix" for bugs #7578 and #6116 on DROP OWNED at fe3b5eb0 not only
      misstated that it applied to REASSIGN OWNED (which it did not affect),
      but it also failed to fix the problems fully, because I didn't test the
      case of owned shared objects.  Thus I created a new bug, reported by
      Thomas Kellerer as #7748, which would cause DROP OWNED to fail with a
      not-for-user-consumption error message.  The code would attempt to drop
      the database, which not only fails to work because the underlying code
      does not support that, but is a pretty dangerous and undesirable thing
      to be doing as well.
      
      This patch fixes that bug by having DROP OWNED only attempt to process
      shared objects when grants on them are found, ignoring ownership.
      
      Backpatch to 8.3, which is as far as the previous bug was backpatched.
      2d4e3387
  28. Jan 25, 2013
  29. Dec 02, 2012
  30. Nov 29, 2012
    • Tom Lane's avatar
      Fix assorted bugs in CREATE/DROP INDEX CONCURRENTLY. · 94c014b5
      Tom Lane authored
      Commit 8cb53654, which introduced DROP
      INDEX CONCURRENTLY, managed to break CREATE INDEX CONCURRENTLY via a poor
      choice of catalog state representation.  The pg_index state for an index
      that's reached the final pre-drop stage was the same as the state for an
      index just created by CREATE INDEX CONCURRENTLY.  This meant that the
      (necessary) change to make RelationGetIndexList ignore about-to-die indexes
      also made it ignore freshly-created indexes; which is catastrophic because
      the latter do need to be considered in HOT-safety decisions.  Failure to
      do so leads to incorrect index entries and subsequently wrong results from
      queries depending on the concurrently-created index.
      
      To fix, make the final state be indisvalid = true and indisready = false,
      which is otherwise nonsensical.  This is pretty ugly but we can't add
      another column without forcing initdb, and it's too late for that in 9.2.
      (There's a cleaner fix in HEAD.)
      
      In addition, change CREATE/DROP INDEX CONCURRENTLY so that the pg_index
      flag changes they make without exclusive lock on the index are made via
      heap_inplace_update() rather than a normal transactional update.  The
      latter is not very safe because moving the pg_index tuple could result in
      concurrent SnapshotNow scans finding it twice or not at all, thus possibly
      resulting in index corruption.  This is a pre-existing bug in CREATE INDEX
      CONCURRENTLY, which was copied into the DROP code.
      
      In addition, fix various places in the code that ought to check to make
      sure that the indexes they are manipulating are valid and/or ready as
      appropriate.  These represent bugs that have existed since 8.2, since
      a failed CREATE INDEX CONCURRENTLY could leave a corrupt or invalid
      index behind, and we ought not try to do anything that might fail with
      such an index.
      
      Also fix RelationReloadIndexInfo to ensure it copies all the pg_index
      columns that are allowed to change after initial creation.  Previously we
      could have been left with stale values of some fields in an index relcache
      entry.  It's not clear whether this actually had any user-visible
      consequences, but it's at least a bug waiting to happen.
      
      In addition, do some code and docs review for DROP INDEX CONCURRENTLY;
      some cosmetic code cleanup but mostly addition and revision of comments.
      
      Portions of this need to be back-patched even further, but I'll work
      on that separately.
      
      Problem reported by Amit Kapila, diagnosis by Pavan Deolasee,
      fix by Tom Lane and Andres Freund.
      94c014b5
  31. Oct 26, 2012
    • Tom Lane's avatar
      In pg_dump, dump SEQUENCE SET items in the data not pre-data section. · 725fa25e
      Tom Lane authored
      Represent a sequence's current value as a separate TableDataInfo dumpable
      object, so that it can be dumped within the data section of the archive
      rather than in pre-data.  This fixes an undesirable inconsistency between
      the meanings of "--data-only" and "--section=data", and also fixes dumping
      of sequences that are marked as extension configuration tables, as per a
      report from Marko Kreen back in July.  The main cost is that we do one more
      SQL query per sequence, but that's probably not very meaningful in most
      databases.
      
      Back-patch to 9.1, since it has the extension configuration issue even
      though not the --section switch.
      725fa25e
  32. Oct 20, 2012
    • Tom Lane's avatar
      Fix pg_dump's handling of DROP DATABASE commands in --clean mode. · a4ef1f09
      Tom Lane authored
      In commit 4317e024, I accidentally broke
      this behavior while rearranging code to ensure that --create wouldn't
      affect whether a DATABASE entry gets put into archive-format output.
      Thus, 9.2 would issue a DROP DATABASE command in --clean mode, which is
      either useless or dangerous depending on the usage scenario.
      It should not do that, and no longer does.
      
      A bright spot is that this refactoring makes it easy to allow the
      combination of --clean and --create to work sensibly, ie, emit DROP
      DATABASE then CREATE DATABASE before reconnecting.  Ordinarily we'd
      consider that a feature addition and not back-patch it, but it seems
      silly to not include the extra couple of lines required in the 9.2
      version of the code.
      
      Per report from Guillaume Lelarge, though this is slightly more extensive
      than his proposed patch.
      a4ef1f09
  33. Oct 17, 2012
  34. Oct 04, 2012
    • Tom Lane's avatar
      Fix permissions explanations in CREATE DATABASE and CREATE SCHEMA docs. · cb4083df
      Tom Lane authored
      These reference pages still claimed that you have to be superuser to create
      a database or schema owned by a different role.  That was true before 8.1,
      but it was changed in commits aa111062 and
      f91370cd to allow assignment of ownership
      to any role you are a member of.  However, at the time we were thinking of
      that primarily as a change to the ALTER OWNER rules, so the need to touch
      these two CREATE ref pages got missed.
      cb4083df
  35. Sep 17, 2012
    • Tom Lane's avatar
      Provide adequate documentation of the "table_name *" notation. · 634d80ab
      Tom Lane authored
      Somewhere along the line, somebody decided to remove all trace of this
      notation from the documentation text.  It was still in the command syntax
      synopses, or at least some of them, but with no indication what it meant.
      This will not do, as evidenced by the confusion apparent in bug #7543;
      even if the notation is now unnecessary, people will find it in legacy
      SQL code and need to know what it does.
      634d80ab
  36. Aug 24, 2012
  37. Aug 11, 2012
  38. Aug 04, 2012
  39. Aug 03, 2012
Loading