1. 14 May, 2020 7 commits
    • Amit Kapila's avatar
      Fix the MSVC build for versions 2015 and later. · a1691554
      Amit Kapila authored
      Visual Studio 2015 and later versions should still be able to do the same
      as Visual Studio 2012, but the declaration of locale_name is missing in
      _locale_t, causing the code compilation to fail, hence this falls back
      instead on to enumerating all system locales by using EnumSystemLocalesEx
      to find the required locale name.  If the input argument is in Unix-style
      then we can get ISO Locale name directly by using GetLocaleInfoEx() with
      LCType as LOCALE_SNAME.
      
      In passing, change the documentation references of the now obsolete links.
      
      Note that this problem occurs only with NLS enabled builds.
      
      Author: Juan José Santamaría Flecha, Davinder Singh and Amit Kapila
      Reviewed-by: Ranier Vilela and Amit Kapila
      Backpatch-through: 9.5
      Discussion: https://postgr.es/m/CAHzhFSFoJEWezR96um4-rg5W6m2Rj9Ud2CNZvV4NWc9tXV7aXQ@mail.gmail.com
      a1691554
    • Noah Misch's avatar
      Fix pg_recvlogical avoidance of superfluous Standby Status Update. · cee9cadb
      Noah Misch authored
      The defect suppressed a Standby Status Update message when bytes flushed
      to disk had changed but bytes received had not changed.  If
      pg_recvlogical then exited with no intervening Standby Status Update,
      the next pg_recvlogical repeated already-flushed records.  The defect
      could also cause superfluous messages, which are functionally harmless.
      Back-patch to 9.5 (all supported versions).
      
      Discussion: https://postgr.es/m/20200502221647.GA3941274@rfd.leadboat.com
      cee9cadb
    • Noah Misch's avatar
      In successful pg_recvlogical, end PGRES_COPY_OUT cleanly. · 8222a9d9
      Noah Misch authored
      pg_recvlogical merely called PQfinish(), so the backend sent messages
      after the disconnect.  When that caused EPIPE in internal_flush(),
      before a LogicalConfirmReceivedLocation(), the next pg_recvlogical would
      repeat already-acknowledged records.  Whether or not the defect causes
      EPIPE, post-disconnect messages could contain an ErrorResponse that the
      user should see.  One properly ends PGRES_COPY_OUT by repeating
      PQgetCopyData() until it returns a negative value.  Augment one of the
      tests to cover the case of WAL past --endpos.  Back-patch to v10, where
      commit 7c030783 first appeared.  Before
      that commit, pg_recvlogical never reached PGRES_COPY_OUT.
      
      Reported by Thomas Munro.
      
      Discussion: https://postgr.es/m/CAEepm=1MzM2Z_xNe4foGwZ1a+MO_2S9oYDq3M5D11=JDU_+0Nw@mail.gmail.com
      8222a9d9
    • Tom Lane's avatar
      Doc: split up wait_event table. · 4fa8bd39
      Tom Lane authored
      The previous design for this table didn't really work in narrow views,
      such as PDF output; besides which its reliance on large morerows
      values made it a pain to maintain (cf ab3e4fbd, for example).
      
      I experimented with a couple of ways to fix it, but the best and
      simplest is to split it up into a separate table for each event
      type category.
      
      I also rearranged the event ordering to be strictly alphabetical,
      as nobody would ever be able to find entries otherwise.
      
      There is work afoot to revise the set of event names described
      in this table, but this commit just changes the layout, not the
      contents.
      
      In passing, add a missing entry to pg_locks.locktype,
      and cross-reference that to the related wait event list.
      
      Discussion: https://postgr.es/m/6916.1589146280@sss.pgh.pa.us
      4fa8bd39
    • Tom Lane's avatar
      Doc: reformat catalog/view description tables. · a0427506
      Tom Lane authored
      This changes our catalog and view descriptions to use a style inspired
      by the new format for function/operator tables: each table entry is
      formatted roughly like a <varlistentry>, with the column name and type
      on the first line and then an indented description.  This provides much
      more room for expansive descriptions than we had before, and thereby
      eliminates a passel of PDF build warnings.
      
      Discussion: https://postgr.es/m/12984.1588643549@sss.pgh.pa.us
      a0427506
    • Tom Lane's avatar
      Fix async.c to not register any SLRU stats counts in the postmaster. · 7fd89f4d
      Tom Lane authored
      Previously, AsyncShmemInit forcibly initialized the first page of the
      async SLRU, to save dealing with that case in asyncQueueAddEntries.
      But this is a poor tradeoff, since many installations do not ever use
      NOTIFY; for them, expending those cycles in AsyncShmemInit is a
      complete waste.  Besides, this only saves a couple of instructions
      in asyncQueueAddEntries, which hardly seems likely to be measurable.
      
      The real reason to change this now, though, is that now that we track
      SLRU access stats, the existing code is causing the postmaster to
      accumulate some access counts, which then get inherited into child
      processes by fork(), messing up the statistics.  Delaying the
      initialization into the first child that does a NOTIFY fixes that.
      
      Hence, we can revert f3d23d83, which was an incorrect attempt at
      fixing that issue.  Also, add an Assert to pgstat.c that should
      catch any future errors of the same sort.
      
      Discussion: https://postgr.es/m/8367.1589391884@sss.pgh.pa.us
      7fd89f4d
    • Bruce Momjian's avatar
      d82a5058
  2. 13 May, 2020 5 commits
    • Alvaro Herrera's avatar
      Dial back -Wimplicit-fallthrough to level 3 · 17cc133f
      Alvaro Herrera authored
      The additional pain from level 4 is excessive for the gain.
      
      Also revert all the source annotation changes to their original
      wordings, to avoid back-patching pain.
      
      Discussion: https://postgr.es/m/31166.1589378554@sss.pgh.pa.us
      17cc133f
    • Tom Lane's avatar
      Improve management of SLRU statistics collection. · 81ca8686
      Tom Lane authored
      Instead of re-identifying which statistics bucket to use for a given
      SLRU on every counter increment, do it once during shmem initialization.
      This saves a fair number of cycles, and there's no real cost because
      we could not have a bucket assignment that varies over time or across
      backends anyway.
      
      Also, get rid of the ill-considered decision to let pgstat.c pry
      directly into SLRU's shared state; it's cleaner just to have slru.c
      pass the stats bucket number.
      
      In consequence of these changes, there's no longer any need to store
      an SLRU's LWLock tranche info in shared memory, so get rid of that,
      making this a net reduction in shmem consumption.  (That partly
      reverts fe702a7b.)
      
      This is basically code review for 28cac71b, so I also cleaned up
      some comments, removed a dangling extern declaration, fixed some
      things that should be static and/or const, etc.
      
      Discussion: https://postgr.es/m/3618.1589313035@sss.pgh.pa.us
      81ca8686
    • Alvaro Herrera's avatar
      Adjust walsender usage of xlogreader, simplify APIs · 850196b6
      Alvaro Herrera authored
      * Have both physical and logical walsender share a 'xlogreader' state
        struct for tracking state.  This replaces the existing globals sendSeg
        and sendCxt.
      
      * Change WALRead not to receive XLogReaderState->seg and ->segcxt as
        separate arguments anymore; just use the ones from 'state'.  This is
        made possible by the above change.
      
      * have the XLogReader segment_open contract require the callbacks to
        install the file descriptor in the state struct themselves instead of
        returning it.  xlogreader was already ignoring any possible failed
        return from the callbacks, relying solely on them never returning.
      
        (This point is not altogether excellent, as it means the callbacks
        have to know more of XLogReaderState; but to really improve on that
        we would have to pass back error info from the callbacks to
        xlogreader.  And the complexity would not be saved but instead just
        transferred to the callers of WALRead, which would have to learn how
        to throw errors from the open_segment callback in addition of, as
        currently, from pg_pread.)
      
      * segment_open no longer receives the 'segcxt' as a separate argument,
        since it's part of the XLogReaderState argument.
      
      Per comments from Kyotaro Horiguchi.
      
      Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
      Discussion: https://postgr.es/m/20200511203336.GA9913@alvherre.pgsql
      850196b6
    • Fujii Masao's avatar
      Use proper GetDatum function in pg_stat_get_slru(). · 043e3e04
      Fujii Masao authored
      This commit changes pg_stat_get_slru() so that it uses
      TimestampTzGetDatum() for stats_reset field because that field
      stores the timestamp with time zone value. Previously
      Int64GetDatum() was used.
      
      Author: Fujii Masao
      Reviewed-by: Tomas Vondra
      Discussion: https://postgr.es/m/b8784fe6-1401-ab35-aa14-d57b5bb8e312@oss.nttdata.com
      043e3e04
    • Fujii Masao's avatar
      Initialize SLRU stats entries to zero. · f3d23d83
      Fujii Masao authored
      Previously since SLRUStats was not initialized, SLRU stats counters
      could begin with non-zero value. Which could lead to incorrect results
      in pg_stat_slru view.
      
      Author: Fujii Masao
      Reviewed-by: Tomas Vondra
      Discussion: https://postgr.es/m/976bbb73-a112-de3c-c488-b34b64609793@oss.nttdata.com
      f3d23d83
  3. 12 May, 2020 14 commits
  4. 11 May, 2020 4 commits
    • Tom Lane's avatar
      Doc: fix "Unresolved ID reference" warnings, clean up man page cross-refs. · 60c90c16
      Tom Lane authored
      Use xreflabel attributes instead of endterm attributes to control the
      appearance of links to subsections of SQL command reference pages.
      This is simpler, it matches what we do elsewhere (e.g. for GUC variables),
      and it doesn't draw "Unresolved ID reference" warnings from the PDF
      toolchain.
      
      Fix some places where the text was absolutely dependent on an <xref>
      rendering exactly so, by using a <link> around the required text
      instead.  At least one of those spots had already been turned into
      bad grammar by subsequent changes, and the whole idea is just too
      fragile for my taste.  <xref> does NOT have fixed output, don't write
      as if it does.
      
      Consistently include a page-level link in cross-man-page references,
      because otherwise they are useless/nonsensical in man-page output.
      Likewise, be consistent about mentioning "below" or "above" in same-page
      references; we were doing that in about 90% of the cases, but now it's
      100%.
      
      Also get rid of another nonfunctional-in-PDF idea, of making
      cross-references to functions by sticking ID tags on <row> constructs.
      We can put the IDs on <indexterm>s instead --- which is probably not any
      more sensible in abstract terms, but it works where the other doesn't.
      (There is talk of attaching cross-reference IDs to most or all of
      the docs' function descriptions, but for now I just fixed the two
      that exist.)
      
      Discussion: https://postgr.es/m/14480.1589154358@sss.pgh.pa.us
      60c90c16
    • Peter Geoghegan's avatar
      Adjust "root of to-be-deleted subtree" function. · 624686ab
      Peter Geoghegan authored
      Restructure the function that locates the root of the to-be-deleted
      subtree during nbtree page deletion.  Handle the conditions that make
      page deletion unsafe in a slightly more uniform way, and acknowledge the
      fact that the behavior with incomplete splits on internal pages is
      different (as pointed out in the nbtree README as of commit 35bc0ec7).
      Also invent new terminology that avoids ambiguity around which pages are
      about to be deleted.  Consistently use the term "to-be-deleted subtree",
      not the ambiguous term "branch".
      
      We were calling the subtree parent page the "top parent page", but that
      was quite misleading.  The top parent page usually refers to a page
      unlinked from its siblings and marked deleted (during the second stage
      of page deletion).  There was one kind of top parent page that we merely
      removed a downlink from, and another kind of top parent page that we
      actually marked deleted.  Eliminate the ambiguity by inventing a new
      term ("subtree parent page") that refers to the former kind of page
      only.
      624686ab
    • Alvaro Herrera's avatar
      Fix obsolete references to "XLogRead" · a8be5364
      Alvaro Herrera authored
      The one in xlogreader.h was pointed out by Antonin Houska; I (Álvaro) noticed the
      others by grepping.
      
      Author: Antonin Houska <ah@cybertec.at>
      Discussion: https://postgr.es/m/28250.1589186654@antos
      a8be5364
    • Peter Eisentraut's avatar
      Translation updates · 7a9c9ce6
      Peter Eisentraut authored
      Source-Git-URL: https://git.postgresql.org/git/pgtranslation/messages.git
      Source-Git-Hash: 80d8f54b3c5533ec036404bd3c3b24ff4825d037
      7a9c9ce6
  5. 10 May, 2020 2 commits
    • Tom Lane's avatar
      Doc: marginal hacking to remove some PDF build warnings. · 336aa51b
      Tom Lane authored
      This patch eliminates a few more "exceed the available area" warnings
      whose causes aren't particularly connected to anything else.
      
      The only one really worthy of comment is that I increased the space
      allowed for an <orderedlist>'s numbers, because the default of 1em
      doesn't quite work for more than one digit.  The rest are one-off
      insertions of &zwsp; and suchlike tweaks, in places where they
      shouldn't do any damage to the material.  (In particular, although
      I split some long identifiers with zwsp's, there are other nearby
      occurrences of each one; so those changes shouldn't hurt greppability
      of the document sources.)
      336aa51b
    • Michael Paquier's avatar
      Remove smgrdounlink() in smgr.c from the code tree · e111c9f9
      Michael Paquier authored
      The last caller of this routine was removed in b4166911, and as a wise
      man said one day, dead code tends to silently break.
      
      Per discussion between Fujii Masao, Peter Geoghegan, Vignesh C and me.
      
      Reported-by: Peter Geoghegan
      Discussion: https://postgr.es/m/CAH2-Wz=sg5H8-vG4d5UmAofdcRMpeTDt2K-NUWp4GSfhenRGAQ@mail.gmail.com
      e111c9f9
  6. 09 May, 2020 6 commits
    • Tom Lane's avatar
      Doc: fix assorted misstatements of fact in catalog & system view docs. · 9356e435
      Tom Lane authored
      I made up a very crude hack to compare the docs with reality (as
      embodied in the system catalogs) ... and indeed they don't match
      everywhere.  Missing oid columns, wrong data types, wrong "references"
      links, columns listed in the wrong order.  None of this seems quite
      important enough to back-patch.
      9356e435
    • Tom Lane's avatar
      Fix findoidjoins to recognize oidvector columns. · 96d175e3
      Tom Lane authored
      Somehow we'd never noticed this oversight, even though it means
      that such basic columns as pg_proc.proargtypes were not being
      validated by the oidjoins test.  Correct the query and update
      the test script with the newly-found dependencies.
      96d175e3
    • Tomas Vondra's avatar
      Simplify show_incremental_sort_info a bit · ebeb3dea
      Tomas Vondra authored
      Incremental sort always processes at least one full group group before
      switching to prefix groups, so it's enough to check just the number of
      full groups. There was no risk of division by zero due to the extra
      condition, but it made the code harder to understand.
      
      Reported-by: Ranier Vilela
      Discussion: https://postgr.es/m/CAEudQAp+7qoS92-4V1vLChpdY3vEkLCbf+gye6P-4cirE-0z0A@mail.gmail.com
      ebeb3dea
    • Tomas Vondra's avatar
      Do no reset bounded before incremental sort rescan · 9155b4be
      Tomas Vondra authored
      ExecReScanIncrementalSort was resetting bounded=false, which means the
      optimization would be disabled on all rescans. This happens because
      ExecSetTupleBound is called before the rescan, not after it.
      
      Author: James Coleman
      Reviewed-by: Tomas Vondra
      Discussion: https://postgr.es/m/20200414065336.GI1492@paquier.xyz
      9155b4be
    • Tomas Vondra's avatar
      Fix handling of REWIND/MARK/BACKWARD in incremental sort · c4427226
      Tomas Vondra authored
      The executor flags were not handled entirely correctly, although the
      bugs were mostly harmless and it was mostly comment inaccuracy. We don't
      need to strip any of the flags for child nodes.
      
      Incremental sort does not support backward scans of mark/restore, so
      MARK/BACKWARDS flags should not be possible. So we simply ensure this
      using an assert, and we don't bother removing them when initializing
      the child node.
      
      With REWIND it's a bit less clear - incremental sort does not support
      REWIND, but there is no way to signal this - it's legal to just ignore
      the flag. We however continue passing the flag to child nodes, because
      they might be useful to leverage that.
      
      Reported-by: Michael Paquier
      Author: James Coleman
      Reviewed-by: Tomas Vondra
      Discussion: https://postgr.es/m/20200414065336.GI1492@paquier.xyz
      c4427226
    • Tom Lane's avatar
      Update oidjoins regression test for v13. · 6c298881
      Tom Lane authored
      We seem to have forgotten to do this in the v12 cycle, so add it as
      a task in the RELEASE_CHANGES list, in hopes we won't forget again.
      
      While here, fix findoidjoins.c so that it actually works in the
      new dispensation where OID is a regular column, and change it to only
      consider system relations (this avoids being fooled by the OID column
      in the brintest test table).
      
      Also tweak the largeobject test so that the somewhat-recently-added
      manual creation of a LO with an OID in the system range doesn't
      fool findoidjoins.c.  For the moment I just made that use an unused
      OID, but we might have to find a more robust solution someday.
      6c298881
  7. 08 May, 2020 2 commits