From: Pavan Deolasee Date: Thu, 31 Mar 2016 10:50:05 +0000 (+0530) Subject: Merge upto PostgreSQL 9.5.2 (730811c7d1600b92d4bcb91ac66d2206cf3a06ef) X-Git-Tag: XL9_5_R1~24 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=53f27d860eda2ebf67c7a054487f136572823aa2;p=postgres-xl.git Merge upto PostgreSQL 9.5.2 (730811c7d1600b92d4bcb91ac66d2206cf3a06ef) --- 53f27d860eda2ebf67c7a054487f136572823aa2 diff --cc configure index 2d108cb270,3fa4f29fba..8c38bcf993 --- a/configure +++ 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 . +# Report bugs to . # # # 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='pgsql-bugs@postgresql.org' ++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='bugs@postgres-xl.org' 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]... @@@ -1464,7 -1460,7 +1464,7 @@@ f 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 @@@ -1614,7 -1610,7 +1614,7 @@@ f 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 fa68ed53fe,91abcf771f..5348eaee21 --- a/configure.in +++ b/configure.in @@@ -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)], [bugs@postgres-xl.org]) -AC_INIT([PostgreSQL], [9.5.2], [pgsql-bugs@postgresql.org]) ++AC_INIT([PostgreSQL], [9.5.2 (Postgres-XL 9.5r1beta2)], [bugs@postgres-xl.org]) 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 diff --cc doc/bug.template index faac584cad,91bed7fdfa..b3434b2516 --- a/doc/bug.template +++ b/doc/bug.template @@@ -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) : diff --cc doc/src/sgml/ddl.sgml index 0c350fbab3,2cd1c08944..41bf79e5c2 mode 100755,100644..100755 --- a/doc/src/sgml/ddl.sgml +++ b/doc/src/sgml/ddl.sgml @@@ -737,14 -635,16 +728,24 @@@ CREATE TABLE example usually best to follow it. + + As mentioned when discussing UNIQUE constraint, the distribution column + must be included in PRIMARY KEY. Other restrictions + apply to the PRIMARY KEY as well. When an expression is used on + a PRIMARY KEY constraint, this expression must contain + the distribution column of its parent table. It cannot use other + columns as well. + + + 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. + diff --cc doc/src/sgml/ref/create_table.sgml index 95182f6326,cd234dbf4e..136d0a10ba mode 100755,100644..100755 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@@ -544,16 -520,12 +542,18 @@@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORAR - 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. + PRIMARY KEY enforces the same data constraints as + a combination of UNIQUE and 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. + + + In Postgres-XL, if DISTRIBUTE BY REPLICATION is not specified, the + distribution key must be included in the set of primary key + columns. + diff --cc src/backend/replication/logical/decode.c index 53691f8342,9c08047162..a8084699fa --- a/src/backend/replication/logical/decode.c +++ b/src/backend/replication/logical/decode.c @@@ -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)); diff --cc src/backend/utils/cache/plancache.c index 353e618c8e,5eefa74a61..fb9a8e1fce --- a/src/backend/utils/cache/plancache.c +++ b/src/backend/utils/cache/plancache.c @@@ -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; } +#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 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; - } - /* * 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 diff --cc src/bin/pg_dump/pg_dump.c index a87eeb14ab,d6f466d878..fc494c9732 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@@ -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); diff --cc src/include/catalog/pg_proc.h index 14214df39f,5c58108bda..7335670797 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@@ -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 diff --cc src/include/pg_config.h.win32 index 75f3572c0e,5b74b265f3..d20d86c424 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@@ -557,16 -557,16 +557,16 @@@ #define MEMSET_LOOP_LIMIT 1024 /* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "pgsql-bugs@postgresql.org" +#define PACKAGE_BUGREPORT "postgres-xl-bugs@lists.sourceforge.net" /* 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 @@@ -575,19 -575,13 +575,19 @@@ #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) */ diff --cc src/test/regress/expected/groupingsets.out index 0cb9dea220,260ccd52c8..56de3449fd --- a/src/test/regress/expected/groupingsets.out +++ b/src/test/regress/expected/groupingsets.out @@@ -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 diff --cc src/test/regress/expected/join.out index 5c579e9c3a,bade392394..adedcd8b42 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@@ -2374,6 -2331,34 +2374,40 @@@ select tt1.*, tt2.* from tt2 right joi reset enable_hashjoin; reset enable_nestloop; -- + -- 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; - QUERY PLAN ------------------------------------------------------------- ++ QUERY PLAN ++----------------------------------------------------------------------------------- + Aggregate - -> 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) ++ -> 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); diff --cc src/test/regress/expected/rowsecurity.out index 322ab47c37,067aa8d5fb..626a6f6edf --- a/src/test/regress/expected/rowsecurity.out +++ b/src/test/regress/expected/rowsecurity.out @@@ -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) + -- 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 -------------------------- - 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) + -- -- CTE and RLS -- diff --cc src/test/regress/expected/rowtypes.out index 19a0e7700e,3630ef4943..7aff45e78e --- a/src/test/regress/expected/rowtypes.out +++ b/src/test/regress/expected/rowtypes.out @@@ -283,6 -278,29 +283,30 @@@ order by thousand, tenthous 999 | 9999 (25 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 --------------------------------------------------------- - Index Only Scan using test_table_a_b_idx on test_table - Index Cond: (ROW(a, b) > ROW('a'::text, 'a'::text)) -(2 rows) ++ 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 diff --cc src/test/regress/expected/timestamptz.out index 26b4a837c8,50661bb592..bba95d40a3 --- a/src/test/regress/expected/timestamptz.out +++ b/src/test/regress/expected/timestamptz.out @@@ -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'); diff --cc src/test/regress/expected/updatable_views.out index fa35c55caa,c5dfbb5dee..2b7356be8d --- a/src/test/regress/expected/updatable_views.out +++ b/src/test/regress/expected/updatable_views.out @@@ -2374,3 -2420,42 +2374,47 @@@ DROP VIEW vx1 DROP TABLE tx1; DROP TABLE tx2; DROP TABLE tx3; + -- + -- 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 "v1" -DETAIL: Failing row contains (-1, ONE, 10). ++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 -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. + 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 -(1 row) ++ 1 | one | 10 ++ 2 | two | 20 ++(2 rows) + + DROP VIEW v2; + DROP VIEW v1; + DROP TABLE t2; + DROP TABLE t1; diff --cc src/test/regress/sql/timestamptz.sql index f1cd872242,5e52f5f0c1..a79ace481f --- a/src/test/regress/sql/timestamptz.sql +++ b/src/test/regress/sql/timestamptz.sql @@@ -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