1. 30 Mar, 2018 11 commits
  2. 29 Mar, 2018 16 commits
  3. 28 Mar, 2018 13 commits
    • Peter Eisentraut's avatar
      Allow committing inside cursor loop · 056a5a3f
      Peter Eisentraut authored
      Previously, committing or aborting inside a cursor loop was prohibited
      because that would close and remove the cursor.  To allow that,
      automatically convert such cursors to holdable cursors so they survive
      commits or rollbacks.  Portals now have a new state "auto-held", which
      means they have been converted automatically from pinned.  An auto-held
      portal is kept on transaction commit or rollback, but is still removed
      when returning to the main loop on error.
      
      This supports all languages that have cursor loop constructs: PL/pgSQL,
      PL/Python, PL/Perl.
      Reviewed-by: default avatarIldus Kurbangaliev <i.kurbangaliev@postgrespro.ru>
      056a5a3f
    • Bruce Momjian's avatar
      C comment: fix typo, log -> lag · a2894cce
      Bruce Momjian authored
      Reported-by: atorikoshi
      
      Discussion: https://postgr.es/m/b61f2ab9-c0e0-d33d-ce3f-42a228025681@lab.ntt.co.jp
      
      Author: atorikoshi
      a2894cce
    • Andres Freund's avatar
      Fix mistakes in the just added JIT docs. · a0a08c1d
      Andres Freund authored
      Reported-By: Lukas Fittl
      Author: Andres Freund
      a0a08c1d
    • Andres Freund's avatar
      Add documentation for the JIT feature. · e6c039d1
      Andres Freund authored
      As promised in earlier commits, this adds documentation about the new
      build options, the new GUCs, about the planner logic when JIT is used,
      and the benefits of JIT in general.
      
      Also adds a more implementation oriented README.
      
      I'm sure we're going to want to expand this further, but I think this
      is a reasonable start.
      
      Author: Andres Freund, with contributions by Thomas Munro
      Reviewed-By: Thomas Munro
      Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
      e6c039d1
    • Andres Freund's avatar
      Add EXPLAIN support for JIT. · 1f0c6a9e
      Andres Freund authored
      This just shows a few details about JITing, e.g. how many functions
      have been JITed, and how long that took.  To avoid noise in regression
      tests with functions sometimes being JITed in --with-llvm builds,
      disable display when COSTS OFF is specified.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
      1f0c6a9e
    • Andres Freund's avatar
      Add inlining support to LLVM JIT provider. · 9370462e
      Andres Freund authored
      This provides infrastructure to allow JITed code to inline code
      implemented in C. This e.g. can be postgres internal functions or
      extension code.
      
      This already speeds up long running queries, by allowing the LLVM
      optimizer to optimize across function boundaries. The optimization
      potential currently doesn't reach its full potential because LLVM
      cannot optimize the FunctionCallInfoData argument fully away, because
      it's allocated on the heap rather than the stack. Fixing that is
      beyond what's realistic for v11.
      
      To be able to do that, use CLANG to convert C code to LLVM bitcode,
      and have LLVM build a summary for it. That bitcode can then be used to
      to inline functions at runtime. For that the bitcode needs to be
      installed. Postgres bitcode goes into $pkglibdir/bitcode/postgres,
      extensions go into equivalent directories.  PGXS has been modified so
      that happens automatically if postgres has been compiled with LLVM
      support.
      
      Currently this isn't the fastest inline implementation, modules are
      reloaded from disk during inlining. That's to work around an apparent
      LLVM bug, triggering an apparently spurious error in LLVM assertion
      enabled builds.  Once that is resolved we can remove the superfluous
      read from disk.
      
      Docs will follow in a later commit containing docs for the whole JIT
      feature.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
      9370462e
    • Andres Freund's avatar
      Use isinf builtin for clang, for performance. · 8a934d67
      Andres Freund authored
      When compiling with clang glibc's definition of isinf() ends up
      leading to and external libc function call. That's because there was a
      bug in the builtin in an old gcc version, and clang claims
      compatibility with an older version.  That causes clang to be
      measurably slower for floating point heavy workloads than gcc.
      
      To fix simply redirect isinf when using clang and clang confirms it
      has __builtin_isinf().
      8a934d67
    • Fujii Masao's avatar
      Make pg_rewind skip files and directories that are removed during server start. · 266b6acb
      Fujii Masao authored
      The target cluster that was rewound needs to perform recovery from
      the checkpoint created at failover, which leads it to remove or recreate
      some files and directories that may have been copied from the source
      cluster. So pg_rewind can skip synchronizing such files and directories,
      and which reduces the amount of data transferred during a rewind
      without changing the usefulness of the operation.
      
      Author: Michael Paquier
      Reviewed-by: Anastasia Lubennikova, Stephen Frost and me
      
      Discussion: https://postgr.es/m/20180205071022.GA17337@paquier.xyz
      266b6acb
    • Fujii Masao's avatar
      Fix handling of files that source server removes during pg_rewind is running. · 09e96b3f
      Fujii Masao authored
      After processing the filemap to build the list of chunks that will be
      fetched from the source to rewing the target server, it is possible that
      a file which was previously processed is removed from the source.  A
      simple example of such an occurence is a WAL segment which gets recycled
      on the target in-between.  When the filemap is processed, files not
      categorized as relation files are first truncated to prepare for its
      full copy of which is going to be taken from the source, divided into a
      set of junks.  However, for a recycled WAL segment, this would result in
      a segment which has a zero-byte size.  With such an empty file,
      post-rewind recovery thinks that records are saved but they are actually
      not because of the truncation which happened when processing the
      filemap, resulting in data loss.
      
      In order to fix the problem, make sure that files which are found as
      removed on the source when receiving chunks of them are as well deleted
      on the target server for consistency.
      
      Back-patch to 9.5 where pg_rewind was added.
      
      Author: Tsunakawa Takayuki
      Reviewed-by: Michael Paquier
      Reported-by: Tsunakawa Takayuki
      
      Discussion: https://postgr.es/m/0A3221C70F24FB45833433255569204D1F8DAAA2%40G01JPEXMBYT05
      09e96b3f
    • Peter Eisentraut's avatar
      PL/pgSQL: Nested CALL with transactions · d92bc83c
      Peter Eisentraut authored
      So far, a nested CALL or DO in PL/pgSQL would not establish a context
      where transaction control statements were allowed.  This fixes that by
      handling CALL and DO specially in PL/pgSQL, passing the atomic/nonatomic
      execution context through and doing the required management around
      transaction boundaries.
      Reviewed-by: default avatarTomas Vondra <tomas.vondra@2ndquadrant.com>
      d92bc83c
    • Tom Lane's avatar
      Fix actual and potential double-frees around tuplesort usage. · c2d4eb1b
      Tom Lane authored
      tuplesort_gettupleslot() passed back tuples allocated in the tuplesort's
      own memory context, even when the caller was responsible to free them.
      This created a double-free hazard, because some callers might destroy
      the tuplesort object (via tuplesort_end) before trying to clean up the
      last returned tuple.  To avoid this, change the API to specify that the
      tuple is allocated in the caller's memory context.  v10 and HEAD already
      did things that way, but in 9.5 and 9.6 this is a live bug that can
      demonstrably cause crashes with some grouping-set usages.
      
      In 9.5 and 9.6, this requires doing an extra tuple copy in some cases,
      which is unfortunate.  But the amount of refactoring needed to avoid it
      seems excessive for a back-patched change, especially since the cases
      where an extra copy happens are less performance-critical.
      
      Likewise change tuplesort_getdatum() to return pass-by-reference Datums
      in the caller's context not the tuplesort's context.  There seem to be
      no live bugs among its callers, but clearly the same sort of situation
      could happen in future.
      
      For other tuplesort fetch routines, continue to allocate the memory in
      the tuplesort's context.  This is a little inconsistent with what we now
      do for tuplesort_gettupleslot() and tuplesort_getdatum(), but that's
      preferable to adding new copy overhead in the back branches where it's
      clearly unnecessary.  These other fetch routines provide the weakest
      possible guarantees about tuple memory lifespan from v10 on, anyway,
      so this actually seems more consistent overall.
      
      Adjust relevant comments to reflect these API redefinitions.
      
      Arguably, we should change the pre-9.5 branches as well, but since
      there are no known failure cases there, it seems not worth the risk.
      
      Peter Geoghegan, per report from Bernd Helmle.  Reviewed by Kyotaro
      Horiguchi; thanks also to Andreas Seltenreich for extracting a
      self-contained test case.
      
      Discussion: https://postgr.es/m/1512661638.9720.34.camel@oopsware.de
      c2d4eb1b
    • Simon Riggs's avatar
      Store 2PC GID in commit/abort WAL recs for logical decoding · 1eb6d652
      Simon Riggs authored
      Store GID of 2PC in commit/abort WAL records when wal_level = logical.
      This allows logical decoding to send the SAME gid to subscribers
      across restarts of logical replication.
      
      Track relica origin replay progress for 2PC.
      
      (Edited from patch 0003 in the logical decoding 2PC series.)
      
      Authors: Nikhil Sontakke, Stas Kelvich
      Reviewed-by: Simon Riggs, Andres Freund
      1eb6d652
    • Peter Eisentraut's avatar
      75e95dd7