1. 01 Aug, 2019 2 commits
  2. 31 Jul, 2019 5 commits
    • Tom Lane's avatar
      Fix pg_dump's handling of dependencies for custom opclasses. · 07b39083
      Tom Lane authored
      Since pg_dump doesn't treat the member operators and functions of operator
      classes/families (that is, the pg_amop and pg_amproc entries, not the
      underlying operators/functions) as separate dumpable objects, it missed
      their dependency information.  I think this was safe when the code was
      designed, because the default object sorting rule emits operators and
      functions before opclasses, and there were no dependency types that could
      mess that up.  However, the introduction of range types in 9.2 broke it:
      now a type can have a dependency on an opclass, allowing dependency rules
      to push the opclass before the type and hence before custom operators.
      Lacking any information showing that it shouldn't do so, pg_dump emitted
      the objects in the wrong order.
      
      Fix by teaching getDependencies() to translate pg_depend entries for
      pg_amop/amproc rows to look like dependencies for their parent opfamily.
      
      I added a regression test for this in HEAD/v12, but not further back;
      life is too short to fight with 002_pg_dump.pl.
      
      Per bug #15934 from Tom Gottfried.  Back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/15934-58b8c8ab7a09ea15@postgresql.org
      07b39083
    • Peter Eisentraut's avatar
      Run UTF8-requiring collation tests by default · f1400070
      Peter Eisentraut authored
      The tests collate.icu.utf8 and collate.linux.utf8 were previously only
      run when explicitly selected via EXTRA_TESTS.  They require a UTF8
      database, because the error messages in the expected files refer to
      that, and they use some non-ASCII characters in the tests.  Since
      users can select any locale and encoding for the regression test run,
      it was not possible to include these tests automatically.
      
      To fix, use psql's \if facility to check various prerequisites such as
      platform and the server encoding and quit the tests at the very
      beginning if the configuration is not adequate.  We then need to
      maintain alternative expected files for these tests, but they are very
      tiny and never need to change after this.
      
      These two tests are now run automatically as part of the regression
      tests.
      Reviewed-by: default avatarTom Lane <tgl@sss.pgh.pa.us>
      Discussion: https://www.postgresql.org/message-id/flat/052295c2-a2e1-9a21-bd36-8fbff8686cf3%402ndquadrant.com
      f1400070
    • Andres Freund's avatar
      Remove superfluous newlines in function prototypes. · 870b1d68
      Andres Freund authored
      These were introduced by pgindent due to fixe to broken
      indentation (c.f. 8255c7a5). Previously the mis-indentation of
      function prototypes was creatively used to reduce indentation in a few
      places.
      
      As that formatting only exists in master and REL_12_STABLE, it seems
      better to fix it in both, rather than having some odd indentation in
      v12 that somebody might copy for future patches or such.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20190728013754.jwcbe5nfyt3533vx@alap3.anarazel.de
      Backpatch: 12-
      870b1d68
    • Andres Freund's avatar
      Remove superfluous semicolon. · 6384e87b
      Andres Freund authored
      Author: Andres Freund
      6384e87b
    • Michael Paquier's avatar
      Remove orphaned structure member in pgcrypto · 652a8947
      Michael Paquier authored
      int_name has never been used for digest lookups since its introduction
      in e94dd6ab.
      
      Author: Daniel Gustafsson
      Discussion: https://postgr.es/m/386C26CB-628B-4A4C-8879-D8BF190F2C77@yesql.se
      652a8947
  3. 30 Jul, 2019 4 commits
    • Heikki Linnakangas's avatar
      Allow table AM's to use rd_amcache, too. · a29834be
      Heikki Linnakangas authored
      The rd_amcache allows an index AM to cache arbitrary information in a
      relcache entry. This commit moves the cleanup of rd_amcache so that it
      can also be used by table AMs. Nothing takes advantage of that yet, but
      I'm sure it'll come handy for anyone writing new table AMs.
      
      Backpatch to v12, where table AM interface was introduced.
      
      Reviewed-by: Julien Rouhaud
      a29834be
    • Heikki Linnakangas's avatar
      Print WAL position correctly in pg_rewind error message. · d8b094da
      Heikki Linnakangas authored
      This has been wrong ever since pg_rewind was added. The if-branch just
      above this, where we print the same error with an extra message supplied
      by XLogReadRecord() got this right, but the variable name was wrong in the
      else-branch. As a consequence, the error printed the WAL position as
      0/0 if there was an error reading a WAL file.
      
      Backpatch to 9.5, where pg_rewind was added.
      d8b094da
    • Tomas Vondra's avatar
      Don't build extended statistics on inheritance trees · 14ef15a2
      Tomas Vondra authored
      When performing ANALYZE on inheritance trees, we collect two samples for
      each relation - one for the relation alone, and one for the inheritance
      subtree (relation and its child relations). And then we build statistics
      on each sample, so for each relation we get two sets of statistics.
      
      For regular (per-column) statistics this works fine, because the catalog
      includes a flag differentiating statistics built from those two samples.
      But we don't have such flag in the extended statistics catalogs, and we
      ended up updating the same row twice, triggering this error:
      
        ERROR:  tuple already updated by self
      
      The simplest solution is to disable extended statistics on inheritance
      trees, which is what this commit is doing. In the future we may need to
      do something similar to per-column statistics, but that requires adding a
      flag to the catalog - and that's not backpatchable. Moreover, the current
      selectivity estimation code only works with individual relations, so
      building statistics on inheritance trees would be pointless anyway.
      
      Author: Tomas Vondra
      Backpatch-to: 10-
      Discussion: https://postgr.es/m/20190618231233.GA27470@telsasoft.com
      Reported-by: Justin Pryzby
      14ef15a2
    • Michael Paquier's avatar
      Fix memory leak coming from simple lists built in reindexdb · 04cf0bfc
      Michael Paquier authored
      When building a list of relations for a parallel processing of a schema
      or a database (or just a single-entry list for the non-parallel case
      with the database name), the list is allocated and built on-the-fly for
      each database processed, leaking after one database-level reindex is
      done.  This accumulates leaks when processing all databases, and could
      become a visible issue with thousands of relations.
      
      This is fixed by introducing a new routine in simple_list.c to free all
      the elements in a simple list made of strings or OIDs.  The header of
      the list may be using a variable declaration or an allocated pointer,
      so we don't have a routine to free this part to keep the interface
      simple.
      
      Per report from coverity for an issue introduced by 5ab892c3, and
      valgrind complains about the leak as well.  The idea to introduce a new
      routine in simple_list.c is from Tom Lane.
      
      Author: Michael Paquier
      Reviewed-by: Tom Lane
      04cf0bfc
  4. 29 Jul, 2019 4 commits
  5. 28 Jul, 2019 5 commits
    • Thomas Munro's avatar
      Avoid macro clash with LLVM 9. · a2a777d0
      Thomas Munro authored
      Early previews of LLVM 9 reveal that our Min() macro causes compiler
      errors in LLVM headers reached by the #include directives in
      llvmjit_inline.cpp.  Let's just undefine it.  Per buildfarm animal
      seawasp.  Back-patch to 11.
      
      Reviewed-by: Fabien Coelho, Tom Lane
      Discussion: https://postgr.es/m/20190606173216.GA6306%40alvherre.pgsql
      a2a777d0
    • Tom Lane's avatar
      Improve test coverage for LISTEN/NOTIFY. · b10f40bf
      Tom Lane authored
      We had no actual end-to-end test of NOTIFY message delivery.  In the
      core async.sql regression test, testing this is problematic because psql
      traditionally prints the PID of the sending backend, making the output
      unstable.  We also have an isolation test script, but it likewise
      failed to prove that delivery worked, because isolationtester.c had
      no provisions for detecting/reporting NOTIFY messages.
      
      Hence, add such provisions to isolationtester.c, and extend
      async-notify.spec to include direct tests of basic NOTIFY functionality.
      
      I also added tests showing that NOTIFY de-duplicates messages normally,
      but not across subtransaction boundaries.  (That's the historical
      behavior since we introduced subtransactions, though perhaps we ought
      to change it.)
      
      Patch by me, with suggestions/review by Andres Freund.
      
      Discussion: https://postgr.es/m/31304.1564246011@sss.pgh.pa.us
      b10f40bf
    • Michael Paquier's avatar
      Doc: Fix event trigger firing table · 44460d70
      Michael Paquier authored
      The table has not been updated for some commands introduced in recent
      releases, so refresh it.  While on it, reorder entries alphabetically.
      
      Backpatch all the way down for all the commands which have gone
      missing.
      
      Reported-by: Jeremy Smith
      Discussion: https://postgr.es/m/15883-afff0ea3cc2dbbb6@postgresql.org
      Backpatch-through: 9.4
      44460d70
    • Michael Paquier's avatar
      Fix typo in fd.c · b7a82317
      Michael Paquier authored
      The frontend version of walkdir() is defined in file_utils.c, and not
      initdb.c.
      
      Author: Sehrope Sarkuni
      Discussion: https://postgr.es/m/CAH7T-artawnBt4=KODNCD8Mt2ZX4CCjJT8c=_=950xjutcRZ4Q@mail.gmail.com
      b7a82317
    • Tom Lane's avatar
      Fix isolationtester race condition for notices sent before blocking. · 30717637
      Tom Lane authored
      If a test sends a notice just before blocking, it's possible on
      slow machines for isolationtester to detect the blocked state before
      it's consumed the notice.  (For this to happen, the notice would have
      to arrive after isolationtester has waited for data for 10ms, so on
      fast/lightly-loaded machines it's hard to reproduce the failure.)
      But, if we have seen the backend as blocked, it's certainly already
      sent any notices it's going to send.  Therefore, one more round of
      PQconsumeInput and PQisBusy should be enough to collect and process
      any such notices.
      
      This appears to explain the instability noted in commit ebd49928, so undo
      the hack therein to not print notices from insert-conflict-specconflict.
      
      Patch by me, diagnosis by Andres Freund.
      
      Discussion: https://postgr.es/m/14616.1564251339@sss.pgh.pa.us
      30717637
  6. 27 Jul, 2019 6 commits
    • Tom Lane's avatar
      Don't drop NOTICE messages in isolation tests. · ebd49928
      Tom Lane authored
      For its entire existence, isolationtester.c has forced client_min_messages
      to WARNING, but that seems like a very poor choice of test design.  It
      should be up to individual test scripts to manage whether they emit notices
      and to ensure that the results are stable.  (There were no NOTICE messages
      in the original set of isolation tests, so this was certainly dead code
      when committed, but perhaps it was needed at some earlier point.)
      
      It's possible that the original motivation was due to platform-dependent
      variations in the timing of stdout vs. stderr output.  That should be
      moot since commits 73bcb76b/6eda3e9c, but just in case, adjust
      isotesterNoticeProcessor to print to stdout not stderr.  (stderr seems
      like the wrong thing anyway: it should be for error printouts not expected
      test output.)
      
      Testing shows that the notices in insert-conflict-specconflict are indeed
      a bit timing-unstable on very slow machines, so hide them; maybe we can
      improve that later.  Also, make the notices in plpgsql-toast a bit less
      verbose than the original code would've had them.
      
      Discussion: https://postgr.es/m/14616.1564251339@sss.pgh.pa.us
      ebd49928
    • Michael Paquier's avatar
      Add support for --jobs in reindexdb · 5ab892c3
      Michael Paquier authored
      When doing a schema-level or a database-level operation, a list of
      relations to build is created which gets processed in parallel using
      multiple connections, based on the recent refactoring for parallel slots
      in src/bin/scripts/.  System catalogs are processed first in a
      serialized fashion to prevent deadlocks, followed by the rest done in
      parallel.
      
      This new option is not compatible with --system as reindexing system
      catalogs in parallel can lead to deadlocks, and with --index as there is
      no conflict handling for indexes rebuilt in parallel depending in the
      same relation.
      
      Author: Julien Rouhaud
      Reviewed-by: Sergei Kornilov, Michael Paquier
      Discussion: https://postgr.es/m/CAOBaU_YrnH_Jqo46NhaJ7uRBiWWEcS40VNRQxgFbqYo9kApUsg@mail.gmail.com
      5ab892c3
    • Peter Eisentraut's avatar
      pg_upgrade: Update obsolescent documentation note · 4552c0f5
      Peter Eisentraut authored
      Recently released xfsprogs 5.1.0 has reflink support enabled by
      default, so the note that it's not enabled by default can be removed.
      4552c0f5
    • Peter Eisentraut's avatar
      pg_upgrade: Default new bindir to pg_upgrade location · 959f6d6a
      Peter Eisentraut authored
      Make the directory where the pg_upgrade binary resides the default for
      new bindir, as running the pg_upgrade binary from where the new
      cluster is installed is a very common scenario.  Setting this as the
      defauly bindir for the new cluster will remove the need to provide it
      explicitly via -B in many cases.
      
      To support directories being missing from option parsing, extend the
      directory check with a missingOk mode where the path must be filled at
      a later point before being used.  Also move the exec_path check to
      earlier in setup to make sure we know the new cluster bindir when we
      scan for required executables.
      
      This removes the exec_path from the OSInfo struct as it is not used
      anywhere.
      
      Author: Daniel Gustafsson <daniel@yesql.se>
      Reviewed-by: default avatarPeter Eisentraut <peter.eisentraut@2ndquadrant.com>
      Discussion: https://www.postgresql.org/message-id/flat/9328.1552952117@sss.pgh.pa.us
      959f6d6a
    • Peter Eisentraut's avatar
      pg_upgrade: Check all used executables · 0befb4f3
      Peter Eisentraut authored
      Expand the validate_exec() calls to cover all the used binaries.
      
      Author: Daniel Gustafsson <daniel@yesql.se>
      Reviewed-by: default avatarPeter Eisentraut <peter.eisentraut@2ndquadrant.com>
      Discussion: https://www.postgresql.org/message-id/flat/9328.1552952117@sss.pgh.pa.us
      0befb4f3
    • Peter Eisentraut's avatar
      Fix typo in pg_upgrade file header · 28cb0555
      Peter Eisentraut authored
      Author: Daniel Gustafsson <daniel@yesql.se>
      28cb0555
  7. 26 Jul, 2019 8 commits
    • Alvaro Herrera's avatar
    • Tom Lane's avatar
      Tweak our special-case logic for the IANA "Factory" timezone. · 8ab66081
      Tom Lane authored
      pg_timezone_names() tries to avoid showing the "Factory" zone in
      the view, mainly because that has traditionally had a very long
      "abbreviation" such as "Local time zone must be set--see zic manual page",
      so that showing it messes up psql's formatting of the whole view.
      Since tzdb version 2016g, IANA instead uses the abbreviation "-00",
      which is sane enough that there's no reason to discriminate against it.
      
      On the other hand, it emerges that FreeBSD and possibly other packagers
      are so wedded to backwards compatibility that they hack the IANA data
      to keep the old spelling --- and not just that old spelling, but even
      older spellings that IANA used back in the stone age.  This caused the
      filter logic to fail to suppress "Factory" at all on such platforms,
      though the formatting problem is definitely real in that case.
      
      To solve both problems, get rid of the hard-wired assumption about
      exactly what Factory's abbreviation is, and instead reject abbreviations
      exceeding 31 characters.  This will allow Factory to appear in the view
      if and only if it's using the modern abbreviation.
      
      In passing, simplify the code we add to zic.c to support "zic -P"
      to remove its now-obsolete hacks to not print the Factory zone's
      abbreviation.  Unlike pg_timezone_names(), there's no reason for
      that code to support old/nonstandard timezone data.
      
      Since we generally prefer to keep timezone-related behavior the
      same in all branches, and since this is arguably a bug fix,
      back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/3961.1564086915@sss.pgh.pa.us
      8ab66081
    • Tom Lane's avatar
      Avoid choosing "localtime" or "posixrules" as TimeZone during initdb. · 3754113f
      Tom Lane authored
      Some platforms create a file named "localtime" in the system
      timezone directory, making it a copy or link to the active time
      zone file.  If Postgres is built with --with-system-tzdata, initdb
      will see that file as an exact match to localtime(3)'s behavior,
      and it may decide that "localtime" is the most preferred spelling of
      the active zone.  That's a very bad choice though, because it's
      neither informative, nor portable, nor stable if someone changes
      the system timezone setting.  Extend the preference logic added by
      commit e3846a00 so that we will prefer any other zone file that
      matches localtime's behavior over "localtime".
      
      On the same logic, also discriminate against "posixrules", which
      is another not-really-a-zone file that is often present in the
      timezone directory.  (Since we install "posixrules" but not
      "localtime", this change can affect the behavior of Postgres
      with or without --with-system-tzdata.)
      
      Note that this change doesn't prevent anyone from choosing these
      pseudo-zones if they really want to (i.e., by setting TZ for initdb,
      or modifying the timezone GUC later on).  It just prevents initdb
      from preferring these zone names when there are multiple matches to
      localtime's behavior.
      
      Since we generally prefer to keep timezone-related behavior the
      same in all branches, and since this is arguably a bug fix,
      back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/CADT4RqCCnj6FKLisvT8tTPfTP4azPhhDFJqDF1JfBbOH5w4oyQ@mail.gmail.com
      Discussion: https://postgr.es/m/27991.1560984458@sss.pgh.pa.us
      3754113f
    • Tom Lane's avatar
      Fix loss of fractional digits for large values in cash_numeric(). · b9d2c5c7
      Tom Lane authored
      Money values exceeding about 18 digits (depending on lc_monetary)
      could be inaccurately converted to numeric, due to select_div_scale()
      deciding it didn't need to compute any fractional digits.  Force
      its hand by setting the dscale of one division input to equal the
      number of fractional digits we need.
      
      In passing, rearrange the logic to not do useless work in locales
      where money values are considered integral.
      
      Per bug #15925 from Slawomir Chodnicki.  Back-patch to all supported
      branches.
      
      Discussion: https://postgr.es/m/15925-da9953e2674bb5c8@postgresql.org
      b9d2c5c7
    • Peter Eisentraut's avatar
      doc: Make libpq documentation navigable between functions · e829337d
      Peter Eisentraut authored
      Turn most mentions of libpq functions into links.  At id attributes to
      most libpq functions, where not existing yet, so that they can be
      linked to.  (In a handful of cases there were problems with the PDF
      processing toolchain, so those instances were not changed.)
      
      Author: Fabien COELHO <coelho@cri.ensmp.fr>
      Reviewed-by: default avatarPeter Eisentraut <peter.eisentraut@2ndquadrant.com>
      Discussion: https://www.postgresql.org/message-id/flat/alpine.DEB.2.21.1905121032330.27203@lancre
      e829337d
    • Peter Eisentraut's avatar
      doc: Fix some markup whitespace issues · f4100839
      Peter Eisentraut authored
      When making an xref to a varlistentry, the stylesheets use the first
      <term> as the link text.  In the cases fixed here, the <term> element
      contained extra whitespace that ended up being part of the link text,
      which looked strange in the output in some cases.  This whitespace is
      significant, so remove it since we don't want it.
      f4100839
    • Peter Eisentraut's avatar
    • Peter Eisentraut's avatar
      doc: Change libpq function ids to mixed case · d0f5d25b
      Peter Eisentraut authored
      The ids for linking to libpq functions were previously all lower-case.
      Change to mixed-case, matching the actual function name, for easier
      readability in the source.  The output isn't changed in a significant
      way, since the ids are converted to lower or upper case for file names
      and anchors.
      d0f5d25b
  8. 25 Jul, 2019 6 commits
    • Thomas Munro's avatar
      Fix LDAP test instability. · 27cd521e
      Thomas Munro authored
      After starting slapd, wait until it can accept a connection before
      beginning the real test work.  This avoids occasional test failures.
      Back-patch to 11, where the LDAP tests arrived.
      
      Author: Thomas Munro
      Reviewed-by: Michael Paquier
      Discussion: https://postgr.es/m/20190719033013.GI1859%40paquier.xyz
      27cd521e
    • Andres Freund's avatar
      Add missing (COSTS OFF) to EXPLAIN added in previous commit. · f63d9e68
      Andres Freund authored
      Backpatch: 12-, like the previous commit
      f63d9e68
    • Andres Freund's avatar
      Fix slot type handling for Agg nodes performing internal sorts. · af3deff3
      Andres Freund authored
      Since 15d8f831 we assert that - and since 7ef04e4d, 4da597ed
      rely on - the slot type for an expression's
      ecxt_{outer,inner,scan}tuple not changing, unless explicitly flagged
      as such. That allows to either skip deforming (for a virtual tuple
      slot) or optimize the code for JIT accelerated deforming
      appropriately (for other known slot types).
      
      This assumption was sometimes violated for grouping sets, when
      nodeAgg.c internally uses tuplesorts, and the child node doesn't
      return a TTSOpsMinimalTuple type slot. Detect that case, and flag that
      the outer slot might not be "fixed".
      
      It's probably worthwhile to optimize this further in the future, and
      more granularly determine whether the slot is fixed. As we already
      instantiate per-phase transition and equal expressions, we could
      cheaply set the slot type appropriately for each phase.  But that's a
      separate change from this bugfix.
      
      This commit does include a very minor optimization by avoiding to
      create a slot for handling tuplesorts, if no such sorts are
      performed. Previously we created that slot unnecessarily in the common
      case of computing all grouping sets via hashing. The code looked too
      confusing without that, as the conditions for needing a sort slot and
      flagging that the slot type isn't fixed, are the same.
      
      Reported-By: Ashutosh Sharma
      Author: Andres Freund
      Discussion: https://postgr.es/m/CAE9k0PmNaMD2oHTEAhRyxnxpaDaYkuBYkLa1dpOpn=RS0iS2AQ@mail.gmail.com
      Backpatch: 12-, where the bug was introduced in 15d8f831
      af3deff3
    • Tom Lane's avatar
      Fix syntax error in commit 20e99cdd. · cb9bb157
      Tom Lane authored
      Per buildfarm.
      cb9bb157
    • Tom Lane's avatar
      Fix failures to ignore \r when reading Windows-style newlines. · b654714f
      Tom Lane authored
      libpq failed to ignore Windows-style newlines in connection service files.
      This normally wasn't a problem on Windows itself, because fgets() would
      convert \r\n to just \n.  But if libpq were running inside a program that
      changes the default fopen mode to binary, it would see the \r's and think
      they were data.  In any case, it's project policy to ignore \r in text
      files unconditionally, because people sometimes try to use files with
      DOS-style newlines on Unix machines, where the C library won't hide that
      from us.
      
      Hence, adjust parseServiceFile() to ignore \r as well as \n at the end of
      the line.  In HEAD, go a little further and make it ignore all trailing
      whitespace, to match what it's always done with leading whitespace.
      
      In HEAD, also run around and fix up everyplace where we have
      newline-chomping code to make all those places look consistent and
      uniformly drop \r.  It is not clear whether any of those changes are
      fixing live bugs.  Most of the non-cosmetic changes are in places that
      are reading popen output, and the jury is still out as to whether popen
      on Windows can return \r\n.  (The Windows-specific code in pipe_read_line
      seems to think so, but our lack of support for this elsewhere suggests
      maybe it's not a problem in practice.)  Hence, I desisted from applying
      those changes to back branches, except in run_ssl_passphrase_command()
      which is new enough and little-tested enough that we'd probably not have
      heard about any problems there.
      
      Tom Lane and Michael Paquier, per bug #15827 from Jorge Gustavo Rocha.
      Back-patch the parseServiceFile() change to all supported branches,
      and the run_ssl_passphrase_command() change to v11 where that was added.
      
      Discussion: https://postgr.es/m/15827-e6ba53a3a7ed543c@postgresql.org
      b654714f
    • Andrew Dunstan's avatar
      Honor MSVC WindowsSDKVersion if set · 20e99cdd
      Andrew Dunstan authored
      Add a line to the project file setting the target SDK. Otherwise, in for
      example VS2017, if the default but optional 8.1 SDK is not installed the
      build will fail.
      
      Patch from Peifeng Qiu, slightly edited by me.
      
      Discussion: https://postgr.es/m/CABmtVJhw1boP_bd4=b3Qv5YnqEdL696NtHFi2ruiyQ6mFHkeQQ@mail.gmail.com
      
      Backpatch to all live branches.
      20e99cdd