Merge upto PostgreSQL 9.5.2 (730811c7d1600b92d4bcb91ac66d2206cf3a06ef)
authorPavan Deolasee <[email protected]>
Thu, 31 Mar 2016 10:50:05 +0000 (16:20 +0530)
committerPavan Deolasee <[email protected]>
Thu, 31 Mar 2016 10:50:05 +0000 (16:20 +0530)
70 files changed:
1  2 
configure
configure.in
contrib/hstore/expected/hstore.out
contrib/hstore/sql/hstore.sql
contrib/pg_stat_statements/pg_stat_statements.c
doc/bug.template
doc/src/sgml/datatype.sgml
doc/src/sgml/ddl.sgml
doc/src/sgml/func.sgml
doc/src/sgml/installation.sgml
doc/src/sgml/pgstattuple.sgml
doc/src/sgml/recovery-config.sgml
doc/src/sgml/ref/create_index.sgml
doc/src/sgml/ref/create_table.sgml
doc/src/sgml/ref/pg_ctl-ref.sgml
doc/src/sgml/runtime.sgml
doc/src/sgml/start.sgml
src/backend/access/transam/subtrans.c
src/backend/access/transam/xlog.c
src/backend/commands/trigger.c
src/backend/executor/nodeModifyTable.c
src/backend/main/main.c
src/backend/nodes/makefuncs.c
src/backend/optimizer/plan/planner.c
src/backend/parser/parse_coerce.c
src/backend/parser/parse_relation.c
src/backend/parser/parse_type.c
src/backend/postmaster/postmaster.c
src/backend/replication/logical/decode.c
src/backend/replication/logical/logicalfuncs.c
src/backend/replication/syncrep.c
src/backend/storage/buffer/bufmgr.c
src/backend/storage/file/fd.c
src/backend/storage/file/reinit.c
src/backend/utils/adt/json.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/cache/plancache.c
src/backend/utils/init/miscinit.c
src/backend/utils/init/postinit.c
src/backend/utils/misc/guc.c
src/backend/utils/mmgr/mcxt.c
src/backend/utils/time/snapmgr.c
src/bin/initdb/initdb.c
src/bin/pg_ctl/pg_ctl.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.h
src/bin/pgbench/pgbench.c
src/bin/psql/describe.c
src/bin/psql/tab-complete.c
src/include/catalog/pg_proc.h
src/include/nodes/primnodes.h
src/include/pg_config.h.in
src/include/pg_config.h.win32
src/include/utils/builtins.h
src/test/regress/expected/groupingsets.out
src/test/regress/expected/join.out
src/test/regress/expected/json.out
src/test/regress/expected/jsonb.out
src/test/regress/expected/rowsecurity.out
src/test/regress/expected/rowtypes.out
src/test/regress/expected/rules.out
src/test/regress/expected/timestamptz.out
src/test/regress/expected/updatable_views.out
src/test/regress/input/create_function_2.source
src/test/regress/output/create_function_2.source
src/test/regress/sql/join.sql
src/test/regress/sql/rowsecurity.sql
src/test/regress/sql/rowtypes.sql
src/test/regress/sql/timestamptz.sql
src/test/regress/sql/updatable_views.sql

diff --cc configure
index 2d108cb270fcf2f71b888b3c5cbc6f192694eb2c,3fa4f29fbaad0396bc11b5d1efa80c20176e3edf..8c38bcf99358bba896727e8c89320c15b5cb8288
+++ b/configure
@@@ -1,8 -1,8 +1,8 @@@
  #! /bin/sh
  # Guess values for system-dependent variables and create Makefiles.
- # Generated by GNU Autoconf 2.69 for PostgreSQL 9.5.0 (Postgres-XL 9.5r1beta2).
 -# Generated by GNU Autoconf 2.69 for PostgreSQL 9.5.2.
++# Generated by GNU Autoconf 2.69 for PostgreSQL 9.5.2 (Postgres-XL 9.5r1beta2).
  #
 -# Report bugs to <pgsql-bugs@postgresql.org>.
 +# Report bugs to <bugs@postgres-xl.org>.
  #
  #
  # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@@ -582,10 -582,9 +582,10 @@@ MAKEFLAGS
  # Identity of this package.
  PACKAGE_NAME='PostgreSQL'
  PACKAGE_TARNAME='postgresql'
- PACKAGE_VERSION='9.5.0 (Postgres-XL 9.5r1beta2)'
 -PACKAGE_VERSION='9.5.2'
 -PACKAGE_STRING='PostgreSQL 9.5.2'
 -PACKAGE_BUGREPORT='[email protected]'
++PACKAGE_VERSION='9.5.2 (Postgres-XL 9.5r1beta2)'
 +PACKAGE_XC_VERSION='9.5r1beta2'
- PACKAGE_STRING='PostgreSQL 9.5.0 (Postgres-XL 9.5r1beta2)'
++PACKAGE_STRING='PostgreSQL 9.5.2 (Postgres-XL 9.5r1beta2)'
 +PACKAGE_BUGREPORT='[email protected]'
  PACKAGE_URL=''
  
  ac_unique_file="src/backend/access/common/heaptuple.c"
