1. 20 Mar, 2021 2 commits
    • Tom Lane's avatar
      Fix memory leak when rejecting bogus DH parameters. · e835e89a
      Tom Lane authored
      While back-patching e0e569e1, I noted that there were some other
      places where we ought to be applying DH_free(); namely, where we
      load some DH parameters from a file and then reject them as not
      being sufficiently secure.  While it seems really unlikely that
      anybody would hit these code paths in production, let alone do
      so repeatedly, let's fix it for consistency.
      
      Back-patch to v10 where this code was introduced.
      
      Discussion: https://postgr.es/m/16160-18367e56e9a28264@postgresql.org
      e835e89a
    • Tom Lane's avatar
      Avoid leaking memory in RestoreGUCState(), and improve comments. · f0c2a5bb
      Tom Lane authored
      RestoreGUCState applied InitializeOneGUCOption to already-live
      GUC entries, causing any malloc'd subsidiary data to be forgotten.
      We do want the effect of resetting the GUC to its compiled-in
      default, and InitializeOneGUCOption seems like the best way to do
      that, so add code to free any existing subsidiary data beforehand.
      
      The interaction between can_skip_gucvar, SerializeGUCState, and
      RestoreGUCState is way more subtle than their opaque comments
      would suggest to an unwary reader.  Rewrite and enlarge the
      comments to try to make it clearer what's happening.
      
      Remove a long-obsolete assertion in read_nondefault_variables: the
      behavior of set_config_option hasn't depended on IsInitProcessingMode
      since f5d9698a installed a better way of controlling it.
      
      Although this is fixing a clear memory leak, the leak is quite unlikely
      to involve any large amount of data, and it can only happen once in the
      lifetime of a worker process.  So it seems unnecessary to take any
      risk of back-patching.
      
      Discussion: https://postgr.es/m/4105247.1616174862@sss.pgh.pa.us
      f0c2a5bb
  2. 19 Mar, 2021 14 commits
    • Thomas Munro's avatar
      Provide recovery_init_sync_method=syncfs. · 61752afb
      Thomas Munro authored
      Since commit 2ce439f3 we have opened every file in the data directory
      and called fsync() at the start of crash recovery.  This can be very
      slow if there are many files, leading to field complaints of systems
      taking minutes or even hours to begin crash recovery.
      
      Provide an alternative method, for Linux only, where we call syncfs() on
      every possibly different filesystem under the data directory.  This is
      equivalent, but avoids faulting in potentially many inodes from
      potentially slow storage.
      
      The new mode comes with some caveats, described in the documentation, so
      the default value for the new setting is "fsync", preserving the older
      behavior.
      Reported-by: default avatarMichael Brown <michael.brown@discourse.org>
      Reviewed-by: default avatarFujii Masao <masao.fujii@oss.nttdata.com>
      Reviewed-by: default avatarPaul Guo <guopa@vmware.com>
      Reviewed-by: default avatarBruce Momjian <bruce@momjian.us>
      Reviewed-by: default avatarJustin Pryzby <pryzby@telsasoft.com>
      Reviewed-by: default avatarDavid Steele <david@pgmasters.net>
      Discussion: https://postgr.es/m/11bc2bb7-ecb5-3ad0-b39f-df632734cd81%40discourse.org
      Discussion: https://postgr.es/m/CAEET0ZHGnbXmi8yF3ywsDZvb3m9CbdsGZgfTXscQ6agcbzcZAw%40mail.gmail.com
      61752afb
    • Tomas Vondra's avatar
      Use lfirst_int in cmp_list_len_contents_asc · b822ae13
      Tomas Vondra authored
      The function added in be45be9c is comparing integer lists (IntList) by
      length and contents, but there were two bugs.  Firstly, it used intVal()
      to extract the value, but that's for Value nodes, not for extracting int
      values from IntList.  Secondly, it called it directly on the ListCell,
      without doing lfirst().  So just do lfirst_int() instead.
      
      Interestingly enough, this did not cause any crashes on the buildfarm,
      but valgrind rightfully complained about it.
      
      Discussion: https://postgr.es/m/bf3805a8-d7d1-ae61-fece-761b7ff41ecc@postgresfriends.org
      b822ae13
    • Robert Haas's avatar
      Fix use-after-ReleaseSysCache problem in ATExecAlterColumnType. · d00fbdc4
      Robert Haas authored
      Introduced by commit bbe0a81d.
      
      Per buildfarm member prion.
      d00fbdc4
    • Robert Haas's avatar
      Allow configurable LZ4 TOAST compression. · bbe0a81d
      Robert Haas authored
      There is now a per-column COMPRESSION option which can be set to pglz
      (the default, and the only option in up until now) or lz4. Or, if you
      like, you can set the new default_toast_compression GUC to lz4, and
      then that will be the default for new table columns for which no value
      is specified. We don't have lz4 support in the PostgreSQL code, so
      to use lz4 compression, PostgreSQL must be built --with-lz4.
      
      In general, TOAST compression means compression of individual column
      values, not the whole tuple, and those values can either be compressed
      inline within the tuple or compressed and then stored externally in
      the TOAST table, so those properties also apply to this feature.
      
      Prior to this commit, a TOAST pointer has two unused bits as part of
      the va_extsize field, and a compessed datum has two unused bits as
      part of the va_rawsize field. These bits are unused because the length
      of a varlena is limited to 1GB; we now use them to indicate the
      compression type that was used. This means we only have bit space for
      2 more built-in compresison types, but we could work around that
      problem, if necessary, by introducing a new vartag_external value for
      any further types we end up wanting to add. Hopefully, it won't be
      too important to offer a wide selection of algorithms here, since
      each one we add not only takes more coding but also adds a build
      dependency for every packager. Nevertheless, it seems worth doing
      at least this much, because LZ4 gets better compression than PGLZ
      with less CPU usage.
      
      It's possible for LZ4-compressed datums to leak into composite type
      values stored on disk, just as it is for PGLZ. It's also possible for
      LZ4-compressed attributes to be copied into a different table via SQL
      commands such as CREATE TABLE AS or INSERT .. SELECT.  It would be
      expensive to force such values to be decompressed, so PostgreSQL has
      never done so. For the same reasons, we also don't force recompression
      of already-compressed values even if the target table prefers a
      different compression method than was used for the source data.  These
      architectural decisions are perhaps arguable but revisiting them is
      well beyond the scope of what seemed possible to do as part of this
      project.  However, it's relatively cheap to recompress as part of
      VACUUM FULL or CLUSTER, so this commit adjusts those commands to do
      so, if the configured compression method of the table happens not to
      match what was used for some column value stored therein.
      
      Dilip Kumar. The original patches on which this work was based were
      written by Ildus Kurbangaliev, and those were patches were based on
      even earlier work by Nikita Glukhov, but the design has since changed
      very substantially, since allow a potentially large number of
      compression methods that could be added and dropped on a running
      system proved too problematic given some of the architectural issues
      mentioned above; the choice of which specific compression method to
      add first is now different; and a lot of the code has been heavily
      refactored.  More recently, Justin Przyby helped quite a bit with
      testing and reviewing and this version also includes some code
      contributions from him. Other design input and review from Tomas
      Vondra, Álvaro Herrera, Andres Freund, Oleg Bartunov, Alexander
      Korotkov, and me.
      
      Discussion: http://postgr.es/m/20170907194236.4cefce96%40wp.localdomain
      Discussion: http://postgr.es/m/CAFiTN-uUpX3ck%3DK0mLEk-G_kUQY%3DSNOTeqdaNRR9FMdQrHKebw%40mail.gmail.com
      bbe0a81d
    • Tomas Vondra's avatar
      Fix race condition in remove_temp_files_after_crash TAP test · e589c489
      Tomas Vondra authored
      The TAP test was written so that it was not waiting for the correct SQL
      command, but for output from the preceding one.  This resulted in race
      conditions, allowing the commands to run in a different order, not block
      as expected and so on.  This fixes it by inverting the order of commands
      where possible, so that observing the output guarantees the data was
      inserted properly, and waiting for a lock to appear in pg_locks.
      
      Discussion: https://postgr.es/m/CAH503wDKdYzyq7U-QJqGn%3DGm6XmoK%2B6_6xTJ-Yn5WSvoHLY1Ww%40mail.gmail.com
      e589c489
    • Tom Lane's avatar
      Blindly try to fix test script's tar invocation for MSYS. · 27ab1981
      Tom Lane authored
      Buildfarm member fairywren doesn't like the test case I added
      in commit 081876d7.  I'm guessing the reason is that I shouldn't
      be using a perl2host-ified path in the tar command line.
      27ab1981
    • Fujii Masao's avatar
      Fix comments in postmaster.c. · fd312140
      Fujii Masao authored
      Commit 86c23a6e changed the option to specify that postgres will
      stop all other server processes by sending the signal SIGSTOP,
      from -s to -T. But previously there were comments incorrectly
      explaining that SIGSTOP behavior is set by -s option. This commit
      fixes them.
      
      Author: Kyotaro Horiguchi
      Reviewed-by: Fujii Masao
      Discussion: https://postgr.es/m/20210316.165141.1400441966284654043.horikyota.ntt@gmail.com
      fd312140
    • Tom Lane's avatar
      Don't leak malloc'd error string in libpqrcv_check_conninfo(). · 9bacdf9f
      Tom Lane authored
      We leaked the error report from PQconninfoParse, when there was
      one.  It seems unlikely that real usage patterns would repeat
      the failure often enough to create serious bloat, but let's
      back-patch anyway to keep the code similar in all branches.
      
      Found via valgrind testing.
      Back-patch to v10 where this code was added.
      
      Discussion: https://postgr.es/m/3816764.1616104288@sss.pgh.pa.us
      9bacdf9f
    • Tom Lane's avatar
      Don't leak malloc'd strings when a GUC setting is rejected. · 377b7a83
      Tom Lane authored
      Because guc.c prefers to keep all its string values in malloc'd
      not palloc'd storage, it has to be more careful than usual to
      avoid leaks.  Error exits out of string GUC hook checks failed
      to clear the proposed value string, and error exits out of
      ProcessGUCArray() failed to clear the malloc'd results of
      ParseLongOption().
      
      Found via valgrind testing.
      This problem is ancient, so back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/3816764.1616104288@sss.pgh.pa.us
      377b7a83
    • Tom Lane's avatar
      Don't leak compiled regex(es) when an ispell cache entry is dropped. · d303849b
      Tom Lane authored
      The text search cache mechanisms assume that we can clean up
      an invalidated dictionary cache entry simply by resetting the
      associated long-lived memory context.  However, that does not work
      for ispell affixes that make use of regular expressions, because
      the regex library deals in plain old malloc.  Hence, we leaked
      compiled regex(es) any time we dropped such a cache entry.  That
      could quickly add up, since even a fairly trivial regex can use up
      tens of kB, and a large one can eat megabytes.  Add a memory context
      callback to ensure that a regex gets freed when its owning cache
      entry is cleared.
      
      Found via valgrind testing.
      This problem is ancient, so back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/3816764.1616104288@sss.pgh.pa.us
      d303849b
    • Tom Lane's avatar
      Don't run RelationInitTableAccessMethod in a long-lived context. · 415ffdc2
      Tom Lane authored
      Some code paths in this function perform syscache lookups, which
      can lead to table accesses and possibly leakage of cruft into
      the caller's context.  If said context is CacheMemoryContext,
      we eventually will have visible bloat.  But fixing this is no
      harder than moving one memory context switch step.  (The other
      callers don't have a problem.)
      
      Andres Freund and I independently found this via valgrind testing.
      Back-patch to v12 where this code was added.
      
      Discussion: https://postgr.es/m/20210317023101.anvejcfotwka6gaa@alap3.anarazel.de
      Discussion: https://postgr.es/m/3816764.1616104288@sss.pgh.pa.us
      415ffdc2
    • Tom Lane's avatar
      Don't leak rd_statlist when a relcache entry is dropped. · 28644fac
      Tom Lane authored
      Although these lists are usually NIL, and even when not empty
      are unlikely to be large, constant relcache update traffic could
      eventually result in visible bloat of CacheMemoryContext.
      
      Found via valgrind testing.
      Back-patch to v10 where this field was added.
      
      Discussion: https://postgr.es/m/3816764.1616104288@sss.pgh.pa.us
      28644fac
    • Tomas Vondra's avatar
      Fix TAP test for remove_temp_files_after_crash · a16b2b96
      Tomas Vondra authored
      The test included in cd91de0d had two simple flaws.
      
      Firstly, the number of rows was low and on some platforms (e.g. 32-bit)
      the sort did not require on-disk sort, so on those machines it was not
      testing the automatic removal.  The test was however failing, because
      without any temporary files the base/pgsql_tmp directory was not even
      created.  Fixed by increasing the rowcount to 5000, which should be high
      engough on any platform.
      
      Secondly, the test used a simple sleep to wait for the temporary file to
      be created.  This is obviously problematic, because on slow machines (or
      with valgrind, CLOBBER_CACHE_ALWAYS etc.) it may take a while to create
      the temporary file.  But we also want the tests run reasonably fast.
      Fixed by instead relying on a UNIQUE constraint, blocking the query that
      created the temporary file.
      
      Author: Euler Taveira
      Reviewed-by: Tomas Vondra
      Discussion: https://postgr.es/m/CAH503wDKdYzyq7U-QJqGn%3DGm6XmoK%2B6_6xTJ-Yn5WSvoHLY1Ww%40mail.gmail.com
      a16b2b96
    • Michael Paquier's avatar
      Improve tab completion of IMPORT FOREIGN SCHEMA with \h in psql · 5b2266e3
      Michael Paquier authored
      Only "IMPORT" was showing as result of the completion, while IMPORT
      FOREIGN SCHEMA is the only command using this keyword in first
      position.  This changes the completion to show the full command name
      instead of just "IMPORT".
      
      Reviewed-by: Georgios Kokolatos, Julien Rouhaud
      Discussion: https://postgr.es/m/YFL6JneBiuMWYyoh@paquier.xyz
      5b2266e3
  3. 18 Mar, 2021 6 commits
  4. 17 Mar, 2021 15 commits
    • Andres Freund's avatar
      Fix memory lifetime issues of replication slot stats. · 5f79580a
      Andres Freund authored
      When accessing replication slot stats, introduced in 98681675,
      pgstat_read_statsfiles() reads the data into newly allocated
      memory. Unfortunately the current memory context at that point is the
      callers, leading to leaks and use-after-free dangers.
      
      The fix is trivial, explicitly use pgStatLocalContext. There's some
      potential for further improvements, but that's outside of the scope of
      this bugfix.
      
      No backpatch necessary, feature is only in HEAD.
      
      Author: Andres Freund <andres@anarazel.de>
      Discussion: https://postgr.es/m/20210317230447.c7uc4g3vbs4wi32i@alap3.anarazel.de
      5f79580a
    • Tom Lane's avatar
      Doc: remove duplicated step in RLS example. · 70945649
      Tom Lane authored
      Seems to have been a copy-and-paste mistake in 093129c9.
      Per report from max1@inbox.ru.
      
      Discussion: https://postgr.es/m/161591740692.24273.4202054598867879464@wrigleys.postgresql.org
      70945649
    • Tom Lane's avatar
      Code review for server's handling of "tablespace map" files. · 8620a7f6
      Tom Lane authored
      While looking at Robert Foggia's report, I noticed a passel of
      other issues in the same area:
      
      * The scheme for backslash-quoting newlines in pathnames is just
      wrong; it will misbehave if the last ordinary character in a pathname
      is a backslash.  I'm not sure why we're bothering to allow newlines
      in tablespace paths, but if we're going to do it we should do it
      without introducing other problems.  Hence, backslashes themselves
      have to be backslashed too.
      
      * The author hadn't read the sscanf man page very carefully, because
      this code would drop any leading whitespace from the path.  (I doubt
      that a tablespace path with leading whitespace could happen in
      practice; but if we're bothering to allow newlines in the path, it
      sure seems like leading whitespace is little less implausible.)  Using
      sscanf for the task of finding the first space is overkill anyway.
      
      * While I'm not 100% sure what the rationale for escaping both \r and
      \n is, if the idea is to allow Windows newlines in the file then this
      code failed, because it'd throw an error if it saw \r followed by \n.
      
      * There's no cross-check for an incomplete final line in the map file,
      which would be a likely apparent symptom of the improper-escaping
      bug.
      
      On the generation end, aside from the escaping issue we have:
      
      * If needtblspcmapfile is true then do_pg_start_backup will pass back
      escaped strings in tablespaceinfo->path values, which no caller wants
      or is prepared to deal with.  I'm not sure if there's a live bug from
      that, but it looks like there might be (given the dubious assumption
      that anyone actually has newlines in their tablespace paths).
      
      * It's not being very paranoid about the possibility of random stuff
      in the pg_tblspc directory.  IMO we should ignore anything without an
      OID-like name.
      
      The escaping rule change doesn't seem back-patchable: it'll require
      doubling of backslashes in the tablespace_map file, which is basically
      a basebackup format change.  The odds of that causing trouble are
      considerably more than the odds of the existing bug causing trouble.
      The rest of this seems somewhat unlikely to cause problems too,
      so no back-patch.
      8620a7f6
    • Tom Lane's avatar
      Prevent buffer overrun in read_tablespace_map(). · a50e4fd0
      Tom Lane authored
      Robert Foggia of Trustwave reported that read_tablespace_map()
      fails to prevent an overrun of its on-stack input buffer.
      Since the tablespace map file is presumed trustworthy, this does
      not seem like an interesting security vulnerability, but still
      we should fix it just in the name of robustness.
      
      While here, document that pg_basebackup's --tablespace-mapping option
      doesn't work with tar-format output, because it doesn't.  To make it
      work, we'd have to modify the tablespace_map file within the tarball
      sent by the server, which might be possible but I'm not volunteering.
      (Less-painful solutions would require changing the basebackup protocol
      so that the source server could adjust the map.  That's not very
      appetizing either.)
      a50e4fd0
    • Tom Lane's avatar
      Add end-to-end testing of pg_basebackup's tar-format output. · 081876d7
      Tom Lane authored
      The existing test script does run pg_basebackup with the -Ft option,
      but it makes no real attempt to verify the sanity of the results.
      We wouldn't know if the output is incompatible with standard "tar"
      programs, nor if the server fails to start from the restored output.
      Notably, this means that xlog.c's read_tablespace_map() is not being
      meaningfully tested, since that code is used only in the tar-format
      case.  (We do have reasonable coverage of restoring from plain-format
      output, though it's over in src/test/recovery not here.)
      
      Hence, attempt to untar the output and start a server from it,
      rather just hoping it's OK.
      
      This test assumes that the local "tar" has the "-C directory"
      switch.  Although that's not promised by POSIX, my research
      suggests that all non-extinct tar implementations have it.
      Should the buildfarm's opinion differ, we can complicate the
      test a bit to avoid requiring that.
      
      Possibly this should be back-patched, but I'm unsure about
      whether it could work on Windows before d66b23b0.
      081876d7
    • Tom Lane's avatar
      Doc: improve discussion of variable substitution in PL/pgSQL. · c783e656
      Tom Lane authored
      This was a bit disjointed, partly because of a not-well-considered
      decision to document SQL commands that don't return result rows as
      though they had nothing in common with commands that do.  Rearrange
      so that we have one discussion of variable substitution that clearly
      applies to all types of SQL commands, and then handle the question
      of processing command output separately.  Clarify that EXPLAIN,
      CREATE TABLE AS SELECT, and similar commands that incorporate an
      optimizable statement will act like optimizable statements for the
      purposes of variable substitution.  Do a bunch of minor wordsmithing
      in the same area.
      
      David Johnston and Tom Lane, reviewed by Pavel Stehule and David
      Steele
      
      Discussion: https://postgr.es/m/CAKFQuwYvMKucM5fnZvHSo-ah4S=_n9gmKeu6EAo=_fTrohunqQ@mail.gmail.com
      c783e656
    • Thomas Munro's avatar
    • Michael Paquier's avatar
      Fix comment in indexing.c · 9fd2952c
      Michael Paquier authored
      578b2297, that removed support for WITH OIDS, has changed
      CatalogTupleInsert() to not return an Oid, but one comment was still
      mentioning that.
      
      Author: Vik Fearing
      Discussion: https://postgr.es/m/fef01975-ed10-3601-7b9e-80ecef72d00b@postgresfriends.org
      9fd2952c
    • Peter Eisentraut's avatar
      Small error message improvement · e1ae40f3
      Peter Eisentraut authored
      e1ae40f3
    • Thomas Munro's avatar
      Update the names of Parallel Hash Join phases. · 378802e3
      Thomas Munro authored
      Commit 3048898e dropped -ING from some wait event names that correspond
      to barrier phases.  Update the phases' names to match.
      
      While we're here making cosmetic changes, also rename "DONE" to "FREE".
      That pairs better with "ALLOCATE", and describes the activity that
      actually happens in that phase (as we do for the other phases) rather
      than describing a state.  The distinction is clearer after bugfix commit
      3b8981b6 split the phase into two.  As for the growth barriers, rename
      their "ALLOCATE" phase to "REALLOCATE", which is probably a better
      description of what happens then.  Also improve the comments about
      the phases a bit.
      
      Discussion: https://postgr.es/m/CA%2BhUKG%2BMDpwF2Eo2LAvzd%3DpOh81wUTsrwU1uAwR-v6OGBB6%2B7g%40mail.gmail.com
      378802e3
    • Thomas Munro's avatar
      Fix race in Parallel Hash Join batch cleanup. · 3b8981b6
      Thomas Munro authored
      With very unlucky timing and parallel_leader_participation off, PHJ
      could attempt to access per-batch state just as it was being freed.
      There was code intended to prevent that by checking for a cleared
      pointer, but it was buggy.
      
      Fix, by introducing an extra barrier phase.  The new phase
      PHJ_BUILD_RUNNING means that it's safe to access the per-batch state to
      find a batch to help with, and PHJ_BUILD_DONE means that it is too late.
      The last to detach will free the array of per-batch state as before, but
      now it will also atomically advance the phase at the same time, so that
      late attachers can avoid the hazard, without the data race.  This
      mirrors the way per-batch hash tables are freed (see phases
      PHJ_BATCH_PROBING and PHJ_BATCH_DONE).
      
      Revealed by a one-off build farm failure, where BarrierAttach() failed a
      sanity check assertion, because the memory had been clobbered by
      dsa_free().
      
      Back-patch to 11, where the code arrived.
      Reported-by: default avatarMichael Paquier <michael@paquier.xyz>
      Discussion: https://postgr.es/m/20200929061142.GA29096%40paquier.xyz
      3b8981b6
    • Thomas Munro's avatar
      Fix transaction.sql tests in higher isolation levels. · 37929599
      Thomas Munro authored
      It seems like a useful sanity check to be able to run "installcheck"
      against a cluster running with default_transaction_level set to
      serializable or repeatable read.  Only one thing currently fails in
      those configurations, so let's fix that.
      
      No back-patch for now, because it fails in many other places in some of
      the stable branches.  We'd have to go back and fix those too if we
      included this configuration in automated testing.
      Reviewed-by: default avatarTom Lane <tgl@sss.pgh.pa.us>
      Discussion: https://postgr.es/m/CA%2BhUKGJUaHeK%3DHLATxF1JOKDjKJVrBKA-zmbPAebOM0Se2FQRg%40mail.gmail.com
      37929599
    • Amit Kapila's avatar
      Fix race condition in drop subscription's handling of tablesync slots. · 6b67d72b
      Amit Kapila authored
      Commit ce0fdbfe made tablesync slots permanent and allow Drop
      Subscription to drop such slots. However, it is possible that before
      tablesync worker could get the acknowledgment of slot creation, drop
      subscription stops it and that can lead to a dangling slot on the
      publisher. Prevent cancel/die interrupts while creating a slot in the
      tablesync worker.
      
      Reported-by: Thomas Munro as per buildfarm
      Author: Amit Kapila
      Reviewed-by: Vignesh C, Takamichi Osumi
      Discussion: https://postgr.es/m/CA+hUKGJG9dWpw1cOQ2nzWU8PHjm=PTraB+KgE5648K9nTfwvxg@mail.gmail.com
      6b67d72b
    • Amit Kapila's avatar
      Doc: Add a description of substream in pg_subscription. · 7efeb214
      Amit Kapila authored
      Commit 46482432 added a new column substream in pg_subscription but
      forgot to update the docs.
      
      Reported-by: Peter Smith
      Author: Amit Kapila
      Reviewed-by: Peter Smith
      Discussion: https://postgr.es/m/CAHut+PuPGGASnh2Dy37VYODKULVQo-5oE=Shc6gwtRizDt==cA@mail.gmail.com
      7efeb214
    • Thomas Munro's avatar
      Enable parallelism in REFRESH MATERIALIZED VIEW. · 9e7ccd9e
      Thomas Munro authored
      Pass CURSOR_OPT_PARALLEL_OK to pg_plan_query() so that parallel plans
      are considered when running the underlying SELECT query.  This wasn't
      done in commit e9baa5e9, which did this for CREATE MATERIALIZED VIEW,
      because it wasn't yet known to be safe.
      
      Since REFRESH always inserts into a freshly created table before later
      merging or swapping the data into place with separate operations, we can
      enable such plans here too.
      
      Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
      Reviewed-by: default avatarHou, Zhijie <houzj.fnst@cn.fujitsu.com>
      Reviewed-by: default avatarLuc Vlaming <luc@swarm64.com>
      Reviewed-by: default avatarThomas Munro <thomas.munro@gmail.com>
      Discussion: https://postgr.es/m/CALj2ACXg-4hNKJC6nFnepRHYT4t5jJVstYvri%2BtKQHy7ydcr8A%40mail.gmail.com
      9e7ccd9e
  5. 16 Mar, 2021 3 commits
    • Peter Geoghegan's avatar
      Fix comment about promising tuples. · fbe4cb3b
      Peter Geoghegan authored
      Oversight in commit d168b666, which added bottom-up index deletion.
      fbe4cb3b
    • Peter Geoghegan's avatar
      amcheck: Reduce debug message verbosity. · 65445469
      Peter Geoghegan authored
      Empty sibling pages can occasionally be much more common than any other
      event that we report on at elevel DEBUG1.  Increase the elevel for
      relevant cases to DEBUG2 to avoid overwhelming the user with relatively
      insignificant details.
      65445469
    • Tom Lane's avatar
      Avoid corner-case memory leak in SSL parameter processing. · 4b12ab18
      Tom Lane authored
      After reading the root cert list from the ssl_ca_file, immediately
      install it as client CA list of the new SSL context.  That gives the
      SSL context ownership of the list, so that SSL_CTX_free will free it.
      This avoids a permanent memory leak if we fail further down in
      be_tls_init(), which could happen if bogus CRL data is offered.
      
      The leak could only amount to something if the CRL parameters get
      broken after server start (else we'd just quit) and then the server
      is SIGHUP'd many times without fixing the CRL data.  That's rather
      unlikely perhaps, but it seems worth fixing, if only because the
      code is clearer this way.
      
      While we're here, add some comments about the memory management
      aspects of this logic.
      
      Noted by Jelte Fennema and independently by Andres Freund.
      Back-patch to v10; before commit de41869b it doesn't matter,
      since we'd not re-execute this code during SIGHUP.
      
      Discussion: https://postgr.es/m/16160-18367e56e9a28264@postgresql.org
      4b12ab18