1. 21 9月, 2017 2 次提交
    • H
      Add support for CREATE FUNCTION EXECUTE ON [MASTER | ALL SEGMENTS] · aa148d2a
      Heikki Linnakangas 提交于
      We already had a hack for the EXECUTE ON ALL SEGMENTS case, by setting
      prodataaccess='s'. This exposes the functionality to users via DDL, and adds
      support for the EXECUTE ON MASTER case.
      
      There was discussion on gpdb-dev about also supporting ON MASTER AND ALL
      SEGMENTS, but that is not implemented yet. There is no handy "locus" in the
      planner to represent that. There was also discussion about making a
      gp_segment_id column implicitly available for functions, but that is also
      not implemented yet.
      
      The old behavior was that a function that if a function was marked as
      IMMUTABLE, it could be executed anywhere. Otherwise it was always executed
      on the master. For backwards-compatibility, this keeps that behavior for
      EXECUTE ON ANY (the default), so even if a function is marked as EXECUTE ON
      ANY, it will always be executed on the master unless it's IMMUTABLE.
      
      There is no support for these new options in ORCA. Using any ON MASTER or
      ON ALL SEGMENTS functions in a query cause ORCA to fall back. This is the
      same as with the prodataaccess='s' hack that this replaces, but now that it
      is more user-visible, it would be nice to teach ORCA about it.
      
      The new options are only supported for set-returning functions, because for
      a regular function marked as EXECUTE ON ALL SEGMENTS, it's not clear how
      the results should be combined. ON MASTER would probably be doable, but
      there's no need for that right now, so punt.
      
      Another restriction is that a function with ON ALL SEGMENTS or ON MASTER can
      only be used in the FROM clause, or in the target list of a simple SELECT
      with no FROM clause. So "SELECT func()" is accepted, but "SELECT func() FROM
      foo" is not. "SELECT * FROM func(), foo" works, however. EXECUTE ON ANY
      functions, which is the default, work the same as before.
      aa148d2a
    • B
      Fix multistage aggregation plan targetlists · 41640e69
      Bhuvnesh Chaudhary 提交于
      If there are aggregation queries with aliases same as the table actual
      columns and they are propagated further from subqueries and grouping is
      applied on the column alias it may result in inconsistent targetlists
      for aggregation plan causing crash.
      
      	CREATE TABLE t1 (a int) DISTRIBUTED RANDOMLY;
      	SELECT substr(a, 2) as a
      	FROM
      		(SELECT ('-'||a)::varchar as a
      			FROM (SELECT a FROM t1) t2
      		) t3
      	GROUP BY a;
      41640e69
  2. 20 9月, 2017 10 次提交
  3. 19 9月, 2017 8 次提交
  4. 18 9月, 2017 3 次提交
  5. 17 9月, 2017 2 次提交
    • H
      Convert WindowFrame to frameOptions + start + end · ebf9763c
      Heikki Linnakangas 提交于
      In GPDB, we have so far used a WindowFrame struct to represent the start
      and end window bound, in a ROWS/RANGE BETWEEN clause, while PostgreSQL
      uses the combination of  a frameOptions bitmask and start and end
      expressions. Refactor to replace the WindowFrame with the upstream
      representation.
      ebf9763c
    • H
      Hardcode the "frame maker" function for LEAD and LAG. · 686aab95
      Heikki Linnakangas 提交于
      This removes pg_window.winframemakerfunc column. It was only used for
      LEAD/LAG, and only in the Postgres planner. Hardcode the same special
      handling for LEAD/LAG in planwindow.c instead, based on winkind.
      
      This is one step in refactoring the planner and executor further, to
      replace the GPDB implementation of window functions with the upstream
      one.
      686aab95
  6. 16 9月, 2017 12 次提交
  7. 15 9月, 2017 3 次提交
    • H
      Make it possible to build without libbz2, also on non-Windows. · d6749c3c
      Heikki Linnakangas 提交于
      The bzip2 library is only used by the gfile/fstream code, used for external
      tables and gpfdist. The usage of bzip2 was in #ifndef WIN32 blocks, so it
      was only built on non-Windows systems.
      
      Instead of tying it to the platform, use a proper autoconf check and
      HAVE_LIBBZ2 flags. This makes it possible to build gpfdist with bzip2
      support on Windows, as well as building without bzip2 on non-Windows
      systems. That makes it easier to test the otherwise Windows-only codepaths
      on other platforms. --with-libbz2 is still the default, but you can now use
      --without-libbz2 if you wish.
      
      I'm sure that some regression tests will fail if you actually build the
      server without libbz2, but I'm not going to address that right now. We have
      similar problems with other features that are in principle optional, but
      cause some regression tests to fail.
      
      Also use "#ifdef HAVE_LIBZ" rather than "#ifndef WIN32" to enable/disable
      zlib support in gpfdist. Building the server still fails if you use
      --without-zlib, but at least you can build the client programs without
      zlib, also on non-Windows systems.
      
      Remove obsolete copy of bzlib.h from the repository while we're at it.
      d6749c3c
    • H
      Fix stanullfrac computation on column with all-wide values. · 90bcf3fd
      Heikki Linnakangas 提交于
      If a the sample of a column consists entirely of "too wide" values, which
      are left out of the sample when it's passed to the compute_stats function,
      we pass an empty sample to it. The default compute_stats gets confused by
      that, and computes the null fraction as 0 / 0 = NaN, so we end up storing
      NaN as stanullfrac.
      
      If all the values in the sample are wide values, then they're surely not
      NULLs, so the right thing to do is to store stanullfrac = 0. That is a
      bit non-linear with the normal compute_stats function, which effectively
      treats too wide values as not existing at all, which artificially inflates
      the null fraction. Another non-linear thing is that we store stawidth=1024
      in this special case, but the normal computation again ignores the wide
      values in computing stawidth. If we wanted to do something about that, we
      should adjust the normal computation to take those wide values better into
      account, but that's a different story, and now we at least won't store NaN
      in stanullfrac any longer.
      
      Fixes github issue #3259.
      90bcf3fd
    • H
      Fix test case after the change to ALTER TYPE SET DEFAULT ENCODING. · 30e50772
      Heikki Linnakangas 提交于
      Commit b4f125bd changed ALTER TYPE SET DEFAULT ENCODING to no longer
      accept SQL type aliases. A consequence of that is that "char" no longer
      meand "character varying", but actual "char" datatype. Change the tests
      to use the PostgreSQL name for that datatype, "bpchar".
      30e50772