1. 04 2月, 2014 1 次提交
  2. 01 2月, 2014 1 次提交
    • R
      Introduce replication slots. · 858ec118
      Robert Haas 提交于
      Replication slots are a crash-safe data structure which can be created
      on either a master or a standby to prevent premature removal of
      write-ahead log segments needed by a standby, as well as (with
      hot_standby_feedback=on) pruning of tuples whose removal would cause
      replication conflicts.  Slots have some advantages over existing
      techniques, as explained in the documentation.
      
      In a few places, we refer to the type of replication slots introduced
      by this patch as "physical" slots, because forthcoming patches for
      logical decoding will also have slots, but with somewhat different
      properties.
      
      Andres Freund and Robert Haas
      858ec118
  3. 31 1月, 2014 1 次提交
  4. 30 1月, 2014 1 次提交
  5. 29 1月, 2014 2 次提交
    • A
      New json functions. · 10563990
      Andrew Dunstan 提交于
      json_build_array() and json_build_object allow for the construction of
      arbitrarily complex json trees. json_object() turns a one or two
      dimensional array, or two separate arrays, into a json_object of
      name/value pairs, similarly to the hstore() function.
      json_object_agg() aggregates its two arguments into a single json object
      as name value pairs.
      
      Catalog version bumped.
      
      Andrew Dunstan, reviewed by Marko Tiikkaja.
      10563990
    • F
      Add pg_stat_archiver statistics view. · 9132b189
      Fujii Masao 提交于
      This view shows the statistics about the WAL archiver process's activity.
      
      Gabriele Bartolini, reviewed by Michael Paquier, refactored a bit by me.
      9132b189
  6. 22 1月, 2014 1 次提交
    • R
      Add a cardinality function for arrays. · 01f7808b
      Robert Haas 提交于
      Unlike our other array functions, this considers the total number of
      elements across all dimensions, and returns 0 rather than NULL when the
      array has no elements.  But it seems that both of those behaviors are
      almost universally disliked, so hopefully that's OK.
      
      Marko Tiikkaja, reviewed by Dean Rasheed and Pavel Stehule
      01f7808b
  7. 11 1月, 2014 1 次提交
  8. 08 1月, 2014 1 次提交
  9. 24 12月, 2013 1 次提交
    • T
      Support ordered-set (WITHIN GROUP) aggregates. · 8d65da1f
      Tom Lane 提交于
      This patch introduces generic support for ordered-set and hypothetical-set
      aggregate functions, as well as implementations of the instances defined in
      SQL:2008 (percentile_cont(), percentile_disc(), rank(), dense_rank(),
      percent_rank(), cume_dist()).  We also added mode() though it is not in the
      spec, as well as versions of percentile_cont() and percentile_disc() that
      can compute multiple percentile values in one pass over the data.
      
      Unlike the original submission, this patch puts full control of the sorting
      process in the hands of the aggregate's support functions.  To allow the
      support functions to find out how they're supposed to sort, a new API
      function AggGetAggref() is added to nodeAgg.c.  This allows retrieval of
      the aggregate call's Aggref node, which may have other uses beyond the
      immediate need.  There is also support for ordered-set aggregates to
      install cleanup callback functions, so that they can be sure that
      infrastructure such as tuplesort objects gets cleaned up.
      
      In passing, make some fixes in the recently-added support for variadic
      aggregates, and make some editorial adjustments in the recent FILTER
      additions for aggregates.  Also, simplify use of IsBinaryCoercible() by
      allowing it to succeed whenever the target type is ANY or ANYELEMENT.
      It was inconsistent that it dealt with other polymorphic target types
      but not these.
      
      Atri Sharma and Andrew Gierth; reviewed by Pavel Stehule and Vik Fearing,
      and rather heavily editorialized upon by Tom Lane
      8d65da1f
  10. 27 11月, 2013 1 次提交
  11. 18 11月, 2013 1 次提交
  12. 17 11月, 2013 1 次提交
    • T
      Improve performance of numeric sum(), avg(), stddev(), variance(), etc. · 69c8fbac
      Tom Lane 提交于
      This patch improves performance of most built-in aggregates that formerly
      used a NUMERIC or NUMERIC array as their transition type; this includes
      not only aggregates on numeric inputs, but some aggregates on integer
      inputs where overflow of an int8 value is a possibility.  The code now
      uses a special-purpose data structure to avoid array construction and
      deconstruction overhead, as well as packing and unpacking overhead for
      numeric values.
      
      These aggregates' transition type is now declared as INTERNAL, since
      it doesn't correspond to any SQL data type.  To keep the planner from
      thinking that that means a lot of storage will be used, we make use
      of the just-added pg_aggregate.aggtransspace feature.  The space estimate
      is set to 128 bytes, which is at least in the right ballpark.
      
      Hadi Moshayedi, reviewed by Pavel Stehule and Tomas Vondra
      69c8fbac
  13. 28 10月, 2013 1 次提交
    • N
      Add large object functions catering to SQL callers. · c50b7c09
      Noah Misch 提交于
      With these, one need no longer manipulate large object descriptors and
      extract numeric constants from header files in order to read and write
      large object contents from SQL.
      
      Pavel Stehule, reviewed by Rushabh Lathia.
      c50b7c09
  14. 11 10月, 2013 1 次提交
  15. 10 10月, 2013 1 次提交
    • K
      Add record_image_ops opclass for matview concurrent refresh. · f5665151
      Kevin Grittner 提交于
      REFRESH MATERIALIZED VIEW CONCURRENTLY was broken for any matview
      containing a column of a type without a default btree operator
      class.  It also did not produce results consistent with a non-
      concurrent REFRESH or a normal view if any column was of a type
      which allowed user-visible differences between values which
      compared as equal according to the type's default btree opclass.
      Concurrent matview refresh was modified to use the new operators
      to solve these problems.
      
      Documentation was added for record comparison, both for the
      default btree operator class for record, and the newly added
      operators.  Regression tests now check for proper behavior both
      for a matview with a box column and a matview containing a citext
      column.
      
      Reviewed by Steve Singer, who suggested some of the doc language.
      f5665151
  16. 22 7月, 2013 1 次提交
    • R
      Add infrastructure for mapping relfilenodes to relation OIDs. · f01d1ae3
      Robert Haas 提交于
      Future patches are expected to introduce logical replication that
      works by decoding WAL.  WAL contains relfilenodes rather than relation
      OIDs, so this infrastructure will be needed to find the relation OID
      based on WAL contents.
      
      If logical replication does not make it into this release, we probably
      should consider reverting this, since it will add some overhead to DDL
      operations that create new relations.  One additional index insert per
      pg_class row is not a large overhead, but it's more than zero.
      Another way of meeting the needs of logical replication would be to
      the relation OID to WAL, but that would burden DML operations, not
      only DDL.
      
      Andres Freund, with some changes by me.  Design review, in earlier
      versions, by Álvaro Herrera.
      f01d1ae3
  17. 05 7月, 2013 1 次提交
  18. 13 6月, 2013 1 次提交
    • T
      Improve updatability checking for views and foreign tables. · dc3eb563
      Tom Lane 提交于
      Extend the FDW API (which we already changed for 9.3) so that an FDW can
      report whether specific foreign tables are insertable/updatable/deletable.
      The default assumption continues to be that they're updatable if the
      relevant executor callback function is supplied by the FDW, but finer
      granularity is now possible.  As a test case, add an "updatable" option to
      contrib/postgres_fdw.
      
      This patch also fixes the information_schema views, which previously did
      not think that foreign tables were ever updatable, and fixes
      view_is_auto_updatable() so that a view on a foreign table can be
      auto-updatable.
      
      initdb forced due to changes in information_schema views and the functions
      they rely on.  This is a bit unfortunate to do post-beta1, but if we don't
      change this now then we'll have another API break for FDWs when we do
      change it.
      
      Dean Rasheed, somewhat editorialized on by Tom Lane
      dc3eb563
  19. 30 5月, 2013 1 次提交
  20. 08 5月, 2013 1 次提交
  21. 07 5月, 2013 1 次提交
    • T
      Move materialized views' is-populated status into their pg_class entries. · 1d6c72a5
      Tom Lane 提交于
      Previously this state was represented by whether the view's disk file had
      zero or nonzero size, which is problematic for numerous reasons, since it's
      breaking a fundamental assumption about heap storage.  This was done to
      allow unlogged matviews to revert to unpopulated status after a crash
      despite our lack of any ability to update catalog entries post-crash.
      However, this poses enough risk of future problems that it seems better to
      not support unlogged matviews until we can find another way.  Accordingly,
      revert that choice as well as a number of existing kluges forced by it
      in favor of creating a pg_class.relispopulated flag column.
      1d6c72a5
  22. 16 4月, 2013 1 次提交
  23. 30 3月, 2013 1 次提交
    • A
      Add new JSON processing functions and parser API. · a570c98d
      Andrew Dunstan 提交于
      The JSON parser is converted into a recursive descent parser, and
      exposed for use by other modules such as extensions. The API provides
      hooks for all the significant parser event such as the beginning and end
      of objects and arrays, and providing functions to handle these hooks
      allows for fairly simple construction of a wide variety of JSON
      processing functions. A set of new basic processing functions and
      operators is also added, which use this API, including operations to
      extract array elements, object fields, get the length of arrays and the
      set of keys of a field, deconstruct an object into a set of key/value
      pairs, and create records from JSON objects and arrays of objects.
      
      Catalog version bumped.
      
      Andrew Dunstan, with some documentation assistance from Merlin Moncure.
      a570c98d
  24. 29 3月, 2013 1 次提交
    • A
      Add sql_drop event for event triggers · 473ab40c
      Alvaro Herrera 提交于
      This event takes place just before ddl_command_end, and is fired if and
      only if at least one object has been dropped by the command.  (For
      instance, DROP TABLE IF EXISTS of a table that does not in fact exist
      will not lead to such a trigger firing).  Commands that drop multiple
      objects (such as DROP SCHEMA or DROP OWNED BY) will cause a single event
      to fire.  Some firings might be surprising, such as
      ALTER TABLE DROP COLUMN.
      
      The trigger is fired after the drop has taken place, because that has
      been deemed the safest design, to avoid exposing possibly-inconsistent
      internal state (system catalogs as well as current transaction) to the
      user function code.  This means that careful tracking of object
      identification is required during the object removal phase.
      
      Like other currently existing events, there is support for tag
      filtering.
      
      To support the new event, add a new pg_event_trigger_dropped_objects()
      set-returning function, which returns a set of rows comprising the
      objects affected by the command.  This is to be used within the user
      function code, and is mostly modelled after the recently introduced
      pg_identify_object() function.
      
      Catalog version bumped due to the new function.
      
      Dimitri Fontaine and Álvaro Herrera
      Review by Robert Haas, Tom Lane
      473ab40c
  25. 21 3月, 2013 1 次提交
    • A
      Allow extracting machine-readable object identity · f8348ea3
      Alvaro Herrera 提交于
      Introduce pg_identify_object(oid,oid,int4), which is similar in spirit
      to pg_describe_object but instead produces a row of machine-readable
      information to uniquely identify the given object, without resorting to
      OIDs or other internal representation.  This is intended to be used in
      the event trigger implementation, to report objects being operated on;
      but it has usefulness of its own.
      
      Catalog version bumped because of the new function.
      f8348ea3
  26. 11 3月, 2013 1 次提交
    • A
      JSON generation improvements. · 38fb4d97
      Andrew Dunstan 提交于
      This adds the following:
      
          json_agg(anyrecord) -> json
          to_json(any) -> json
          hstore_to_json(hstore) -> json (also used as a cast)
          hstore_to_json_loose(hstore) -> json
      
      The last provides heuristic treatment of numbers and booleans.
      
      Also, in json generation, if any non-builtin type has a cast to json,
      that function is used instead of the type's output function.
      
      Andrew Dunstan, reviewed by Steve Singer.
      
      Catalog version bumped.
      38fb4d97
  27. 04 3月, 2013 1 次提交
    • K
      Add a materialized view relations. · 3bf3ab8c
      Kevin Grittner 提交于
      A materialized view has a rule just like a view and a heap and
      other physical properties like a table.  The rule is only used to
      populate the table, references in queries refer to the
      materialized data.
      
      This is a minimal implementation, but should still be useful in
      many cases.  Currently data is only populated "on demand" by the
      CREATE MATERIALIZED VIEW and REFRESH MATERIALIZED VIEW statements.
      It is expected that future releases will add incremental updates
      with various timings, and that a more refined concept of defining
      what is "fresh" data will be developed.  At some point it may even
      be possible to have queries use a materialized in place of
      references to underlying tables, but that requires the other
      above-mentioned features to be working first.
      
      Much of the documentation work by Robert Haas.
      Review by Noah Misch, Thom Brown, Robert Haas, Marko Tiikkaja
      Security review by KaiGai Kohei, with a decision on how best to
      implement sepgsql still pending.
      3bf3ab8c
  28. 14 2月, 2013 1 次提交
    • T
      Fix CVE-2013-0255 properly. · 71627f3d
      Tom Lane 提交于
      Revert commit ab0f7b60 (in HEAD only)
      in favor of the proper solution, which is to declare enum_recv() correctly
      in the system catalogs.  It should be declared to take type "internal"
      not "cstring".
      
      Also improve the type_sanity regression test, which should have caught
      this typo, so that it actually would.  Most of the relevant checks on
      the signature of type I/O functions should not have been restricted to
      basetypes/pseudotypes, as they should apply to any type's I/O functions.
      71627f3d
  29. 23 1月, 2013 1 次提交
    • A
      Improve concurrency of foreign key locking · 0ac5ad51
      Alvaro Herrera 提交于
      This patch introduces two additional lock modes for tuples: "SELECT FOR
      KEY SHARE" and "SELECT FOR NO KEY UPDATE".  These don't block each
      other, in contrast with already existing "SELECT FOR SHARE" and "SELECT
      FOR UPDATE".  UPDATE commands that do not modify the values stored in
      the columns that are part of the key of the tuple now grab a SELECT FOR
      NO KEY UPDATE lock on the tuple, allowing them to proceed concurrently
      with tuple locks of the FOR KEY SHARE variety.
      
      Foreign key triggers now use FOR KEY SHARE instead of FOR SHARE; this
      means the concurrency improvement applies to them, which is the whole
      point of this patch.
      
      The added tuple lock semantics require some rejiggering of the multixact
      module, so that the locking level that each transaction is holding can
      be stored alongside its Xid.  Also, multixacts now need to persist
      across server restarts and crashes, because they can now represent not
      only tuple locks, but also tuple updates.  This means we need more
      careful tracking of lifetime of pg_multixact SLRU files; since they now
      persist longer, we require more infrastructure to figure out when they
      can be removed.  pg_upgrade also needs to be careful to copy
      pg_multixact files over from the old server to the new, or at least part
      of multixact.c state, depending on the versions of the old and new
      servers.
      
      Tuple time qualification rules (HeapTupleSatisfies routines) need to be
      careful not to consider tuples with the "is multi" infomask bit set as
      being only locked; they might need to look up MultiXact values (i.e.
      possibly do pg_multixact I/O) to find out the Xid that updated a tuple,
      whereas they previously were assured to only use information readily
      available from the tuple header.  This is considered acceptable, because
      the extra I/O would involve cases that would previously cause some
      commands to block waiting for concurrent transactions to finish.
      
      Another important change is the fact that locking tuples that have
      previously been updated causes the future versions to be marked as
      locked, too; this is essential for correctness of foreign key checks.
      This causes additional WAL-logging, also (there was previously a single
      WAL record for a locked tuple; now there are as many as updated copies
      of the tuple there exist.)
      
      With all this in place, contention related to tuples being checked by
      foreign key rules should be much reduced.
      
      As a bonus, the old behavior that a subtransaction grabbing a stronger
      tuple lock than the parent (sub)transaction held on a given tuple and
      later aborting caused the weaker lock to be lost, has been fixed.
      
      Many new spec files were added for isolation tester framework, to ensure
      overall behavior is sane.  There's probably room for several more tests.
      
      There were several reviewers of this patch; in particular, Noah Misch
      and Andres Freund spent considerable time in it.  Original idea for the
      patch came from Simon Riggs, after a problem report by Joel Jacobson.
      Most code is from me, with contributions from Marti Raudsepp, Alexander
      Shulgin, Noah Misch and Andres Freund.
      
      This patch was discussed in several pgsql-hackers threads; the most
      important start at the following message-ids:
      	AANLkTimo9XVcEzfiBR-ut3KVNDkjm2Vxh+t8kAmWjPuv@mail.gmail.com
      	1290721684-sup-3951@alvh.no-ip.org
      	1294953201-sup-2099@alvh.no-ip.org
      	1320343602-sup-2290@alvh.no-ip.org
      	1339690386-sup-8927@alvh.no-ip.org
      	4FE5FF020200002500048A3D@gw.wicourts.gov
      	4FEAB90A0200002500048B7D@gw.wicourts.gov
      0ac5ad51
  30. 02 1月, 2013 1 次提交
  31. 09 12月, 2012 1 次提交
    • T
      Support automatically-updatable views. · a99c42f2
      Tom Lane 提交于
      This patch makes "simple" views automatically updatable, without the need
      to create either INSTEAD OF triggers or INSTEAD rules.  "Simple" views
      are those classified as updatable according to SQL-92 rules.  The rewriter
      transforms INSERT/UPDATE/DELETE commands on such views directly into an
      equivalent command on the underlying table, which will generally have
      noticeably better performance than is possible with either triggers or
      user-written rules.  A view that has INSTEAD OF triggers or INSTEAD rules
      continues to operate the same as before.
      
      For the moment, security_barrier views are not considered simple.
      Also, we do not support WITH CHECK OPTION.  These features may be
      added in future.
      
      Dean Rasheed, reviewed by Amit Kapila
      a99c42f2
  32. 11 10月, 2012 1 次提交
    • T
      Set procost to 10 for each of the pg_foo_is_visible() functions. · a80889a7
      Tom Lane 提交于
      The idea here is to make sure the planner will evaluate these functions
      last not first among the filter conditions in psql pattern search and
      tab-completion queries.  We've discussed this several times, and there
      was consensus to do it back in August, but we didn't want to do it just
      before a release.  Now seems like a safer time.
      
      No catversion bump, since this catalog change doesn't create a backend
      incompatibility nor any regression test result changes.
      a80889a7
  33. 09 10月, 2012 1 次提交
    • T
      Code review for 64-bit-large-object patch. · 26fe5648
      Tom Lane 提交于
      Fix broken-on-bigendian-machines byte-swapping functions, add missed update
      of alternate regression expected file, improve error reporting, remove some
      unnecessary code, sync testlo64.c with current testlo.c (it seems to have
      been cloned from a very old copy of that), assorted cosmetic improvements.
      26fe5648
  34. 07 10月, 2012 1 次提交
    • T
      Add API for 64-bit large object access. Now users can access up to · 461ef73f
      Tatsuo Ishii 提交于
      4TB large objects (standard 8KB BLCKSZ case).  For this purpose new
      libpq API lo_lseek64, lo_tell64 and lo_truncate64 are added.  Also
      corresponding new backend functions lo_lseek64, lo_tell64 and
      lo_truncate64 are added. inv_api.c is changed to handle 64-bit
      offsets.
      
      Patch contributed by Nozomi Anzai (backend side) and Yugo Nagata
      (frontend side, docs, regression tests and example program). Reviewed
      by Kohei Kaigai. Committed by Tatsuo Ishii with minor editings.
      461ef73f
  35. 27 8月, 2012 1 次提交
    • H
      Collect and use histograms of lower and upper bounds for range types. · 918eee0c
      Heikki Linnakangas 提交于
      This enables selectivity estimation of the <<, >>, &<, &> and && operators,
      as well as the normal inequality operators: <, <=, >=, >. "range @> element"
      is also supported, but the range-variant @> and <@ operators are not,
      because they cannot be sensibly estimated with lower and upper bound
      histograms alone. We would need to make some assumption about the lengths of
      the ranges for that. Alexander's patch included a separate histogram of
      lengths for that, but I left that out of the patch for simplicity. Hopefully
      that will be added as a followup patch.
      
      The fraction of empty ranges is also calculated and used in estimation.
      
      Alexander Korotkov, heavily modified by me.
      918eee0c
  36. 16 8月, 2012 1 次提交
    • H
      Add SP-GiST support for range types. · 317dd55a
      Heikki Linnakangas 提交于
      The implementation is a quad-tree, largely copied from the quad-tree
      implementation for points. The lower and upper bound of ranges are the 2d
      coordinates, with some extra code to handle empty ranges.
      
      I left out the support for adjacent operator, -|-, from the original patch.
      Not because there was necessarily anything wrong with it, but it was more
      complicated than the other operators, and I only have limited time for
      reviewing. That will follow as a separate patch.
      
      Alexander Korotkov, reviewed by Jeff Davis and me.
      317dd55a
  37. 18 7月, 2012 1 次提交
    • R
      Syntax support and documentation for event triggers. · 3855968f
      Robert Haas 提交于
      They don't actually do anything yet; that will get fixed in a
      follow-on commit.  But this gets the basic infrastructure in place,
      including CREATE/ALTER/DROP EVENT TRIGGER; support for COMMENT,
      SECURITY LABEL, and ALTER EXTENSION .. ADD/DROP EVENT TRIGGER;
      pg_dump and psql support; and documentation for the anticipated
      initial feature set.
      
      Dimitri Fontaine, with review and a bunch of additional hacking by me.
      Thom Brown extensively reviewed earlier versions of this patch set,
      but there's not a whole lot of that code left in this commit, as it
      turns out.
      3855968f
  38. 12 7月, 2012 1 次提交
    • T
      Add array_remove() and array_replace() functions. · 84a42560
      Tom Lane 提交于
      These functions support removing or replacing array element value(s)
      matching a given search value.  Although intended mainly to support a
      future array-foreign-key feature, they seem useful in their own right.
      
      Marco Nenciarini and Gabriele Bartolini, reviewed by Alex Hunsaker
      84a42560
  39. 25 6月, 2012 1 次提交
    • P
      Replace int2/int4 in C code with int16/int32 · b8b2e3b2
      Peter Eisentraut 提交于
      The latter was already the dominant use, and it's preferable because
      in C the convention is that intXX means XX bits.  Therefore, allowing
      mixed use of int2, int4, int8, int16, int32 is obviously confusing.
      
      Remove the typedefs for int2 and int4 for now.  They don't seem to be
      widely used outside of the PostgreSQL source tree, and the few uses
      can probably be cleaned up by the time this ships.
      b8b2e3b2