1. 06 Aug, 2019 3 commits
    • Tom Lane's avatar
      Fix intarray's GiST opclasses to not fail for empty arrays with <@. · efc77cf5
      Tom Lane authored
      contrib/intarray considers "arraycol <@ constant-array" to be indexable,
      but its GiST opclass code fails to reliably find index entries for empty
      array values (which of course should trivially match such queries).
      This is because the test condition to see whether we should descend
      through a non-leaf node is wrong.
      
      Unfortunately, empty array entries could be anywhere in the index,
      as these index opclasses are currently designed.  So there's no way
      to fix this except by lobotomizing <@ indexscans to scan the whole
      index ... which is what this patch does.  That's pretty unfortunate:
      the performance is now actually worse than a seqscan, in most cases.
      We'd be better off to remove <@ from the GiST opclasses entirely,
      and perhaps a future non-back-patchable patch will do so.
      
      In the meantime, applications whose performance is adversely impacted
      have a couple of options.  They could switch to a GIN index, which
      doesn't have this bug, or they could replace "arraycol <@ constant-array"
      with "arraycol <@ constant-array AND arraycol && constant-array".
      That will provide about the same performance as before, and it will find
      all non-empty subsets of the given constant-array, which is all that
      could reliably be expected of the query before.
      
      While at it, add some more regression test cases to improve code
      coverage of contrib/intarray.
      
      In passing, adjust resize_intArrayType so that when it's returning an
      empty array, it uses construct_empty_array for that rather than
      cowboy hacking on the input array.  While the hack produces an array
      that looks valid for most purposes, it isn't bitwise equal to empty
      arrays produced by other code paths, which could have subtle odd
      effects.  I don't think this code path is performance-critical
      enough to justify such shortcuts.  (Back-patch this part only as far
      as v11; before commit 01783ac3 we were not careful about this in
      other intarray code paths either.)
      
      Back-patch the <@ fixes to all supported versions, since this was
      broken from day one.
      
      Patch by me; thanks to Alexander Korotkov for review.
      
      Discussion: https://postgr.es/m/458.1565114141@sss.pgh.pa.us
      efc77cf5
    • Tom Lane's avatar
      Save Kerberos and LDAP daemon logs where the buildfarm can find them. · 4ecd05cb
      Tom Lane authored
      src/test/kerberos and src/test/ldap try to run private authentication
      servers, which of course might fail.  The logs from these servers
      were being dropped into the tmp_check/ subdirectory, but they should
      be put in tmp_check/log/, because the buildfarm will only capture
      log files in that subdirectory.  Without the log output there's
      little hope of diagnosing buildfarm failures related to these servers.
      
      Backpatch to v11 where these test suites were added.
      
      Discussion: https://postgr.es/m/16017.1565047605@sss.pgh.pa.us
      4ecd05cb
    • Michael Paquier's avatar
  2. 05 Aug, 2019 6 commits
    • Peter Geoghegan's avatar
      Show specific OID suggestion in unused_oids output. · 98eab30b
      Peter Geoghegan authored
      Commit a6417078 established a new project policy around OID assignment:
      new patches are encouraged to choose a random OID in the 8000..9999
      range when a manually-assigned OID is required (if multiple OIDs are
      required, a consecutive block of OIDs starting from the random point
      should be used).  Catalog entries added by committed patches that use
      OIDs from this "unstable" range are renumbered after feature freeze.
      This practice minimizes OID collisions among concurrently-developed
      patches.
      
      Show a specific random OID suggestion when the unused_oids script is
      run.  This makes it easy for patch authors to use a random OID from the
      unstable range, per the new policy.
      
      Author: Julien Rouhaud, Peter Geoghegan
      Reviewed-By: Tom Lane
      Discussion: https://postgr.es/m/CAH2-WzkkRs2ScmuBQ7xWi7xzp7fC1B3w0Nt8X+n4rBw5k+Z=zA@mail.gmail.com
      98eab30b
    • Tom Lane's avatar
      Fix choice of comparison operators for cross-type hashed subplans. · 4766dce0
      Tom Lane authored
      Commit bf6c614a rearranged the lookup of the comparison operators
      needed in a hashed subplan, and in so doing, broke the cross-type
      case: it caused the original LHS-vs-RHS operator to be used to compare
      hash table entries too (which of course are all of the RHS type).
      This leads to C functions being passed a Datum that is not of the
      type they expect, with the usual hazards of crashes and unauthorized
      server memory disclosure.
      
      For the set of hashable cross-type operators present in v11 core
      Postgres, this bug is nearly harmless on 64-bit machines, which
      may explain why it escaped earlier detection.  But it is a live
      security hazard on 32-bit machines; and of course there may be
      extensions that add more hashable cross-type operators, which
      would increase the risk.
      
      Reported by Andreas Seltenreich.  Back-patch to v11 where the
      problem came in.
      
      Security: CVE-2019-10209
      4766dce0
    • Noah Misch's avatar
      Require the schema qualification in pg_temp.type_name(arg). · ffa2d37e
      Noah Misch authored
      Commit aa27977f introduced this
      restriction for pg_temp.function_name(arg); do likewise for types
      created in temporary schemas.  Programs that this breaks should add
      "pg_temp." schema qualification or switch to arg::type_name syntax.
      Back-patch to 9.4 (all supported versions).
      
      Reviewed by Tom Lane.  Reported by Tom Lane.
      
      Security: CVE-2019-10208
      ffa2d37e
    • Michael Paquier's avatar
      Add safeguards in LSN, numeric and float calculation for custom errors · a76cfba6
      Michael Paquier authored
      Those data types use parsing and/or calculation wrapper routines which
      can generate some generic error messages in the event of a failure.  The
      caller of these routines can also pass a pointer variable settable by
      the routine to track if an error has happened, letting the caller decide
      what to do in the event of an error and what error message to generate.
      
      Those routines have been slacking the initialization of the tracking
      flag, which can be confusing when reading the code, so add some
      safeguards against calls of these parsing routines which could lead to a
      dubious result.
      
      The LSN parsing gains an assertion to make sure that the tracking flag
      is set, while numeric and float paths initialize the flag to a saner
      state.
      
      Author: Jeevan Ladhe
      Reviewed-by: Álvaro Herrera, Michael Paquier
      Discussion: https://postgr.es/m/CAOgcT0NOM9oR0Hag_3VpyW0uF3iCU=BDUFSPfk9JrWXRcWQHqw@mail.gmail.com
      a76cfba6
    • Michael Paquier's avatar
      Fix tab completion for ALTER LANGUAGE in psql · 05ba8370
      Michael Paquier authored
      OWNER_TO was used for the completion, which is not a supported grammar,
      but OWNER TO is.
      
      This error has been introduced by d37b816d, so backpatch down to 9.6.
      
      Author: Alexander Lakhin
      Discussion: https://postgr.es/m/7ab243e0-116d-3e44-d120-76b3df7abefd@gmail.com
      Backpatch-through: 9.6
      05ba8370
    • Michael Paquier's avatar
      Fix inconsistencies and typos in the tree, take 9 · 8548ddc6
      Michael Paquier authored
      This addresses more issues with code comments, variable names and
      unreferenced variables.
      
      Author: Alexander Lakhin
      Discussion: https://postgr.es/m/7ab243e0-116d-3e44-d120-76b3df7abefd@gmail.com
      8548ddc6
  3. 04 Aug, 2019 6 commits
    • Tomas Vondra's avatar
      Revert "Add log_statement_sample_rate parameter" · 75506195
      Tomas Vondra authored
      This reverts commit 88bdbd3f.
      
      As committed, statement sampling used the existing duration threshold
      (log_min_duration_statement) when decide which statements to sample.
      The issue is that even the longest statements are subject to sampling,
      and so may not end up logged. An improvement was proposed, introducing
      a second duration threshold, but it would not be backwards compatible.
      So we've decided to revert this feature - the separate threshold should
      be part of the feature itself.
      
      Discussion: https://postgr.es/m/CAFj8pRDS8tQ3Wviw9%3DAvODyUciPSrGeMhJi_WPE%2BEB8%2B4gLL-Q%40mail.gmail.com
      75506195
    • Tomas Vondra's avatar
      Revert "Silence compiler warning" · 4f9ed8f3
      Tomas Vondra authored
      This reverts commit 9dc12258.
      
      As committed, statement sampling used the existing duration threshold
      (log_min_duration_statement) when decide which statements to sample.
      The issue is that even the longest statements are subject to sampling,
      and so may not end up logged. An improvement was proposed, introducing
      a second duration threshold, but it would not be backwards compatible.
      So we've decided to revert this feature - the separate threshold should
      be part of the feature itself.
      
      Discussion: https://postgr.es/m/CAFj8pRDS8tQ3Wviw9%3DAvODyUciPSrGeMhJi_WPE%2BEB8%2B4gLL-Q%40mail.gmail.com
      4f9ed8f3
    • Tom Lane's avatar
      Fix handling of "undef" in contrib/jsonb_plperl. · e0f50488
      Tom Lane authored
      Perl has multiple internal representations of "undef", and just
      testing for SvTYPE(x) == SVt_NULL doesn't recognize all of them,
      leading to "cannot transform this Perl type to jsonb" errors.
      Use the approved test SvOK() instead.
      
      Report and patch by Ivan Panchenko.  Back-patch to v11 where
      this module was added.
      
      Discussion: https://postgr.es/m/1564783533.324795401@f193.i.mail.ru
      e0f50488
    • Tom Lane's avatar
      Avoid picking already-bound TCP ports in kerberos and ldap test suites. · 803466b6
      Tom Lane authored
      src/test/kerberos and src/test/ldap need to run a private authentication
      server of the relevant type, for which they need a free TCP port.
      They were just picking a random port number in 48K-64K, which works
      except when something's already using the particular port.  Notably,
      the probability of failure rises dramatically if one simply runs those
      tests in a tight loop, because each test cycle leaves behind a bunch of
      high ports that are transiently in TIME_WAIT state.
      
      To fix, split out the code that PostgresNode.pm already had for
      identifying a free TCP port number, so that it can be invoked to choose
      a port for the KDC or LDAP server.  This isn't 100% bulletproof, since
      conceivably something else on the machine could grab the port between
      the time we check and the time we actually start the server.  But that's
      a pretty short window, so in practice this should be good enough.
      
      Back-patch to v11 where these test suites were added.
      
      Patch by me, reviewed by Andrew Dunstan.
      
      Discussion: https://postgr.es/m/3397.1564872168@sss.pgh.pa.us
      803466b6
    • Alvaro Herrera's avatar
      Improve pruning of a default partition · 489247b0
      Alvaro Herrera authored
      When querying a partitioned table containing a default partition, we
      were wrongly deciding to include it in the scan too early in the
      process, failing to exclude it in some cases.  If we reinterpret the
      PruneStepResult.scan_default flag slightly, we can do a better job at
      detecting that it can be excluded.  The change is that we avoid setting
      the flag for that pruning step unless the step absolutely requires the
      default partition to be scanned (in contrast with the previous
      arrangement, which was to set it unless the step was able to prune it).
      So get_matching_partitions() must explicitly check the partition that
      each returned bound value corresponds to in order to determine whether
      the default one needs to be included, rather than relying on the flag
      from the final step result.
      
      Author: Yuzuko Hosoya <hosoya.yuzuko@lab.ntt.co.jp>
      Reviewed-by: default avatarAmit Langote <Langote_Amit_f8@lab.ntt.co.jp>
      Discussion: https://postgr.es/m/00e601d4ca86$932b8bc0$b982a340$@lab.ntt.co.jp
      489247b0
    • Michael Paquier's avatar
      Refactor BuildIndexInfo() with the new makeIndexInfo() · 69edf4f8
      Michael Paquier authored
      This portion of the code got forgotten in 7cce1593 which has introduced a
      new routine to build this node, and this finishes the unification of the
      places where IndexInfo is initialized.
      
      Author: Michael Paquier
      Discussion: https://postgr.es/m/20190801041322.GA3435@paquier.xyz
      69edf4f8
  4. 02 Aug, 2019 2 commits
    • Andres Freund's avatar
      Fix representation of hash keys in Hash/HashJoin nodes. · 2abd7ae9
      Andres Freund authored
      In 5f32b29c I changed the creation of HashState.hashkeys to
      actually use HashState as the parent (instead of HashJoinState, which
      was incorrect, as they were executed below HashState), to fix the
      problem of hashkeys expressions otherwise relying on slot types
      appropriate for HashJoinState, rather than HashState as would be
      correct. That reliance was only introduced in 12, which is why it
      previously worked to use HashJoinState as the parent (although I'd be
      unsurprised if there were problematic cases).
      
      Unfortunately that's not a sufficient solution, because before this
      commit, the to-be-hashed expressions referenced inner/outer as
      appropriate for the HashJoin, not Hash. That didn't have obvious bad
      consequences, because the slots containing the tuples were put into
      ecxt_innertuple when hashing a tuple for HashState (even though Hash
      doesn't have an inner plan).
      
      There are less common cases where this can cause visible problems
      however (rather than just confusion when inspecting such executor
      trees). E.g. "ERROR: bogus varno: 65000", when explaining queries
      containing a HashJoin where the subsidiary Hash node's hash keys
      reference a subplan. While normally hashkeys aren't displayed by
      EXPLAIN, if one of those expressions references a subplan, that
      subplan may be printed as part of the Hash node - which then failed
      because an inner plan was referenced, and Hash doesn't have that.
      
      It seems quite possible that there's other broken cases, too.
      
      Fix the problem by properly splitting the expression for the HashJoin
      and Hash nodes at plan time, and have them reference the proper
      subsidiary node. While other workarounds are possible, fixing this
      correctly seems easy enough. It was a pretty ugly hack to have
      ExecInitHashJoin put the expression into the already initialized
      HashState, in the first place.
      
      I decided to not just split inner/outer hashkeys inside
      make_hashjoin(), but also to separate out hashoperators and
      hashcollations at plan time. Otherwise we would have ended up having
      two very similar loops, one at plan time and the other during executor
      startup. The work seems to more appropriately belong to plan time,
      anyway.
      
      Reported-By: Nikita Glukhov, Alexander Korotkov
      Author: Andres Freund
      Reviewed-By: Tom Lane, in an earlier version
      Discussion: https://postgr.es/m/CAPpHfdvGVegF_TKKRiBrSmatJL2dR9uwFCuR+teQ_8tEXU8mxg@mail.gmail.com
      Backpatch: 12-
      2abd7ae9
    • Michael Paquier's avatar
      Fix format truncation issue from ECPG test · a9f301df
      Michael Paquier authored
      This fixes one warning generated by GCC and present in the test case
      array part of ECPG.  This likely got missed in past fixes like 3a4b8919
      because the compilation of those tests is not done by default.
      
      Reported-by: Sergei Kornilov
      Discussion: https://postgr.es/m/14951331562847675@sas2-a1efad875d04.qloud-c.yandex.net
      a9f301df
  5. 01 Aug, 2019 8 commits
    • Jeff Davis's avatar
      Allow simplehash to use already-calculated hash values. · 6ae4e8ea
      Jeff Davis authored
      Add _lookup_hash and _insert_hash functions for callers that have
      already calculated the hash value of the key.
      
      The immediate use case is for hash algorithms that write to disk in
      partitions. The hash value can be calculated once, used to perform a
      lookup, used to select the partition, then written to the partition
      along with the tuple. When the tuple is read back, the hash value does
      not need to be recalculated.
      
      Author: Jeff Davis
      Reviewed-by: Andres Freund
      Discussion: https://postgr.es/m/48abe675e1330f0c264ab2fe0d4ff23eb244f9ef.camel%40j-davis.com
      6ae4e8ea
    • Tom Lane's avatar
      Allow functions-in-FROM to be pulled up if they reduce to constants. · 7266d099
      Tom Lane authored
      This allows simplification of the plan tree in some common usage
      patterns: we can get rid of a join to the function RTE.
      
      In principle we could pull up any immutable expression, but restricting
      it to Consts avoids the risk that multiple evaluations of the expression
      might cost more than we can save.  (Possibly this could be improved in
      future --- but we've more or less promised people that putting a function
      in FROM guarantees single evaluation, so we'd have to tread carefully.)
      
      To do this, we need to rearrange when eval_const_expressions()
      happens for expressions in function RTEs.  I moved it to
      inline_set_returning_functions(), which already has to iterate over
      every function RTE, and in consequence renamed that function to
      preprocess_function_rtes().  A useful consequence is that
      inline_set_returning_function() no longer has to do this for itself,
      simplifying that code.
      
      In passing, break out pull_up_simple_subquery's code that knows where
      everything that needs pullup_replace_vars() processing is, so that
      the new pull_up_constant_function() routine can share it.  We'd
      gotten away with one-and-a-half copies of that code so far, since
      pull_up_simple_values() could assume that a lot of cases didn't apply
      to it --- but I don't think pull_up_constant_function() can make any
      simplifying assumptions.  Might as well make pull_up_simple_values()
      use it too.
      
      (Possibly this refactoring should go further: maybe we could share
      some of the code to fill in the pullup_replace_vars_context struct?
      For now, I left it that the callers fill that completely.)
      
      Note: the one existing test case that this patch changes has to be
      changed because inlining its function RTEs would destroy the point
      of the test, namely to check join order.
      
      Alexander Kuzmenkov and Aleksandr Parfenov, reviewed by
      Antonin Houska and Anastasia Lubennikova, and whacked around
      some more by me
      
      Discussion: https://postgr.es/m/402356c32eeb93d4fed01f66d6c7fe2d@postgrespro.ru
      7266d099
    • Peter Geoghegan's avatar
      Bump catversion. · a8d6a95e
      Peter Geoghegan authored
      Oversight in commit 71dcd743.
      a8d6a95e
    • Peter Geoghegan's avatar
      Add sort support routine for the inet data type. · 71dcd743
      Peter Geoghegan authored
      Add sort support for inet, including support for abbreviated keys.
      Testing has shown that this reduces the time taken to sort medium to
      large inet/cidr inputs by ~50-60% in realistic cases.
      
      Author: Brandur Leach
      Reviewed-By: Peter Geoghegan, Edmund Horner
      Discussion: https://postgr.es/m/CABR_9B-PQ8o2MZNJ88wo6r-NxW2EFG70M96Wmcgf99G6HUQ3sw@mail.gmail.com
      71dcd743
    • Tom Lane's avatar
      Add an isolation test to exercise parallel-worker deadlock resolution. · da9456d2
      Tom Lane authored
      Commit a1c1af2a added logic in the deadlock checker to handle lock
      grouping, but it was very poorly tested, as evidenced by the bug
      fixed in 3420851a.  Add a test case that exercises that a bit better
      (and catches the bug --- if you revert 3420851a, this will hang).
      
      Since it's pretty hard to get parallel workers to take exclusive
      regular locks that their parents don't already have, this test operates
      by creating a deadlock among advisory locks taken in parallel workers.
      To make that happen, we must override the parallel-safety labeling of
      the advisory-lock functions, which we do by putting them in mislabeled,
      non-inlinable wrapper functions.
      
      We also have to remove the redundant PreventAdvisoryLocksInParallelMode
      checks in lockfuncs.c.  That seems fine though; if some user accidentally
      does what this test is intentionally doing, not much harm will ensue.
      (If there are any remaining bugs that are reachable that way, they're
      probably reachable in other ways too.)
      
      Discussion: https://postgr.es/m/3243.1564437314@sss.pgh.pa.us
      da9456d2
    • Tom Lane's avatar
      Mark advisory-lock functions as parallel restricted, not parallel unsafe. · 4886da83
      Tom Lane authored
      There seems no good reason not to allow a parallel leader to execute
      these functions.  (The workers still can't, though.  Although the code
      would work, any such lock would go away at worker exit, which is not
      the documented behavior of advisory locks.)
      
      Discussion: https://postgr.es/m/11847.1564496844@sss.pgh.pa.us
      4886da83
    • Peter Eisentraut's avatar
      Add error codes to some corruption log messages · fd6ec93b
      Peter Eisentraut authored
      In some cases we have elog(ERROR) while corruption is certain and we
      can give a clear error code ERRCODE_DATA_CORRUPTED or
      ERRCODE_INDEX_CORRUPTED.
      
      Author: Andrey Borodin <x4mmm@yandex-team.ru>
      Discussion: https://www.postgresql.org/message-id/flat/25F6C686-6442-4A6B-BAF8-A6F7B84B16DE@yandex-team.ru
      fd6ec93b
    • Michael Paquier's avatar
      Fix handling of previous password hooks in passwordcheck · b2a3d706
      Michael Paquier authored
      When piling up loading of modules using check_password_hook_type,
      loading passwordcheck would remove any trace of a previously-loaded
      hook.  Unloading the module would also cause previous hooks to be
      entirely gone.
      
      Reported-by: Rafael Castro
      Author: Michael Paquier
      Reviewed-by: Daniel Gustafsson
      Discussion: https://postgr.es/m/15932-78f48f9ef166778c@postgresql.org
      Backpatch-through: 9.4
      b2a3d706
  6. 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
  7. 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
  8. 29 Jul, 2019 4 commits
  9. 28 Jul, 2019 2 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