@@@ -1399,7 -1395,7 +1399,7 @@@ if test "$ac_init_help" = "long"; the
    # Omit some internal or obsolete options to make the list less imposing.
    # This message is too long to be a string in the A/UX 3.1 sh.
    cat <<_ACEOF
- \`configure' configures PostgreSQL 9.5.0 (Postgres-XL 9.5r1beta2) to adapt to many kinds of systems.
 -\`configure' configures PostgreSQL 9.5.2 to adapt to many kinds of systems.
++\`configure' configures PostgreSQL 9.5.2 (Postgres-XL 9.5r1beta2) to adapt to many kinds of systems.
  
  Usage: $0 [OPTION]... [VAR=VALUE]...
  
  
  if test -n "$ac_init_help"; then
    case $ac_init_help in
-      short | recursive ) echo "Configuration of PostgreSQL 9.5.0 (Postgres-XL 9.5r1beta2):";;
 -     short | recursive ) echo "Configuration of PostgreSQL 9.5.2:";;
++     short | recursive ) echo "Configuration of PostgreSQL 9.5.2 (Postgres-XL 9.5r1beta2):";;
     esac
    cat <<\_ACEOF
  
  test -n "$ac_init_help" && exit $ac_status
  if $ac_init_version; then
    cat <<\_ACEOF
- PostgreSQL configure 9.5.0 (Postgres-XL 9.5r1beta2)
 -PostgreSQL configure 9.5.2
++PostgreSQL configure 9.5.2 (Postgres-XL 9.5r1beta2)
  generated by GNU Autoconf 2.69
  
  Copyright (C) 2012 Free Software Foundation, Inc.
@@@ -2325,7 -2321,7 +2325,7 @@@ cat >config.log <<_ACEO
  This file contains any messages produced by compilers while
  running configure, to aid debugging if configure makes a mistake.
  
- It was created by PostgreSQL $as_me 9.5.0 (Postgres-XL 9.5r1beta2), which was
 -It was created by PostgreSQL $as_me 9.5.2, which was
++It was created by PostgreSQL $as_me 9.5.2 (Postgres-XL 9.5r1beta2), which was
  generated by GNU Autoconf 2.69.  Invocation command line was
  
    $ $0 $@
@@@ -16192,7 -16195,7 +16245,7 @@@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wr
  # report actual input values of CONFIG_FILES etc. instead of their
  # values after options handling.
  ac_log="
- This file was extended by PostgreSQL $as_me 9.5.0 (Postgres-XL 9.5r1beta2), which was
 -This file was extended by PostgreSQL $as_me 9.5.2, which was
++This file was extended by PostgreSQL $as_me 9.5.2 (Postgres-XL 9.5r1beta2), which was
  generated by GNU Autoconf 2.69.  Invocation command line was
  
    CONFIG_FILES    = $CONFIG_FILES
@@@ -16262,7 -16265,7 +16315,7 @@@ _ACEO
  cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
  ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
  ac_cs_version="\\
- PostgreSQL config.status 9.5.0 (Postgres-XL 9.5r1beta2)
 -PostgreSQL config.status 9.5.2
++PostgreSQL config.status 9.5.2 (Postgres-XL 9.5r1beta2)
  configured by $0, generated by GNU Autoconf 2.69,
    with options \\"\$ac_cs_config\\"
  
diff --cc configure.in
index fa68ed53febbb62037d3099afacc3a6a4561d27d,91abcf771fab01f8a07ff5a9f44a3320cc0bb58b..5348eaee2168fc907051d56989ce51a688d3e058
@@@ -17,7 -17,7 +17,7 @@@ dnl Read the Autoconf manual for detail
  dnl
  m4_pattern_forbid(^PGAC_)dnl to catch undefined macros
  
- AC_INIT([PostgreSQL], [9.5.0 (Postgres-XL 9.5r1beta2)], [[email protected]])
 -AC_INIT([PostgreSQL], [9.5.2], [[email protected]])
++AC_INIT([PostgreSQL], [9.5.2 (Postgres-XL 9.5r1beta2)], [[email protected]])
  
  m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.69], [], [m4_fatal([Autoconf version 2.69 is required.
  Untested combinations of 'autoconf' and PostgreSQL versions are not
Simple merge
Simple merge
index faac584cad9550bec4966bcb633119bbb0273fbf,91bed7fdfa11eada2ebfe8dfb1cc8e10a078443d..b3434b251622bebe9bf20a71b48de07a830a057a
@@@ -27,7 -27,7 +27,7 @@@ System Configuration
  
    Operating System (example: Linux 2.4.18)    :
  
-   PostgreSQL version (example: PostgreSQL 9.5.0):  Postgres-XL 9.5r1beta2
 -  PostgreSQL version (example: PostgreSQL 9.5.2):  PostgreSQL 9.5.2
++  PostgreSQL version (example: PostgreSQL 9.5.2):  Postgres-XL 9.5r1beta2
  
    Compiler used (example: gcc 3.3.5)          :
  
Simple merge
index 0c350fbab37d1833da8162265076fa1300c4c523,2cd1c08944595e1abdfc51b11875dea229cfa62a..41bf79e5c28d5bc543b592e158ca21fa74545091
mode 100755,100644..100755
@@@ -737,14 -635,16 +728,24 @@@ CREATE TABLE example 
      usually best to follow it.
     </para>
  
 +   <para>
 +    As mentioned when discussing <type>UNIQUE</> constraint, the distribution column
 +    must be included in <type>PRIMARY KEY</type>.  Other restrictions
 +    apply to the <type>PRIMARY KEY</> as well.  When an expression is used on
 +    a <type>PRIMARY KEY</> constraint, this expression must contain
 +    the distribution column of its parent table. It cannot use other
 +    columns as well.
 +   </para>
+    <para>
+     Primary keys are useful both for
+     documentation purposes and for client applications.  For example,
+     a GUI application that allows modifying row values probably needs
+     to know the primary key of a table to be able to identify rows
+     uniquely.  There are also various ways in which the database system
+     makes use of a primary key if one has been declared; for example,
+     the primary key defines the default target column(s) for foreign keys
+     referencing its table.
+    </para>
    </sect2>
  
    <sect2 id="ddl-constraints-fk">
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 95182f63264c5d459012637c29b50a0cde8a84ef,cd234dbf4e3177e70e40de0242afede9b8d371ec..136d0a10ba0f3abd12ad1992c3fa70866a181baa
mode 100755,100644..100755
@@@ -544,16 -520,12 +542,18 @@@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORAR
       </para>
  
       <para>
-       The primary key constraint should name a set of columns that is
-       different from other sets of columns named by any unique
-       constraint defined for the same table.
+       <literal>PRIMARY KEY</literal> enforces the same data constraints as
+       a combination of <literal>UNIQUE</> and <literal>NOT NULL</>, but
+       identifying a set of columns as the primary key also provides metadata
+       about the design of the schema, since a primary key implies that other
+       tables can rely on this set of columns as a unique identifier for rows.
       </para>
 +
 +     <para>
 +      In <productname>Postgres-XL</>, if <command>DISTRIBUTE BY REPLICATION</> is not specified, the
 +      distribution key must be included in the set of primary key
 +      columns.
 +     </para>
      </listitem>
     </varlistentry>
  
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 53691f8342bb1b07301f3a19213fd826e00f9c14,9c080471626757f8e35539718c69143ab6959a7f..a8084699faef8faad7c24eb889290d905357d4a0
@@@ -134,10 -142,10 +142,13 @@@ LogicalDecodingProcessRecord(LogicalDec
                case RM_SPGIST_ID:
                case RM_BRIN_ID:
                case RM_COMMIT_TS_ID:
 +#ifdef PGXC 
 +              case RM_BARRIER_ID:
 +#endif
                case RM_REPLORIGIN_ID:
+                       /* just deal with xid, and done */
+                       ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(record),
+                                                                       buf.origptr);
                        break;
                case RM_NEXT_ID:
                        elog(ERROR, "unexpected RM_NEXT_ID rmgr_id: %u", (RmgrIds) XLogRecGetRmid(buf.record));
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 353e618c8e7cfb4460adf34ef3a49a9e6bd91364,5eefa74a61d84a6bb27d8344cbf9ff72660abad6..fb9a8e1fcef270f643368321f75eaa4e474fb66a
@@@ -424,10 -411,9 +427,12 @@@ CompleteCachedPlan(CachedPlanSource *pl
        plansource->parserSetupArg = parserSetupArg;
        plansource->cursor_options = cursor_options;
        plansource->fixed_result = fixed_result;
 +#ifdef PGXC
 +      //plansource->stmt_name = NULL;
 +#endif
        plansource->resultDesc = PlanCacheComputeResultDesc(querytree_list);
+       plansource->planUserId = GetUserId();
+       plansource->row_security_env = row_security;
  
        MemoryContextSwitchTo(oldcxt);
  
@@@ -602,34 -576,6 +607,23 @@@ RevalidateCachedQuery(CachedPlanSource 
                return NIL;
        }
  
-       /*
-        * If this is a new cached plan, then set the user id it was planned by
-        * and under what row security settings; these are needed to determine
-        * plan invalidation when RLS is involved.
-        */
-       if (!OidIsValid(plansource->planUserId))
-       {
-               plansource->planUserId = GetUserId();
-               plansource->row_security_env = row_security;
-       }
 +#ifdef XCP
 +      /*
 +       * In the raw_parse_tree is not available, there is no way the plan can be
 +       * revalidated and there must not be any need to do so. Trust the existing
 +       * plan
 +       *
 +       * XXX We should rather check this as an assertion, but currently
 +       * RemoteSubplan gets invalidated because of search_path changes as temp
 +       * namespace gets added in subsequent revalidation.
 +       */
 +      if (plansource->raw_parse_tree == NULL)
 +      {
 +              Assert(plansource->is_valid);
 +              return NIL;
 +      }
 +#endif
 +
        /*
         * If the query is currently valid, we should have a saved search_path ---
         * check to see if that matches the current environment.  If not, we want
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index a87eeb14ab5254a9fab970314489fa8504d7951b,d6f466d87883369feb08d745bace154bf76d1b98..fc494c973288f3f381e9a122cdfd1459ae07395e
@@@ -125,12 -124,8 +125,12 @@@ char             g_comment_end[10]
  
  static const CatalogId nilCatalogId = {0, 0};
  
 +#ifdef PGXC
 +static int    include_nodes = 0;
 +#endif
 +
  static void help(const char *progname);
- static void setup_connection(Archive *AH, DumpOptions *dopt,
+ static void setup_connection(Archive *AH,
                                 const char *dumpencoding, const char *dumpsnapshot,
                                 char *use_role);
  static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode);
Simple merge
Simple merge
Simple merge
Simple merge
index 14214df39f67a21817e2b6044693c5f1ef3a4bdb,5c58108bda99d1d032e971b81bf16890f9ecb5dd..7335670797379a60186ce10348fe385e1b2dd0aa
@@@ -5382,20 -5325,11 +5382,25 @@@ DESCR("get an individual replication or
  DATA(insert OID = 6014 ( pg_show_replication_origin_status PGNSP PGUID 12 1 100 0 0 f f f f f t v 0 0 2249 "" "{26,25,3220,3220}" "{o,o,o,o}" "{local_id, external_id, remote_lsn, local_lsn}" _null_ _null_ pg_show_replication_origin_status _null_ _null_ _null_ ));
  DESCR("get progress for all replication origins");
  
 +#ifdef USE_MODULE_MSGIDS
 +DATA(insert OID = 6015 ( pg_msgmodule_set PGNSP PGUID 12 1 1 0 0 f f f f t t i 4 0 16 "20 20 20 2275" _null_ _null_ _null_ _null_ _null_ pg_msgmodule_set _null_ _null_ _null_ ));
 +DESCR("set debugging level for module/file/msg");
 +DATA(insert OID = 6016 ( pg_msgmodule_change PGNSP PGUID 12 1 1 0 0 f f f f t t i 4 0 16 "20 20 20 20" _null_ _null_ _null_ _null_ _null_ pg_msgmodule_change _null_ _null_ _null_ ));
 +DESCR("change debugging level for module/file/msg");
 +DATA(insert OID = 6017 ( pg_msgmodule_enable PGNSP PGUID 12 1 1 0 0 f f f f t t i 1 0 16 "20" _null_ _null_ _null_ _null_ _null_ pg_msgmodule_enable _null_ _null_ _null_ ));
 +DESCR("pid to honour overriden log levels");
 +DATA(insert OID = 6018 ( pg_msgmodule_disable PGNSP PGUID 12 1 1 0 0 f f f f t t i 1 0 16 "20" _null_ _null_ _null_ _null_ _null_ pg_msgmodule_disable _null_ _null_ _null_ ));
 +DESCR("pid to ignore overriden log levels");
 +DATA(insert OID = 6019 ( pg_msgmodule_enable_all PGNSP PGUID 12 1 1 0 0 f f f f t t i 1 0 16 "16" _null_ _null_ _null_ _null_ _null_ pg_msgmodule_enable_all _null_ _null_ _null_ ));
 +DESCR("all current/future processes to honour overriden log levels");
 +DATA(insert OID = 6020 ( pg_msgmodule_disable_all PGNSP PGUID 12 1 1 0 0 f f f f t t 0 0 0 16 "" _null_ _null_ _null_ _null_ _null_ pg_msgmodule_disable_all _null_ _null_ _null_ ));
 +DESCR("all processes to ignore overriden log levels");
 +#endif
+ /* rls */
+ DATA(insert OID = 3298 (  row_security_active    PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 16 "26" _null_ _null_ _null_ _null_ _null_  row_security_active _null_ _null_ _null_ ));
+ DESCR("row security for current context active on table by table oid");
+ DATA(insert OID = 3299 (  row_security_active    PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 16 "25" _null_ _null_ _null_ _null_ _null_  row_security_active_name _null_ _null_ _null_ ));
+ DESCR("row security for current context active on table by table name");
  
  /*
   * Symbolic values for provolatile column: these indicate whether the result
Simple merge
Simple merge
index 75f3572c0e47038d308e155d3614c198f6be4d25,5b74b265f3f6eebeebb1b20a280ce0d452d59c6d..d20d86c424572acd7a194c41572cd43733142aec
  #define MEMSET_LOOP_LIMIT 1024
  
  /* Define to the address where bug reports for this package should be sent. */
 -#define PACKAGE_BUGREPORT "p[email protected]"
 +#define PACKAGE_BUGREPORT "p[email protected]"
  
  /* Define to the full name of this package. */
 -#define PACKAGE_NAME "PostgreSQL"
 +#define PACKAGE_NAME "Postgres-XL"
  
  /* Define to the full name and version of this package. */
 -#define PACKAGE_STRING "PostgreSQL 9.5.2"
 +#define PACKAGE_STRING "Postgres-XL 9.5r1beta2"
  
  /* Define to the version of this package. */
- #define PACKAGE_VERSION "9.5.0"
+ #define PACKAGE_VERSION "9.5.2"
  
  /* Define to the name of a signed 128-bit integer type. */
  #undef PG_INT128_TYPE
  #define PG_INT64_TYPE long long int
  
  /* PostgreSQL version as a string */
- #define PG_VERSION "9.5.0"
+ #define PG_VERSION "9.5.2"
  
  /* PostgreSQL version as a number */
- #define PG_VERSION_NUM 90500
+ #define PG_VERSION_NUM 90502
  
  /* Define to the one symbol short name of this package. */
 -#define PACKAGE_TARNAME "postgresql"
 +#define PACKAGE_TARNAME "postgres-xl"
 +
 +/* Postgres-XC version as a string */
 +#define PGXC_VERSION "1.1devel"
 +
 +/* Postgres-XC version as a number */
 +#define PGXC_VERSION_NUM 10100
  
  /* Define to the name of the default PostgreSQL service principal in Kerberos.
     (--with-krb-srvnam=NAME) */
Simple merge
index 0cb9dea220a166202895b36d3ec41f792722a47c,260ccd52c87b03831133d1679e28221c9f0aca84..56de3449fd4d0ae245f2b2d8870a566edf26ad77
@@@ -197,7 -578,89 +197,42 @@@ ERROR:  GROUPING SETS, ROLLUP or CUBE i
  select ten, sum(distinct four) from onek a
  group by grouping sets((ten,four),(ten))
  having exists (select 1 from onek b where sum(distinct a.four) = b.four);
 - ten | sum 
 ------+-----
 -   0 |   0
 -   0 |   2
 -   0 |   2
 -   1 |   1
 -   1 |   3
 -   2 |   0
 -   2 |   2
 -   2 |   2
 -   3 |   1
 -   3 |   3
 -   4 |   0
 -   4 |   2
 -   4 |   2
 -   5 |   1
 -   5 |   3
 -   6 |   0
 -   6 |   2
 -   6 |   2
 -   7 |   1
 -   7 |   3
 -   8 |   0
 -   8 |   2
 -   8 |   2
 -   9 |   1
 -   9 |   3
 -(25 rows)
 -
 +ERROR:  GROUPING SETS, ROLLUP or CUBE is not yet supported
+ -- Tests around pushdown of HAVING clauses, partially testing against previous bugs
+ select a,count(*) from gstest2 group by rollup(a) order by a;
 - a | count 
 ----+-------
 - 1 |     8
 - 2 |     1
 -   |     9
 -(3 rows)
 -
++ERROR:  GROUPING SETS, ROLLUP or CUBE is not yet supported
+ select a,count(*) from gstest2 group by rollup(a) having a is distinct from 1 order by a;
 - a | count 
 ----+-------
 - 2 |     1
 -   |     9
 -(2 rows)
 -
++ERROR:  GROUPING SETS, ROLLUP or CUBE is not yet supported
+ explain (costs off)
+   select a,count(*) from gstest2 group by rollup(a) having a is distinct from 1 order by a;
 -            QUERY PLAN            
 -----------------------------------
 - GroupAggregate
 -   Group Key: a
 -   Group Key: ()
 -   Filter: (a IS DISTINCT FROM 1)
 -   ->  Sort
 -         Sort Key: a
 -         ->  Seq Scan on gstest2
 -(7 rows)
 -
++ERROR:  GROUPING SETS, ROLLUP or CUBE is not yet supported
+ select v.c, (select count(*) from gstest2 group by () having v.c)
+   from (values (false),(true)) v(c) order by v.c;
+  c | count 
+ ---+-------
+  f |      
+  t |     9
+ (2 rows)
+ explain (costs off)
+   select v.c, (select count(*) from gstest2 group by () having v.c)
+     from (values (false),(true)) v(c) order by v.c;
 -                        QUERY PLAN                         
 ------------------------------------------------------------
++                               QUERY PLAN                                
++-------------------------------------------------------------------------
+  Sort
+    Sort Key: "*VALUES*".column1
+    ->  Values Scan on "*VALUES*"
+          SubPlan 1
+            ->  Aggregate
+                  Group Key: ()
+                  Filter: "*VALUES*".column1
 -                 ->  Result
 -                       One-Time Filter: "*VALUES*".column1
 -                       ->  Seq Scan on gstest2
 -(10 rows)
++                 ->  Remote Subquery Scan on all (datanode_1,datanode_2)
++                       ->  Aggregate
++                             ->  Result
++                                   One-Time Filter: "*VALUES*".column1
++                                   ->  Seq Scan on gstest2
++(12 rows)
  -- HAVING with GROUPING queries
  select ten, grouping(ten) from onek
  group by grouping sets(ten) having grouping(ten) >= 0
index 5c579e9c3abca356f8ac520c07eded4a61d0b5af,bade392394644ed5057a7c2c7d445e85415b4154..adedcd8b422de8c6dd4c5b6945c877b3bb242881
@@@ -2374,6 -2331,34 +2374,40 @@@ select tt1.*, tt2.* from tt2 right joi
  reset enable_hashjoin;
  reset enable_nestloop;
  --
 -                         QUERY PLAN                         
 -------------------------------------------------------------
+ -- regression test for bug #13908 (hash join with skew tuples & nbatch increase)
+ --
+ set work_mem to '64kB';
+ set enable_mergejoin to off;
+ explain (costs off)
+ select count(*) from tenk1 a, tenk1 b
+   where a.hundred = b.thousand and (b.fivethous % 10) < 10;
 -   ->  Hash Join
 -         Hash Cond: (a.hundred = b.thousand)
 -         ->  Index Only Scan using tenk1_hundred on tenk1 a
 -         ->  Hash
 -               ->  Seq Scan on tenk1 b
 -                     Filter: ((fivethous % 10) < 10)
 -(7 rows)
++                                    QUERY PLAN                                     
++-----------------------------------------------------------------------------------
+  Aggregate
++   ->  Remote Subquery Scan on all (datanode_1,datanode_2)
++         ->  Aggregate
++               ->  Hash Join
++                     Hash Cond: (a.hundred = b.thousand)
++                     ->  Remote Subquery Scan on all (datanode_1,datanode_2)
++                           Distribute results by H: hundred
++                           ->  Seq Scan on tenk1 a
++                     ->  Hash
++                           ->  Remote Subquery Scan on all (datanode_1,datanode_2)
++                                 Distribute results by H: thousand
++                                 ->  Seq Scan on tenk1 b
++                                       Filter: ((fivethous % 10) < 10)
++(13 rows)
+ select count(*) from tenk1 a, tenk1 b
+   where a.hundred = b.thousand and (b.fivethous % 10) < 10;
+  count  
+ --------
+  100000
+ (1 row)
+ reset work_mem;
+ reset enable_mergejoin;
+ --
  -- regression test for 8.2 bug with improper re-ordering of left joins
  --
  create temp table tt3(f1 int, f2 text);
Simple merge
Simple merge
index 322ab47c37d1f54cf14bf61d54abf02820a0ebb9,067aa8d5fb738e81fbef1597ada7fa742b18d83a..626a6f6edf00612094d489da2896c519f3401523
@@@ -2075,27 -2334,37 +2075,43 @@@ GRANT SELECT ON t1 TO rls_regress_user1
  CREATE POLICY p1 ON t1 TO rls_regress_user1 USING ((a % 2) = 0);
  CREATE POLICY p2 ON t1 TO rls_regress_user2 USING ((a % 4) = 0);
  ALTER TABLE t1 ENABLE ROW LEVEL SECURITY;
+ -- Prepare as rls_regress_user1
  SET ROLE rls_regress_user1;
  PREPARE role_inval AS SELECT * FROM t1;
+ -- Check plan
  EXPLAIN (COSTS OFF) EXECUTE role_inval;
 -       QUERY PLAN        
 --------------------------
 - Seq Scan on t1
 -   Filter: ((a % 2) = 0)
 -(2 rows)
 +            QUERY PLAN            
 +----------------------------------
 + Remote Fast Query Execution
 +   Node/s: datanode_1, datanode_2
 +   ->  Seq Scan on t1
 +         Filter: ((a % 2) = 0)
 +(4 rows)
  
+ -- Change to rls_regress_user2
  SET ROLE rls_regress_user2;
+ -- Check plan- should be different
  EXPLAIN (COSTS OFF) EXECUTE role_inval;
 -       QUERY PLAN        
 --------------------------
 - Seq Scan on t1
 -   Filter: ((a % 4) = 0)
 -(2 rows)
 +            QUERY PLAN            
 +----------------------------------
 + Remote Fast Query Execution
 +   Node/s: datanode_1, datanode_2
 +   ->  Seq Scan on t1
 +         Filter: ((a % 4) = 0)
 +(4 rows)
  
 -       QUERY PLAN        
 --------------------------
 - Seq Scan on t1
 -   Filter: ((a % 2) = 0)
 -(2 rows)
+ -- Change back to rls_regress_user1
+ SET ROLE rls_regress_user1;
+ -- Check plan- should be back to original
+ EXPLAIN (COSTS OFF) EXECUTE role_inval;
++            QUERY PLAN            
++----------------------------------
++ Remote Fast Query Execution
++   Node/s: datanode_1, datanode_2
++   ->  Seq Scan on t1
++         Filter: ((a % 2) = 0)
++(4 rows)
  --
  -- CTE and RLS
  --
index 19a0e7700ec45f441a414760d97c78cf5805ecf8,3630ef4943842ba4110ba1e29b861b8a60d7ff3d..7aff45e78e5e860a58b3e59d46566a99016ccd50
@@@ -283,6 -278,29 +283,30 @@@ order by thousand, tenthous
        999 |     9999
  (25 rows)
  
 -                       QUERY PLAN                       
 ---------------------------------------------------------
 - Index Only Scan using test_table_a_b_idx on test_table
 -   Index Cond: (ROW(a, b) > ROW('a'::text, 'a'::text))
 -(2 rows)
+ -- Test case for bug #14010: indexed row comparisons fail with nulls
+ create temp table test_table (a text, b text);
+ insert into test_table values ('a', 'b');
+ insert into test_table select 'a', null from generate_series(1,1000);
+ insert into test_table values ('b', 'a');
+ create index on test_table (a,b);
+ set enable_sort = off;
+ explain (costs off)
+ select a,b from test_table where (a,b) > ('a','a') order by a,b;
++                          QUERY PLAN                          
++--------------------------------------------------------------
++ Remote Subquery Scan on all (datanode_1,datanode_2)
++   ->  Index Only Scan using test_table_a_b_idx on test_table
++         Index Cond: (ROW(a, b) > ROW('a'::text, 'a'::text))
++(3 rows)
+ select a,b from test_table where (a,b) > ('a','a') order by a,b;
+  a | b 
+ ---+---
+  a | b
+  b | a
+ (2 rows)
+ reset enable_sort;
  -- Check row comparisons with IN
  select * from int8_tbl i8 where i8 in (row(123,456));  -- fail, type mismatch
  ERROR:  cannot compare dissimilar column types bigint and integer at record column 1
Simple merge
index 26b4a837c840395ea12571ebc9f2da6e8ce3aa34,50661bb5929990953f35dcbe5fa7925e19783952..bba95d40a3e6e9fc5b61616a647e6c470941679a
@@@ -1668,18 -1671,61 +1668,69 @@@ SELECT '' AS to_char_11, to_char(d1, 'F
              | 1998 998 98 8 1 3 3
              | 1999 999 99 9 52 362 5
              | 1999 999 99 9 52 363 6
 +            | 2000 0 0 0 11 73 3
 +            | 2000 0 0 0 11 73 3
 +            | 2000 0 0 0 11 73 3
 +            | 2000 0 0 0 11 73 3
 +            | 2000 0 0 0 11 73 3
              | 2000 0 0 0 52 364 7
              | 2001 1 1 1 1 1 1
 +            | 2001 1 1 1 38 265 6
 +            | 2097 97 97 7 7 48 6
 +            | 
  (66 rows)
  
+ -- Check OF with various zone offsets, particularly fractional hours
+ SET timezone = '00:00';
+ SELECT to_char(now(), 'OF');
+  to_char 
+ ---------
+  +00
+ (1 row)
+ SET timezone = '+02:00';
+ SELECT to_char(now(), 'OF');
+  to_char 
+ ---------
+  -02
+ (1 row)
+ SET timezone = '-13:00';
+ SELECT to_char(now(), 'OF');
+  to_char 
+ ---------
+  +13
+ (1 row)
+ SET timezone = '-00:30';
+ SELECT to_char(now(), 'OF');
+  to_char 
+ ---------
+  +00:30
+ (1 row)
+ SET timezone = '00:30';
+ SELECT to_char(now(), 'OF');
+  to_char 
+ ---------
+  -00:30
+ (1 row)
+ SET timezone = '-04:30';
+ SELECT to_char(now(), 'OF');
+  to_char 
+ ---------
+  +04:30
+ (1 row)
+ SET timezone = '04:30';
+ SELECT to_char(now(), 'OF');
+  to_char 
+ ---------
+  -04:30
+ (1 row)
+ RESET timezone;
  CREATE TABLE TIMESTAMPTZ_TST (a int , b timestamptz);
  -- Test year field value with len > 4
  INSERT INTO TIMESTAMPTZ_TST VALUES(1, 'Sat Mar 12 23:58:48 1000 IST');
index fa35c55caae3d1b3bffb781c52a1596e4d5da59f,c5dfbb5dee8325dabb828d09e1abf7df64d5f4dd..2b7356be8d56f262f4caddd4bf8072feae5507cb
@@@ -2374,3 -2420,42 +2374,47 @@@ DROP VIEW vx1
  DROP TABLE tx1;
  DROP TABLE tx2;
  DROP TABLE tx3;
 -ERROR:  new row violates check option for view "v1"
 -DETAIL:  Failing row contains (-1, ONE, 10).
+ --
+ -- Test handling of vars from correlated subqueries in quals from outer
+ -- security barrier views, per bug #13988
+ --
+ CREATE TABLE t1 (a int, b text, c int);
+ INSERT INTO t1 VALUES (1, 'one', 10);
+ CREATE TABLE t2 (cc int);
+ INSERT INTO t2 VALUES (10), (20);
+ CREATE VIEW v1 WITH (security_barrier = true) AS
+   SELECT * FROM t1 WHERE (a > 0)
+   WITH CHECK OPTION;
+ CREATE VIEW v2 WITH (security_barrier = true) AS
+   SELECT * FROM v1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.cc = v1.c)
+   WITH CHECK OPTION;
+ INSERT INTO v2 VALUES (2, 'two', 20); -- ok
+ INSERT INTO v2 VALUES (-2, 'minus two', 20); -- not allowed
+ ERROR:  new row violates check option for view "v1"
+ DETAIL:  Failing row contains (-2, minus two, 20).
+ INSERT INTO v2 VALUES (3, 'three', 30); -- not allowed
+ ERROR:  new row violates check option for view "v2"
+ DETAIL:  Failing row contains (3, three, 30).
+ UPDATE v2 SET b = 'ONE' WHERE a = 1; -- ok
++ERROR:  could not plan this distributed update
++DETAIL:  correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+ UPDATE v2 SET a = -1 WHERE a = 1; -- not allowed
 -ERROR:  new row violates check option for view "v2"
 -DETAIL:  Failing row contains (1, ONE, 30).
++ERROR:  could not plan this distributed update
++DETAIL:  correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+ UPDATE v2 SET c = 30 WHERE a = 1; -- not allowed
 - 1 | ONE | 10
 -(1 row)
++ERROR:  could not plan this distributed update
++DETAIL:  correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
+ DELETE FROM v2 WHERE a = 2; -- ok
++ERROR:  could not plan this distributed delete
++DETAIL:  correlated or complex DELETE is currently not supported in Postgres-XL.
+ SELECT * FROM v2;
+  a |  b  | c  
+ ---+-----+----
++ 1 | one | 10
++ 2 | two | 20
++(2 rows)
+ DROP VIEW v2;
+ DROP VIEW v1;
+ DROP TABLE t2;
+ DROP TABLE t1;
Simple merge
Simple merge
Simple merge
index f1cd872242f9d9e5bd76c5291dd600bde7d5ae64,5e52f5f0c15fd4b12b20ca3e7c1039b2c398655e..a79ace481f07e4027b31c9eb812ed93324102c45
@@@ -205,42 -205,59 +205,59 @@@ SELECT '' AS "54", d1 as timestamptz
  SELECT '' AS "54", d1 as timestamptz,
     date_part( 'isoyear', d1) AS isoyear, date_part( 'week', d1) AS week,
     date_part( 'dow', d1) AS dow
 -   FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
 +   FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01' ORDER BY d1;
  
  -- TO_CHAR()
 -SELECT '' AS to_char_1, to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon')
 -   FROM TIMESTAMPTZ_TBL;
 -
 +SELECT '' AS to_char_1, to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon') 
 +   FROM TIMESTAMPTZ_TBL ORDER BY d1;
 +      
  SELECT '' AS to_char_2, to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth FMRM')
 -   FROM TIMESTAMPTZ_TBL;
 +   FROM TIMESTAMPTZ_TBL ORDER BY d1;  
  
  SELECT '' AS to_char_3, to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J')
 -   FROM TIMESTAMPTZ_TBL;
 -
 -SELECT '' AS to_char_4, to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM FMWW FMDDD FMDD FMD FMJ')
 -   FROM TIMESTAMPTZ_TBL;
 -
 -SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS')
 -   FROM TIMESTAMPTZ_TBL;
 -
 -SELECT '' AS to_char_6, to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between quote marks\\""')
 -   FROM TIMESTAMPTZ_TBL;
 -
 +   FROM TIMESTAMPTZ_TBL ORDER BY d1;
 +      
 +SELECT '' AS to_char_4, to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM FMWW FMDDD FMDD FMD FMJ') 
 +   FROM TIMESTAMPTZ_TBL ORDER BY d1;  
 +      
 +SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS') 
 +   FROM TIMESTAMPTZ_TBL ORDER BY d1;
 +
 +SELECT '' AS to_char_6, to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between quote marks\\""') 
 +   FROM TIMESTAMPTZ_TBL ORDER BY d1;          
 +              
  SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS')
 -   FROM TIMESTAMPTZ_TBL;
 -
 -SELECT '' AS to_char_8, to_char(d1, 'YYYYTH YYYYth Jth')
 -   FROM TIMESTAMPTZ_TBL;
 +   FROM TIMESTAMPTZ_TBL ORDER BY d1;          
  
 -SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. HH:MI:SS p.m. HH:MI:SS pm')
 -   FROM TIMESTAMPTZ_TBL;
 +SELECT '' AS to_char_8, to_char(d1, 'YYYYTH YYYYth Jth') 
 +   FROM TIMESTAMPTZ_TBL ORDER BY d1;
 +  
 +SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. HH:MI:SS p.m. HH:MI:SS pm') 
 +   FROM TIMESTAMPTZ_TBL ORDER BY d1;   
  
  SELECT '' AS to_char_10, to_char(d1, 'IYYY IYY IY I IW IDDD ID')
 -   FROM TIMESTAMPTZ_TBL;
 +   FROM TIMESTAMPTZ_TBL ORDER BY d1;
  
  SELECT '' AS to_char_11, to_char(d1, 'FMIYYY FMIYY FMIY FMI FMIW FMIDDD FMID')
 -   FROM TIMESTAMPTZ_TBL;
 +   FROM TIMESTAMPTZ_TBL ORDER BY d1;
  
+ -- Check OF with various zone offsets, particularly fractional hours
+ SET timezone = '00:00';
+ SELECT to_char(now(), 'OF');
+ SET timezone = '+02:00';
+ SELECT to_char(now(), 'OF');
+ SET timezone = '-13:00';
+ SELECT to_char(now(), 'OF');
+ SET timezone = '-00:30';
+ SELECT to_char(now(), 'OF');
+ SET timezone = '00:30';
+ SELECT to_char(now(), 'OF');
+ SET timezone = '-04:30';
+ SELECT to_char(now(), 'OF');
+ SET timezone = '04:30';
+ SELECT to_char(now(), 'OF');
+ RESET timezone;
  CREATE TABLE TIMESTAMPTZ_TST (a int , b timestamptz);
  
  -- Test year field value with len > 4