1. 27 Aug, 2019 2 commits
    • Tom Lane's avatar
      Reject empty names and recursion in config-file include directives. · 6e421305
      Tom Lane authored
      An empty file name or subdirectory name leads join_path_components() to
      just produce the parent directory name, which leads to weird failures or
      recursive inclusions.  Let's throw a specific error for that.  It takes
      only slightly more code to detect all-blank names, so do so.
      
      Also, detect direct recursion, ie a file calling itself.  As coded
      this will also detect recursion via "include_dir '.'", which is
      perhaps more likely than explicitly including the file itself.
      
      Detecting indirect recursion would require API changes for guc-file.l
      functions, which seems not worth it since extensions might call them.
      The nesting depth limit will catch such cases eventually, just not
      with such an on-point error message.
      
      In passing, adjust the example usages in postgresql.conf.sample
      to perhaps eliminate the problem at the source: there's no reason
      for the examples to suggest that an empty value is valid.
      
      Per a trouble report from Brent Bates.  Back-patch to 9.5; the
      issue is old, but the code in 9.4 is enough different that the
      patch doesn't apply easily, and it doesn't seem worth the trouble
      to fix there.
      
      Ian Barwick and Tom Lane
      
      Discussion: https://postgr.es/m/8c8bcbca-3bd9-dc6e-8986-04a5abdef142@2ndquadrant.com
      6e421305
    • Michael Paquier's avatar
      Fix failure of --jobs with reindexdb and vacuumdb on Windows · 9acda731
      Michael Paquier authored
      FD_SETSIZE needs to be declared before winsock2.h, or it is possible to
      run into buffer overflow issues when using --jobs.  This is similar to
      pgbench's solution done in a23c6415.
      
      This has been introduced by 71d84efb, and older versions have been using
      the default value of FD_SETSIZE, defined at 64.
      
      Per buildfarm member jacana, but this impacts all Windows animals
      running the TAP tests.  I have reproduced the failure locally to check
      the patch.
      
      Author: Michael Paquier
      Reviewed-by: Andrew Dunstan
      Discussion: https://postgr.es/m/20190826054000.GE7005@paquier.xyz
      Backpatch-through: 9.5
      9acda731
  2. 26 Aug, 2019 7 commits
    • Tom Lane's avatar
      Fix 007_sync_rep.pl to notice failures in ALTER SYSTEM SET. · fb57f40e
      Tom Lane authored
      If a test case tried to set an invalid value of synchronous_standby_names,
      the test script didn't detect that, which seems like a bad idea.
      Noticed while testing a proposed patch that broke some of these
      test cases.
      fb57f40e
    • Tom Lane's avatar
      Fix postmaster state machine to handle dead_end child crashes better. · ee327823
      Tom Lane authored
      A report from Alvaro Herrera shows that if we're in PM_STARTUP
      state, and we spawn a dead_end child to reject some incoming
      connection request, and that child dies with an unexpected exit
      code, the postmaster does not respond well.  We correctly send
      SIGQUIT to the startup process, but then:
      
      * if the startup process exits with nonzero exit code, as expected,
      we thought that that indicated a crash and aborted startup.
      
      * if the startup process exits with zero exit code, which is possible
      due to the inherent race condition, we'd advance to PM_RUN state
      which is fine --- but the code forgot that AbortStartTime would be
      nonzero in this situation.  We'd either die on the Asserts saying
      that it was zero, or perhaps misbehave later on.  (A quick look
      suggests that the only misbehavior might be busy-waiting due to
      DetermineSleepTime doing the wrong thing.)
      
      To fix the first point, adjust the state-machine logic to recognize
      that a nonzero exit code is expected after sending SIGQUIT, and have
      it transition to a state where we can restart the startup process.
      To fix the second point, change the Asserts to clear the variable
      rather than just claiming it should be clear already.
      
      Perhaps we could improve this further by not treating a crash of
      a dead_end child as a reason for panic'ing the database.  However,
      since those child processes are connected to shared memory, that
      seems a bit risky.  There are few good reasons for a dead_end child
      to report failure anyway (the cause of this in Alvaro's report is
      quite unclear).  On balance, therefore, a minimal fix seems best.
      
      This is an oversight in commit 45811be9.  While that was back-patched,
      I'm hesitant to back-patch this change.  The lack of reasons for a
      dead_end child to fail suggests that the case should be very rare in
      the field, which squares with the lack of reports; so it seems like
      this might not be worth the risk of introducing new issues.  In any
      case we can let it bake awhile in HEAD before considering a back-patch.
      
      Discussion: https://postgr.es/m/20190615160950.GA31378@alvherre.pgsql
      ee327823
    • Tom Lane's avatar
      Make comment in fmgr.h match the one in fmgr.c. · 348778dd
      Tom Lane authored
      Incompletely quoting an API spec does nobody any good.  Noted by
      Paul Jungwirth.  Looks like the discrepancy was my fault originally :-(
      
      Discussion: https://postgr.es/m/CA+renyU_J8TU_d3Kr0PkuOgFbpypextendu7a+_d5NOfVdvDeA@mail.gmail.com
      348778dd
    • Peter Eisentraut's avatar
      Fix gettext triggers specification · f2690338
      Peter Eisentraut authored
      In cc8d4151, the arguments of
      warn_or_exit_horribly() were changed but this was not updated.
      f2690338
    • Andrew Dunstan's avatar
      Adjust to latest Msys2 kernel release number · c62b8443
      Andrew Dunstan authored
      Previously 'uname -r' on Msys2 reported a kernele release starting with
      2. The latest version starts with 3. In commit 1638623f we specifically
      looked for one starting with 2. This is now changed to look for any
      digit between 2 and 9.
      
      backpatch to release 10.
      c62b8443
    • Andrew Dunstan's avatar
      Treat MINGW and MSYS the same in pg_upgrade test script · acb96eb7
      Andrew Dunstan authored
      On msys2, 'uname -s' reports a string starting MSYS instead on MINGW
      as happens on msys1. Treat these both the same way. This reverts
      608a7101 in favor of a more general solution.
      
      Backpatch to all live branches.
      acb96eb7
    • Michael Paquier's avatar
      Fix error handling of vacuumdb and reindexdb when running out of fds · 71d84efb
      Michael Paquier authored
      When trying to use a high number of jobs, vacuumdb (and more recently
      reindexdb) has only checked for a maximum number of jobs used, causing
      confusing failures when running out of file descriptors when the jobs
      open connections to Postgres.  This commit changes the error handling so
      as we do not check anymore for a maximum number of allowed jobs when
      parsing the option value with FD_SETSIZE, but check instead if a file
      descriptor is within the supported range when opening the connections
      for the jobs so as this is detected at the earliest time possible.
      
      Also, improve the error message to give a hint about the number of jobs
      recommended, using a wording given by the reviewers of the patch.
      
      Reported-by: Andres Freund
      Author: Michael Paquier
      Reviewed-by: Andres Freund, Álvaro Herrera, Tom Lane
      Discussion: https://postgr.es/m/20190818001858.ho3ev4z57fqhs7a5@alap3.anarazel.de
      Backpatch-through: 9.5
      71d84efb
  3. 25 Aug, 2019 3 commits
  4. 24 Aug, 2019 4 commits
  5. 23 Aug, 2019 1 commit
  6. 22 Aug, 2019 3 commits
  7. 21 Aug, 2019 5 commits
  8. 20 Aug, 2019 4 commits
  9. 19 Aug, 2019 8 commits
    • Tom Lane's avatar
      Restore json{b}_populate_record{set}'s ability to take type info from AS. · e136a0d8
      Tom Lane authored
      If the record argument is NULL and has no declared type more concrete
      than RECORD, we can't extract useful information about the desired
      rowtype from it.  In this case, see if we're in FROM with an AS clause,
      and if so extract the needed rowtype info from AS.
      
      It worked like this before v11, but commit 37a795a6 removed the
      behavior, reasoning that it was undocumented, inefficient, and utterly
      not self-consistent.  If you want to take type info from an AS clause,
      you should be using the json_to_record() family of functions not the
      json_populate_record() family.  Also, it was already the case that
      the "populate" functions would fail for a null-valued RECORD input
      (with an unfriendly "record type has not been registered" error)
      when there wasn't an AS clause at hand, and it wasn't obvious that
      that behavior wasn't OK when there was one.  However, it emerges
      that some people were depending on this to work, and indeed the
      rather off-point error message you got if you left off AS encouraged
      slapping on AS without switching to the json_to_record() family.
      
      Hence, put back the fallback behavior of looking for AS.  While at it,
      improve the run-time error you get when there's no place to obtain type
      info; we can do a lot better than "record type has not been registered".
      (We can't, unfortunately, easily improve the parse-time error message
      that leads people down this path in the first place.)
      
      While at it, I refactored the code a bit to avoid duplicating the
      same logic in several different places.
      
      Per bug #15940 from Jaroslav Sivy.  Back-patch to v11 where the
      current coding came in.  (The pre-v11 deficiencies in this area
      aren't regressions, so we'll leave those branches alone.)
      
      Patch by me, based on preliminary analysis by Dmitry Dolgov.
      
      Discussion: https://postgr.es/m/15940-2ab76dc58ffb85b6@postgresql.org
      e136a0d8
    • Andres Freund's avatar
      Add fmgr.h include to selfuncs.h. · 4c01a111
      Andres Freund authored
      Necessary after fb3b098f. That previously escaped notice, because all
      including sites already include fmgr.h some other way.
      
      Reported-By: Tom Lane
      Author: Andres Freund
      Discussion: https://postgr.es/m/17463.1566153454@sss.pgh.pa.us
      4c01a111
    • Tom Lane's avatar
      Add "headerscheck" script to test header-file compilability under C. · 55ea1091
      Tom Lane authored
      We already had "cpluspluscheck", which served the dual purposes of
      verifying that headers compile standalone and that they compile as C++.
      However, C++ compilers don't have the exact same set of error conditions
      as C compilers, so this doesn't really prove that a header will compile
      standalone as C.
      
      Hence, add a second script that's largely similar but runs the C
      compiler not C++.
      
      Also add a bit more documentation than the none-at-all we had before.
      
      Discussion: https://postgr.es/m/14803.1566175851@sss.pgh.pa.us
      55ea1091
    • Tom Lane's avatar
      Use zic's new "-b slim" option to generate smaller timezone files. · a1207910
      Tom Lane authored
      IANA tzcode release 2019b adds an option that tells zic not to emit
      the old 32-bit section of the timezone files, and to skip some other
      space-wasting hacks needed for compatibility with old timezone client
      libraries.  Since we only expect our own code to use the timezone data
      we install, and our code is up-to-date with 2019b, there's no apparent
      reason not to generate the smallest possible files.
      
      Unfortunately, while the individual zone files do get significantly
      smaller in many cases, they were not that big to begin with; which
      means that no real space savings ensues on filesystems that don't
      optimize small files.  (For instance, on ext4 with 4K block size,
      "du" says the installed timezone tree is the same size as before.)
      Still, it seems worth making the change, if only because this is
      presumably the wave of the future.  At the very least, we'll save
      some cycles while reading a zone file.
      
      But given the marginal value and the fact that this is a new code
      path, it doesn't seem worth the risk of back-patching this change
      into stable branches.  Hence, unlike most of our timezone-related
      changes, apply to HEAD only.
      
      Discussion: https://postgr.es/m/24998.1563403327@sss.pgh.pa.us
      a1207910
    • Alvaro Herrera's avatar
    • Peter Eisentraut's avatar
      doc: Fix image use in PDF build with vpath · a407012c
      Peter Eisentraut authored
      In a vpath build, we need to point to the source directory to allow
      FOP to find the images.
      a407012c
    • Michael Paquier's avatar
      Fix tab completion for CREATE TYPE in psql · 71851e9a
      Michael Paquier authored
      Oversight in 7bdc6556.
      
      Author: Alexander Lakhin
      Discussion: https://postgr.es/m/5da8e325-c665-da95-21e0-c8a99ea61fbf@gmail.com
      71851e9a
    • Michael Paquier's avatar
      Fix inconsistencies and typos in the tree, take 11 · c96581ab
      Michael Paquier authored
      This fixes various typos in docs and comments, and removes some orphaned
      definitions.
      
      Author: Alexander Lakhin
      Discussion: https://postgr.es/m/5da8e325-c665-da95-21e0-c8a99ea61fbf@gmail.com
      c96581ab
  10. 18 Aug, 2019 3 commits