1. 25 Nov, 2018 3 commits
    • Michael Paquier's avatar
      Add PGXS options to control TAP and isolation tests · 03faa4a8
      Michael Paquier authored
      The following options are added for extensions:
      - TAP_TESTS, to allow an extention to run TAP tests which are the ones
      present in t/*.pl.  A subset of tests can always be run with the
      existing PROVE_TESTS for developers.
      - ISOLATION, to define a list of isolation tests.
      - ISOLATION_OPTS, to pass custom options to isolation_tester.
      
      A couple of custom Makefile targets have been accumulated across the
      tree to cover the lack of facility in PGXS for a couple of releases when
      using those test suites, which are all now replaced with the new flags,
      without reducing the test coverage.  This also fixes an issue with
      contrib/bloom/, which had a custom target to trigger its TAP tests of
      its own not part of the main check runs.
      
      Author: Michael Paquier
      Reviewed-by: Adam Berlin, Álvaro Herrera, Tom Lane, Nikolay Shaplov,
      Arthur Zakirov
      Discussion: https://postgr.es/m/20180906014849.GG2726@paquier.xyz
      03faa4a8
    • Peter Eisentraut's avatar
      Integrate recovery.conf into postgresql.conf · 2dedf4d9
      Peter Eisentraut authored
      recovery.conf settings are now set in postgresql.conf (or other GUC
      sources).  Currently, all the affected settings are PGC_POSTMASTER;
      this could be refined in the future case by case.
      
      Recovery is now initiated by a file recovery.signal.  Standby mode is
      initiated by a file standby.signal.  The standby_mode setting is
      gone.  If a recovery.conf file is found, an error is issued.
      
      The trigger_file setting has been renamed to promote_trigger_file as
      part of the move.
      
      The documentation chapter "Recovery Configuration" has been integrated
      into "Server Configuration".
      
      pg_basebackup -R now appends settings to postgresql.auto.conf and
      creates a standby.signal file.
      
      Author: Fujii Masao <masao.fujii@gmail.com>
      Author: Simon Riggs <simon@2ndquadrant.com>
      Author: Abhijit Menon-Sen <ams@2ndquadrant.com>
      Author: Sergei Kornilov <sk@zsrv.org>
      Discussion: https://www.postgresql.org/message-id/flat/607741529606767@web3g.yandex.ru/
      2dedf4d9
    • Thomas Munro's avatar
      Fix assertion failure for SSL connections. · ab69ea9f
      Thomas Munro authored
      Commit cfdf4dc4 added an assertion that every WaitLatch() or similar
      handles postmaster death.  One place did not, but was missed in
      review and testing due to the need for an SSL connection.  Fix, by
      asking for WL_EXIT_ON_PM_DEATH.
      
      Reported-by: Christoph Berg
      Discussion: https://postgr.es/m/20181124143845.GA15039%40msg.df7cb.de
      ab69ea9f
  2. 24 Nov, 2018 4 commits
    • Andrew Gierth's avatar
      Fix hstore hash function for empty hstores upgraded from 8.4. · d5890f49
      Andrew Gierth authored
      Hstore data generated on pg 8.4 and pg_upgraded to current versions
      remains in its original on-disk format unless modified. The same goes
      for values generated by the addon hstore-new module on pre-9.0
      versions. (The hstoreUpgrade function converts old values on the fly
      when read in, but the on-disk value is not modified by this.)
      
      Since old-format empty hstores (and hstore-new hstores) have
      representations compatible with the new format, hstoreUpgrade thought
      it could get away without modifying such values; but this breaks
      hstore_hash (and the new hstore_hash_extended) which assumes
      bit-perfect matching between semantically identical hstore values.
      Only one bit actually differs (the "new version" flag in the count
      field) but that of course is enough to break the hash.
      
      Fix by making hstoreUpgrade unconditionally convert all old values to
      new format.
      
      Backpatch all the way, even though this changes a hash value in some
      cases, because in those cases the hash value is already failing - for
      example, a hash join between old- and new-format empty hstores will be
      failing to match, or a hash index on an hstore column containing an
      old-format empty value will be failing to find the value since it will
      be searching for a hash derived from a new-format datum. (There are no
      known field reports of this happening, probably because hashing of
      hstores has only been useful in limited circumstances and there
      probably isn't much upgraded data being used this way.)
      
      Per concerns arising from discussion of commit eb6f2914. Original
      bug is my fault.
      
      Discussion: https://postgr.es/m/60b1fd3b-7332-40f0-7e7f-f2f04f777747%402ndquadrant.com
      d5890f49
    • Andrew Gierth's avatar
      Avoid crashes in contrib/intarray gist__int_ops (bug #15518) · 757c5182
      Andrew Gierth authored
      1. Integer overflow in internal_size could result in memory corruption
      in decompression since a zero-length array would be allocated and then
      written to. This leads to crashes or corruption when traversing an
      index which has been populated with sufficiently sparse values. Fix by
      using int64 for computations and checking for overflow.
      
      2. Integer overflow in g_int_compress could cause pessimal merge
      choices, resulting in unnecessarily large ranges (which would in turn
      trigger issue 1 above). Fix by using int64 again.
      
      3. Even without overflow, array sizes could become large enough to
      cause unexplained memory allocation errors. Fix by capping the sizes
      to a safe limit and report actual errors pointing at gist__intbig_ops
      as needed.
      
      4. Large inputs to the compression function always consist of large
      runs of consecutive integers, and the compression loop was processing
      these one at a time in an O(N^2) manner with a lot of overhead. The
      expected runtime of this function could easily exceed 6 months for a
      single call as a result. Fix by performing a linear-time first pass,
      which reduces the worst case to something on the order of seconds.
      
      Backpatch all the way, since this has been wrong forever.
      
      Per bug #15518 from report from irc user "dymk", analysis and patch by
      me.
      
      Discussion: https://postgr.es/m/15518-799e426c3b4f8358@postgresql.org
      757c5182
    • Tom Lane's avatar
      Adjust new test case for more portability. · 452b637d
      Tom Lane authored
      Early returns from the buildfarm say that most critters are good with
      commit cbdb8b4c, but gaur gives unexpected results with the test case
      involving a float8 that's one-ULP-less-than-2^63.  It appears that that
      platform's version of rint() rounds that value up to 2^63 instead of
      leaving it be.  This is possibly a bug, and it's also possible that no
      other platform anybody is using anywhere behaves likewise.  Still, the
      point of the test is not to insist that everybody's rint() behaves exactly
      the same.  Let's use two-ULPs-less-than-2^63 instead, which I've tested
      to act the same on gaur as on more modern hardware.
      
      (This is, more or less, exactly the portability issue I'd feared might
      arise...)
      
      Discussion: https://postgr.es/m/15519-4fc785b483201ff1@postgresql.org
      452b637d
    • Tom Lane's avatar
      Fix float-to-integer coercions to handle edge cases correctly. · cbdb8b4c
      Tom Lane authored
      ftoi4 and its sibling coercion functions did their overflow checks in
      a way that looked superficially plausible, but actually depended on an
      assumption that the MIN and MAX comparison constants can be represented
      exactly in the float4 or float8 domain.  That fails in ftoi4, ftoi8,
      and dtoi8, resulting in a possibility that values near the MAX limit will
      be wrongly converted (to negative values) when they need to be rejected.
      
      Also, because we compared before rounding off the fractional part,
      the other three functions threw errors for values that really ought
      to get rounded to the min or max integer value.
      
      Fix by doing rint() first (requiring an assumption that it handles
      NaN and Inf correctly; but dtoi8 and ftoi8 were assuming that already),
      and by comparing to values that should coerce to float exactly, namely
      INTxx_MIN and -INTxx_MIN.  Also remove some random cosmetic discrepancies
      between these six functions.
      
      Per bug #15519 from Victor Petrovykh.  This should get back-patched,
      but first let's see what the buildfarm thinks of it --- I'm not too
      sure about portability of some of the regression test cases.
      
      Patch by me; thanks to Andrew Gierth for analysis and discussion.
      
      Discussion: https://postgr.es/m/15519-4fc785b483201ff1@postgresql.org
      cbdb8b4c
  3. 23 Nov, 2018 9 commits
  4. 22 Nov, 2018 3 commits
  5. 21 Nov, 2018 9 commits
    • Bruce Momjian's avatar
      doc: adjust time zone names text, v2 · 9cf5d3c4
      Bruce Momjian authored
      Removed one too many words.  Fix for
      7906de84.
      
      Reported-by: Thomas Munro
      
      Backpatch-through: 9.4
      9cf5d3c4
    • Bruce Momjian's avatar
    • Alvaro Herrera's avatar
      Rework the pgbench state machine code for clarity · 3bac77c4
      Alvaro Herrera authored
      This commit continues the code improvements started by commit
      12788ae4.  With this commit, state machine transitions are better
      contained in the routine that was called doCustom() and is now called
      advanceConnectionState -- the resulting code is easier to reason about,
      since there are no state changes occuring in the outer layer.
      
      This change is prompted by future patches to add more features to
      pgbench, which will need to effect some more surgery to this code.
      
      Fabien's original had all the machine state changes inside one routine,
      but I (Álvaro) thought that a subroutine to handle command execution is
      more straightforward to review, so this commit does not match Fabien's
      submission closely.  If something is broken, it's probably my fault.
      
      Author: Fabien Coelho, Álvaro Herrera
      Reviewed-by: Kirk Jamison
      Discussion: https://postgr.es/m/alpine.DEB.2.21.1808111104320.1705@lancre
      3bac77c4
    • Alvaro Herrera's avatar
      Fix typo in commit 6f7d02aa · 03e10b96
      Alvaro Herrera authored
      Per pink buildfarm.
      03e10b96
    • Alvaro Herrera's avatar
    • Alvaro Herrera's avatar
      instr_time.h: add INSTR_TIME_SET_CURRENT_LAZY · 6f7d02aa
      Alvaro Herrera authored
      Sets the timestamp to current if not already set.  Will acquire more
      callers momentarily.
      
      Author: Fabien Coelho
      Discussion: https://postgr.es/m/alpine.DEB.2.21.1808111104320.1705@lancre
      6f7d02aa
    • Andres Freund's avatar
      7306d5e9
    • Andres Freund's avatar
      Fix sepgsql compile error caused by oid removal. · 937e4e50
      Andres Freund authored
      Per buildfarm animal rhinoceros. I (Andres) missed replacing a few
      uses of ObjectIdAttributeNumber in sepgsql.
      
      It's quite probable that the sepgsql test output will need more
      adapting than done in 578b22...
      
      Author: Thomas Munro
      Discussion: https://postgr.es/m/CAEepm=2Sk+66HJV8FLDfm_sKTn22j7cWTY_Y1Rok3RxeWL_Y0w@mail.gmail.com
      937e4e50
    • Andres Freund's avatar
      Remove WITH OIDS support, change oid catalog column visibility. · 578b2297
      Andres Freund authored
      Previously tables declared WITH OIDS, including a significant fraction
      of the catalog tables, stored the oid column not as a normal column,
      but as part of the tuple header.
      
      This special column was not shown by default, which was somewhat odd,
      as it's often (consider e.g. pg_class.oid) one of the more important
      parts of a row.  Neither pg_dump nor COPY included the contents of the
      oid column by default.
      
      The fact that the oid column was not an ordinary column necessitated a
      significant amount of special case code to support oid columns. That
      already was painful for the existing, but upcoming work aiming to make
      table storage pluggable, would have required expanding and duplicating
      that "specialness" significantly.
      
      WITH OIDS has been deprecated since 2005 (commit ff02d0a05280e0).
      Remove it.
      
      Removing includes:
      - CREATE TABLE and ALTER TABLE syntax for declaring the table to be
        WITH OIDS has been removed (WITH (oids[ = true]) will error out)
      - pg_dump does not support dumping tables declared WITH OIDS and will
        issue a warning when dumping one (and ignore the oid column).
      - restoring an pg_dump archive with pg_restore will warn when
        restoring a table with oid contents (and ignore the oid column)
      - COPY will refuse to load binary dump that includes oids.
      - pg_upgrade will error out when encountering tables declared WITH
        OIDS, they have to be altered to remove the oid column first.
      - Functionality to access the oid of the last inserted row (like
        plpgsql's RESULT_OID, spi's SPI_lastoid, ...) has been removed.
      
      The syntax for declaring a table WITHOUT OIDS (or WITH (oids = false)
      for CREATE TABLE) is still supported. While that requires a bit of
      support code, it seems unnecessary to break applications / dumps that
      do not use oids, and are explicit about not using them.
      
      The biggest user of WITH OID columns was postgres' catalog. This
      commit changes all 'magic' oid columns to be columns that are normally
      declared and stored. To reduce unnecessary query breakage all the
      newly added columns are still named 'oid', even if a table's column
      naming scheme would indicate 'reloid' or such.  This obviously
      requires adapting a lot code, mostly replacing oid access via
      HeapTupleGetOid() with access to the underlying Form_pg_*->oid column.
      
      The bootstrap process now assigns oids for all oid columns in
      genbki.pl that do not have an explicit value (starting at the largest
      oid previously used), only oids assigned later by oids will be above
      FirstBootstrapObjectId. As the oid column now is a normal column the
      special bootstrap syntax for oids has been removed.
      
      Oids are not automatically assigned during insertion anymore, all
      backend code explicitly assigns oids with GetNewOidWithIndex(). For
      the rare case that insertions into the catalog via SQL are called for
      the new pg_nextoid() function can be used (which only works on catalog
      tables).
      
      The fact that oid columns on system tables are now normal columns
      means that they will be included in the set of columns expanded
      by * (i.e. SELECT * FROM pg_class will now include the table's oid,
      previously it did not). It'd not technically be hard to hide oid
      column by default, but that'd mean confusing behavior would either
      have to be carried forward forever, or it'd cause breakage down the
      line.
      
      While it's not unlikely that further adjustments are needed, the
      scope/invasiveness of the patch makes it worthwhile to get merge this
      now. It's painful to maintain externally, too complicated to commit
      after the code code freeze, and a dependency of a number of other
      patches.
      
      Catversion bump, for obvious reasons.
      
      Author: Andres Freund, with contributions by John Naylor
      Discussion: https://postgr.es/m/20180930034810.ywp2c7awz7opzcfr@alap3.anarazel.de
      578b2297
  6. 20 Nov, 2018 7 commits
  7. 19 Nov, 2018 5 commits
    • Tom Lane's avatar
      Add needed #include. · cb09903f
      Tom Lane authored
      Per POSIX, WIFSIGNALED and related macros are provided by <sys/wait.h>.
      Apparently on Linux they're also pulled in by some other inclusions,
      but BSD-ish systems are pickier.  Fixes portability issue in ffa4cbd6.
      
      Per buildfarm.
      cb09903f
    • Tom Lane's avatar
      Handle EPIPE more sanely when we close a pipe reading from a program. · ffa4cbd6
      Tom Lane authored
      Previously, any program launched by COPY TO/FROM PROGRAM inherited the
      server's setting of SIGPIPE handling, i.e. SIG_IGN.  Hence, if we were
      doing COPY FROM PROGRAM and closed the pipe early, the child process
      would see EPIPE on its output file and typically would treat that as
      a fatal error, in turn causing the COPY to report error.  Similarly,
      one could get a failure report from a query that didn't read all of
      the output from a contrib/file_fdw foreign table that uses file_fdw's
      PROGRAM option.
      
      To fix, ensure that child programs inherit SIG_DFL not SIG_IGN processing
      of SIGPIPE.  This seems like an all-around better situation since if
      the called program wants some non-default treatment of SIGPIPE, it would
      expect to have to set that up for itself.  Then in COPY, if it's COPY
      FROM PROGRAM and we stop reading short of detecting EOF, treat a SIGPIPE
      exit from the called program as a non-error condition.  This still allows
      us to report an error for any case where the called program gets SIGPIPE
      on some other file descriptor.
      
      As coded, we won't report a SIGPIPE if we stop reading as a result of
      seeing an in-band EOF marker (e.g. COPY BINARY EOF marker).  It's
      somewhat debatable whether we should complain if the called program
      continues to transmit data after an EOF marker.  However, it seems like
      we should avoid throwing error in any questionable cases, especially in a
      back-patched fix, and anyway it would take additional code to make such
      an error get reported consistently.
      
      Back-patch to v10.  We could go further back, since COPY FROM PROGRAM
      has been around awhile, but AFAICS the only way to reach this situation
      using core or contrib is via file_fdw, which has only supported PROGRAM
      sources since v10.  The COPY statement per se has no feature whereby
      it'd stop reading without having hit EOF or an error already.  Therefore,
      I don't see any upside to back-patching further that'd outweigh the
      risk of complaints about behavioral change.
      
      Per bug #15449 from Eric Cyr.
      
      Patch by me, review by Etsuro Fujita and Kyotaro Horiguchi
      
      Discussion: https://postgr.es/m/15449-1cf737dd5929450e@postgresql.org
      ffa4cbd6
    • Alvaro Herrera's avatar
      psql: Describe partitioned tables/indexes as such · d56e0fde
      Alvaro Herrera authored
      In \d and \z, instead of conflating partitioned tables and indexes with
      plain ones, set the "type" column and table title differently to make
      the distinction obvious.  A simple ease-of-use improvement.
      
      Author: Pavel Stehule, Michaël Paquier, Álvaro Herrera
      Reviewed-by: Amit Langote
      Discussion: https://postgr.es/m/CAFj8pRDMWPgijpt_vPj1t702PgLG4Ls2NCf+rEcb+qGPpossmg@mail.gmail.com
      d56e0fde
    • Tom Lane's avatar
      Update config/ax_pthread.m4 to latest upstream version. · df303aff
      Tom Lane authored
      This change doesn't fix any bugs that we've heard about, but it seems
      like a good idea on general principles to track upstream occasionally.
      
      Discussion: https://postgr.es/m/3320.1542647565@sss.pgh.pa.us
      df303aff
    • Tom Lane's avatar
      Postpone LLVM-related uses of AC_CHECK_DECLS. · 640a4ba0
      Tom Lane authored
      Calling AC_CHECK_DECLS before we've finished setting up the compiler's
      CFLAGS seems like a pretty risky proposition, especially now that the
      first use of that macro will result in a test to see whether the compiler
      gives warning or error for undeclared built-in functions.  That answer
      could very easily get changed later than where PGAC_LLVM_SUPPORT is
      called; furthermore, it's hardly unlikely that flags such as -D_GNU_SOURCE
      could change visibility of declarations.  Hence, be a little less cavalier
      about where to do LLVM-related tests.  This results in v11 and HEAD doing
      the warning-or-error check at the same place in the script as older
      branches are doing it, which seems like a good thing.
      
      Per further thought about commits 0b59b0e8 and 16fbac39.
      640a4ba0