1. 17 Aug, 2016 5 commits
    • Tom Lane's avatar
      Fix -e option in contrib/intarray/bench/bench.pl. · 6657acc0
      Tom Lane authored
      As implemented, -e ran an EXPLAIN but then discarded the output, which
      certainly seems pointless.  Make it print to stdout instead.  It's been
      like that forever, so back-patch to all supported branches.
      
      Daniel Gustafsson, reviewed by Andreas Scherbaum
      
      Patch: <B97BDCB7-A3B3-4734-90B5-EDD586941629@yesql.se>
      6657acc0
    • Tom Lane's avatar
      Improve plpgsql's memory management to fix some function-lifespan leaks. · bfaaacc8
      Tom Lane authored
      In some cases, exiting out of a plpgsql statement due to an error, then
      catching the error in a surrounding exception block, led to leakage of
      temporary data the statement was working with, because we kept all such
      data in the function-lifespan SPI Proc context.  Iterating such behavior
      many times within one function call thus led to noticeable memory bloat.
      
      To fix, create an additional memory context meant to have statement
      lifespan.  Since many plpgsql statements, particularly the simpler/more
      common ones, don't need this, create it only on demand.  Reset this context
      at the end of any statement that uses it, and arrange for exception cleanup
      to reset it too, thereby fixing the memory-leak issue.  Allow a stack of
      such contexts to exist to handle cases where a compound statement needs
      statement-lifespan data that persists across calls of inner statements.
      
      While at it, clean up code and improve comments referring to the existing
      short-term memory context, which by plpgsql convention is the per-tuple
      context of the eval_econtext ExprContext.  We now uniformly refer to that
      as the eval_mcontext, whereas the new statement-lifespan memory contexts
      are called stmt_mcontext.
      
      This change adds some context-creation overhead, but on the other hand
      it allows removal of some retail pfree's in favor of context resets.
      On balance it seems to be about a wash performance-wise.
      
      In principle this is a bug fix, but it seems too invasive for a back-patch,
      and the infrequency of complaints weighs against taking the risk in the
      back branches.  So we'll fix it only in HEAD, at least for now.
      
      Tom Lane, reviewed by Pavel Stehule
      
      Discussion: <17863.1469142152@sss.pgh.pa.us>
      bfaaacc8
    • Magnus Hagander's avatar
      Disable update_process_title by default on Windows · 09215546
      Magnus Hagander authored
      The performance overhead of this can be significant on Windows, and most
      people don't have the tools to view it anyway as Windows does not have
      native support for process titles.
      
      Discussion: <0A3221C70F24FB45833433255569204D1F5BE3E8@G01JPEXMBYT05>
      
      Takayuki Tsunakawa
      09215546
    • Bruce Momjian's avatar
      docs: my third pass over the 9.6 release notes · d125d257
      Bruce Momjian authored
      Backpatch-through: 9.6
      d125d257
    • Tom Lane's avatar
      Improve parsetree representation of special functions such as CURRENT_DATE. · 0bb51aa9
      Tom Lane authored
      We implement a dozen or so parameterless functions that the SQL standard
      defines special syntax for.  Up to now, that was done by converting them
      into more or less ad-hoc constructs such as "'now'::text::date".  That's
      messy for multiple reasons: it exposes what should be implementation
      details to users, and performance is worse than it needs to be in several
      cases.  To improve matters, invent a new expression node type
      SQLValueFunction that can represent any of these parameterless functions.
      
      Bump catversion because this changes stored parsetrees for rules.
      
      Discussion: <30058.1463091294@sss.pgh.pa.us>
      0bb51aa9
  2. 16 Aug, 2016 9 commits
    • Tom Lane's avatar
      Suppress -Wunused-result warning for strtol(). · 4bc4cfe3
      Tom Lane authored
      I'm not sure which bozo thought it's a problem to use strtol() only
      for its endptr result, but silence the warning using same method
      used elsewhere.
      
      Report: <f845d3a6-5328-3e2a-924f-f8e91aa2b6d2@2ndquadrant.com>
      4bc4cfe3
    • Tom Lane's avatar
      Fix assorted places in psql to print version numbers >= 10 in new style. · 7f61fd10
      Tom Lane authored
      This is somewhat cosmetic, since as long as you know what you are looking
      at, "10.0" is a serviceable substitute for "10".  But there is a potential
      for confusion between version numbers with minor numbers and those without
      --- we don't want people asking "why is psql saying 10.0 when my server is
      10.2".  Therefore, back-patch as far as practical, which turns out to be
      9.3.  I could have redone the patch to use fprintf(stderr) in place of
      psql_error(), but it seems more work than is warranted for branches that
      will be EOL or nearly so by the time v10 comes out.
      
      Although only psql seems to contain any code that needs this, I chose
      to put the support function into fe_utils, since it seems likely we'll
      need it in other client programs in future.  (In 9.3-9.5, use dumputils.c,
      the predecessor of fe_utils/string_utils.c.)
      
      In HEAD, also fix the backend code that whines about loadable-library
      version mismatch.  I don't see much need to back-patch that.
      7f61fd10
    • Peter Eisentraut's avatar
      doc: Remove some confusion from pg_archivecleanup doc · 63916664
      Peter Eisentraut authored
      From: Jeff Janes <jeff.janes@gmail.com>
      63916664
    • Peter Eisentraut's avatar
      Fix typos · f0fe1c8f
      Peter Eisentraut authored
      From: Alexander Law <exclusion@gmail.com>
      f0fe1c8f
    • Tom Lane's avatar
      Automate the maintenance of SO_MINOR_VERSION for our shared libraries. · a3bce17e
      Tom Lane authored
      Up to now we've manually adjusted these numbers in several different
      Makefiles at the start of each development cycle.  While that's not
      much work, it's easily forgotten, so let's get rid of it by setting
      the SO_MINOR_VERSION values directly from $(MAJORVERSION).
      
      In the case of libpq, this dev cycle's value of SO_MINOR_VERSION happens
      to be "10" anyway, so this switch is transparent.  For ecpg's shared
      libraries, this will result in skipping one or two minor version numbers
      between v9.6 and v10, which seems like no big problem; and it was a bit
      inconsistent that they didn't have equal minor version numbers anyway.
      
      Discussion: <21969.1471287988@sss.pgh.pa.us>
      a3bce17e
    • Robert Haas's avatar
      Fix possible crash due to incorrect allocation context. · 41fb35fa
      Robert Haas authored
      Commit af330393 aimed to reduce
      leakage from tqueue.c, which is good.  Unfortunately, by changing the
      memory context in which all of gather_readnext() executes, it also
      changed the context in which ExecShutdownGatherWorkers executes, which
      is not good, because that function eventually causes a call to
      ExecParallelRetrieveInstrumentation, which proceeds to allocate
      planstate->worker_instrument in a short-lived context, causing a
      crash.
      
      Rushabh Lathia, reviewed by Amit Kapila and by me.
      41fb35fa
    • Tom Lane's avatar
      Remove separate version numbering for ecpg preprocessor. · a7b5573d
      Tom Lane authored
      Once upon a time, it made sense for the ecpg preprocessor to have its
      own version number, because it used a manually-maintained grammar that
      wasn't always in sync with the core grammar.  But those days are
      thankfully long gone, leaving only a maintenance nuisance behind.
      Let's use the PG v10 version numbering changeover as an excuse to get
      rid of the ecpg version number and just have ecpg identify itself by
      PG_VERSION.  From the user's standpoint, ecpg will go from "4.12" in
      the 9.6 branch to "10" in the 10 branch, so there's no failure of
      monotonicity.
      
      Discussion: <1471332659.4410.67.camel@postgresql.org>
      a7b5573d
    • Tom Lane's avatar
      Doc: copy-editing in create_access_method.sgml. · 9b002cc9
      Tom Lane authored
      Improve shaky English grammar.  And markup.
      9b002cc9
    • Tom Lane's avatar
      Doc: remove out-of-date claim that pg_am rows must be inserted by hand. · 8fc571b7
      Tom Lane authored
      Commit 473b9328 added a sentence about that, but neglected to remove
      the adjacent sentence it had falsified.  Per Alexander Law.
      8fc571b7
  3. 15 Aug, 2016 7 commits
  4. 14 Aug, 2016 2 commits
    • Tom Lane's avatar
      Remove bogus dependencies on NUMERIC_MAX_PRECISION. · 9389fbd0
      Tom Lane authored
      NUMERIC_MAX_PRECISION is a purely arbitrary constraint on the precision
      and scale you can write in a numeric typmod.  It might once have had
      something to do with the allowed range of a typmod-less numeric value,
      but at least since 9.1 we've allowed, and documented that we allowed,
      any value that would physically fit in the numeric storage format;
      which is something over 100000 decimal digits, not 1000.
      
      Hence, get rid of numeric_in()'s use of NUMERIC_MAX_PRECISION as a limit
      on the allowed range of the exponent in scientific-format input.  That was
      especially silly in view of the fact that you can enter larger numbers as
      long as you don't use 'e' to do it.  Just constrain the value enough to
      avoid localized overflow, and let make_result be the final arbiter of what
      is too large.  Likewise adjust ecpg's equivalent of this code.
      
      Also get rid of numeric_recv()'s use of NUMERIC_MAX_PRECISION to limit the
      number of base-NBASE digits it would accept.  That created a dump/restore
      hazard for binary COPY without doing anything useful; the wire-format
      limit on number of digits (65535) is about as tight as we would want.
      
      In HEAD, also get rid of pg_size_bytes()'s unnecessary intimacy with what
      the numeric range limit is.  That code doesn't exist in the back branches.
      
      Per gripe from Aravind Kumar.  Back-patch to all supported branches,
      since they all contain the documentation claim about allowed range of
      NUMERIC (cf commit cabf5d84).
      
      Discussion: <2895.1471195721@sss.pgh.pa.us>
      9389fbd0
    • Tom Lane's avatar
      Fix assorted bugs in contrib/bloom. · d6c9e05c
      Tom Lane authored
      In blinsert(), cope with the possibility that a page we pull from the
      notFullPage list is marked BLOOM_DELETED.  This could happen if VACUUM
      recently marked it deleted but hasn't (yet) updated the metapage.
      We can re-use such a page safely, but we *must* reinitialize it so that
      it's no longer marked deleted.
      
      Fix blvacuum() so that it updates the notFullPage list even if it's
      going to update it to empty.  The previous "optimization" of skipping
      the update seems pretty dubious, since it means that the next blinsert()
      will uselessly visit whatever pages we left in the list.
      
      Uniformly treat PageIsNew pages the same as deleted pages.  This should
      allow proper recovery if a crash occurs just after relation extension.
      
      Properly use vacuum_delay_point, not assorted ad-hoc CHECK_FOR_INTERRUPTS
      calls, in the blvacuum() main loop.
      
      Fix broken tuple-counting logic: blvacuum.c counted the number of live
      index tuples over again in each scan, leading to VACUUM VERBOSE reporting
      some multiple of the actual number of surviving index tuples after any
      vacuum that removed any tuples (since they'd be counted in blvacuum, maybe
      more than once, and then again in blvacuumcleanup, without ever zeroing the
      counter).  It's sufficient to count them in blvacuumcleanup.
      
      stats->estimated_count is a boolean, not a counter, and we don't want
      to set it true, so don't add tuple counts to it.
      
      Add a couple of Asserts that we don't overrun available space on a bloom
      page.  I don't think there's any bug there today, but the way the
      FreeBlockNumberArray size calculation is set up is scarily fragile, and
      BloomPageGetFreeSpace isn't much better.  The Asserts should help catch
      any future mistakes.
      
      Per investigation of a report from Jeff Janes.  I think the first item
      above may explain his report; the other changes were things I noticed
      while casting about for an explanation.
      
      Report: <CAMkU=1xEUuBphDwDmB1WjN4+td4kpnEniFaTBxnk1xzHCw8_OQ@mail.gmail.com>
      d6c9e05c
  5. 13 Aug, 2016 1 commit
    • Tom Lane's avatar
      Add SQL-accessible functions for inspecting index AM properties. · ed0097e4
      Tom Lane authored
      Per discussion, we should provide such functions to replace the lost
      ability to discover AM properties by inspecting pg_am (cf commit
      65c5fcd3).  The added functionality is also meant to displace any code
      that was looking directly at pg_index.indoption, since we'd rather not
      believe that the bit meanings in that field are part of any client API
      contract.
      
      As future-proofing, define the SQL API to not assume that properties that
      are currently AM-wide or index-wide will remain so unless they logically
      must be; instead, expose them only when inquiring about a specific index
      or even specific index column.  Also provide the ability for an index
      AM to override the behavior.
      
      In passing, document pg_am.amtype, overlooked in commit 473b9328.
      
      Andrew Gierth, with kibitzing by me and others
      
      Discussion: <87mvl5on7n.fsf@news-spur.riddles.org.uk>
      ed0097e4
  6. 12 Aug, 2016 4 commits
    • Tom Lane's avatar
      Doc: clarify that DROP ... CASCADE is recursive. · 49978781
      Tom Lane authored
      Apparently that's not obvious to everybody, so let's belabor the point.
      
      In passing, document that DROP POLICY has CASCADE/RESTRICT options (which
      it does, per gram.y) but they do nothing (I assume, anyway).  Also update
      some long-obsolete commentary in gram.y.
      
      Discussion: <20160805104837.1412.84915@wrigleys.postgresql.org>
      49978781
    • Tom Lane's avatar
      Fix inappropriate printing of never-measured times in EXPLAIN. · 4b234fd8
      Tom Lane authored
      EXPLAIN (ANALYZE, TIMING OFF) would print an elapsed time of zero for
      a trigger function, because no measurement has been taken but it printed
      the field anyway.  This isn't what EXPLAIN does elsewhere, so suppress it.
      
      In the same vein, EXPLAIN (ANALYZE, BUFFERS) with non-text output format
      would print buffer I/O timing numbers even when no measurement has been
      taken because track_io_timing is off.  That seems not per policy, either,
      so change it.
      
      Back-patch to 9.2 where these features were introduced.
      
      Maksim Milyutin
      
      Discussion: <081c0540-ecaa-bd29-3fd2-6358f3b359a9@postgrespro.ru>
      4b234fd8
    • Simon Riggs's avatar
      Code cleanup in SyncRepWaitForLSN() · e05f6f75
      Simon Riggs authored
      Commit 14e8803f removed LWLocks when accessing MyProc->syncRepState
      but didn't clean up the surrounding code and comments.
      
      Cleanup and backpatch to 9.5, to keep code similar.
      
      Julien Rouhaud, improved by suggestion from Michael Paquier,
      implemented trivially by myself.
      e05f6f75
    • Simon Riggs's avatar
      Correct TABLESAMPLE docs · 6e75559e
      Simon Riggs authored
      Original wording was correct but not the intended meaning.
      
      Reported by Patrik Wenger
      6e75559e
  7. 11 Aug, 2016 5 commits
  8. 09 Aug, 2016 3 commits
  9. 08 Aug, 2016 4 commits