Skip to content
Snippets Groups Projects
  1. 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
  2. Sep 04, 2014
  3. Aug 30, 2014
  4. Aug 29, 2014
    • Tom Lane's avatar
      Fix citext upgrade script for disallowance of oidvector element assignment. · f3998521
      Tom Lane authored
      In commit 45e02e32, we intentionally
      disallowed updates on individual elements of oidvector columns.  While that
      still seems like a sane idea in the abstract, we (I) forgot that citext's
      "upgrade from unpackaged" script did in fact perform exactly such updates,
      in order to fix the problem that citext indexes should have a collation
      but would not in databases dumped or upgraded from pre-9.1 installations.
      
      Even if we wanted to add casts to allow such updates, there's no practical
      way to do so in the back branches, so the only real alternative is to make
      citext's kluge even klugier.  In this patch, I cast the oidvector to text,
      fix its contents with regexp_replace, and cast back to oidvector.  (Ugh!)
      
      Since the aforementioned commit went into all active branches, we have to
      fix this in all branches that contain the now-broken update script.
      
      Per report from Eric Malm.
      f3998521
  5. Aug 25, 2014
  6. Aug 19, 2014
    • Noah Misch's avatar
      Install libpq DLL with $(INSTALL_SHLIB). · ebd4d9cd
      Noah Misch authored
      Programs need execute permission on a DLL file to load it.  MSYS
      "install" ignores the mode argument, and our Cygwin build statically
      links libpq into programs.  That explains the lack of buildfarm trouble.
      Back-patch to 9.0 (all supported versions).
      ebd4d9cd
  7. Aug 18, 2014
  8. Aug 16, 2014
    • Tom Lane's avatar
      Fix bogus return macros in range_overright_internal(). · 6ad25325
      Tom Lane authored
      PG_RETURN_BOOL() should only be used in functions following the V1 SQL
      function API.  This coding accidentally fails to fail since letting the
      compiler coerce the Datum representation of bool back to plain bool
      does give the right answer; but that doesn't make it a good idea.
      
      Back-patch to older branches just to avoid unnecessary code divergence.
      6ad25325
  9. 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
  10. 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
  11. 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
    • Tom Lane's avatar
      Fix conversion of domains to JSON in 9.3 and 9.2. · 15026ab9
      Tom Lane authored
      In commit 0ca6bda8, I rewrote the json.c
      code that decided how to convert SQL data types into JSON values, so that
      it no longer relied on typcategory which is a pretty untrustworthy guide
      to the output format of user-defined datatypes.  However, I overlooked the
      fact that CREATE DOMAIN inherits typcategory from the base type, so that
      the old coding did have the desirable property of treating domains like
      their base types --- but only in some cases, because not all its decisions
      turned on typcategory.  The version of the patch that went into 9.4 and
      up did a getBaseType() call to ensure that domains were always treated
      like their base types, but I omitted that from the older branches, because
      it would result in a behavioral change for domains over json or hstore;
      a change that's arguably a bug fix, but nonetheless a change that users
      had not asked for.  What I overlooked was that this meant that domains
      over numerics and boolean were no longer treated like their base types,
      and that we *did* get a complaint about, ie bug #11103 from David Grelaud.
      So let's do the getBaseType() call in the older branches as well, to
      restore their previous behavior in these cases.  That means 9.2 and 9.3
      will now make these decisions just like 9.4.  We could probably kluge
      things to still ignore the domain's base type if it's json etc, but that
      seems a bit silly.
      15026ab9
  12. Aug 09, 2014
    • Tom Lane's avatar
      Reject duplicate column names in foreign key referenced-columns lists. · b4dacab1
      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
      b4dacab1
  13. Aug 01, 2014
  14. Jul 30, 2014
    • Tom Lane's avatar
      Avoid wholesale autovacuuming when autovacuum is nominally off. · c83aed34
      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.
      c83aed34
  15. Jul 29, 2014
    • Heikki Linnakangas's avatar
      Treat 2PC commit/abort the same as regular xacts in recovery. · 1578d13d
      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).
      1578d13d
  16. Jul 28, 2014
    • Fujii Masao's avatar
      Fix typo in doc. · af9d5162
      Fujii Masao authored
      unix_socket_directories was introduced in 9.3, but the document
      in older versions wrongly have mentioned it. This commit replaces
      it with the correct older name unix_socket_directory.
      
      This is applied to only 9.2 and older supported versions.
      
      Guillaume Lelarge
      af9d5162
  17. Jul 26, 2014
    • Tom Lane's avatar
      Fix a performance problem in pg_dump's dump order selection logic. · a6c56743
      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.
      a6c56743
  18. Jul 24, 2014
  19. Jul 23, 2014
    • Tom Lane's avatar
      Rearrange documentation paragraph describing pg_relation_size(). · 1da2f64f
      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.
      1da2f64f
    • Noah Misch's avatar
      Report success when Windows kill() emulation signals an exiting process. · 748da01d
      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.
      748da01d
    • Noah Misch's avatar
      MSVC: Substitute $(top_builddir) in REGRESS_OPTS. · 98d3a7b9
      Noah Misch authored
      Commit d7cdf6ee introduced a usage
      thereof.  Back-patch to 9.0, like that commit.
      98d3a7b9
  20. Jul 22, 2014
    • Tom Lane's avatar
      Check block number against the correct fork in get_raw_page(). · 810f0d2a
      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.
      810f0d2a
    • Noah Misch's avatar
      Diagnose incompatible OpenLDAP versions during build and test. · cec0c218
      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).
      cec0c218
    • Tom Lane's avatar
      Reject out-of-range numeric timezone specifications. · f54d97c5
      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.)
      f54d97c5
  21. Jul 21, 2014
  22. Jul 20, 2014
  23. Jul 19, 2014
  24. Jul 18, 2014
    • Noah Misch's avatar
      Limit pg_upgrade authentication advice to always-secure techniques. · 9cef05e0
      Noah Misch authored
      ~/.pgpass is a sound choice everywhere, and "peer" authentication is
      safe on every platform it supports.  Cease to recommend "trust"
      authentication, the safety of which is deeply configuration-specific.
      Back-patch to 9.0, where pg_upgrade was introduced.
      9cef05e0
    • Tom Lane's avatar
      Fix two low-probability memory leaks in regular expression parsing. · a223b9e3
      Tom Lane authored
      If pg_regcomp failed after having invoked markst/cleanst, it would leak any
      "struct subre" nodes it had created.  (We've already detected all regex
      syntax errors at that point, so the only likely causes of later failure
      would be query cancel or out-of-memory.)  To fix, make sure freesrnode
      knows the difference between the pre-cleanst and post-cleanst cleanup
      procedures.  Add some documentation of this less-than-obvious point.
      
      Also, newlacon did the wrong thing with an out-of-memory failure from
      realloc(), so that the previously allocated array would be leaked.
      
      Both of these are pretty low-probability scenarios, but a bug is a bug,
      so patch all the way back.
      
      Per bug #10976 from Arthur O'Dwyer.
      a223b9e3
  25. Jul 15, 2014
    • Alvaro Herrera's avatar
      Fix REASSIGN OWNED for text search objects · b42f09fc
      Alvaro Herrera authored
      Trying to reassign objects owned by a user that had text search
      dictionaries or configurations used to fail with:
      ERROR:  unexpected classid 3600
      or
      ERROR:  unexpected classid 3602
      
      Fix by adding cases for those object types in a switch in pg_shdepend.c.
      
      Both REASSIGN OWNED and text search objects go back all the way to 8.1,
      so backpatch to all supported branches.  In 9.3 the alter-owner code was
      made generic, so the required change in recent branches is pretty
      simple; however, for 9.2 and older ones we need some additional
      reshuffling to enable specifying objects by OID rather than name.
      
      Text search templates and parsers are not owned objects, so there's no
      change required for them.
      
      Per bug #9749 reported by Michal Novotný
      b42f09fc
    • Simon Riggs's avatar
      Reset master xmin when hot_standby_feedback disabled. · 2dde11a6
      Simon Riggs authored
      If walsender has xmin of standby then ensure we
      reset the value to 0 when we change from hot_standby_feedback=on
      to hot_standby_feedback=off.
      2dde11a6
    • Peter Eisentraut's avatar
      doc: small fixes for REINDEX reference page · f18858dc
      Peter Eisentraut authored
      From: Josh Kupershmidt <schmiddy@gmail.com>
      f18858dc
  26. Jul 12, 2014
    • Magnus Hagander's avatar
      Add autocompletion of locale keywords for CREATE DATABASE · 2ead596c
      Magnus Hagander authored
      Adds support for autocomplete of LC_COLLATE and LC_CTYPE to
      the CREATE DATABASE command in psql.
      2ead596c
    • Tom Lane's avatar
      Fix bug with whole-row references to append subplans. · 261f954e
      Tom Lane authored
      ExecEvalWholeRowVar incorrectly supposed that it could "bless" the source
      TupleTableSlot just once per query.  But if the input is coming from an
      Append (or, perhaps, other cases?) more than one slot might be returned
      over the query run.  This led to "record type has not been registered"
      errors when a composite datum was extracted from a non-blessed slot.
      
      This bug has been there a long time; I guess it escaped notice because when
      dealing with subqueries the planner tends to expand whole-row Vars into
      RowExprs, which don't have the same problem.  It is possible to trigger
      the problem in all active branches, though, as illustrated by the added
      regression test.
      261f954e
Loading