1. 19 2月, 2016 1 次提交
  2. 26 1月, 2016 1 次提交
    • K
      DEFAULT paramters of UDF ported from PostgreSQL 8.4 · 5b2af3cf
      Kuien Liu 提交于
      Functions can be declared with parameters with default values or
      expressions.  The default expressions are used as parameter value
      if the parameter is not explicitly specified in a function call.
      All parameters after a parameter with default value have to be
      parameters with default values as well.
      
      It allows user to invoke a UDF without setting all the parameters.
      Two examples to demo its usage:
      
          CREATE FUNCTION dfunc1(text DEFAULT 'Hello', text DEFAULT 'World')
              RETURNS text AS $$
              SELECT $1 || ', ' || $2;
              $$ LANGUAGE SQL;
          SELECT dfunc1();  -- 'Hello, World'
          SELECT dfunc1('Hi');  -- 'Hi, World'
          SELECT dfunc1('Hi', 'Beijing');  -- 'Hi, Beijing'
      
          CREATE FUNCTION dfunc2(id int4, t timestamp DEFAULT now())
              RETURNS text AS $$
              SELECT 'Time for id:' || $1 || ' is ' || $2;
              $$ LANGUAGE SQL;
          SELECT dfunc2(24);  -- 'Time for id:24 is 2016-01-07 14:38'
      
      NOTE: The default change set is ported from from PostgreSQL 8.4,
          original commits:
          '517ae403'
          '455dffbb'
      5b2af3cf
  3. 25 1月, 2016 1 次提交
    • H
      Silence compiler warnings about unused functions. · c81435b9
      Heikki Linnakangas 提交于
      _outEquivalenceClass and _outEquivalenceMember were unused, when included
      into outfast.c. We have no need to serialize them when shipping a finished
      Plan to segments, so just ifdef them out to silence the compiler. (The
      regular textual "out" functions, for debugging purposes, work normally.)
      c81435b9
  4. 22 12月, 2015 1 次提交
    • Y
      VARIADIC paramters of UDF ported from PostgreSQL. · 4665a8d5
      Yu Yang 提交于
      User could use VARIADIC to specify parameter list when defining UDF
      if they want to use variadic parameters. It is easier for user to write
      only one variadic function instead of same name function with different
      parameters. An example for using variadic:
      create function concat(text, variadic anyarray) returns text as $$
      select array_to_string($2, $1);
      $$ language sql immutable strict;
      
      select concat('%', 1, 2, 3, 4, 5);
      
      NOTE: The variadic change set is ported from upstream of PostgreSQL:
      commit 517ae403
      Author: Tom Lane <tgl@sss.pgh.pa.us>
      Date:   Thu Dec 18 18:20:35 2008 +0000
      
      Code review for function default parameters patch.  Fix numerous problems as
      per recent discussions.  In passing this also fixes a couple of bugs in
      the previous variadic-parameters patch.
      
      commit 6563e9e2
      Author: Tom Lane <tgl@sss.pgh.pa.us>
      Date:   Wed Jul 16 16:55:24 2008 +0000
      
      Add a "provariadic" column to pg_proc to eliminate the remarkably expensive
      need to deconstruct proargmodes for each pg_proc entry inspected by
      FuncnameGetCandidates().  Fixes function lookup performance regression
      caused by yesterday's variadic-functions patch.
      
      In passing, make pg_proc.probin be NULL, rather than a dummy value '-',
      in cases where it is not actually used for the particular type of function.
      This should buy back some of the space cost of the extra column.
      
      commit d89737d3
      Author: Tom Lane <tgl@sss.pgh.pa.us>
      Date:   Wed Jul 16 01:30:23 2008 +0000
      
      Support "variadic" functions, which can accept a variable number of arguments
      so long as all the trailing arguments are of the same (non-array) type.
      The function receives them as a single array argument (which is why they
      have to all be the same type).
      
      It might be useful to extend this facility to aggregates, but this patch
      doesn't do that.
      
      This patch imposes a noticeable slowdown on function lookup --- a follow-on
      patch will fix that by adding a redundant column to pg_proc.
      
      Conflicts:
      	src/backend/gpopt/gpdbwrappers.cpp
      4665a8d5
  5. 02 12月, 2015 1 次提交
  6. 18 11月, 2015 1 次提交
    • H
      Remove back-ported partial FDW support. · 601c58c3
      Heikki Linnakangas 提交于
      It was just syntax and catalogs, you couldn't actually do anything useful
      with it. Remove it, so that we have less code to maintain, until it's time
      to merge this stuff from upstream again when we merge with PostgreSQL 8.4.
      It's probably easier to merge this back at that point than maintain this
      backported version in the meanwhile. Less effort now, until we reach that
      point, and once we get to the point in 8.4 that we merge this in, we'll
      have all the preceding patches applied already, so it should merge quite
      smoothly.
      601c58c3
  7. 13 11月, 2015 2 次提交
    • H
      In readfast.c/outfast.c, reuse functions from readfuncs.c/outfuncs.c. · a64174dd
      Heikki Linnakangas 提交于
      Currently, readfast.c / outfast.c are mostly copy-pasted from readfuncs.c /
      outfuncs.c. That's a merge hazard: if a new field is added to a struct in
      upstream, and it's added to readfuncs.c and outfuncs.c, we would need to
      manually do the same in the readfast.c/outfast.c. If the patch applies
      cleanly, we will not notice, and we'll have a bug of omission.
      
      Refactor the code so that all those node types where the text and binary
      functions are identical, the duplicate in [read/out]fast.c is removed, and
      the definition [read/out]funcs.c is used to compile the binary version too.
      This involves some tricks with #ifdefs and #includes, but cuts a lot of
      duplicate code. This should avoid the merge hazard.
      
      We'll still need to maintain the read/out functions whenever we modify a
      struct in Greenplum, but that's no different from what needs to be done in
      PostgreSQL.
      a64174dd
    • H
      Refactor _read functions in readfast.c to be more like readfuncs.c · b0b3bf2d
      Heikki Linnakangas 提交于
      This reduces the diff between readfast.c and readfuncs.c. There are
      of course parts of these files that need to be different, but the bulk
      of the functions should be identical, with all the differences hidden
      in the READ_* macros. This patch reduces the diff and thus makes any
      suspicious differences between them more obvious.
      b0b3bf2d
  8. 12 11月, 2015 1 次提交
    • H
      Put back the out-function for PlannedStmt. · 35f25e89
      Heikki Linnakangas 提交于
      This partially reverts commit 4e01c159.
      The out-function for PlannedStmt is still needed, for debugging purposes,
      even though we never try to read them back in from text format. There is
      debug code in serializeNode that serializes a complete plan, and that
      gives a WARNING if there is no out-function for PlannedStmt. (I'm not
      convinced that code is doing much good, as it's only spewing stuff to the
      log under DEBUG5, and at that level it will just get lost in the noise.
      But that's a separate discussion). There is an out-function for
      PlannedStmt in PostgreSQL 9.3 too, which is where we it was backported
      from.
      
      While we're at it, take the opportunity to move _outPlannedStmt to the
      same location it's in in upstream, and remove spurious whitespace
      differences.
      35f25e89
  9. 11 11月, 2015 1 次提交
    • H
      Remove broken out/read support for PlannedStmts. · 4e01c159
      Heikki Linnakangas 提交于
      _readTupleDescNode function in readfuncs.c had an 'str' argument, but it
      was called with zero arguments. The reason that we haven't seen crashes
      is that the out/readfuncs.c support for PlannedStmts and TupleDescNodes is
      dead code. They are only serialized when sent from QD to QE, and we use
      the out/readfast.c functions for that.
      
      Remove the code, and add a few comments to TupleDescNode and PlannedStmt
      to clarify this a bit.
      4e01c159
  10. 28 10月, 2015 1 次提交
  11. 13 2月, 2007 1 次提交
  12. 10 2月, 2007 1 次提交
  13. 03 2月, 2007 1 次提交
  14. 23 1月, 2007 2 次提交
    • T
      Add CREATE/ALTER/DROP OPERATOR FAMILY commands, also COMMENT ON OPERATOR · a33cf104
      Tom Lane 提交于
      FAMILY; and add FAMILY option to CREATE OPERATOR CLASS to allow adding a
      class to a pre-existing family.  Per previous discussion.  Man, what a
      tedious lot of cutting and pasting ...
      a33cf104
    • T
      Put back planner's ability to cache the results of mergejoinscansel(), · 4f06c688
      Tom Lane 提交于
      which I had removed in the first cut of the EquivalenceClass rewrite to
      simplify that patch a little.  But it's still important --- in a four-way
      join problem mergejoinscansel() was eating about 40% of the planning time
      according to gprof.  Also, improve the EquivalenceClass code to re-use
      join RestrictInfos rather than generating fresh ones for each join
      considered.  This saves some memory space but more importantly improves
      the effectiveness of caching planning info in RestrictInfos.
      4f06c688
  15. 21 1月, 2007 2 次提交
    • T
      Refactor planner's pathkeys data structure to create a separate, explicit · f41803bb
      Tom Lane 提交于
      representation of equivalence classes of variables.  This is an extensive
      rewrite, but it brings a number of benefits:
      * planner no longer fails in the presence of "incomplete" operator families
      that don't offer operators for every possible combination of datatypes.
      * avoid generating and then discarding redundant equality clauses.
      * remove bogus assumption that derived equalities always use operators
      named "=".
      * mergejoins can work with a variety of sort orders (e.g., descending) now,
      instead of tying each mergejoinable operator to exactly one sort order.
      * better recognition of redundant sort columns.
      * can make use of equalities appearing underneath an outer join.
      f41803bb
    • P
      Remove remains of old depend target. · 2cc01004
      Peter Eisentraut 提交于
      2cc01004
  16. 11 1月, 2007 1 次提交
    • T
      Change the planner-to-executor API so that the planner tells the executor · a191a169
      Tom Lane 提交于
      which comparison operators to use for plan nodes involving tuple comparison
      (Agg, Group, Unique, SetOp).  Formerly the executor looked up the default
      equality operator for the datatype, which was really pretty shaky, since it's
      possible that the data being fed to the node is sorted according to some
      nondefault operator class that could have an incompatible idea of equality.
      The planner knows what it has sorted by and therefore can provide the right
      equality operator to use.  Also, this change moves a couple of catalog lookups
      out of the executor and into the planner, which should help startup time for
      pre-planned queries by some small amount.  Modify the planner to remove some
      other cavalier assumptions about always being able to use the default
      operators.  Also add "nulls first/last" info to the Plan node for a mergejoin
      --- neither the executor nor the planner can cope yet, but at least the API is
      in place.
      a191a169
  17. 09 1月, 2007 1 次提交
    • T
      Support ORDER BY ... NULLS FIRST/LAST, and add ASC/DESC/NULLS FIRST/NULLS LAST · 44317582
      Tom Lane 提交于
      per-column options for btree indexes.  The planner's support for this is still
      pretty rudimentary; it does not yet know how to plan mergejoins with
      nondefault ordering options.  The documentation is pretty rudimentary, too.
      I'll work on improving that stuff later.
      
      Note incompatible change from prior behavior: ORDER BY ... USING will now be
      rejected if the operator is not a less-than or greater-than member of some
      btree opclass.  This prevents less-than-sane behavior if an operator that
      doesn't actually define a proper sort ordering is selected.
      44317582
  18. 06 1月, 2007 1 次提交
  19. 31 12月, 2006 1 次提交
  20. 24 12月, 2006 1 次提交
  21. 23 12月, 2006 1 次提交
    • T
      Restructure operator classes to allow improved handling of cross-data-type · a78fcfb5
      Tom Lane 提交于
      cases.  Operator classes now exist within "operator families".  While most
      families are equivalent to a single class, related classes can be grouped
      into one family to represent the fact that they are semantically compatible.
      Cross-type operators are now naturally adjunct parts of a family, without
      having to wedge them into a particular opclass as we had done originally.
      
      This commit restructures the catalogs and cleans up enough of the fallout so
      that everything still works at least as well as before, but most of the work
      needed to actually improve the planner's behavior will come later.  Also,
      there are not yet CREATE/DROP/ALTER OPERATOR FAMILY commands; the only way
      to create a new family right now is to allow CREATE OPERATOR CLASS to make
      one by default.  I owe some more documentation work, too.  But that can all
      be done in smaller pieces once this infrastructure is in place.
      a78fcfb5
  22. 22 12月, 2006 1 次提交
  23. 11 12月, 2006 1 次提交
    • T
      Add a paramtypmod field to Param nodes. This is dead weight for Params · 9fa12ddd
      Tom Lane 提交于
      representing externally-supplied values, since the APIs that carry such
      values only specify type not typmod.  However, for PARAM_SUBLINK Params
      it is handy to carry the typmod of the sublink's output column.  This
      is a much cleaner solution for the recently reported 'could not find
      pathkey item to sort' and 'failed to find unique expression in subplan
      tlist' bugs than my original 8.2-compatible patch.  Besides, someday we
      might want to support typmods for external parameters ...
      9fa12ddd
  24. 06 11月, 2006 1 次提交
    • T
      Fix recently-understood problems with handling of XID freezing, particularly · 48188e16
      Tom Lane 提交于
      in PITR scenarios.  We now WAL-log the replacement of old XIDs with
      FrozenTransactionId, so that such replacement is guaranteed to propagate to
      PITR slave databases.  Also, rather than relying on hint-bit updates to be
      preserved, pg_clog is not truncated until all instances of an XID are known to
      have been replaced by FrozenTransactionId.  Add new GUC variables and
      pg_autovacuum columns to allow management of the freezing policy, so that
      users can trade off the size of pg_clog against the amount of freezing work
      done.  Revise the already-existing code that forces autovacuum of tables
      approaching the wraparound point to make it more bulletproof; also, revise the
      autovacuum logic so that anti-wraparound vacuuming is done per-table rather
      than per-database.  initdb forced because of changes in pg_class, pg_database,
      and pg_autovacuum catalogs.  Heikki Linnakangas, Simon Riggs, and Tom Lane.
      48188e16
  25. 14 10月, 2006 1 次提交
  26. 04 10月, 2006 1 次提交
  27. 28 9月, 2006 1 次提交
  28. 20 9月, 2006 1 次提交
    • T
      Improve usage of effective_cache_size parameter by assuming that all the · b74c5436
      Tom Lane 提交于
      tables in the query compete for cache space, not just the one we are
      currently costing an indexscan for.  This seems more realistic, and it
      definitely will help in examples recently exhibited by Stefan
      Kaltenbrunner.  To get the total size of all the tables involved, we must
      tweak the handling of 'append relations' a bit --- formerly we looked up
      information about the child tables on-the-fly during set_append_rel_pathlist,
      but it needs to be done before we start doing any cost estimation, so
      push it into the add_base_rels_to_query scan.
      b74c5436
  29. 31 8月, 2006 1 次提交
  30. 25 8月, 2006 1 次提交
  31. 21 8月, 2006 1 次提交
    • T
      Fix all known problems with pg_dump's handling of serial sequences · 2b2a5072
      Tom Lane 提交于
      by abandoning the idea that it should say SERIAL in the dump.  Instead,
      dump serial sequences and column defaults just like regular ones.
      Add a new backend command ALTER SEQUENCE OWNED BY to let pg_dump recreate
      the sequence-to-column dependency that was formerly created "behind the
      scenes" by SERIAL.  This restores SERIAL to being truly "just a macro"
      consisting of component operations that can be stated explicitly in SQL.
      Furthermore, the new command allows sequence ownership to be reassigned,
      so that old mistakes can be cleaned up.
      
      Also, downgrade the OWNED-BY dependency from INTERNAL to AUTO, since there
      is no longer any very compelling argument why the sequence couldn't be
      dropped while keeping the column.  (This forces initdb, to be sure the
      right kinds of dependencies are in there.)
      
      Along the way, add checks to prevent ALTER OWNER or SET SCHEMA on an
      owned sequence; you can now only do this indirectly by changing the
      owning table's owner or schema.  This is an oversight in previous
      releases, but probably not worth back-patching.
      2b2a5072
  32. 12 8月, 2006 1 次提交
  33. 10 8月, 2006 1 次提交
  34. 02 8月, 2006 1 次提交
  35. 28 7月, 2006 1 次提交
    • T
      Aggregate functions now support multiple input arguments. I also took · 108fe473
      Tom Lane 提交于
      the opportunity to treat COUNT(*) as a zero-argument aggregate instead
      of the old hack that equated it to COUNT(1); this is materially cleaner
      (no more weird ANYOID cases) and ought to be at least a tiny bit faster.
      Original patch by Sergey Koposov; review, documentation, simple regression
      tests, pg_dump and psql support by moi.
      108fe473
  36. 14 7月, 2006 2 次提交