Skip to content
Snippets Groups Projects
  1. Feb 06, 2017
  2. Feb 02, 2017
  3. Jan 30, 2017
    • Tom Lane's avatar
      Update time zone data files to tzdata release 2016j. · a7b5de3b
      Tom Lane authored
      DST law changes in northern Cyprus (new zone Asia/Famagusta), Russia (new
      zone Europe/Saratov), Tonga, Antarctica/Casey.  Historical corrections for
      Asia/Aqtau, Asia/Atyrau, Asia/Gaza, Asia/Hebron, Italy, Malta.  Replace
      invented zone abbreviation "TOT" for Tonga with numeric UTC offset; but
      as in the past, we'll keep accepting "TOT" for input.
      a7b5de3b
  4. Jan 27, 2017
    • Tom Lane's avatar
      Orthography fixes for new castNode() macro. · d02f038c
      Tom Lane authored
      Clean up hastily-composed comment.  Normalize whitespace.
      
      Erik Rijkers and myself
      d02f038c
    • Simon Riggs's avatar
      Check interrupts during hot standby waits · 357e0612
      Simon Riggs authored
      357e0612
    • Andres Freund's avatar
      Add castNode(type, ptr) for safe casting between NodeTag based types. · cf8c86af
      Andres Freund authored
      The new function allows to cast from one NodeTag based type to
      another, while asserting that the conversion is valid.  This replaces
      the common pattern of doing a cast and a Assert(IsA(ptr, type))
      close-by.
      
      As this seems likely to be used pervasively, we decided to backpatch
      this change the addition of this macro. Otherwise backpatched fixes
      are more likely not to work on back-branches.
      
      On branches before 9.6, where we do not yet rely on inline functions
      being available, the type assertion is only performed if PG_USE_INLINE
      support is detected. The cast obviously is performed regardless.
      
      For the benefit of verifying the macro compiles in the back-branches,
      this commit contains a single use of the new macro. On master, a
      somewhat larger conversion will be committed separately.
      
      Author: Peter Eisentraut and Andres Freund
      Reviewed-By: Tom Lane
      Discussion: https://postgr.es/m/c5d387d9-3440-f5e0-f9d4-71d53b9fbe52@2ndquadrant.com
      Backpatch: 9.2-
      cf8c86af
  5. Jan 26, 2017
    • Simon Riggs's avatar
      Reset hot standby xmin after restart · 800d89a9
      Simon Riggs authored
      Hot_standby_feedback could be reset by reload and worked correctly, but if
      the server was restarted rather than reloaded the xmin was not reset.
      Force reset always if hot_standby_feedback is enabled at startup.
      
      Ants Aasma, Craig Ringer
      
      Reported-by: Ants Aasma
      800d89a9
    • Tom Lane's avatar
      Ensure that a tsquery like '!foo' matches empty tsvectors. · 2c1976a6
      Tom Lane authored
      !foo means "the tsvector does not contain foo", and therefore it should
      match an empty tsvector.  ts_match_vq() overenthusiastically supposed
      that an empty tsvector could never match any query, so it forcibly
      returned FALSE, the wrong answer.  Remove the premature optimization.
      
      Our behavior on this point was inconsistent, because while seqscans and
      GIST index searches both failed to match empty tsvectors, GIN index
      searches would find them, since GIN scans don't rely on ts_match_vq().
      That makes this certainly a bug, not a debatable definition disagreement,
      so back-patch to all supported branches.
      
      Report and diagnosis by Tom Dunstan (bug #14515); added test cases by me.
      
      Discussion: https://postgr.es/m/20170126025524.1434.97828@wrigleys.postgresql.org
      2c1976a6
  6. Jan 24, 2017
  7. Jan 23, 2017
  8. Jan 20, 2017
    • Robert Haas's avatar
      Avoid useless respawining the autovacuum launcher at high speed. · 806f9b3d
      Robert Haas authored
      When (1) autovacuum = off and (2) there's at least one database with
      an XID age greater than autovacuum_freeze_max_age and (3) all tables
      in that database that need vacuuming are already being processed by a
      worker and (4) the autovacuum launcher is started, a kind of infinite
      loop occurs.  The launcher starts a worker and immediately exits.  The
      worker, finding no worker to do, immediately starts the launcher,
      supposedly so that the next database can be processed.  But because
      datfrozenxid for that database hasn't been advanced yet, the new
      worker gets put right back into the same database as the old one,
      where it once again starts the launcher and exits.  High-speed ping
      pong ensues.
      
      There are several possible ways to break the cycle; this seems like
      the safest one.
      
      Amit Khandekar (code) and Robert Haas (comments), reviewed by
      Álvaro Herrera.
      
      Discussion: http://postgr.es/m/CAJ3gD9eWejf72HKquKSzax0r+epS=nAbQKNnykkMA0E8c+rMDg@mail.gmail.com
      806f9b3d
  9. Jan 18, 2017
    • Tom Lane's avatar
      Reset the proper GUC in create_index test. · 6290f8e9
      Tom Lane authored
      Thinko in commit a4523c5a.  It doesn't really affect anything at
      present, but it would be a problem if any tests added later in this
      file ought to get index-only-scan plans.  Back-patch, like the previous
      commit, just to avoid surprises in case we add such a test and then
      back-patch it.
      
      Nikita Glukhov
      
      Discussion: https://postgr.es/m/8b70135d-ad38-bdd8-ac92-71e2b3c273cf@postgrespro.ru
      6290f8e9
    • Alvaro Herrera's avatar
      Change some test macros to return true booleans · 75c155f6
      Alvaro Herrera authored
      These macros work fine when they are used directly in an "if" test or
      similar, but as soon as the return values are assigned to boolean
      variables (or passed as boolean arguments to some function), they become
      bugs, hopefully caught by compiler warnings.  To avoid future problems,
      fix the definitions so that they return actual booleans.
      
      To further minimize the risk that somebody uses them in back-patched
      fixes that only work correctly in branches starting from the current
      master and not in old ones, back-patch the change to supported branches
      as appropriate.
      
      See also commit af4472bc, and the long
      discussion (and larger patch) in the thread mentioned in its commit
      message.
      
      Discussion: https://postgr.es/m/18672.1483022414@sss.pgh.pa.us
      75c155f6
  10. Jan 17, 2017
    • Fujii Masao's avatar
      Fix an assertion failure related to an exclusive backup. · 9e7f00d8
      Fujii Masao authored
      Previously multiple sessions could execute pg_start_backup() and
      pg_stop_backup() to start and stop an exclusive backup at the same time.
      This could trigger the assertion failure of
      "FailedAssertion("!(XLogCtl->Insert.exclusiveBackup)".
      This happend because, even while pg_start_backup() was starting
      an exclusive backup, other session could run pg_stop_backup()
      concurrently and mark the backup as not-in-progress unconditionally.
      
      This patch introduces ExclusiveBackupState indicating the state of
      an exclusive backup. This state is used to ensure that there is only
      one session running pg_start_backup() or pg_stop_backup() at
      the same time, to avoid the assertion failure.
      
      Back-patch to all supported versions.
      
      Author: Michael Paquier
      Reviewed-By: Kyotaro Horiguchi and me
      Reported-By: Andreas Seltenreich
      Discussion: <87mvktojme.fsf@credativ.de>
      9e7f00d8
  11. Jan 14, 2017
  12. Jan 11, 2017
    • Stephen Frost's avatar
      pg_restore: Don't allow non-positive number of jobs · 2c72d9c5
      Stephen Frost authored
      pg_restore will currently accept invalid values for the number of
      parallel jobs to run (eg: -1), unlike pg_dump which does check that the
      value provided is reasonable.
      
      Worse, '-1' is actually a valid, independent, parameter (as an alias for
      --single-transaction), leading to potentially completely unexpected
      results from a command line such as:
      
        -> pg_restore -j -1
      
      Where a user would get neither parallel jobs nor a single-transaction.
      
      Add in validity checking of the parallel jobs option, as we already have
      in pg_dump, before we try to open up the archive.  Also move the check
      that we haven't been asked to run more parallel jobs than possible on
      Windows to the same place, so we do all the option validity checking
      before opening the archive.
      
      Back-patch all the way, though for 9.2 we're adding the Windows-specific
      check against MAXIMUM_WAIT_OBJECTS as that check wasn't back-patched
      originally.
      
      Discussion: https://www.postgresql.org/message-id/20170110044815.GC18360%40tamriel.snowman.net
      2c72d9c5
  13. Jan 10, 2017
    • Stephen Frost's avatar
      Fix invalid-parallel-jobs error message · 499606c8
      Stephen Frost authored
      Including the program name twice is not helpful:
      
      -> pg_dump -j -1
      pg_dump: pg_dump: invalid number of parallel jobs
      
      Correct by removing the progname from the exit_horribly() call used when
      validating the number of parallel jobs.
      
      Noticed while testing various pg_dump error cases.
      
      Back-patch to 9.3 where parallel pg_dump was added.
      499606c8
  14. Jan 06, 2017
    • Tom Lane's avatar
      Invalidate cached plans on FDW option changes. · e4380e4c
      Tom Lane authored
      This fixes problems where a plan must change but fails to do so,
      as seen in a bug report from Rajkumar Raghuwanshi.
      
      For ALTER FOREIGN TABLE OPTIONS, do this through the standard method of
      forcing a relcache flush on the table.  For ALTER FOREIGN DATA WRAPPER
      and ALTER SERVER, just flush the whole plan cache on any change in
      pg_foreign_data_wrapper or pg_foreign_server.  That matches the way
      we handle some other low-probability cases such as opclass changes, and
      it's unclear that the case arises often enough to be worth working harder.
      Besides, that gives a patch that is simple enough to back-patch with
      confidence.
      
      Back-patch to 9.3.  In principle we could apply the code change to 9.2 as
      well, but (a) we lack postgres_fdw to test it with, (b) it's doubtful that
      anyone is doing anything exciting enough with FDWs that far back to need
      this desperately, and (c) the patch doesn't apply cleanly.
      
      Patch originally by Amit Langote, reviewed by Etsuro Fujita and Ashutosh
      Bapat, who each contributed substantial changes as well.
      
      Discussion: https://postgr.es/m/CAKcux6m5cA6rRPTKkqVdJ-R=KKDfe35Q_ZuUqxDSV_4hwga=og@mail.gmail.com
      e4380e4c
  15. Jan 05, 2017
    • Tom Lane's avatar
      Fix handling of empty arrays in array_fill(). · 4e446563
      Tom Lane authored
      array_fill(..., array[0]) produced an empty array, which is probably
      what users expect, but it was a one-dimensional zero-length array
      which is not our standard representation of empty arrays.  Also, for
      no very good reason, it rejected empty input arrays; that case should
      be allowed and produce an empty output array.
      
      In passing, remove the restriction that the input array(s) have lower
      bound 1.  That seems rather pointless, and it would have needed extra
      complexity to make the check deal with empty input arrays.
      
      Per bug #14487 from Andrew Gierth.  It's been broken all along, so
      back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/20170105152156.10135.64195@wrigleys.postgresql.org
      4e446563
    • Tom Lane's avatar
      Handle OID column inheritance correctly in ALTER TABLE ... INHERIT. · 696d40d3
      Tom Lane authored
      Inheritance operations must treat the OID column, if any, much like
      regular user columns.  But MergeAttributesIntoExisting() neglected to
      do that, leading to weird results after a table with OIDs is associated
      to a parent with OIDs via ALTER TABLE ... INHERIT.
      
      Report and patch by Amit Langote, reviewed by Ashutosh Bapat, some
      adjustments by me.  It's been broken all along, so back-patch to
      all supported branches.
      
      Discussion: https://postgr.es/m/cb13cfe7-a48c-5720-c383-bb843ab28298@lab.ntt.co.jp
      696d40d3
  16. Jan 03, 2017
  17. Jan 02, 2017
  18. Jan 01, 2017
  19. Dec 30, 2016
  20. Dec 27, 2016
    • Tom Lane's avatar
      Fix interval_transform so it doesn't throw away non-no-op casts. · 0b947b69
      Tom Lane authored
      interval_transform() contained two separate bugs that caused it to
      sometimes mistakenly decide that a cast from interval to restricted
      interval is a no-op and throw it away.
      
      First, it was wrong to rely on dt.h's field type macros to have an
      ordering consistent with the field's significance; in one case they do
      not.  This led to mistakenly treating YEAR as less significant than MONTH,
      so that a cast from INTERVAL MONTH to INTERVAL YEAR was incorrectly
      discarded.
      
      Second, fls(1<<k) produces k+1 not k, so comparing its output directly
      to SECOND was wrong.  This led to supposing that a cast to INTERVAL
      MINUTE was really a cast to INTERVAL SECOND and so could be discarded.
      
      To fix, get rid of the use of fls(), and make a function based on
      intervaltypmodout to produce a field ID code adapted to the need here.
      
      Per bug #14479 from Piotr Stefaniak.  Back-patch to 9.2 where transform
      functions were introduced, because this code was born broken.
      
      Discussion: https://postgr.es/m/20161227172307.10135.7747@wrigleys.postgresql.org
      0b947b69
    • Andrew Dunstan's avatar
      Explain unaccounted for space in pgstattuple. · 99ae68da
      Andrew Dunstan authored
      In addition to space accounted for by tuple_len, dead_tuple_len and
      free_space, the table_len includes page overhead, the item pointers
      table and padding bytes.
      
      Backpatch to live branches.
      99ae68da
  21. Dec 26, 2016
    • Tom Lane's avatar
      Remove triggerable Assert in hashname(). · 56d58fa0
      Tom Lane authored
      hashname() asserted that the key string it is given is shorter than
      NAMEDATALEN.  That should surely always be true if the input is in fact a
      regular value of type "name".  However, for reasons of coding convenience,
      we allow plain old C strings to be treated as "name" values in many places.
      Some SQL functions accept arbitrary "text" inputs, convert them to C
      strings, and pass them otherwise-untransformed to syscache lookups for name
      columns, allowing an overlength input value to trigger hashname's Assert.
      
      This would be a DOS problem, except that it only happens in assert-enabled
      builds which aren't recommended for production.  In a production build,
      you'll just get a name lookup error, since regardless of the hash value
      computed by hashname, the later equality comparison checks can't match.
      Likewise, if the catalog lookup is done by seqscan or indexscan searches,
      there will just be a lookup error, since the name comparison functions
      don't contain any similar length checks, and will see an overlength input
      as unequal to any stored entry.
      
      After discussion we concluded that we should simply remove this Assert.
      It's inessential to hashname's own functionality, and having such an
      assertion in only some paths for name lookup is more of a foot-gun than
      a useful check.  There may or may not be a case for the affected callers
      to do something other than let the name lookup fail, but we'll consider
      that separately; in any case we probably don't want to change such
      behavior in the back branches.
      
      Per report from Tushar Ahuja.  Back-patch to all supported branches.
      
      Report: https://postgr.es/m/7d0809ee-6f25-c9d6-8e74-5b2967830d49@enterprisedb.com
      Discussion: https://postgr.es/m/17691.1482523168@sss.pgh.pa.us
      56d58fa0
  22. Dec 24, 2016
    • Stephen Frost's avatar
      pg_dumpall: Include --verbose option in --help output · 2ed97140
      Stephen Frost authored
      The -v/--verbose option was not included in the output from --help for
      pg_dumpall even though it's in the pg_dumpall documentation and has
      apparently been around since pg_dumpall was reimplemented in C in 2002.
      
      Fix that by adding it.
      
      Pointed out by Daniel Westermann.
      
      Back-patch to all supported branches.
      
      Discussion: https://www.postgresql.org/message-id/2020970042.4589542.1482482101585.JavaMail.zimbra%40dbi-services.com
      2ed97140
    • Stephen Frost's avatar
      Fix tab completion in psql for ALTER DEFAULT PRIVILEGES · 98f30a0e
      Stephen Frost authored
      When providing tab completion for ALTER DEFAULT PRIVILEGES, we are
      including the list of roles as possible options for completion after the
      GRANT or REVOKE.  Further, we accept FOR ROLE/IN SCHEMA at the same time
      and in either order, but the tab completion was only working for one or
      the other.  Lastly, we weren't using the actual list of allowed kinds of
      objects for default privileges for completion after the 'GRANT X ON' but
      instead were completeing to what 'GRANT X ON' supports, which isn't the
      ssame at all.
      
      Address these issues by improving the forward tab-completion for ALTER
      DEFAULT PRIVILEGES and then constrain and correct how the tail
      completion is done when it is for ALTER DEFAULT PRIVILEGES.
      
      Back-patch the forward/tail tab-completion to 9.6, where we made it easy
      to handle such cases.
      
      For 9.5 and earlier, correct the initial tab-completion to at least be
      correct as far as it goes and then add a check for GRANT/REVOKE to only
      tab-complete when the GRANT/REVOKE is the start of the command, so we
      don't try to do tab-completion after we get to the GRANT/REVOKE part of
      the ALTER DEFAULT PRIVILEGES command, which is better than providing
      incorrect completions.
      
      Initial patch for master and 9.6 by Gilles Darold, though I cleaned it
      up and added a few comments.  All bugs in the 9.5 and earlier patch are
      mine.
      
      Discussion: https://www.postgresql.org/message-id/1614593c-e356-5b27-6dba-66320a9bc68b@dalibo.com
      98f30a0e
  23. Dec 23, 2016
    • Tom Lane's avatar
      Doc: improve index entry for "median". · 090a3870
      Tom Lane authored
      We had an index entry for "median" attached to the percentile_cont function
      entry, which was pretty useless because a person following the link would
      never realize that that function was the one they were being hinted to use.
      
      Instead, make the index entry point at the example in syntax-aggregates,
      and add a <seealso> link to "percentile".
      
      Also, since that example explicitly claims to be calculating the median,
      make it use percentile_cont not percentile_disc.  This makes no difference
      in terms of the larger goals of that section, but so far as I can find,
      nearly everyone thinks that "median" means the continuous not discrete
      calculation.
      
      Per gripe from Steven Winfield.  Back-patch to 9.4 where we introduced
      percentile_cont.
      
      Discussion: https://postgr.es/m/20161223102056.25614.1166@wrigleys.postgresql.org
      090a3870
  24. Dec 22, 2016
    • Stephen Frost's avatar
      Use TSConfigRelationId in AlterTSConfiguration() · ac1ec9c1
      Stephen Frost authored
      When we are altering a text search configuration, we are getting the
      tuple from pg_ts_config and using its OID, so use TSConfigRelationId
      when invoking any post-alter hooks and setting the object address.
      
      Further, in the functions called from AlterTSConfiguration(), we're
      saving information about the command via
      EventTriggerCollectAlterTSConfig(), so we should be setting
      commandCollected to true.  Also add a regression test to
      test_ddl_deparse for ALTER TEXT SEARCH CONFIGURATION.
      
      Author: Artur Zakirov, a few additional comments by me
      Discussion: https://www.postgresql.org/message-id/57a71eba-f2c7-e7fd-6fc0-2126ec0b39bd%40postgrespro.ru
      
      Back-patch the fix for the InvokeObjectPostAlterHook() call to 9.3 where
      it was introduced, and the fix for the ObjectAddressSet() call and
      setting commandCollected to true to 9.5 where those changes to
      ProcessUtilitySlow() were introduced.
      ac1ec9c1
    • Robert Haas's avatar
      Fix broken error check in _hash_doinsert. · c2f78e5e
      Robert Haas authored
      You can't just cast a HashMetaPage to a Page, because the meta page
      data is stored after the page header, not at offset 0.  Fortunately,
      this didn't break anything because it happens to find hashm_bsize
      at the offset at which it expects to find pd_pagesize_version, and
      the values are close enough to the same that this works out.
      
      Still, it's a bug, so back-patch to all supported versions.
      
      Mithun Cy, revised a bit by me.
      c2f78e5e
Loading