1. 14 3月, 2019 1 次提交
  2. 05 12月, 2018 1 次提交
  3. 22 9月, 2018 1 次提交
    • H
      Change pretty-printing of expressions in EXPLAIN to match upstream. · 4c54c894
      Heikki Linnakangas 提交于
      We had changed this in GPDB, to print less parens. That's fine and dandy,
      but it hardly seems worth it to carry a diff vs upstream for this. Which
      format is better, is a matter of taste. The extra parens make some
      expressions more clear, but OTOH, it's unnecessarily verbose for simple
      expressions. Let's follow the upstream on this.
      
      These changes were made to GPDB back in 2006, as part of backporting
      to EXPLAIN-related patches from PostgreSQL 8.2. But I didn't see any
      explanation for this particular change in output in that commit message.
      
      It's nice to match upstream, to make merging easier. However, this won't
      make much difference to that: almost all EXPLAIN plans in regression
      tests are different from upstream anyway, because GPDB needs Motion nodes
      for most queries. But every little helps.
      4c54c894
  4. 03 8月, 2018 2 次提交
  5. 02 8月, 2018 1 次提交
    • R
      Merge with PostgreSQL 9.2beta2. · 4750e1b6
      Richard Guo 提交于
      This is the final batch of commits from PostgreSQL 9.2 development,
      up to the point where the REL9_2_STABLE branch was created, and 9.3
      development started on the PostgreSQL master branch.
      
      Notable upstream changes:
      
      * Index-only scan was included in the batch of upstream commits. It
        allows queries to retrieve data only from indexes, avoiding heap access.
      
      * Group commit was added to work effectively under heavy load. Previously,
        batching of commits became ineffective as the write workload increased,
        because of internal lock contention.
      
      * A new fast-path lock mechanism was added to reduce the overhead of
        taking and releasing certain types of locks which are taken and released
        very frequently but rarely conflict.
      
      * The new "parameterized path" mechanism was added. It allows inner index
        scans to use values from relations that are more than one join level up
        from the scan. This can greatly improve performance in situations where
        semantic restrictions (such as outer joins) limit the allowed join orderings.
      
      * SP-GiST (Space-Partitioned GiST) index access method was added to support
        unbalanced partitioned search structures. For suitable problems, SP-GiST can
        be faster than GiST in both index build time and search time.
      
      * Checkpoints now are performed by a dedicated background process. Formerly
        the background writer did both dirty-page writing and checkpointing. Separating
        this into two processes allows each goal to be accomplished more predictably.
      
      * Custom plan was supported for specific parameter values even when using
        prepared statements.
      
      * API for FDW was improved to provide multiple access "paths" for their tables,
        allowing more flexibility in join planning.
      
      * Security_barrier option was added for views to prevents optimizations that
        might allow view-protected data to be exposed to users.
      
      * Range data type was added to store a lower and upper bound belonging to its
        base data type.
      
      * CTAS (CREATE TABLE AS/SELECT INTO) is now treated as utility statement. The
        SELECT query is planned during the execution of the utility. To conform to
        this change, GPDB executes the utility statement only on QD and dispatches
        the plan of the SELECT query to QEs.
      Co-authored-by: NAdam Lee <ali@pivotal.io>
      Co-authored-by: NAlexandra Wang <lewang@pivotal.io>
      Co-authored-by: NAshwin Agrawal <aagrawal@pivotal.io>
      Co-authored-by: NAsim R P <apraveen@pivotal.io>
      Co-authored-by: NDaniel Gustafsson <dgustafsson@pivotal.io>
      Co-authored-by: NGang Xiong <gxiong@pivotal.io>
      Co-authored-by: NHaozhou Wang <hawang@pivotal.io>
      Co-authored-by: NHeikki Linnakangas <hlinnakangas@pivotal.io>
      Co-authored-by: NJesse Zhang <sbjesse@gmail.com>
      Co-authored-by: NJinbao Chen <jinchen@pivotal.io>
      Co-authored-by: NJoao Pereira <jdealmeidapereira@pivotal.io>
      Co-authored-by: NMelanie Plageman <mplageman@pivotal.io>
      Co-authored-by: NPaul Guo <paulguo@gmail.com>
      Co-authored-by: NRichard Guo <guofenglinux@gmail.com>
      Co-authored-by: NShujie Zhang <shzhang@pivotal.io>
      Co-authored-by: NTaylor Vesely <tvesely@pivotal.io>
      Co-authored-by: NZhenghua Lyu <zlv@pivotal.io>
      4750e1b6
  6. 13 1月, 2016 1 次提交
  7. 12 1月, 2016 1 次提交
  8. 01 12月, 2015 1 次提交
    • H
      Make 'union' test case match the upstream version. · 6d594e28
      Heikki Linnakangas 提交于
      1. Remove unnecessary ORDER BYs (one of them still needed, as gpdiff.pl got
      confused by the ORDER BY within subquery, thinking that the order of the
      overall query was well-ordered).
      
      2. Move GPDB-added test queries to separate test file, union_gp.sql.
      6d594e28
  9. 28 10月, 2015 1 次提交
  10. 27 6月, 2014 1 次提交
  11. 28 3月, 2014 1 次提交
    • T
      Fix EquivalenceClass processing for nested append relations. · a87c7291
      Tom Lane 提交于
      The original coding of EquivalenceClasses didn't foresee that appendrel
      child relations might themselves be appendrels; but this is possible for
      example when a UNION ALL subquery scans a table with inheritance children.
      The oversight led to failure to optimize ordering-related issues very well
      for the grandchild tables.  After some false starts involving explicitly
      flattening the appendrel representation, we found that this could be fixed
      easily by removing a few implicit assumptions about appendrel parent rels
      not being children themselves.
      
      Kyotaro Horiguchi and Tom Lane, reviewed by Noah Misch
      a87c7291
  12. 13 12月, 2013 1 次提交
  13. 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
  14. 08 7月, 2013 1 次提交
    • T
      Fix planning of parameterized appendrel paths with expensive join quals. · 5372275b
      Tom Lane 提交于
      The code in set_append_rel_pathlist() for building parameterized paths
      for append relations (inheritance and UNION ALL combinations) supposed
      that the cheapest regular path for a child relation would still be cheapest
      when reparameterized.  Which might not be the case, particularly if the
      added join conditions are expensive to compute, as in a recent example from
      Jeff Janes.  Fix it to compare child path costs *after* reparameterizing.
      We can short-circuit that if the cheapest pre-existing path is already
      parameterized correctly, which seems likely to be true often enough to be
      worth checking for.
      
      Back-patch to 9.2 where parameterized paths were introduced.
      5372275b
  15. 06 6月, 2013 1 次提交
    • T
      Prevent pushing down WHERE clauses into unsafe UNION/INTERSECT nests. · 964c0d0f
      Tom Lane 提交于
      The planner is aware that it mustn't push down upper-level quals into
      subqueries if the quals reference subquery output columns that contain
      set-returning functions or volatile functions, or are non-DISTINCT outputs
      of a DISTINCT ON subquery.  However, it missed making this check when
      there were one or more levels of UNION or INTERSECT above the dangerous
      expression.  This could lead to "set-valued function called in context that
      cannot accept a set" errors, as seen in bug #8213 from Eric Soroos, or to
      silently wrong answers in the other cases.
      
      To fix, refactor the checks so that we make the column-is-unsafe checks
      during subquery_is_pushdown_safe(), which already has to recursively
      inspect all arms of a set-operation tree.  This makes
      qual_is_pushdown_safe() considerably simpler, at the cost that we will
      spend some cycles checking output columns that possibly aren't referenced
      in any upper qual.  But the cases where this code gets executed at all
      are already nontrivial queries, so it's unlikely anybody will notice any
      slowdown of planning.
      
      This has been broken since commit 05f916e6,
      which makes the bug over ten years old.  A bit surprising nobody noticed it
      before now.
      964c0d0f
  16. 15 3月, 2013 1 次提交
    • T
      Avoid inserting Result nodes that only compute identity projections. · 4387cf95
      Tom Lane 提交于
      The planner sometimes inserts Result nodes to perform column projections
      (ie, arbitrary scalar calculations) above plan nodes that lack projection
      logic of their own.  However, we did that even if the lower plan node was
      in fact producing the required column set already; which is a pretty common
      case given the popularity of "SELECT * FROM ...".  Measurements show that
      the useless plan node adds non-negligible overhead, especially when there
      are many columns in the result.  So add a check to avoid inserting a Result
      node unless there's something useful for it to do.
      
      There are a couple of remaining places where unnecessary Result nodes
      could get inserted, but they are (a) much less performance-critical,
      and (b) coded in such a way that it's hard to avoid inserting a Result,
      because the desired tlist is changed on-the-fly in subsequent logic.
      We'll leave those alone for now.
      
      Kyotaro Horiguchi; reviewed and further hacked on by Amit Kapila and
      Tom Lane.
      4387cf95
  17. 08 8月, 2012 1 次提交
    • T
      Implement SQL-standard LATERAL subqueries. · 5ebaaa49
      Tom Lane 提交于
      This patch implements the standard syntax of LATERAL attached to a
      sub-SELECT in FROM, and also allows LATERAL attached to a function in FROM,
      since set-returning function calls are expected to be one of the principal
      use-cases.
      
      The main change here is a rewrite of the mechanism for keeping track of
      which relations are visible for column references while the FROM clause is
      being scanned.  The parser "namespace" lists are no longer lists of bare
      RTEs, but are lists of ParseNamespaceItem structs, which carry an RTE
      pointer as well as some visibility-controlling flags.  Aside from
      supporting LATERAL correctly, this lets us get rid of the ancient hacks
      that required rechecking subqueries and JOIN/ON and function-in-FROM
      expressions for invalid references after they were initially parsed.
      Invalid column references are now always correctly detected on sight.
      
      In passing, remove assorted parser error checks that are now dead code by
      virtue of our having gotten rid of add_missing_from, as well as some
      comments that are obsolete for the same reason.  (It was mainly
      add_missing_from that caused so much fudging here in the first place.)
      
      The planner support for this feature is very minimal, and will be improved
      in future patches.  It works well enough for testing purposes, though.
      
      catversion bump forced due to new field in RangeTblEntry.
      5ebaaa49
  18. 05 7月, 2012 1 次提交
  19. 17 3月, 2012 1 次提交
    • T
      Revisit handling of UNION ALL subqueries with non-Var output columns. · dd4134ea
      Tom Lane 提交于
      In commit 57664ed2 I tried to fix a bug
      reported by Teodor Sigaev by making non-simple-Var output columns distinct
      (by wrapping their expressions with dummy PlaceHolderVar nodes).  This did
      not work too well.  Commit b28ffd0f fixed
      some ensuing problems with matching to child indexes, but per a recent
      report from Claus Stadler, constraint exclusion of UNION ALL subqueries was
      still broken, because constant-simplification didn't handle the injected
      PlaceHolderVars well either.  On reflection, the original patch was quite
      misguided: there is no reason to expect that EquivalenceClass child members
      will be distinct.  So instead of trying to make them so, we should ensure
      that we can cope with the situation when they're not.
      
      Accordingly, this patch reverts the code changes in the above-mentioned
      commits (though the regression test cases they added stay).  Instead, I've
      added assorted defenses to make sure that duplicate EC child members don't
      cause any problems.  Teodor's original problem ("MergeAppend child's
      targetlist doesn't match MergeAppend") is addressed more directly by
      revising prepare_sort_from_pathkeys to let the parent MergeAppend's sort
      list guide creation of each child's sort list.
      
      In passing, get rid of add_sort_column; as far as I can tell, testing for
      duplicate sort keys at this stage is dead code.  Certainly it doesn't
      trigger often enough to be worth expending cycles on in ordinary queries.
      And keeping the test would've greatly complicated the new logic in
      prepare_sort_from_pathkeys, because comparing pathkey list entries against
      a previous output array requires that we not skip any entries in the list.
      
      Back-patch to 9.1, like the previous patches.  The only known issue in
      this area that wasn't caused by the ill-advised previous patches was the
      MergeAppend planning failure, which of course is not relevant before 9.1.
      It's possible that we need some of the new defenses against duplicate child
      EC entries in older branches, but until there's some clear evidence of that
      I'm going to refrain from back-patching further.
      dd4134ea
  20. 30 1月, 2012 1 次提交
    • T
      Fix pushing of index-expression qualifications through UNION ALL. · b28ffd0f
      Tom Lane 提交于
      In commit 57664ed2, I made the planner
      wrap non-simple-variable outputs of appendrel children (IOW, child SELECTs
      of UNION ALL subqueries) inside PlaceHolderVars, in order to solve some
      issues with EquivalenceClass processing.  However, this means that any
      upper-level WHERE clauses mentioning such outputs will now contain
      PlaceHolderVars after they're pushed down into the appendrel child,
      and that prevents indxpath.c from recognizing that they could be matched
      to index expressions.  To fix, add explicit stripping of PlaceHolderVars
      from index operands, same as we have long done for RelabelType nodes.
      Add a regression test covering both this and the plain-UNION case (which
      is a totally different code path, but should also be able to do it).
      
      Per bug #6416 from Matteo Beccati.  Back-patch to 9.1, same as the
      previous change.
      b28ffd0f
  21. 17 12月, 2009 1 次提交
    • T
      Avoid a premature coercion failure in transformSetOperationTree() when · 52fc0075
      Tom Lane 提交于
      presented with an UNKNOWN-type Var, which can happen in cases where an
      unknown literal appeared in a subquery.  While many such cases will fail
      later on anyway in the planner, there are some cases where the planner is
      able to flatten the query and replace the Var by the constant before it has
      to coerce the union column to the final type.  I had added this check in 8.4
      to provide earlier/better error detection, but it causes a regression for
      some cases that worked OK before.  Fix by not making the check if the input
      node is UNKNOWN type and not a Const or Param.  If it isn't going to work,
      it will fail anyway at plan time, with the only real loss being inability to
      provide an error cursor.  Per gripe from Britt Piehler.
      
      In passing, rename a couple of variables to remove confusion from an
      inner scope masking the same variable names in an outer scope.
      52fc0075
  22. 10 2月, 2009 1 次提交
  23. 07 8月, 2008 2 次提交
    • T
      Support hashing for duplicate-elimination in INTERSECT and EXCEPT queries. · 368df304
      Tom Lane 提交于
      This completes my project of improving usage of hashing for duplicate
      elimination (aggregate functions with DISTINCT remain undone, but that's
      for some other day).
      
      As with the previous patches, this means we can INTERSECT/EXCEPT on datatypes
      that can hash but not sort, and it means that INTERSECT/EXCEPT without ORDER
      BY are no longer certain to produce sorted output.
      368df304
    • T
      Teach the system how to use hashing for UNION. (INTERSECT/EXCEPT will follow, · 2d1d96b1
      Tom Lane 提交于
      but seem like a separate patch since most of the remaining work is on the
      executor side.)  I took the opportunity to push selection of the grouping
      operators for set operations into the parser where it belongs.  Otherwise this
      is just a small exercise in making prepunion.c consider both alternatives.
      
      As with the recent DISTINCT patch, this means we can UNION on datatypes that
      can hash but not sort, and it means that UNION without ORDER BY is no longer
      certain to produce sorted output.
      2d1d96b1
  24. 15 3月, 2006 1 次提交
    • T
      Improve parser so that we can show an error cursor position for errors · 20ab467d
      Tom Lane 提交于
      during parse analysis, not only errors detected in the flex/bison stages.
      This is per my earlier proposal.  This commit includes all the basic
      infrastructure, but locations are only tracked and reported for errors
      involving column references, function calls, and operators.  More could
      be done later but this seems like a good set to start with.  I've also
      moved the ReportSyntaxErrorPosition logic out of psql and into libpq,
      which should make it available to more people --- even within psql this
      is an improvement because warnings weren't handled by ReportSyntaxErrorPosition.
      20ab467d
  25. 03 11月, 2003 1 次提交
  26. 25 9月, 2003 1 次提交
  27. 20 7月, 2003 1 次提交
  28. 26 5月, 2003 1 次提交
    • T
      Cause CHAR(n) to TEXT or VARCHAR conversion to automatically strip trailing · f45df8c0
      Tom Lane 提交于
      blanks, in hopes of reducing the surprise factor for newbies.  Remove
      redundant operators for VARCHAR (it depends wholly on TEXT operations now).
      Clean up resolution of ambiguous operators/functions to avoid surprising
      choices for domains: domains are treated as equivalent to their base types
      and binary-coercibility is no longer considered a preference item when
      choosing among multiple operators/functions.  IsBinaryCoercible now correctly
      reflects the notion that you need *only* relabel the type to get from type
      A to type B: that is, a domain is binary-coercible to its base type, but
      not vice versa.  Various marginal cleanup, including merging the essentially
      duplicate resolution code in parse_func.c and parse_oper.c.  Improve opr_sanity
      regression test to understand about binary compatibility (using pg_cast),
      and fix a couple of small errors in the catalogs revealed thereby.
      Restructure "special operator" handling to fetch operators via index opclasses
      rather than hardwiring assumptions about names (cleans up the pattern_ops
      stuff a little).
      f45df8c0
  29. 19 9月, 2002 1 次提交
    • T
      Extend pg_cast castimplicit column to a three-way value; this allows us · b26dfb95
      Tom Lane 提交于
      to be flexible about assignment casts without introducing ambiguity in
      operator/function resolution.  Introduce a well-defined promotion hierarchy
      for numeric datatypes (int2->int4->int8->numeric->float4->float8).
      Change make_const to initially label numeric literals as int4, int8, or
      numeric (never float8 anymore).
      Explicitly mark Func and RelabelType nodes to indicate whether they came
      from a function call, explicit cast, or implicit cast; use this to do
      reverse-listing more accurately and without so many heuristics.
      Explicit casts to char, varchar, bit, varbit will truncate or pad without
      raising an error (the pre-7.2 behavior), while assigning to a column without
      any explicit cast will still raise an error for wrong-length data like 7.3.
      This more nearly follows the SQL spec than 7.2 behavior (we should be
      reporting a 'completion condition' in the explicit-cast cases, but we have
      no mechanism for that, so just do silent truncation).
      Fix some problems with enforcement of typmod for array elements;
      it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
      Provide a generalized array_length_coerce() function to replace the
      specialized per-array-type functions that used to be needed (and were
      missing for NUMERIC as well as all the datetime types).
      Add missing conversions int8<->float4, text<->numeric, oid<->int8.
      initdb forced.
      b26dfb95
  30. 22 3月, 2002 1 次提交
    • T
      First phase of SCHEMA changes, concentrating on fixing the grammar and · 95ef6a34
      Tom Lane 提交于
      the parsetree representation.  As yet we don't *do* anything with schema
      names, just drop 'em on the floor; but you can enter schema-compatible
      command syntax, and there's even a primitive CREATE SCHEMA command.
      No doc updates yet, except to note that you can now extract a field
      from a function-returning-row's result with (foo(...)).fieldname.
      95ef6a34
  31. 09 11月, 2000 1 次提交
  32. 06 10月, 2000 1 次提交
    • T
      Reimplementation of UNION/INTERSECT/EXCEPT. INTERSECT/EXCEPT now meet the · 05e3d0ee
      Tom Lane 提交于
      SQL92 semantics, including support for ALL option.  All three can be used
      in subqueries and views.  DISTINCT and ORDER BY work now in views, too.
      This rewrite fixes many problems with cross-datatype UNIONs and INSERT/SELECT
      where the SELECT yields different datatypes than the INSERT needs.  I did
      that by making UNION subqueries and SELECT in INSERT be treated like
      subselects-in-FROM, thereby allowing an extra level of targetlist where the
      datatype conversions can be inserted safely.
      INITDB NEEDED!
      05e3d0ee
  33. 06 1月, 2000 1 次提交
  34. 29 5月, 1998 1 次提交
    • T
      Add test for UNION. · 3955d668
      Thomas G. Lockhart 提交于
      Add additional tests in strings for conversions of the "name" data type.
      Test SQL92 string functions such as SUBSTRING() and POSITION().
      Fix geometry tests to reflect code fixed by Gautam.
      Update error messages.
      3955d668