Skip to content
Snippets Groups Projects
  1. May 02, 2012
    • Robert Haas's avatar
      Avoid repeated CLOG access from heap_hot_search_buffer. · 00381104
      Robert Haas authored
      At the time we check whether the tuple is dead to all running
      transactions, we've already verified that it isn't visible to our
      scan, setting hint bits if appropriate.  So there's no need to
      recheck CLOG for the all-dead test we do just a moment later.
      So, add HeapTupleIsSurelyDead() to test the appropriate condition
      under the assumption that all relevant hit bits are already set.
      
      Review by Tom Lane.
      00381104
  2. Apr 30, 2012
  3. 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
  4. 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
  5. Mar 26, 2012
    • Tom Lane's avatar
      Replace empty locale name with implied value in CREATE DATABASE and initdb. · c7cea267
      Tom Lane authored
      setlocale() accepts locale name "" as meaning "the locale specified by the
      process's environment variables".  Historically we've accepted that for
      Postgres' locale settings, too.  However, it's fairly unsafe to store an
      empty string in a new database's pg_database.datcollate or datctype fields,
      because then the interpretation could vary across postmaster restarts,
      possibly resulting in index corruption and other unpleasantness.
      
      Instead, we should expand "" to whatever it means at the moment of calling
      CREATE DATABASE, which we can do by saving the value returned by
      setlocale().
      
      For consistency, make initdb set up the initial lc_xxx parameter values the
      same way.  initdb was already doing the right thing for empty locale names,
      but it did not replace non-empty names with setlocale results.  On a
      platform where setlocale chooses to canonicalize the spellings of locale
      names, this would result in annoying inconsistency.  (It seems that popular
      implementations of setlocale don't do such canonicalization, which is a
      pity, but the POSIX spec certainly allows it to be done.)  The same risk
      of inconsistency leads me to not venture back-patching this, although it
      could certainly be seen as a longstanding bug.
      
      Per report from Jeff Davis, though this is not his proposed patch.
      c7cea267
  6. Mar 15, 2012
  7. Mar 14, 2012
  8. Mar 07, 2012
    • Tom Lane's avatar
      Expose an API for calculating catcache hash values. · d4bf3c9c
      Tom Lane authored
      Now that cache invalidation callbacks get only a hash value, and not a
      tuple TID (per commits 632ae682 and
      b5282aa8), the only way they can restrict
      what they invalidate is to know what the hash values mean.  setrefs.c was
      doing this via a hard-wired assumption but that seems pretty grotty, and
      it'll only get worse as more cases come up.  So let's expose a calculation
      function that takes the same parameters as SearchSysCache.  Per complaint
      from Marko Kreen.
      d4bf3c9c
  9. Mar 06, 2012
    • Tom Lane's avatar
      Add a hook for processing messages due to be sent to the server log. · 19dbc346
      Tom Lane authored
      Use-cases for this include custom log filtering rules and custom log
      message transmission mechanisms (for instance, lossy log message
      collection, which has been discussed several times recently).
      
      As is our common practice for hooks, there's no regression test nor
      user-facing documentation for this, though the author did exhibit a
      sample module using the hook.
      
      Martin Pihlak, reviewed by Marti Raudsepp
      19dbc346
  10. Mar 04, 2012
    • 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
  11. Mar 02, 2012
  12. Feb 29, 2012
    • Alvaro Herrera's avatar
      Fix typo in comment · 58e9f974
      Alvaro Herrera authored
      Haifeng Liu
      58e9f974
    • Tom Lane's avatar
      Move CRC tables to libpgport, and provide them in a separate include file. · 5c02a00d
      Tom Lane authored
      This makes it much more convenient to build tools for Postgres that are
      separately compiled and require a matching CRC implementation.
      
      To prevent multiple copies of the CRC polynomial tables being introduced
      into the postgres binaries, they are now included in the static library
      libpgport that is mainly meant for replacement system functions.  That
      seems like a bit of a kludge, but there's no better place.
      
      This cleans up building of the tools pg_controldata and pg_resetxlog,
      which previously had to build their own copies of pg_crc.o.
      
      In the future, external programs that need access to the CRC tables can
      include the tables directly from the new header file pg_crc_tables.h.
      
      Daniel Farina, reviewed by Abhijit Menon-Sen and Tom Lane
      5c02a00d
  13. Feb 28, 2012
  14. 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
  15. Feb 16, 2012
    • Tom Lane's avatar
      Improve statistics estimation to make some use of DISTINCT in sub-queries. · 4767bc8f
      Tom Lane authored
      Formerly, we just punted when trying to estimate stats for variables coming
      out of sub-queries using DISTINCT, on the grounds that whatever stats we
      might have for underlying table columns would be inapplicable.  But if the
      sub-query has only one DISTINCT column, we can consider its output variable
      as being unique, which is useful information all by itself.  The scope of
      this improvement is pretty narrow, but it costs nearly nothing, so we might
      as well do it.  Per discussion with Andres Freund.
      
      This patch differs from the draft I submitted yesterday in updating various
      comments about vardata.isunique (to reflect its extended meaning) and in
      tweaking the interaction with security_barrier views.  There does not seem
      to be a reason why we can't use this sort of knowledge even when the
      sub-query is such a view.
      4767bc8f
  16. Feb 15, 2012
    • Tom Lane's avatar
      Run a portal's cleanup hook immediately when pushing it to FAILED state. · 4bfe68df
      Tom Lane authored
      This extends the changes of commit 6252c4f9
      so that we run the cleanup hook earlier for failure cases as well as
      success cases.  As before, the point is to avoid an assertion failure from
      an Assert I added in commit a874fe7b, which
      was meant to check that no user-written code can be called during portal
      cleanup.  This fixes a case reported by Pavan Deolasee in which the Assert
      could be triggered during backend exit (see the new regression test case),
      and also prevents the possibility that the cleanup hook is run after
      portions of the portal's state have already been recycled.  That doesn't
      really matter in current usage, but it foreseeably could matter in the
      future.
      
      Back-patch to 9.1 where the Assert in question was added.
      4bfe68df
  17. Feb 14, 2012
    • 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
  18. Feb 08, 2012
  19. 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
  20. Feb 03, 2012
  21. Jan 31, 2012
    • 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
  22. 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
  23. Jan 19, 2012
  24. Jan 12, 2012
    • Tom Lane's avatar
      Fix CLUSTER/VACUUM FULL for toast values owned by recently-updated rows. · 21b446dd
      Tom Lane authored
      In commit 7b0d0e93, I made CLUSTER and
      VACUUM FULL try to preserve toast value OIDs from the original toast table
      to the new one.  However, if we have to copy both live and recently-dead
      versions of a row that has a toasted column, those versions may well
      reference the same toast value with the same OID.  The patch then led to
      duplicate-key failures as we tried to insert the toast value twice with the
      same OID.  (The previous behavior was not very desirable either, since it
      would have silently inserted the same value twice with different OIDs.
      That wastes space, but what's worse is that the toast values inserted for
      already-dead heap rows would not be reclaimed by subsequent ordinary
      VACUUMs, since they go into the new toast table marked live not deleted.)
      
      To fix, check if the copied OID already exists in the new toast table, and
      if so, assume that it stores the desired value.  This is reasonably safe
      since the only case where we will copy an OID from a previous toast pointer
      is when toast_insert_or_update was given that toast pointer and so we just
      pulled the data from the old table; if we got two different values that way
      then we have big problems anyway.  We do have to assume that no other
      backend is inserting items into the new toast table concurrently, but
      that's surely safe for CLUSTER and VACUUM FULL.
      
      Per bug #6393 from Maxim Boguk.  Back-patch to 9.0, same as the previous
      patch.
      21b446dd
  25. Jan 07, 2012
    • Robert Haas's avatar
      Slightly reorganize struct SnapshotData. · 1fc3d18f
      Robert Haas authored
      This squeezes out a bunch of alignment padding, reducing the size
      from 72 to 56 bytes on my machine.  At least in my testing, this
      didn't produce any measurable performance improvement, but the space
      savings seem like enough justification.
      
      Andres Freund
      1fc3d18f
  26. Jan 02, 2012
  27. Dec 23, 2011
  28. Dec 22, 2011
    • Robert Haas's avatar
      Add a security_barrier option for views. · 0e4611c0
      Robert Haas authored
      When a view is marked as a security barrier, it will not be pulled up
      into the containing query, and no quals will be pushed down into it,
      so that no function or operator chosen by the user can be applied to
      rows not exposed by the view.  Views not configured with this
      option cannot provide robust row-level security, but will perform far
      better.
      
      Patch by KaiGai Kohei; original problem report by Heikki Linnakangas
      (in October 2009!).  Review (in earlier versions) by Noah Misch and
      others.  Design advice by Tom Lane and myself.  Further review and
      cleanup by me.
      0e4611c0
  29. Dec 19, 2011
    • Peter Eisentraut's avatar
      Add support for privileges on types · 72920557
      Peter Eisentraut authored
      This adds support for the more or less SQL-conforming USAGE privilege
      on types and domains.  The intent is to be able restrict which users
      can create dependencies on types, which restricts the way in which
      owners can alter types.
      
      reviewed by Yeb Havinga
      72920557
  30. Dec 18, 2011
    • Tom Lane's avatar
      Replace simple constant pg_am.amcanreturn with an AM support function. · 3695a555
      Tom Lane authored
      The need for this was debated when we put in the index-only-scan feature,
      but at the time we had no near-term expectation of having AMs that could
      support such scans for only some indexes; so we kept it simple.  However,
      the SP-GiST AM forces the issue, so let's fix it.
      
      This patch only installs the new API; no behavior actually changes.
      3695a555
  31. Dec 17, 2011
    • Tom Lane's avatar
      Add SP-GiST (space-partitioned GiST) index access method. · 8daeb5dd
      Tom Lane authored
      SP-GiST is comparable to GiST in flexibility, but supports non-balanced
      partitioned search structures rather than balanced trees.  As described at
      PGCon 2011, this new indexing structure can beat GiST in both index build
      time and query speed for search problems that it is well matched to.
      
      There are a number of areas that could still use improvement, but at this
      point the code seems committable.
      
      Teodor Sigaev and Oleg Bartunov, with considerable revisions by Tom Lane
      8daeb5dd
  32. Dec 16, 2011
    • Andrew Dunstan's avatar
      include_if_exists facility for config file. · 6d09b210
      Andrew Dunstan authored
      This works the same as include, except that an error is not thrown
      if the file is missing. Instead the fact that it's missing is
      logged.
      
      Greg Smith, reviewed by Euler Taveira de Oliveira.
      6d09b210
  33. Dec 12, 2011
    • Heikki Linnakangas's avatar
      Revert the behavior of inet/cidr functions to not unpack the arguments. · 8409b604
      Heikki Linnakangas authored
      I forgot to change the functions to use the PG_GETARG_INET_PP() macro,
      when I changed DatumGetInetP() to unpack the datum, like Datum*P macros
      usually do. Also, I screwed up the definition of the PG_GETARG_INET_PP()
      macro, and didn't notice because it wasn't used.
      
      This fixes the memory leak when sorting inet values, as reported
      by Jochen Erwied and debugged by Andres Freund. Backpatch to 8.3, like
      the previous patch that broke it.
      8409b604
  34. Dec 07, 2011
    • Magnus Hagander's avatar
      Remove spclocation field from pg_tablespace · 16d8e594
      Magnus Hagander authored
      Instead, add a function pg_tablespace_location(oid) used to return
      the same information, and do this by reading the symbolic link.
      
      Doing it this way makes it possible to relocate a tablespace when the
      database is down by simply changing the symbolic link.
      16d8e594
    • Tom Lane's avatar
      Create a "sort support" interface API for faster sorting. · c6e3ac11
      Tom Lane authored
      This patch creates an API whereby a btree index opclass can optionally
      provide non-SQL-callable support functions for sorting.  In the initial
      patch, we only use this to provide a directly-callable comparator function,
      which can be invoked with a bit less overhead than the traditional
      SQL-callable comparator.  While that should be of value in itself, the real
      reason for doing this is to provide a datatype-extensible framework for
      more aggressive optimizations, as in Peter Geoghegan's recent work.
      
      Robert Haas and Tom Lane
      c6e3ac11
  35. Nov 27, 2011
    • Tom Lane's avatar
      Improve GiST range-contained-by searches by adding a flag for empty ranges. · c66e4f13
      Tom Lane authored
      In the original implementation, a range-contained-by search had to scan
      the entire index because an empty range could be lurking anywhere.
      Improve that by adding a flag to upper GiST entries that says whether the
      represented subtree contains any empty ranges.
      
      Also, make a simple mod to the penalty function to discourage empty ranges
      from getting pushed into subtrees without any.  This needs more work, and
      the picksplit function should be taught about it too, but that code can be
      improved without causing an on-disk compatibility break; so we'll leave it
      for another day.
      
      Since we're breaking on-disk compatibility of range values anyway, I took
      the opportunity to reorganize the range flags bits; the unused
      RANGE_xB_NULL bits are now adjacent, which might open the door for using
      them in some other way later.
      
      In passing, remove the GiST range opclass entry for <>, which doesn't seem
      like it can really be indexed usefully.
      
      Alexander Korotkov, with some editorializing by Tom
      c66e4f13
  36. Nov 23, 2011
    • Tom Lane's avatar
      Remove user-selectable ANALYZE option for range types. · 74c1723f
      Tom Lane authored
      It's not clear that a per-datatype typanalyze function would be any more
      useful than a generic typanalyze for ranges.  What *is* clear is that
      letting unprivileged users select typanalyze functions is a crash risk or
      worse.  So remove the option from CREATE TYPE AS RANGE, and instead put in
      a generic typanalyze function for ranges.  The generic function does
      nothing as yet, but hopefully we'll improve that before 9.2 release.
      74c1723f
    • Tom Lane's avatar
      Remove zero- and one-argument range constructor functions. · df735844
      Tom Lane authored
      Per discussion, the zero-argument forms aren't really worth the catalog
      space (just write 'empty' instead).  The one-argument forms have some use,
      but they also have a serious problem with looking too much like functional
      cast notation; to the point where in many real use-cases, the parser would
      misinterpret what was wanted.
      
      Committing this as a separate patch, with the thought that we might want
      to revert part or all of it if we can think of some way around the cast
      ambiguity.
      df735844
Loading