1. 15 May, 2015 3 commits
  2. 14 May, 2015 11 commits
    • Bruce Momjian's avatar
      doc: list bigint as mapping to int8 and int64 · 333a870f
      Bruce Momjian authored
      Report by Paul Jungwirth
      333a870f
    • Stephen Frost's avatar
      Make repeated 'make installcheck' runs work · b22b7706
      Stephen Frost authored
      In pg_audit, set client_min_messages up to warning, then reset the role
      attributes, to completely reset the session while not making the
      regression tests depend on being run by any particular user.
      b22b7706
    • Stephen Frost's avatar
      Improve pg_audit regression tests · ed6ea8e8
      Stephen Frost authored
      Instead of creating a new superuser role, extract out what the current
      user is and use that user instead.  Further, clean up and drop all
      objects created by the regression test.
      
      Pointed out by Tom.
      ed6ea8e8
    • Tom Lane's avatar
      Docs: fix erroneous claim about max byte length of GB18030. · 333d0779
      Tom Lane authored
      This encoding has characters up to 4 bytes long, not 2.
      333d0779
    • Tom Lane's avatar
      Fix portability issue in pg_audit. · 35a1e1d1
      Tom Lane authored
      "%ld" is not a portable way to print int64's.  This may explain the
      buildfarm crashes we're seeing --- it seems to make dromedary happy,
      at least.
      35a1e1d1
    • Tom Lane's avatar
      Suppress uninitialized-variable warning. · 6c9e93d3
      Tom Lane authored
      6c9e93d3
    • Tom Lane's avatar
      Support "expanded" objects, particularly arrays, for better performance. · 1dc5ebc9
      Tom Lane authored
      This patch introduces the ability for complex datatypes to have an
      in-memory representation that is different from their on-disk format.
      On-disk formats are typically optimized for minimal size, and in any case
      they can't contain pointers, so they are often not well-suited for
      computation.  Now a datatype can invent an "expanded" in-memory format
      that is better suited for its operations, and then pass that around among
      the C functions that operate on the datatype.  There are also provisions
      (rudimentary as yet) to allow an expanded object to be modified in-place
      under suitable conditions, so that operations like assignment to an element
      of an array need not involve copying the entire array.
      
      The initial application for this feature is arrays, but it is not hard
      to foresee using it for other container types like JSON, XML and hstore.
      I have hopes that it will be useful to PostGIS as well.
      
      In this initial implementation, a few heuristics have been hard-wired
      into plpgsql to improve performance for arrays that are stored in
      plpgsql variables.  We would like to generalize those hacks so that
      other datatypes can obtain similar improvements, but figuring out some
      appropriate APIs is left as a task for future work.  (The heuristics
      themselves are probably not optimal yet, either, as they sometimes
      force expansion of arrays that would be better left alone.)
      
      Preliminary performance testing shows impressive speed gains for plpgsql
      functions that do element-by-element access or update of large arrays.
      There are other cases that get a little slower, as a result of added array
      format conversions; but we can hope to improve anything that's annoyingly
      bad.  In any case most applications should see a net win.
      
      Tom Lane, reviewed by Andres Freund
      1dc5ebc9
    • Stephen Frost's avatar
      Further fixes for the buildfarm for pg_audit · 8a2e1edd
      Stephen Frost authored
      Also, use a function to load the extension ahead of all other calls,
      simulating load from shared_libraries_preload, to make sure the
      hooks are in place before logging start.
      8a2e1edd
    • Stephen Frost's avatar
      Further fixes for the buildfarm for pg_audit · c703b1e6
      Stephen Frost authored
      The database built by the buildfarm is specific to the extension, use
      \connect - instead.
      c703b1e6
    • Stephen Frost's avatar
      Fix buildfarm with regard to pg_audit · dfb7624a
      Stephen Frost authored
      Remove the check that pg_audit be installed by
      shared_preload_libraries as that's not going to work when running the
      regressions tests in the buildfarm.  That check was primairly a nice to
      have and isn't required anyway.
      dfb7624a
    • Stephen Frost's avatar
      Add pg_audit, an auditing extension · ac52bb04
      Stephen Frost authored
      This extension provides detailed logging classes, ability to control
      logging at a per-object level, and includes fully-qualified object
      names for logged statements (DML and DDL) in independent fields of the
      log output.
      
      Authors: Ian Barwick, Abhijit Menon-Sen, David Steele
      Reviews by: Robert Haas, Tatsuo Ishii, Sawada Masahiko, Fujii Masao,
      Simon Riggs
      
      Discussion with: Josh Berkus, Jaime Casanova, Peter Eisentraut,
      David Fetter, Yeb Havinga, Alvaro Herrera, Petr Jelinek, Tom Lane,
      MauMau, Bruce Momjian, Jim Nasby, Michael Paquier,
      Fabrízio de Royes Mello, Neil Tiffin
      ac52bb04
  3. 13 May, 2015 8 commits
    • Tom Lane's avatar
      Fix distclean/maintainer-clean targets to remove top-level tmp_install dir. · 9660710e
      Tom Lane authored
      The top-level makefile removes tmp_install in its "clean" target, but the
      distclean and maintainer-clean targets overlooked that (and they don't
      simply invoke clean, because that would result in an extra tree traversal).
      
      While at it, let's just make sure that removing GNUmakefile itself is the
      very last step of the recipe.
      9660710e
    • Robert Haas's avatar
      Fix comment. · 61f68e0b
      Robert Haas authored
      Commit 78efd5c1 overlooked this.
      
      Report by Peter Geoghegan.
      61f68e0b
    • Robert Haas's avatar
      Extend abbreviated key infrastructure to datum tuplesorts. · 78efd5c1
      Robert Haas authored
      Andrew Gierth, reviewed by Peter Geoghegan and by me.
      78efd5c1
    • Tom Lane's avatar
      Fix postgres_fdw to return the right ctid value in EvalPlanQual cases. · 0bb8528b
      Tom Lane authored
      If a postgres_fdw foreign table is a non-locked source relation in an
      UPDATE, DELETE, or SELECT FOR UPDATE/SHARE, and the query selects its
      ctid column, the wrong value would be returned if an EvalPlanQual
      recheck occurred.  This happened because the foreign table's result row
      was copied via the ROW_MARK_COPY code path, and EvalPlanQualFetchRowMarks
      just unconditionally set the reconstructed tuple's t_self to "invalid".
      
      To fix that, we can have EvalPlanQualFetchRowMarks copy the composite
      datum's t_ctid field, and be sure to initialize that along with t_self
      when postgres_fdw constructs a tuple to return.
      
      If we just did that much then EvalPlanQualFetchRowMarks would start
      returning "(0,0)" as ctid for all other ROW_MARK_COPY cases, which perhaps
      does not matter much, but then again maybe it might.  The cause of that is
      that heap_form_tuple, which is the ultimate source of all composite datums,
      simply leaves t_ctid as zeroes in newly constructed tuples.  That seems
      like a bad idea on general principles: a field that's really not been
      initialized shouldn't appear to have a valid value.  So let's eat the
      trivial additional overhead of doing "ItemPointerSetInvalid(&(td->t_ctid))"
      in heap_form_tuple.
      
      This closes out our handling of Etsuro Fujita's report that tableoid and
      ctid weren't correctly set in postgres_fdw EvalPlanQual cases.  Along the
      way we did a great deal of work to improve FDWs' ability to control row
      locking behavior; which was not wasted effort by any means, but it didn't
      end up being a fix for this problem because that feature would be too
      expensive for postgres_fdw to use all the time.
      
      Although the fix for the tableoid misbehavior was back-patched, I'm
      hesitant to do so here; it seems far less likely that people would care
      about remote ctid than tableoid, and even such a minor behavioral change
      as this in heap_form_tuple is perhaps best not back-patched.  So commit
      to HEAD only, at least for the moment.
      
      Etsuro Fujita, with some adjustments by me
      0bb8528b
    • Andrew Dunstan's avatar
      Fix jsonb replace and delete on scalars and empty structures · 3f2cec79
      Andrew Dunstan authored
      These operations now error out if attempted on scalars, and simply
      return the input if attempted on empty arrays or objects. Along the way
      we remove the unnecessary cloning of the input when it's known to be
      unchanged. Regression tests covering these cases are added.
      3f2cec79
    • Robert Haas's avatar
      Remove useless assertion. · ae615716
      Robert Haas authored
      Here, snapshot->xcnt is an unsigned type, so it will always be
      non-negative.
      ae615716
    • Andres Freund's avatar
      Add pgstattuple_approx() to the pgstattuple extension. · 5850b20f
      Andres Freund authored
      The new function allows to estimate bloat and other table level statics
      in a faster, but approximate, way. It does so by using information from
      the free space map for pages marked as all visible in the visibility
      map. The rest of the table is actually read and free space/bloat is
      measured accurately.  In many cases that allows to get bloat information
      much quicker, causing less IO.
      
      Author: Abhijit Menon-Sen
      Reviewed-By: Andres Freund, Amit Kapila and Tomas Vondra
      Discussion: 20140402214144.GA28681@kea.toroid.org
      5850b20f
    • Peter Eisentraut's avatar
      PL/Python: Remove procedure cache invalidation · dcf5e319
      Peter Eisentraut authored
      This was added to react to changes in the pg_transform catalog, but
      building with CLOBBER_CACHE_ALWAYS showed that PL/Python was not
      prepared for having its procedure cache cleared.  Since this is a
      marginal use case, and we don't do this for other catalogs anyway, we
      can postpone this to another day.
      dcf5e319
  4. 12 May, 2015 11 commits
    • Andres Freund's avatar
      Fix ON CONFLICT bugs that manifest when used in rules. · 4af6e61a
      Andres Freund authored
      Specifically the tlist and rti of the pseudo "excluded" relation weren't
      properly treated by expression_tree_walker, which lead to errors when
      excluded was referenced inside a rule because the varnos where not
      properly adjusted.  Similar omissions in OffsetVarNodes and
      expression_tree_mutator had less impact, but should obviously be fixed
      nonetheless.
      
      A couple tests of for ON CONFLICT UPDATE into INSERT rule bearing
      relations have been added.
      
      In passing I updated a couple comments.
      4af6e61a
    • Andrew Dunstan's avatar
      Fix some errors from jsonb functions patch. · 5c7df742
      Andrew Dunstan authored
      The catalog version should have been bumped, and the alternative
      regression result file was not up to date with the name of jsonb_pretty.
      5c7df742
    • Andrew Dunstan's avatar
      Additional functions and operators for jsonb · c6947010
      Andrew Dunstan authored
      jsonb_pretty(jsonb) produces nicely indented json output.
      jsonb || jsonb concatenates two jsonb values.
      jsonb - text removes a key and its associated value from the json
      jsonb - int removes the designated array element
      jsonb - text[] removes a key and associated value or array element at
      the designated path
      jsonb_replace(jsonb,text[],jsonb) replaces the array element designated
      by the path or the value associated with the key designated by the path
      with the given value.
      
      Original work by Dmitry Dolgov, adapted and reworked for PostgreSQL core
      by Andrew Dunstan, reviewed and tidied up by Petr Jelinek.
      c6947010
    • Tom Lane's avatar
      Add support for doing late row locking in FDWs. · afb9249d
      Tom Lane authored
      Previously, FDWs could only do "early row locking", that is lock a row as
      soon as it's fetched, even though local restriction/join conditions might
      discard the row later.  This patch adds callbacks that allow FDWs to do
      late locking in the same way that it's done for regular tables.
      
      To make use of this feature, an FDW must support the "ctid" column as a
      unique row identifier.  Currently, since ctid has to be of type TID,
      the feature is of limited use, though in principle it could be used by
      postgres_fdw.  We may eventually allow FDWs to specify another data type
      for ctid, which would make it possible for more FDWs to use this feature.
      
      This commit does not modify postgres_fdw to use late locking.  We've
      tested some prototype code for that, but it's not in committable shape,
      and besides it's quite unclear whether it actually makes sense to do late
      locking against a remote server.  The extra round trips required are likely
      to outweigh any benefit from improved concurrency.
      
      Etsuro Fujita, reviewed by Ashutosh Bapat, and hacked up a lot by me
      afb9249d
    • Stephen Frost's avatar
      pgbench: Don't fail during startup · aa4a0b95
      Stephen Frost authored
      In pgbench, report, but ignore, any errors returned when attempting to
      vacuum/truncate the default tables during startup.  If the tables are
      needed, we'll error out soon enough anyway.
      
      Per discussion with Tatsuo, David Rowley, Jim Nasby, Robert, Andres,
      Fujii, Fabrízio de Royes Mello, Tomas Vondra, Michael Paquier, Peter,
      based on a suggestion from Jeff Janes, patch from Robert, additional
      message wording from Tom.
      aa4a0b95
    • Andrew Dunstan's avatar
    • Bruce Momjian's avatar
    • Alvaro Herrera's avatar
      "Fix" test_ddl_deparse regress test schedule · 007c932e
      Alvaro Herrera authored
      MSVC is not smart enough to figure it out, so dumb down the Makefile and
      remove the schedule file.
      
      Also add a .gitignore file.
      
      Author: Michael Paquier
      007c932e
    • Bruce Momjian's avatar
      doc: prevent SGML 'make check' from building temp install · e8c19263
      Bruce Momjian authored
      Report by Alvaro Herrera
      e8c19263
    • Andrew Dunstan's avatar
      Map basebackup tablespaces using a tablespace_map file · 72d422a5
      Andrew Dunstan authored
      Windows can't reliably restore symbolic links from a tar format, so
      instead during backup start we create a tablespace_map file, which is
      used by the restoring postgres to create the correct links in pg_tblspc.
      The backup protocol also now has an option to request this file to be
      included in the backup stream, and this is used by pg_basebackup when
      operating in tar mode.
      
      This is done on all platforms, not just Windows.
      
      This means that pg_basebackup will not not work in tar mode against 9.4
      and older servers, as this protocol option isn't implemented there.
      
      Amit Kapila, reviewed by Dilip Kumar, with a little editing from me.
      72d422a5
    • Peter Eisentraut's avatar
      Replace some appendStringInfo* calls with more appropriate variants · d02f1647
      Peter Eisentraut authored
      Author: David Rowley <dgrowleyml@gmail.com>
      d02f1647
  5. 11 May, 2015 7 commits
    • Alvaro Herrera's avatar
      Allow on-the-fly capture of DDL event details · b488c580
      Alvaro Herrera authored
      This feature lets user code inspect and take action on DDL events.
      Whenever a ddl_command_end event trigger is installed, DDL actions
      executed are saved to a list which can be inspected during execution of
      a function attached to ddl_command_end.
      
      The set-returning function pg_event_trigger_ddl_commands can be used to
      list actions so captured; it returns data about the type of command
      executed, as well as the affected object.  This is sufficient for many
      uses of this feature.  For the cases where it is not, we also provide a
      "command" column of a new pseudo-type pg_ddl_command, which is a
      pointer to a C structure that can be accessed by C code.  The struct
      contains all the info necessary to completely inspect and even
      reconstruct the executed command.
      
      There is no actual deparse code here; that's expected to come later.
      What we have is enough infrastructure that the deparsing can be done in
      an external extension.  The intention is that we will add some deparsing
      code in a later release, as an in-core extension.
      
      A new test module is included.  It's probably insufficient as is, but it
      should be sufficient as a starting point for a more complete and
      future-proof approach.
      
      Authors: Álvaro Herrera, with some help from Andres Freund, Ian Barwick,
      Abhijit Menon-Sen.
      
      Reviews by Andres Freund, Robert Haas, Amit Kapila, Michael Paquier,
      Craig Ringer, David Steele.
      Additional input from Chris Browne, Dimitri Fontaine, Stephen Frost,
      Petr Jelínek, Tom Lane, Jim Nasby, Steven Singer, Pavel Stěhule.
      
      Based on original work by Dimitri Fontaine, though I didn't use his
      code.
      
      Discussion:
        https://www.postgresql.org/message-id/m2txrsdzxa.fsf@2ndQuadrant.fr
        https://www.postgresql.org/message-id/20131108153322.GU5809@eldon.alvh.no-ip.org
        https://www.postgresql.org/message-id/20150215044814.GL3391@alvh.no-ip.org
      b488c580
    • Stephen Frost's avatar
      Allow LOCK TABLE .. ROW EXCLUSIVE MODE with INSERT · fa264243
      Stephen Frost authored
      INSERT acquires RowExclusiveLock during normal operation and therefore
      it makes sense to allow LOCK TABLE .. ROW EXCLUSIVE MODE to be executed
      by users who have INSERT rights on a table (even if they don't have
      UPDATE or DELETE).
      
      Not back-patching this as it's a behavior change which, strictly
      speaking, loosens security restrictions.
      
      Per discussion with Tom and Robert (circa 2013).
      fa264243
    • Bruce Momjian's avatar
      pg_upgrade: use single or double-quotes in command-line strings · 9d15292c
      Bruce Momjian authored
      This is platform-dependent.
      9d15292c
    • Tom Lane's avatar
      Fix incorrect checking of deferred exclusion constraint after a HOT update. · 20781765
      Tom Lane authored
      If a row that potentially violates a deferred exclusion constraint is
      HOT-updated later in the same transaction, the exclusion constraint would
      be reported as violated when the check finally occurs, even if the row(s)
      the new row originally conflicted with have since been removed.  This
      happened because the wrong TID was passed to check_exclusion_constraint(),
      causing the live HOT-updated row to be seen as a conflicting row rather
      than recognized as the row-under-test.
      
      Per bug #13148 from Evan Martin.  It's been broken since exclusion
      constraints were invented, so back-patch to all supported branches.
      20781765
    • Robert Haas's avatar
      Increase threshold for multixact member emergency autovac to 50%. · b4d4ce1d
      Robert Haas authored
      Analysis by Noah Misch shows that the 25% threshold set by commit
      53bb309d is lower than any other,
      similar autovac threshold.  While we don't know exactly what value
      will be optimal for all users, it is better to err a little on the
      high side than on the low side.  A higher value increases the risk
      that users might exhaust the available space and start seeing errors
      before autovacuum can clean things up sufficiently, but a user who
      hits that problem can compensate for it by reducing
      autovacuum_multixact_freeze_max_age to a value dependent on their
      average multixact size.  On the flip side, if the emergency cap
      imposed by that patch kicks in too early, the user will experience
      excessive wraparound scanning and will be unable to mitigate that
      problem by configuration.  The new value will hopefully reduce the
      risk of such bad experiences while still providing enough headroom
      to avoid multixact member exhaustion for most users.
      
      Along the way, adjust the documentation to reflect the effects of
      commit 04e6d3b8, which taught
      autovacuum to run for multixact wraparound even when autovacuum
      is configured off.
      b4d4ce1d
    • Bruce Momjian's avatar
      initdb: only recommend pg_ctl to start the server · 2200713a
      Bruce Momjian authored
      Previously we mentioned the 'postgres' binary method as well.
      2200713a
    • Bruce Momjian's avatar
      docs: add "serialization anomaly" to transaction isolation table · 23c33198
      Bruce Momjian authored
      Also distinguish between SQL-standard and Postgres behavior.
      
      Report by David G. Johnston
      23c33198