1. 09 May, 2018 12 commits
    • Tom Lane's avatar
      Update time zone data files to tzdata release 2018e. · 234bb985
      Tom Lane authored
      DST law changes in North Korea.  Redefinition of "daylight savings" in
      Ireland, as well as for some past years in Namibia and Czechoslovakia.
      Additional historical corrections for Czechoslovakia.
      
      With this change, the IANA database models Irish timekeeping as following
      "standard time" in summer, and "daylight savings" in winter, so that the
      daylight savings offset is one hour behind standard time not one hour
      ahead.  This does not change their UTC offset (+1:00 in summer, 0:00 in
      winter) nor their timezone abbreviations (IST in summer, GMT in winter),
      though now "IST" is more correctly read as "Irish Standard Time" not "Irish
      Summer Time".  However, the "is_dst" column in the pg_timezone_names view
      will now be true in winter and false in summer for the Europe/Dublin zone.
      
      Similar changes were made for Namibia between 1994 and 2017, and for
      Czechoslovakia between 1946 and 1947.
      
      So far as I can find, no Postgres internal logic cares about which way
      tm_isdst is reported; in particular, since commit b2cbced9 we do not
      rely on it to decide how to interpret ambiguous timestamps during DST
      transitions.  So I don't think this change will affect any Postgres
      behavior other than the timezone-view outputs.
      
      Discussion: https://postgr.es/m/30996.1525445902@sss.pgh.pa.us
      234bb985
    • Alvaro Herrera's avatar
      pgstatindex, pageinspect: handle partitioned indexes · bef5fcc3
      Alvaro Herrera authored
      Commit 8b08f7d4 failed to update these modules to at least give
      non-broken error messages for partitioned indexes.  Add appropriate
      error support to them.
      
      Peter G. was complaining about a problem of unfriendly error messages;
      while we haven't fixed that yet, subsequent discussion let to discovery
      of these unhandled cases.
      
      Author: Michaël Paquier
      Reported-by: Peter Geoghegan
      Discussion: https://postgr.es/m/CAH2-WzkOKptQiE51Bh4_xeEHhaBwHkZkGtKizrFMgEkfUuRRQg@mail.gmail.com
      bef5fcc3
    • Alvaro Herrera's avatar
      pgstatindex: HASH -> hash · c8478f4f
      Alvaro Herrera authored
      Fix the lone error message in the whole source tree to use capitalized
      HASH when referring to hash indexes, making it look like all the other
      messages.
      
      Someday it would be good to standardize 'B-Tree', 'B-tree', 'btree', and
      random other spellings, too, but that's a larger patch ...
      
      Author: Álvaro Herrera
      c8478f4f
    • Alvaro Herrera's avatar
      Add relkind 'I' to catalog.sgml's list relkinds · 550091f2
      Alvaro Herrera authored
      Commit 8b08f7d4 added a relkind for local partitioned indexes, but
      failed to add it to pg_class's list of possible relkinds.  Repair.
      
      Author: Peter Geoghegan, Michaël Paquier
      Discussion: https://postgr.es/m/CAH2-WzkOKptQiE51Bh4_xeEHhaBwHkZkGtKizrFMgEkfUuRRQg@mail.gmail.com
      550091f2
    • Alvaro Herrera's avatar
      Fix assorted partition pruning bugs · d758d970
      Alvaro Herrera authored
      match_clause_to_partition_key failed to consider COERCION_PATH_ARRAYCOERCE
      cases in scalar-op-array expressions, so it was possible to crash the
      server easily.  To handle this case properly (ie. prune partitions) we
      would need to run a bit of executor code during planning.  Maybe it can
      be improved, but for now let's just not crash.  Add a test case that
      used to trigger the crash.
      Author: Michaël Paquier
      
      match_clause_to_partition_key failed to indicate that operators that
      don't have a commutator in a btree opclass are unsupported.  It is
      possible for this to cause a crash later if such an operator is used in
      a scalar-op-array expression.  Add a test case that used to the crash.
      Author: Amit Langote
      
      One caller of gen_partprune_steps_internal in
      match_clause_to_partition_key was too optimistic about the former never
      returning an empty step list.  Rid it of its innocence.  (Having fixed
      the bug above, I no longer know how to exploit this, so no test case for
      it, but it remained a bug.)  Revise code flow a little bit, for
      succintness.
      Author: Álvaro Herrera
      
      Reported-by: Marina Polyakova
      Reviewed-by: Michaël Paquier
      Reviewed-by: Amit Langote
      Reviewed-by: Álvaro Herrera
      Discussion: https://postgr.es/m/ff8f9bfa485ff961d6bb43e54120485b@postgrespro.ru
      d758d970
    • Andrew Dunstan's avatar
      Restrict vertical tightness to parentheses in Perl code · 35361ee7
      Andrew Dunstan authored
      The vertical tightness settings collapse vertical whitespace between
      opening and closing brackets (parentheses, square brakets and braces).
      This can make data structures in particular harder to read, and is not
      very consistent with our style in non-Perl code. This patch restricts
      that setting to parentheses only, and reformats all the perl code
      accordingly. Not applying this to parentheses has some unfortunate
      effects, so the consensus is to keep the setting for parentheses and not
      for the others.
      
      The diff for this patch does highlight some places where structures
      should have trailing commas. They can be added manually, as there is no
      automatic tool to do so.
      
      Discussion: https://postgr.es/m/a2f2b87c-56be-c070-bfc0-36288b4b41c1@2ndQuadrant.com
      35361ee7
    • Andrew Dunstan's avatar
    • Alvaro Herrera's avatar
      Make gen_partprune_steps static · d1e2cac5
      Alvaro Herrera authored
      There's no need to export this function, so don't.  Michaël didn't
      actually write the patch, but we list him as first author because with a
      trivial one like this, intellectual authorship is as important (if not
      more) as bit shovelling.
      
      Author: Michaël Paquier, Amit Langote
      Discussion: https://postgr.es/m/c91299c4-199b-0f16-339b-a29d6d2a39ee@lab.ntt.co.jp
      d1e2cac5
    • Alvaro Herrera's avatar
      Remove useless 'default' clause · c775fb9e
      Alvaro Herrera authored
      Author: Michael Paquier
      Reviewed-by: Amit Langote
      Reviewed-by: Álvaro Herrera
      Discussion: https://postgr.es/m/20180424012042.GD1570@paquier.xyz
      Discussion: https://postgr.es/m/20180509061039.GC11897@paquier.xyz
      c775fb9e
    • Andrew Dunstan's avatar
      Add a script and a config file to run perlcritic · 91703ca2
      Andrew Dunstan authored
      This is similar to what we do to run perltidy. For now we only run at
      severity level 5. Over time we can improve our perl code and reduce the
      severity level.
      
      Discussion: https://postgr.es/m/86aa2a3a-0c68-21fb-9560-84ad6914d561@2ndQuadrant.com
      91703ca2
    • Teodor Sigaev's avatar
      Improve jsonb cast error message · cb5d9429
      Teodor Sigaev authored
      Initial variant of error message didn't follow style of another casting error
      messages and wasn't informative. Per gripe from Robert Haas.
      
      Reviewer: Tom Lane
      Discussion: https://www.postgresql.org/message-id/flat/CA%2BTgmob08StTV9yu04D0idRFNMh%2BUoyKax5Otvrix7rEZC8rMw%40mail.gmail.com#CA+Tgmob08StTV9yu04D0idRFNMh+UoyKax5Otvrix7rEZC8rMw@mail.gmail.com
      cb5d9429
    • Tom Lane's avatar
      Improve inefficient regexes in vacuumdb TAP test. · c63913ca
      Tom Lane authored
      The regexes used in 102_vacuumdb_stages.pl to check the postmaster log
      for expected output contained several places with ".*.*", which is
      underdetermined and can cause exponential runtime growth in Perl's regex
      matcher (since it's not bright enough not to waste time seeing whether
      different splits of the same substring would allow a match).  We were
      fortunate that the amount of text in the postmaster log was generally not
      enough to make the runtime go to the moon; although commit 6271fceb had
      been on the hairy edge of an obvious problem, thanks to its increasing the
      default log verbosity to DEBUG1.  Experimentation shows that anyone who
      tried to run this test case with an even higher log verbosity would have
      been in for serious pain.  But even at default logging level, fixing this
      saves several hundred ms on my workstation, more on slower buildfarm
      members.
      
      Remove the extra ".*"s, restoring more-or-less-linear matching speed.
      Back-patch to 9.4 where the test case was added, mostly in case anyone
      tries to do related debugging in a back branch.
      
      Discussion: https://postgr.es/m/32459.1525657786@sss.pgh.pa.us
      c63913ca
  2. 08 May, 2018 3 commits
    • Tom Lane's avatar
      Improve initdb's query for generating default descriptions a little. · dec10340
      Tom Lane authored
      While poking into initdb's performance, I noticed that this query
      wasn't being done very intelligently.  By forcing it to execute
      obj_description() for each pg_proc/pg_operator join row, we were
      essentially setting up a nestloop join to pg_description, which
      is not a bright query plan when there are hundreds of outer rows.
      Convert the check for a "deprecated" operator into a NOT EXISTS
      so that it can be done as a hashed antijoin.  On my workstation
      this reduces the time for this query from ~ 35ms to ~ 10ms.
      Which is not a huge win, but it adds up over buildfarm runs.
      
      In passing, insert forced query breaks (\n\n, in single-user mode)
      after each SQL-query file that initdb sources, and after some
      relatively new queries in setup_privileges().  This doesn't make
      a lot of difference normally, but it will result in briefer, saner
      error messages if anything goes wrong.
      dec10340
    • Peter Eisentraut's avatar
      Refine error messages · 831f5d11
      Peter Eisentraut authored
      "JSON" when not referring to a data type should be upper case.
      831f5d11
    • Tom Lane's avatar
      Count heap tuples in non-SnapshotAny path in IndexBuildHeapRangeScan(). · 3a675f72
      Tom Lane authored
      Brown-paper-bag bug in commit 7c91a036: when we rearranged the placement
      of "reltuples += 1" statements, we missed including one in this code path.
      
      The net effect of that was that CREATE INDEX CONCURRENTLY would set the
      table's pg_class.reltuples to zero, as would index builds done during
      bootstrap mode.  (It seems like parallel index builds ought to fail
      similarly, but they don't, perhaps because reltuples is computed in some
      other way.  You certainly couldn't figure that out from the abysmally
      underdocumented parallelism code in this area.)
      
      I was led to this by wondering why initdb seemed to have slowed down as
      a result of 7c91a036, as is evident in the buildfarm's timing history.
      The reason is that every system catalog with indexes had pg_class.reltuples
      = 0 after bootstrap, causing the planner to make some terrible choices for
      queries in the post-bootstrap steps.  On my workstation, this fix causes
      the runtime of "initdb -N" to drop from ~2.0 sec to ~1.4 sec, which is
      almost though not quite back to where it was in v10.  That's not much of
      a deal for production use perhaps, but it makes a noticeable difference
      for buildfarm and "make check-world" runs, which do a lot of initdbs.
      3a675f72
  3. 07 May, 2018 11 commits
  4. 06 May, 2018 2 commits
  5. 05 May, 2018 4 commits
    • Tom Lane's avatar
      Fix bootstrap parser so that its keywords are unreserved words. · d160882a
      Tom Lane authored
      Mark Dilger pointed out that the bootstrap parser does not allow
      any of its keywords to appear as column values unless they're quoted,
      and proposed dealing with that by quoting such values in genbki.pl.
      Looking closer, though, we also have that problem with respect to table,
      column, and type names appearing in the .bki file: the parser would fail
      if any of those matched any of its keywords.  While so far there have
      been no conflicts (that I've heard of), this seems like a booby trap
      waiting to catch somebody.  Rather than clutter genbki.pl with enough
      quoting logic to handle all that, let's make the bootstrap parser grow
      up a little bit and treat its keywords as unreserved.
      
      Experimentation shows that it's fairly easy to do so with the exception
      of _null_, which I don't have a big problem with keeping as a reserved
      word.  The only change needed is that we can't have the "close" command
      take an optional table name: it has to either require or forbid the
      table name to avoid shift/reduce conflicts.  genbki.pl has historically
      always included the table name, so I took that option.
      
      The implementation has bootscanner.l passing forward the string value
      of each keyword, in case bootparse.y needs that.  This avoids needing to
      know the precise spelling of each keyword in bootparse.y, which is good
      because that's not always obvious from the token name.
      
      Discussion: https://postgr.es/m/3024FC91-DB6D-4732-B31C-DF772DF039A0@gmail.com
      d160882a
    • Tom Lane's avatar
      Revert "Test conversion of NaN between float4 and float8." · 5c4c771d
      Tom Lane authored
      This reverts commit 55e0e458.
      It's served its purpose of demonstrating what was wrong on
      buildfarm member opossum.  We could consider putting some kind
      of single-purpose hack into ftod() to make the test pass there;
      but I don't think it's worth the trouble, since there are surely
      many other places whether this platform bug could manifest.
      5c4c771d
    • Tom Lane's avatar
      Put in_range_float4_float8's work in-line. · cb3e9e40
      Tom Lane authored
      In commit 8b29e88c, I'd dithered about whether to make
      in_range_float4_float8 be a standalone copy of the float in-range logic
      or have it punt to in_range_float8_float8.  I went with the latter, which
      saves code space though at the cost of performance and readability.
      
      However, it emerges that this tickles a compiler or hardware bug on
      buildfarm member opossum.  Test results from commit 55e0e458 show
      conclusively that widening a float4 NaN to float8 produces Inf, not NaN,
      on that machine; which accounts perfectly for the window RANGE test
      failures it's been showing.  We can dodge this problem by making
      in_range_float4_float8 be an independent function, so that it checks
      for NaN inputs before widening them.
      
      Ordinarily I'd not be very excited about working around such obviously
      broken functionality; but given that this was a judgment call to begin
      with, I don't mind reversing it.
      cb3e9e40
    • Peter Eisentraut's avatar
      2f525187
  6. 04 May, 2018 8 commits
    • Tom Lane's avatar
      First-draft release notes for 10.4. · 488ccfe4
      Tom Lane authored
      As usual, the release notes for other branches will be made by cutting
      these down, but put them up for community review first.
      488ccfe4
    • Heikki Linnakangas's avatar
      Fix scenario where streaming standby gets stuck at a continuation record. · 06687198
      Heikki Linnakangas authored
      If a continuation record is split so that its first half has already been
      removed from the master, and is only present in pg_wal, and there is a
      recycled WAL segment in the standby server that looks like it would
      contain the second half, recovery would get stuck. The code in
      XLogPageRead() incorrectly started streaming at the beginning of the
      WAL record, even if we had already read the first page.
      
      Backpatch to 9.4. In principle, older versions have the same problem, but
      without replication slots, there was no straightforward mechanism to
      prevent the master from recycling old WAL that was still needed by standby.
      Without such a mechanism, I think it's reasonable to assume that there's
      enough slack in how many old segments are kept around to not run into this,
      or you have a WAL archive.
      
      Reported by Jonathon Nelson. Analysis and patch by Kyotaro HORIGUCHI, with
      some extra comments by me.
      
      Discussion: https://www.postgresql.org/message-id/CACJqAM3xVz0JY1XFDKPP%2BJoJAjoGx%3DGNuOAshEDWCext7BFvCQ%40mail.gmail.com
      06687198
    • Alvaro Herrera's avatar
      Don't mark pages all-visible spuriously · d2599ecf
      Alvaro Herrera authored
      Dan Wood diagnosed a long-standing problem that pages containing tuples
      that are locked by multixacts containing live lockers may spuriously end
      up as candidates for getting their all-visible flag set.  This has the
      long-term effect that multixacts remain unfrozen; this may previously
      pass undetected, but since commit XYZ it would be reported as
        "ERROR: found multixact 134100944 from before relminmxid 192042633"
      because when a later vacuum tries to freeze the page it detects that a
      multixact that should have gotten frozen, wasn't.
      
      Dan proposed a (correct) patch that simply sets a variable to its
      correct value, after a bogus initialization.  But, per discussion, it
      seems better coding to avoid the bogus initializations altogether, since
      they could give rise to more bugs later.  Therefore this fix rewrites
      the logic a little bit to avoid depending on the bogus initializations.
      
      This bug was part of a family introduced in 9.6 by commit a892234f;
      later, commit 38e9f90a fixed most of them, but this one was
      unnoticed.
      
      Authors: Dan Wood, Pavan Deolasee, Álvaro Herrera
      Reviewed-by: Masahiko Sawada, Pavan Deolasee, Álvaro Herrera
      Discussion: https://postgr.es/m/84EBAC55-F06D-4FBE-A3F3-8BDA093CE3E3@amazon.com
      d2599ecf
    • Andrew Dunstan's avatar
      Provide for testing on python3 modules when under MSVC · 966268c7
      Andrew Dunstan authored
      This should have been done some years ago as promised in commit
      c4dcdd0c2. However, better late than never.
      
      Along the way do a little housekeeping, including using a simpler test
      for the python version being tested, and removing a redundant subroutine
      parameter. These changes only apply back to release 9.5.
      
      Backpatch to all live releases.
      966268c7
    • Andrew Dunstan's avatar
      Allow MSYS as well as MINGW in Msys uname · 608a7101
      Andrew Dunstan authored
      Msys2's uname -s outputs a string beginning MSYS rather than MINGW as is
      output by Msys. Allow either in pg_upgrade's test.sh.
      
      Backpatch to all live branches.
      608a7101
    • Tom Lane's avatar
      Sync our copy of the timezone library with IANA release tzcode2018e. · b45f6613
      Tom Lane authored
      The non-cosmetic changes involve teaching the "zic" tzdata compiler about
      negative DST.  While I'm not currently intending that we start using
      negative-DST data right away, it seems possible that somebody would try
      to use our copy of zic with bleeding-edge IANA data.  So we'd better be
      out in front of this change code-wise, even though it doesn't matter for
      the data file we're shipping.
      
      Discussion: https://postgr.es/m/30996.1525445902@sss.pgh.pa.us
      b45f6613
    • Tom Lane's avatar
      Fix precedence problem in new Perl code. · 59cb3230
      Tom Lane authored
      I think this bit of commit 1f1cd9b5 didn't do quite what I meant :-(
      59cb3230
    • Peter Eisentraut's avatar
      pg_dump: Use current_database() instead of PQdb() · 1cd2445c
      Peter Eisentraut authored
      For querying pg_database about information about the database being
      dumped, look up by using current_database() instead of the value
      obtained from PQdb().  When using a connection proxy, the value from
      PQdb() might not be the real name of the database.
      1cd2445c