1. 14 3月, 2019 1 次提交
  2. 04 5月, 2017 1 次提交
    • T
      Remove useless and rather expensive stanza in matview regression test. · fcdccb78
      Tom Lane 提交于
      This removes a test case added by commit b69ec7cc, which was intended
      to exercise a corner case involving the rule used at that time that
      materialized views were unpopulated iff they had physical size zero.
      We got rid of that rule very shortly later, in commit 1d6c72a5, but
      kept the test case.  However, because the case now asks what VACUUM
      will do to a zero-sized physical file, it would be pretty surprising
      if the answer were ever anything but "nothing" ... and if things were
      indeed that broken, surely we'd find it out from other tests.  Since
      the test involves a table that's fairly large by regression-test
      standards (100K rows), it's quite slow to run.  Dropping it should
      save some buildfarm cycles, so let's do that.
      
      Discussion: https://postgr.es/m/32386.1493831320@sss.pgh.pa.us
      fcdccb78
  3. 06 2月, 2017 1 次提交
  4. 11 8月, 2016 1 次提交
    • T
      Fix busted Assert for CREATE MATVIEW ... WITH NO DATA. · 268d92e5
      Tom Lane 提交于
      Commit 874fe3ae changed the command tag returned for CREATE MATVIEW/CREATE
      TABLE AS ... WITH NO DATA, but missed that there was code in spi.c that
      expected the command tag to always be "SELECT".  Fortunately, the
      consequence was only an Assert failure, so this oversight should have no
      impact in production builds.
      
      Since this code path was evidently un-exercised, add a regression test.
      
      Per report from Shivam Saxena. Back-patch to 9.3, like the previous commit.
      
      Michael Paquier
      
      Report: <97218716-480B-4527-B5CD-D08D798A0C7B@dresources.com>
      268d92e5
  5. 28 6月, 2016 1 次提交
    • T
      Fix CREATE MATVIEW/CREATE TABLE AS ... WITH NO DATA to not plan the query. · dc9e03bf
      Tom Lane 提交于
      Previously, these commands always planned the given query and went through
      executor startup before deciding not to actually run the query if WITH NO
      DATA is specified.  This behavior is problematic for pg_dump because it
      may cause errors to be raised that we would rather not see before a
      REFRESH MATERIALIZED VIEW command is issued.  See for example bug #13907
      from Marian Krucina.  This change is not sufficient to fix that particular
      bug, because we also need to tweak pg_dump to issue the REFRESH later,
      but it's a necessary step on the way.
      
      A user-visible side effect of doing things this way is that the returned
      command tag for WITH NO DATA cases will now be "CREATE MATERIALIZED VIEW"
      or "CREATE TABLE AS", not "SELECT 0".  We could preserve the old behavior
      but it would take more code, and arguably that was just an implementation
      artifact not intended behavior anyhow.
      
      In 9.5 and HEAD, also get rid of the static variable CreateAsReladdr, which
      was trouble waiting to happen; there is not any prohibition on nested
      CREATE commands.
      
      Back-patch to 9.3 where CREATE MATERIALIZED VIEW was introduced.
      
      Michael Paquier and Tom Lane
      
      Report: <20160202161407.2778.24659@wrigleys.postgresql.org>
      dc9e03bf
  6. 12 10月, 2014 1 次提交
  7. 05 9月, 2014 1 次提交
  8. 26 8月, 2014 1 次提交
    • K
      Fix superuser concurrent refresh of matview owned by another. · 06414c0f
      Kevin Grittner 提交于
      Use SECURITY_LOCAL_USERID_CHANGE while building temporary tables;
      only escalate to SECURITY_RESTRICTED_OPERATION while potentially
      running user-supplied code.  The more secure mode was preventing
      temp table creation.  Add regression tests to cover this problem.
      
      This fixes Bug #11208 reported by Bruno Emanuel de Andrade Silva.
      
      Backpatch to 9.4, where the bug was introduced.
      06414c0f
  9. 01 5月, 2014 1 次提交
    • T
      Reduce indentation/parenthesization of set operations in rule/view dumps. · 41de93c5
      Tom Lane 提交于
      A query such as "SELECT x UNION SELECT y UNION SELECT z UNION ..."
      produces a left-deep nested parse tree, which we formerly showed in its
      full nested glory and with all the possible parentheses.  This does little
      for readability, though, and long UNION lists resulting in excessive
      indentation are common.  Instead, let's omit parentheses and indent all
      the subqueries at the same level in such cases.
      
      This patch skips indentation/parenthesization whenever the lefthand input
      of a SetOperationStmt is another SetOperationStmt of the same kind and
      ALL/DISTINCT property.  We could teach the code the exact syntactic
      precedence of set operations and thereby avoid parenthesization in some
      more cases, but it's not clear that that'd be a readability win: it seems
      better to parenthesize if the set operation changes.  (As an example,
      if there's one UNION in a long list of UNION ALL, it now stands out like
      a sore thumb, which seems like a good thing.)
      
      Back-patch to 9.3.  This completes our response to a complaint from Greg
      Stark that since commit 62e66640 there's a performance problem in pg_dump
      for views containing long UNION sequences (or other types of deeply nested
      constructs).  The previous commit 0601cb54
      handles the general problem, but this one makes the specific case of UNION
      lists look a lot nicer.
      41de93c5
  10. 30 3月, 2014 1 次提交
  11. 26 3月, 2014 1 次提交
  12. 07 3月, 2014 1 次提交
    • T
      Don't reject ROW_MARK_REFERENCE rowmarks for materialized views. · bf4052fa
      Tom Lane 提交于
      We should allow this so that matviews can be referenced in UPDATE/DELETE
      statements in READ COMMITTED isolation level.  The requirement for that
      is that a re-fetch by TID will see the same row version the query saw
      earlier, which is true of matviews, so there's no reason for the
      restriction.  Per bug #9398.
      
      Michael Paquier, after a suggestion by me
      bf4052fa
  13. 13 12月, 2013 1 次提交
  14. 11 12月, 2013 1 次提交
  15. 12 11月, 2013 1 次提交
    • T
      Fix ruleutils pretty-printing to not generate trailing whitespace. · 0b7e660d
      Tom Lane 提交于
      The pretty-printing logic in ruleutils.c operates by inserting a newline
      and some indentation whitespace into strings that are already valid SQL.
      This naturally results in leaving some trailing whitespace before the
      newline in many cases; which can be annoying when processing the output
      with other tools, as complained of by Joe Abbate.  We can fix that in
      a pretty localized fashion by deleting any trailing whitespace before
      we append a pretty-printing newline.  In addition, we have to modify the
      code inserted by commit 2f582f76 so that
      we also delete trailing whitespace when transposing items from temporary
      buffers into the main result string, when a temporary item starts with a
      newline.
      
      This results in rather voluminous changes to the regression test results,
      but it's easily verified that they are only removal of trailing whitespace.
      
      Back-patch to 9.3, because the aforementioned commit resulted in many
      more cases of trailing whitespace than had occurred in earlier branches.
      0b7e660d
  16. 05 11月, 2013 1 次提交
  17. 03 11月, 2013 1 次提交
  18. 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
  19. 03 8月, 2013 1 次提交
    • A
      Fix crash in error report of invalid tuple lock · 88c55668
      Alvaro Herrera 提交于
      My tweak of these error messages in commit c359a1b0 contained the
      thinko that a query would always have rowMarks set for a query
      containing a locking clause.  Not so: when declaring a cursor, for
      instance, rowMarks isn't set at the point we're checking, so we'd be
      dereferencing a NULL pointer.
      
      The fix is to pass the lock strength to the function raising the error,
      instead of trying to reverse-engineer it.  The result not only is more
      robust, but it also seems cleaner overall.
      
      Per report from Robert Haas.
      88c55668
  20. 17 7月, 2013 1 次提交
    • K
      Add support for REFRESH MATERIALIZED VIEW CONCURRENTLY. · cc1965a9
      Kevin Grittner 提交于
      This allows reads to continue without any blocking while a REFRESH
      runs.  The new data appears atomically as part of transaction
      commit.
      
      Review questioned the Assert that a matview was not a system
      relation.  This will be addressed separately.
      
      Reviewed by Hitoshi Harada, Robert Haas, Andres Freund.
      Merged after review with security patch f3ab5d46.
      cc1965a9
  21. 07 5月, 2013 2 次提交
    • 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
    • T
      Disallow unlogged materialized views. · 3223b25f
      Tom Lane 提交于
      The initial implementation of this feature was really unsupportable,
      because it's relying on the physical size of an on-disk file to carry the
      relation's populated/unpopulated state, which is at least a modularity
      violation and could have serious long-term consequences.  We could say that
      an unlogged matview goes to empty on crash, but not everybody likes that
      definition, so let's just remove the feature for 9.3.  We can add it back
      when we have a less klugy implementation.
      
      I left the grammar and tab-completion support for CREATE UNLOGGED
      MATERIALIZED VIEW in place, since it's harmless and allows delivering a
      more specific error message about the unsupported feature.
      
      I'm committing this separately to ease identification of what should be
      reverted when/if we are able to re-enable the feature.
      3223b25f
  22. 03 5月, 2013 1 次提交
  23. 02 5月, 2013 1 次提交
    • T
      Fix permission tests for views/tables proven empty by constraint exclusion. · 50c13748
      Tom Lane 提交于
      A view defined as "select <something> where false" had the curious property
      that the system wouldn't check whether users had the privileges necessary
      to select from it.  More generally, permissions checks could be skipped
      for tables referenced in sub-selects or views that were proven empty by
      constraint exclusion (although some quick testing suggests this seldom
      happens in cases of practical interest).  This happened because the planner
      failed to include rangetable entries for such tables in the finished plan.
      
      This was noticed in connection with erroneous handling of materialized
      views, but actually the issue is quite unrelated to matviews.  Therefore,
      revert commit 200ba166 in favor of a more
      direct test for the real problem.
      
      Back-patch to 9.2 where the bug was introduced (by commit
      7741dd65).
      50c13748
  24. 01 5月, 2013 1 次提交
  25. 19 3月, 2013 1 次提交
  26. 15 3月, 2013 1 次提交
  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