Skip to content
Snippets Groups Projects
  1. May 02, 2012
  2. Apr 30, 2012
    • Tom Lane's avatar
      Converge all SQL-level statistics timing values to float8 milliseconds. · 809e7e21
      Tom Lane authored
      This patch adjusts the core statistics views to match the decision already
      taken for pg_stat_statements, that values representing elapsed time should
      be represented as float8 and measured in milliseconds.  By using float8,
      we are no longer tied to a specific maximum precision of timing data.
      (Internally, it's still microseconds, but we could now change that without
      needing changes at the SQL level.)
      
      The columns affected are
      pg_stat_bgwriter.checkpoint_write_time
      pg_stat_bgwriter.checkpoint_sync_time
      pg_stat_database.blk_read_time
      pg_stat_database.blk_write_time
      pg_stat_user_functions.total_time
      pg_stat_user_functions.self_time
      pg_stat_xact_user_functions.total_time
      pg_stat_xact_user_functions.self_time
      
      The first four of these are new in 9.2, so there is no compatibility issue
      from changing them.  The others require a release note comment that they
      are now double precision (and can show a fractional part) rather than
      bigint as before; also their underlying statistics functions now match
      the column definitions, instead of returning bigint microseconds.
      809e7e21
    • Tom Lane's avatar
      Rename I/O timing statistics columns to blk_read_time and blk_write_time. · 1dd89ead
      Tom Lane authored
      This seems more consistent with the pre-existing choices for names of
      other statistics columns.  Rename assorted internal identifiers to match.
      1dd89ead
  3. Apr 21, 2012
    • Alvaro Herrera's avatar
      Recast "ONLY" column CHECK constraints as NO INHERIT · 09ff76fc
      Alvaro Herrera authored
      The original syntax wasn't universally loved, and it didn't allow its
      usage in CREATE TABLE, only ALTER TABLE.  It now works everywhere, and
      it also allows using ALTER TABLE ONLY to add an uninherited CHECK
      constraint, per discussion.
      
      The pg_constraint column has accordingly been renamed connoinherit.
      
      This commit partly reverts some of the changes in
      61d81bd2, particularly some pg_dump and
      psql bits, because now pg_get_constraintdef includes the necessary NO
      INHERIT within the constraint definition.
      
      Author: Nikhil Sontakke
      Some tweaks by me
      09ff76fc
  4. Apr 14, 2012
    • Robert Haas's avatar
      pg_size_pretty(numeric) · 4a2d7ad7
      Robert Haas authored
      The output of the new pg_xlog_location_diff function is of type numeric,
      since it could theoretically overflow an int8 due to signedness; this
      provides a convenient way to format such values.
      
      Fujii Masao, with some beautification by me.
      4a2d7ad7
  5. Apr 13, 2012
    • Peter Eisentraut's avatar
      Rename bytea_agg to string_agg and add delimiter argument · c0cc526e
      Peter Eisentraut authored
      Per mailing list discussion, we would like to keep the bytea functions
      parallel to the text functions, so rename bytea_agg to string_agg,
      which already exists for text.
      
      Also, to satisfy the rule that we don't want aggregate functions of
      the same name with a different number of arguments, add a delimiter
      argument, just like string_agg for text already has.
      c0cc526e
  6. Apr 06, 2012
  7. Apr 05, 2012
  8. Apr 03, 2012
  9. Mar 23, 2012
    • Tom Lane's avatar
      Code review for protransform patches. · 0339047b
      Tom Lane authored
      Fix loss of previous expression-simplification work when a transform
      function fires: we must not simply revert to untransformed input tree.
      Instead build a dummy FuncExpr node to pass to the transform function.
      This has the additional advantage of providing a simpler, more uniform
      API for transform functions.
      
      Move documentation to a somewhat less buried spot, relocate some
      poorly-placed code, be more wary of null constants and invalid typmod
      values, add an opr_sanity check on protransform function signatures,
      and some other minor cosmetic adjustments.
      
      Note: although this patch touches pg_proc.h, no need for catversion
      bump, because the changes are cosmetic and don't actually change the
      intended catalog contents.
      0339047b
  10. Mar 20, 2012
    • Tom Lane's avatar
      Restructure SELECT INTO's parsetree representation into CreateTableAsStmt. · 9dbf2b7d
      Tom Lane authored
      Making this operation look like a utility statement seems generally a good
      idea, and particularly so in light of the desire to provide command
      triggers for utility statements.  The original choice of representing it as
      SELECT with an IntoClause appendage had metastasized into rather a lot of
      places, unfortunately, so that this patch is a great deal more complicated
      than one might at first expect.
      
      In particular, keeping EXPLAIN working for SELECT INTO and CREATE TABLE AS
      subcommands required restructuring some EXPLAIN-related APIs.  Add-on code
      that calls ExplainOnePlan or ExplainOneUtility, or uses
      ExplainOneQuery_hook, will need adjustment.
      
      Also, the cases PREPARE ... SELECT INTO and CREATE RULE ... SELECT INTO,
      which formerly were accepted though undocumented, are no longer accepted.
      The PREPARE case can be replaced with use of CREATE TABLE AS EXECUTE.
      The CREATE RULE case doesn't seem to have much real-world use (since the
      rule would work only once before failing with "table already exists"),
      so we'll not bother with that one.
      
      Both SELECT INTO and CREATE TABLE AS still return a command tag of
      "SELECT nnnn".  There was some discussion of returning "CREATE TABLE nnnn",
      but for the moment backwards compatibility wins the day.
      
      Andres Freund and Tom Lane
      9dbf2b7d
  11. Mar 11, 2012
    • Tom Lane's avatar
      Teach SPGiST to store nulls and do whole-index scans. · c6a11b89
      Tom Lane authored
      This patch fixes the other major compatibility-breaking limitation of
      SPGiST, that it didn't store anything for null values of the indexed
      column, and so could not support whole-index scans or "x IS NULL"
      tests.  The approach is to create a wholly separate search tree for
      the null entries, and use fixed "allTheSame" insertion and search
      rules when processing this tree, instead of calling the index opclass
      methods.  This way the opclass methods do not need to worry about
      dealing with nulls.
      
      Catversion bump is for pg_am updates as well as the change in on-disk
      format of SPGiST indexes; there are some tweaks in SPGiST WAL records
      as well.
      
      Heavily rewritten version of a patch by Oleg Bartunov and Teodor Sigaev.
      (The original also stored nulls separately, but it reused GIN code to do
      so; which required undesirable compromises in the on-disk format, and
      would likely lead to bugs due to the GIN code being required to work in
      two very different contexts.)
      c6a11b89
  12. Mar 09, 2012
    • Robert Haas's avatar
      Extend object access hook framework to support arguments, and DROP. · 07d1edb9
      Robert Haas authored
      This allows loadable modules to get control at drop time, perhaps for the
      purpose of performing additional security checks or to log the event.
      The initial purpose of this code is to support sepgsql, but other
      applications should be possible as well.
      
      KaiGai Kohei, reviewed by me.
      07d1edb9
  13. Mar 08, 2012
    • Tom Lane's avatar
      Fix some issues with temp/transient tables in extension scripts. · 08dd23ce
      Tom Lane authored
      Phil Sorber reported that a rewriting ALTER TABLE within an extension
      update script failed, because it creates and then drops a placeholder
      table; the drop was being disallowed because the table was marked as an
      extension member.  We could hack that specific case but it seems likely
      that there might be related cases now or in the future, so the most
      practical solution seems to be to create an exception to the general rule
      that extension member objects can only be dropped by dropping the owning
      extension.  To wit: if the DROP is issued within the extension's own
      creation or update scripts, we'll allow it, implicitly performing an
      "ALTER EXTENSION DROP object" first.  This will simplify cases such as
      extension downgrade scripts anyway.
      
      No docs change since we don't seem to have documented the idea that you
      would need ALTER EXTENSION DROP for such an action to begin with.
      
      Also, arrange for explicitly temporary tables to not get linked as
      extension members in the first place, and the same for the magic
      pg_temp_nnn schemas that are created to hold them.  This prevents assorted
      unpleasant results if an extension script creates a temp table: the forced
      drop at session end would either fail or remove the entire extension, and
      neither of those outcomes is desirable.  Note that this doesn't fix the
      ALTER TABLE scenario, since the placeholder table is not temp (unless the
      table being rewritten is).
      
      Back-patch to 9.1.
      08dd23ce
  14. Mar 04, 2012
    • Magnus Hagander's avatar
      Add function pg_xlog_location_diff to help comparisons · bc5ac368
      Magnus Hagander authored
      Comparing two xlog locations are useful for example when calculating
      replication lag.
      
      Euler Taveira de Oliveira, reviewed by Fujii Masao, and some cleanups
      from me
      bc5ac368
    • Tom Lane's avatar
      Collect and use element-frequency statistics for arrays. · 0e5e167a
      Tom Lane authored
      This patch improves selectivity estimation for the array <@, &&, and @>
      (containment and overlaps) operators.  It enables collection of statistics
      about individual array element values by ANALYZE, and introduces
      operator-specific estimators that use these stats.  In addition,
      ScalarArrayOpExpr constructs of the forms "const = ANY/ALL (array_column)"
      and "const <> ANY/ALL (array_column)" are estimated by treating them as
      variants of the containment operators.
      
      Since we still collect scalar-style stats about the array values as a
      whole, the pg_stats view is expanded to show both these stats and the
      array-style stats in separate columns.  This creates an incompatible change
      in how stats for tsvector columns are displayed in pg_stats: the stats
      about lexemes are now displayed in the array-related columns instead of the
      original scalar-related columns.
      
      There are a few loose ends here, notably that it'd be nice to be able to
      suppress either the scalar-style stats or the array-element stats for
      columns for which they're not useful.  But the patch is in good enough
      shape to commit for wider testing.
      
      Alexander Korotkov, reviewed by Noah Misch and Nathan Boley
      0e5e167a
  15. Mar 02, 2012
  16. Mar 01, 2012
    • Alvaro Herrera's avatar
      Remove TOAST table from pg_database · 3433c6ba
      Alvaro Herrera authored
      The only toastable column now is datacl, but we don't really support
      long ACLs anyway.  The TOAST table should have been removed when the
      pg_db_role_setting catalog was introduced in commit
      2eda8dfb, but I forgot to do that.
      
      Per -hackers discussion on March 2011.
      3433c6ba
  17. Feb 27, 2012
    • Alvaro Herrera's avatar
      ALTER TABLE: skip FK validation when it's safe to do so · cb3a7c2b
      Alvaro Herrera authored
      We already skip rewriting the table in these cases, but we still force a
      whole table scan to validate the data.  This can be skipped, and thus
      we can make the whole ALTER TABLE operation just do some catalog touches
      instead of scanning the table, when these two conditions hold:
      
      (a) Old and new pg_constraint.conpfeqop match exactly.  This is actually
      stronger than needed; we could loosen things by way of operator
      families, but it'd require a lot more effort.
      
      (b) The functions, if any, implementing a cast from the foreign type to
      the primary opcintype are the same.  For this purpose, we can consider a
      binary coercion equivalent to an exact type match.  When the opcintype
      is polymorphic, require that the old and new foreign types match
      exactly.  (Since ri_triggers.c does use the executor, the stronger check
      for polymorphic types is no mere future-proofing.  However, no core type
      exercises its necessity.)
      
      Author: Noah Misch
      
      Committer's note: catalog version bumped due to change of the Constraint
      node.  I can't actually find any way to have such a node in a stored
      rule, but given that we have "out" support for them, better be safe.
      cb3a7c2b
  18. Feb 19, 2012
    • Andrew Dunstan's avatar
      Improve pretty printing of viewdefs. · 2f582f76
      Andrew Dunstan authored
      Some line feeds are added to target lists and from lists to make
      them more readable. By default they wrap at 80 columns if possible,
      but the wrap column is also selectable - if 0 it wraps after every
      item.
      
      Andrew Dunstan, reviewed by Hitoshi Harada.
      2f582f76
  19. Feb 14, 2012
    • Tom Lane's avatar
      Preserve column names in the execution-time tupledesc for a RowExpr. · 398f70ec
      Tom Lane authored
      The hstore and json datatypes both have record-conversion functions that
      pay attention to column names in the composite values they're handed.
      We used to not worry about inserting correct field names into tuple
      descriptors generated at runtime, but given these examples it seems
      useful to do so.  Observe the nicer-looking results in the regression
      tests whose results changed.
      
      catversion bump because there is a subtle change in requirements for stored
      rule parsetrees: RowExprs from ROW() constructs now have to include field
      names.
      
      Andrew Dunstan and Tom Lane
      398f70ec
    • Robert Haas's avatar
      Allow LEAKPROOF functions for better performance of security views. · cd30728f
      Robert Haas authored
      We don't normally allow quals to be pushed down into a view created
      with the security_barrier option, but functions without side effects
      are an exception: they're OK.  This allows much better performance in
      common cases, such as when using an equality operator (that might
      even be indexable).
      
      There is an outstanding issue here with the CREATE FUNCTION / ALTER
      FUNCTION syntax: there's no way to use ALTER FUNCTION to unset the
      leakproof flag.  But I'm committing this as-is so that it doesn't
      have to be rebased again; we can fix up the grammar in a future
      commit.
      
      KaiGai Kohei, with some wordsmithing by me.
      cd30728f
  20. Feb 08, 2012
    • Tom Lane's avatar
      Support min/max index optimizations on boolean columns. · cbba55d6
      Tom Lane authored
      Since bool_and() is equivalent to min(), and bool_or() to max(), we might
      as well let them be index-optimized in the same way.  The practical value
      of this is debatable at best, but it seems nearly cost-free to enable it.
      Code-wise, we need only adjust the entries in pg_aggregate.  There is a
      measurable planning speed penalty for a query involving one of these
      aggregates, but it is only a few percent in simple cases, so that seems
      acceptable.
      
      Marti Raudsepp, reviewed by Abhijit Menon-Sen
      cbba55d6
    • Tom Lane's avatar
      Mark some more I/O-conversion-invoking functions as stable not volatile. · 3db6524f
      Tom Lane authored
      When written, textanycat, anytextcat, quote_literal, and quote_nullable
      were marked volatile, because they could invoke arbitrary type-specific
      output functions as part of casting their anyelement arguments to text.
      Since then, we have defined a project policy that I/O functions must not
      be volatile, as per commit aab353a6.
      So these functions can safely be downgraded to stable.  Most of the time
      this makes no difference since they'll get inlined anyway, but as noted
      by Andrew Dunstan, there are cases where the volatile marking prevents
      optimizations that the planner does before function inlining.  (I think
      I might have overlooked these functions in the earlier commit on the
      grounds that inlining would make it moot, but not so --- tgl)
      
      This change results in a change in the expected output of the json
      regression tests, because the planner can now flatten a sub-select
      that it failed to before.  The old output is preferable, but getting
      that back will require some as-yet-unfinished work on RowExpr handling.
      
      Marti Raudsepp
      3db6524f
    • Robert Haas's avatar
      Add transform functions for various temporal typmod coercisions. · c1389798
      Robert Haas authored
      This enables ALTER TABLE to skip table and index rebuilds in some cases.
      
      Noah Misch, with trivial changes by me.
      c1389798
  21. Feb 07, 2012
    • Robert Haas's avatar
      Add a transform function for varbit typmod coercisions. · f7d7dade
      Robert Haas authored
      This enables ALTER TABLE to skip table and index rebuilds when the
      new type is unconstraint varbit, or when the allowable number of bits
      is not decreasing.
      
      Noah Misch, with review and a fix for an OID collision by me.
      f7d7dade
    • Robert Haas's avatar
      Add a transform function for numeric typmod coercisions. · 3cc08008
      Robert Haas authored
      This enables ALTER TABLE to skip table and index rebuilds when a column
      is changed to an unconstrained numeric, or when the scale is unchanged
      and the precision does not decrease.
      
      Noah Misch, with a few stylistic changes and a fix for an OID
      collision by me.
      3cc08008
  22. Feb 03, 2012
  23. Feb 02, 2012
  24. Jan 31, 2012
    • Robert Haas's avatar
      Catversion bump for JSON patch. · c3271081
      Robert Haas authored
      Sigh.
      c3271081
    • Robert Haas's avatar
      Built-in JSON data type. · 5384a73f
      Robert Haas authored
      Like the XML data type, we simply store JSON data as text, after checking
      that it is valid.  More complex operations such as canonicalization and
      comparison may come later, but this is enough for not.
      
      There are a few open issues here, such as whether we should attempt to
      detect UTF-8 surrogate pairs represented as \uXXXX\uYYYY, but this gets
      the basic framework in place.
      5384a73f
  25. Jan 27, 2012
    • Peter Eisentraut's avatar
      Show default privileges in information schema · b376ec6f
      Peter Eisentraut authored
      Hitherto, the information schema only showed explicitly granted
      privileges that were visible in the *acl catalog columns.  If no
      privileges had been granted, the implicit privileges were not shown.
      
      To fix that, add an SQL-accessible version of the acldefault()
      function, and use that inside the aclexplode() calls to substitute the
      catalog-specific default privilege set for null values.
      
      reviewed by Abhijit Menon-Sen
      b376ec6f
    • Peter Eisentraut's avatar
      Hide most variable-length fields from Form_pg_* structs · 8137f2c3
      Peter Eisentraut authored
      Those fields only appear in the structs so that genbki.pl can create
      the BKI bootstrap files for the catalogs.  But they are not actually
      usable from C.  So hiding them can prevent coding mistakes, saves
      stack space, and can help the compiler.
      
      In certain catalogs, the first variable-length field has been kept
      visible after manual inspection.  These exceptions are noted in C
      comments.
      
      reviewed by Tom Lane
      8137f2c3
  26. Jan 26, 2012
  27. Jan 25, 2012
    • Simon Riggs's avatar
      Allow pg_basebackup from standby node with safety checking. · 8366c780
      Simon Riggs authored
      Base backup follows recommended procedure, plus goes to great
      lengths to ensure that partial page writes are avoided.
      
      Jun Ishizuka and Fujii Masao, with minor modifications
      8366c780
    • Alvaro Herrera's avatar
      Add pg_trigger_depth() function · 74ab96a4
      Alvaro Herrera authored
      This reports the depth level of triggers currently in execution, or zero
      if not called from inside a trigger.
      
      No catversion bump in this patch, but you have to initdb if you want
      access to the new function.
      
      Author: Kevin Grittner
      74ab96a4
Loading