1. 24 Sep, 2015 2 commits
    • Fujii Masao's avatar
      Make pg_controldata report newest XID with valid commit timestamp · 18d938de
      Fujii Masao authored
      Previously pg_controldata didn't report newestCommitTs and this was
      an oversight in commit 73c986ad.
      
      Also this patch changes pg_resetxlog so that it uses the same sentences
      as pg_controldata does, regarding oldestCommitTs and newestCommitTs,
      for the sake of consistency.
      
      Back-patch to 9.5 where track_commit_timestamp was added.
      
      Euler Taveira
      18d938de
    • Andres Freund's avatar
      Lower *_freeze_max_age minimum values. · 020235a5
      Andres Freund authored
      The old minimum values are rather large, making it time consuming to
      test related behaviour. Additionally the current limits, especially for
      multixacts, can be problematic in space-constrained systems. 10000000
      multixacts can contain a lot of members.
      
      Since there's no good reason for the current limits, lower them a good
      bit. Setting them to 0 would be a bad idea, triggering endless vacuums,
      so still retain a limit.
      
      While at it fix autovacuum_multixact_freeze_max_age to refer to
      multixact.c instead of varsup.c.
      
      Reviewed-By: Robert Haas
      Discussion: CA+TgmoYmQPHcrc3GSs7vwvrbTkbcGD9Gik=OztbDGGrovkkEzQ@mail.gmail.com
      Backpatch: back to 9.0 (in parts)
      020235a5
  2. 23 Sep, 2015 5 commits
    • Tom Lane's avatar
      Make ANALYZE compute basic statistics even for types with no "=" operator. · 82e1ba7f
      Tom Lane authored
      Previously, ANALYZE simply ignored columns of datatypes that have neither
      a btree nor hash opclass (which means they have no recognized equality
      operator).  Without a notion of equality, we can't identify most-common
      values nor estimate the number of distinct values.  But we can still
      count nulls and compute the average physical column width, and those
      stats might be of value.  Moreover there are some tools out there that
      don't work so well if rows are missing from pg_statistic.  So let's
      add suitable logic for this case.
      
      While this is arguably a bug fix, it also has the potential to change
      query plans, and the gain seems not worth taking a risk of that in
      stable branches.  So back-patch into 9.5 but not further.
      
      Oleksandr Shulgin, rewritten a bit by me.
      82e1ba7f
    • Robert Haas's avatar
      Add readfuncs.c support for plan nodes. · a0d9f6e4
      Robert Haas authored
      For parallel query, we need to be able to pass a Plan to a worker, so
      that it knows what it's supposed to do.  We could invent our own way
      of serializing plans for that purpose, but piggybacking on the
      existing node infrastructure seems like a much better idea.
      
      Initially, we'll probably only support a limited number of nodes
      within parallel workers, but this commit adds support for everything
      in plannodes.h except CustomScan, because doing it all at once seems
      easier than doing it piecemeal, and it makes testing this code easier,
      too.  CustomScan is excluded because making that work requires a
      larger rework of that facility.
      
      Amit Kapila, reviewed and slightly revised by me.
      a0d9f6e4
    • Robert Haas's avatar
      Print a MergeJoin's mergeNullsFirst array as bool, not int. · 4fe6f72b
      Robert Haas authored
      It's declared as being an array of bool, but it's printed
      differently from the way bool and arrays of bool are handled
      elsewhere.
      
      Patch by Amit Kapila.  Anomaly noted independently by Amit Kapila
      and KaiGai Kohei.
      4fe6f72b
    • Teodor Sigaev's avatar
      Allow autoanalyze to add pages deleted from pending list to FSM · dc943ad9
      Teodor Sigaev authored
      Commit e9568083 introduces adding pages
      to FSM for ordinary insert, but autoanalyze was able just cleanup
      pending list without adding to FSM.
      
      Also fix double call of IndexFreeSpaceMapVacuum() during ginvacuumcleanup()
      
      Report from Fujii Masao
      Patch by me
      Review by Jeff Janes
      dc943ad9
    • Robert Haas's avatar
      Teach planstate_tree_walker about custom scans. · 262e56bc
      Robert Haas authored
      This logic was missing from ExplainPreScanNode, from which I derived
      planstate_tree_walker.  But it shouldn't be missing, especially not
      from a generic walker function, so add it.
      
      KaiGai Kohei
      262e56bc
  3. 22 Sep, 2015 6 commits
  4. 21 Sep, 2015 5 commits
    • Peter Eisentraut's avatar
      Fix whitespace · 13200777
      Peter Eisentraut authored
      13200777
    • Tom Lane's avatar
      Fix possible internal overflow in numeric multiplication. · 246693e5
      Tom Lane authored
      mul_var() postpones propagating carries until it risks overflow in its
      internal digit array.  However, the logic failed to account for the
      possibility of overflow in the carry propagation step, allowing wrong
      results to be generated in corner cases.  We must slightly reduce the
      when-to-propagate-carries threshold to avoid that.
      
      Discovered and fixed by Dean Rasheed, with small adjustments by me.
      
      This has been wrong since commit d72f6c75,
      so back-patch to all supported branches.
      246693e5
    • Noah Misch's avatar
      Remove the SECURITY_ROW_LEVEL_DISABLED security context bit. · 7f11724b
      Noah Misch authored
      This commit's parent made superfluous the bit's sole usage.  Referential
      integrity checks have long run as the subject table's owner, and that
      now implies RLS bypass.  Safe use of the bit was tricky, requiring
      strict control over the SQL expressions evaluating therein.  Back-patch
      to 9.5, where the bit was introduced.
      
      Based on a patch by Stephen Frost.
      7f11724b
    • Noah Misch's avatar
      Remove the row_security=force GUC value. · 537bd178
      Noah Misch authored
      Every query of a single ENABLE ROW SECURITY table has two meanings, with
      the row_security GUC selecting between them.  With row_security=force
      available, every function author would have been advised to either set
      the GUC locally or test both meanings.  Non-compliance would have
      threatened reliability and, for SECURITY DEFINER functions, security.
      Authors already face an obligation to account for search_path, and we
      should not mimic that example.  With this change, only BYPASSRLS roles
      need exercise the aforementioned care.  Back-patch to 9.5, where the
      row_security GUC was introduced.
      
      Since this narrows the domain of pg_db_role_setting.setconfig and
      pg_proc.proconfig, one might bump catversion.  A row_security=force
      setting in one of those columns will elicit a clear message, so don't.
      537bd178
    • Noah Misch's avatar
      Restrict file mode creation mask during tmpfile(). · 8346218c
      Noah Misch authored
      Per Coverity.  Back-patch to 9.0 (all supported versions).
      
      Michael Paquier, reviewed (in earlier versions) by Heikki Linnakangas.
      8346218c
  5. 20 Sep, 2015 1 commit
    • Tom Lane's avatar
      Be more wary about partially-valid LOCALLOCK data in RemoveLocalLock(). · ba51774d
      Tom Lane authored
      RemoveLocalLock() must consider the possibility that LockAcquireExtended()
      failed to palloc the initial space for a locallock's lockOwners array.
      I had evidently meant to cope with this hazard when the code was originally
      written (commit 1785aceb), but missed that
      the pfree needed to be protected with an if-test.  Just to make sure things
      are left in a clean state, reset numLockOwners as well.
      
      Per low-memory testing by Andreas Seltenreich.  Back-patch to all supported
      branches.
      ba51774d
  6. 19 Sep, 2015 4 commits
    • Peter Eisentraut's avatar
      Simplify GETTEXT_FILES list · 85eda7e9
      Peter Eisentraut authored
      85eda7e9
    • Peter Eisentraut's avatar
      Add missing serial comma · 4a1e15e4
      Peter Eisentraut authored
      4a1e15e4
    • Peter Eisentraut's avatar
      Remove trailing slashes from directories in find command · f2dd1061
      Peter Eisentraut authored
      BSD find is not very smart and ends up writing double slashes into the
      output in those cases.  Also, xgettext is not very smart and splits the
      file names incorrectly in those cases, resulting in slightly incorrect
      file names being written into the POT file.
      f2dd1061
    • Robert Haas's avatar
      Glue layer to connect the executor to the shm_mq mechanism. · 4a4e6893
      Robert Haas authored
      The shm_mq mechanism was built to send error (and notice) messages and
      tuples between backends.  However, shm_mq itself only deals in raw
      bytes.  Since commit 2bd9e412, we have
      had infrastructure for one message to redirect protocol messages to a
      queue and for another backend to parse them and do useful things with
      them.  This commit introduces a somewhat analogous facility for tuples
      by adding a new type of DestReceiver, DestTupleQueue, which writes
      each tuple generated by a query into a shm_mq, and a new
      TupleQueueFunnel facility which reads raw tuples out of the queue and
      reconstructs the HeapTuple format expected by the executor.
      
      The TupleQueueFunnel abstraction supports reading from multiple tuple
      streams at the same time, but only in round-robin fashion.  Someone
      could imaginably want other policies, but this should be good enough
      to meet our short-term needs related to parallel query, and we can
      always extend it later.
      
      This also makes one minor addition to the shm_mq API that didn'
      seem worth breaking out as a separate patch.
      
      Extracted from Amit Kapila's parallel sequential scan patch.  This
      code was originally written by me, and then it was revised by Amit,
      and then it was revised some more by me.
      4a4e6893
  7. 18 Sep, 2015 4 commits
    • Andrew Dunstan's avatar
      Cache argument type information in json(b) aggregate functions. · c00c3249
      Andrew Dunstan authored
      These functions have been looking up type info for every row they
      process. Instead of doing that we only look them up the first time
      through and stash the information in the aggregate state object.
      
      Affects json_agg, json_object_agg, jsonb_agg and jsonb_object_agg.
      
      There is plenty more work to do in making these more efficient,
      especially the jsonb functions, but this is a virtually cost free
      improvement that can be done right away.
      
      Backpatch to 9.5 where the jsonb variants were introduced.
      c00c3249
    • Tom Lane's avatar
      Fix low-probability memory leak in regex execution. · d9c0c728
      Tom Lane authored
      After an internal failure in shortest() or longest() while pinning down the
      exact location of a match, find() forgot to free the DFA structure before
      returning.  This is pretty unlikely to occur, since we just successfully
      ran the "search" variant of the DFA; but it could happen, and it would
      result in a session-lifespan memory leak since this code uses malloc()
      directly.  Problem seems to have been aboriginal in Spencer's library,
      so back-patch all the way.
      
      In passing, correct a thinko in a comment I added awhile back about the
      meaning of the "ntree" field.
      
      I happened across these issues while comparing our code to Tcl's version
      of the library.
      d9c0c728
    • Teodor Sigaev's avatar
      Add header forgotten in 213335c1 · d63a1720
      Teodor Sigaev authored
      Report from Peter Eisentraut
      d63a1720
    • Peter Eisentraut's avatar
  8. 17 Sep, 2015 5 commits
    • Teodor Sigaev's avatar
      Fix oversight in tsearch type check · 9acb9007
      Teodor Sigaev authored
      Use IsBinaryCoercible() method instead of custom
      is_expected_type/is_text_type functions which was introduced when tsearch2
      was moved into core.
      
      Per report by David E. Wheeler
      Analysis by Tom Lane
      Patch by me
      9acb9007
    • Andrew Dunstan's avatar
      Honour TEMP_CONFIG when testing pg_upgrade · 5f7c804b
      Andrew Dunstan authored
      This setting contains extra configuration for the temp instance, as used
      in pg_regress' --temp-config flag.
      
      Backpatch to 9.2 where test.sh was introduced.
      5f7c804b
    • Robert Haas's avatar
      Add new function planstate_tree_walker. · 8dd401aa
      Robert Haas authored
      ExplainPreScanNode knows how to iterate over a generic tree of plan
      states; factor that logic out into a separate walker function so that
      other code, such as upcoming patches for parallel query, can also use
      it.
      
      Patch by me, reviewed by Tom Lane.
      8dd401aa
    • Michael Meskes's avatar
      Let compiler handle size calculation of bool types. · 293fd7c7
      Michael Meskes authored
      Back in the day this did not work, but modern compilers should handle it themselves.
      293fd7c7
    • Teodor Sigaev's avatar
      Fix bug introduced by microvacuum for GiST · 22f519c9
      Teodor Sigaev authored
      Commit 013ebc0a introduces microvacuum for
      GiST, deletetion of tuple marked LP_DEAD uses IndexPageMultiDelete while
      recovery code uses IndexPageTupleDelete in loop. This causes a difference
      in offset numbers of tuples to delete. Patch introduces usage of
      IndexPageMultiDelete in GiST except gistplacetopage() where only one tuple is
      deleted at once. That also slightly improve performance, because
      IndexPageMultiDelete is more effective.
      
      Patch changes WAL format, so bump wal page magic.
      
      Bug report from Jeff Janes
      Diagnostic and patch by Anastasia Lubennikova and me
      22f519c9
  9. 16 Sep, 2015 7 commits
    • Robert Haas's avatar
      Determine whether it's safe to attempt a parallel plan for a query. · 7aea8e4f
      Robert Haas authored
      Commit 924bcf4f introduced a framework
      for parallel computation in PostgreSQL that makes most but not all
      built-in functions safe to execute in parallel mode.  In order to have
      parallel query, we'll need to be able to determine whether that query
      contains functions (either built-in or user-defined) that cannot be
      safely executed in parallel mode.  This requires those functions to be
      labeled, so this patch introduces an infrastructure for that.  Some
      functions currently labeled as safe may need to be revised depending on
      how pending issues related to heavyweight locking under paralllelism
      are resolved.
      
      Parallel plans can't be used except for the case where the query will
      run to completion.  If portal execution were suspended, the parallel
      mode restrictions would need to remain in effect during that time, but
      that might make other queries fail.  Therefore, this patch introduces
      a framework that enables consideration of parallel plans only when it
      is known that the plan will be run to completion.  This probably needs
      some refinement; for example, at bind time, we do not know whether a
      query run via the extended protocol will be execution to completion or
      run with a limited fetch count.  Having the client indicate its
      intentions at bind time would constitute a wire protocol break.  Some
      contexts in which parallel mode would be safe are not adjusted by this
      patch; the default is not to try parallel plans except from call sites
      that have been updated to say that such plans are OK.
      
      This commit doesn't introduce any parallel paths or plans; it just
      provides a way to determine whether they could potentially be used.
      I'm committing it on the theory that the remaining parallel sequential
      scan patches will also get committed to this release, hopefully in the
      not-too-distant future.
      
      Robert Haas and Amit Kapila.  Reviewed (in earlier versions) by Noah
      Misch.
      7aea8e4f
    • Tom Lane's avatar
      Sync regex code with Tcl 8.6.4. · b44d92b6
      Tom Lane authored
      Sync our regex code with upstream changes since last time we did this,
      which was Tcl 8.5.11 (see commit 08fd6ff3).
      
      The only functional change here is to disbelieve that an octal escape is
      three digits long if it would exceed \377.  That's a bug fix, but it's
      a minor one and could change the interpretation of working regexes, so
      don't back-patch.
      
      In addition to that, s/INFINITY/DUPINF/ to eliminate the risk of collisions
      with <math.h>'s macro, and s/LOCAL/NOPROP/ because that also seems like
      an unnecessarily collision-prone macro name.
      
      There were some other cosmetic changes in their copy that I did not adopt,
      notably a rather half-hearted attempt at renaming some of the C functions
      in a more verbose style.  (I'm not necessarily against the concept, but
      renaming just a few functions in the package is not an improvement.)
      b44d92b6
    • Tom Lane's avatar
      Fix documentation of regular expression character-entry escapes. · d0f18cde
      Tom Lane authored
      The docs claimed that \uhhhh would be interpreted as a Unicode value
      regardless of the database encoding, but it's never been implemented
      that way: \uhhhh and \xhhhh actually mean exactly the same thing, namely
      the character that pg_mb2wchar translates to 0xhhhh.  Moreover we were
      falsely dismissive of the usefulness of Unicode code points above FFFF.
      Fix that.
      
      It's been like this for ages, so back-patch to all supported branches.
      d0f18cde
    • Tom Lane's avatar
      Don't use "#" as an abbreviation for "number" in PL/Tcl error messages. · 4d0fc1d5
      Tom Lane authored
      Also, rewrite one error message to make it follow our message style
      guidelines better.
      
      Euler Taveira and Tom Lane
      4d0fc1d5
    • Tom Lane's avatar
      Remove no-longer-used T_PrivGrantee node tag. · ad584a08
      Tom Lane authored
      Oversight in commit 31eae602, which
      replaced PrivGrantee nodes with RoleSpec nodes.  Spotted by Yugo Nagata.
      ad584a08
    • Teodor Sigaev's avatar
      pgbench progress with timestamp · 1def9063
      Teodor Sigaev authored
      This patch adds an option to replace the "time since pgbench run
      started" with a Unix epoch timestamp in the progress report so that,
      for instance, it is easier to compare timelines with pgsql log
      
      Fabien COELHO <coelho@cri.ensmp.fr>
      1def9063
    • Peter Eisentraut's avatar
      5878a377
  10. 15 Sep, 2015 1 commit
    • Stephen Frost's avatar
      Enforce ALL/SELECT policies in RETURNING for RLS · 4f3b2a88
      Stephen Frost authored
      For the UPDATE/DELETE RETURNING case, filter the records which are not
      visible to the user through ALL or SELECT policies from those considered
      for the UPDATE or DELETE.  This is similar to how the GRANT system
      works, which prevents RETURNING unless the caller has SELECT rights on
      the relation.
      
      Per discussion with Robert, Dean, Tom, and Kevin.
      
      Back-patch to 9.5 where RLS was introduced.
      4f3b2a88