From: Pavan Deolasee Date: Tue, 25 Sep 2018 11:04:43 +0000 (+0530) Subject: Merge tag 'REL_10_5' into XL_10_STABLE X-Git-Tag: XL_10_R1~37 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=df08ce64148bf232dec075f12e057945c93f4ffa;p=postgres-xl.git Merge tag 'REL_10_5' into XL_10_STABLE --- df08ce64148bf232dec075f12e057945c93f4ffa diff --cc configure index d95dbce046,25fb1c7adb..6a125c44f4 --- 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 10.3 (Postgres-XL 10r1beta1). -# Generated by GNU Autoconf 2.69 for PostgreSQL 10.5. ++# Generated by GNU Autoconf 2.69 for PostgreSQL 10.5 (Postgres-XL 10r1beta1). # -# 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='10.3 (Postgres-XL 10r1beta1)' -PACKAGE_VERSION='10.5' -PACKAGE_STRING='PostgreSQL 10.5' -PACKAGE_BUGREPORT='pgsql-bugs@postgresql.org' ++PACKAGE_VERSION='10.5 (Postgres-XL 10r1beta1)' +PACKAGE_XC_VERSION='10r1beta1' - PACKAGE_STRING='PostgreSQL 10.3 (Postgres-XL 10r1beta1)' ++PACKAGE_STRING='PostgreSQL 10.5 (Postgres-XL 10r1beta1)' +PACKAGE_BUGREPORT='bugs@postgres-xl.org' PACKAGE_URL='' ac_unique_file="src/backend/access/common/heaptuple.c" @@@ -1413,7 -1409,7 +1413,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 10.3 (Postgres-XL 10r1beta1) to adapt to many kinds of systems. -\`configure' configures PostgreSQL 10.5 to adapt to many kinds of systems. ++\`configure' configures PostgreSQL 10.5 (Postgres-XL 10r1beta1) to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@@ -1478,7 -1474,7 +1478,7 @@@ f if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of PostgreSQL 10.3 (Postgres-XL 10r1beta1):";; - short | recursive ) echo "Configuration of PostgreSQL 10.5:";; ++ short | recursive ) echo "Configuration of PostgreSQL 10.5 (Postgres-XL 10r1beta1):";; esac cat <<\_ACEOF @@@ -1637,7 -1633,7 +1637,7 @@@ f test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF - PostgreSQL configure 10.3 (Postgres-XL 10r1beta1) -PostgreSQL configure 10.5 ++PostgreSQL configure 10.5 (Postgres-XL 10r1beta1) generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@@ -2348,7 -2344,7 +2348,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 10.3 (Postgres-XL 10r1beta1), which was -It was created by PostgreSQL $as_me 10.5, which was ++It was created by PostgreSQL $as_me 10.5 (Postgres-XL 10r1beta1), which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@@ -17469,7 -17521,7 +17571,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 10.3 (Postgres-XL 10r1beta1), which was -This file was extended by PostgreSQL $as_me 10.5, which was ++This file was extended by PostgreSQL $as_me 10.5 (Postgres-XL 10r1beta1), which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@@ -17539,7 -17591,7 +17641,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 10.3 (Postgres-XL 10r1beta1) -PostgreSQL config.status 10.5 ++PostgreSQL config.status 10.5 (Postgres-XL 10r1beta1) configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --cc configure.in index 4e47c23ff5,5274865755..b1e7a4b51f --- 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], [10.3 (Postgres-XL 10r1beta1)], [bugs@postgres-xl.org]) -AC_INIT([PostgreSQL], [10.5], [pgsql-bugs@postgresql.org]) ++AC_INIT([PostgreSQL], [10.5 (Postgres-XL 10r1beta1)], [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 47a592a7ee,b3c9f0d7eb..bc382a4d8f --- 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 10.3): Postgres-XL 10r1beta1 - PostgreSQL version (example: PostgreSQL 10.5): PostgreSQL 10.5 ++ PostgreSQL version (example: PostgreSQL 10.5): Postgres-XL 10r1beta1 Compiler used (example: gcc 3.3.5) : diff --cc doc/src/sgml/ddl.sgml index 666dcda396,13a1001761..5b4fe1cd5d mode 100755,100644..100755 --- a/doc/src/sgml/ddl.sgml +++ b/doc/src/sgml/ddl.sgml diff --cc doc/src/sgml/ref/create_table.sgml index ec23959054,d52a3c49d6..846e4b36a6 mode 100755,100644..100755 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml diff --cc doc/src/sgml/ref/declare.sgml index ce4644d6c2,864c3d75f7..09e56f0a39 mode 100755,100644..100755 --- a/doc/src/sgml/ref/declare.sgml +++ b/doc/src/sgml/ref/declare.sgml diff --cc doc/src/sgml/ref/fetch.sgml index 6507361808,d8784e537f..edee457c91 mode 100755,100644..100755 --- a/doc/src/sgml/ref/fetch.sgml +++ b/doc/src/sgml/ref/fetch.sgml diff --cc src/Makefile.global.in index e027262993,d1b8e4fede..f084b2ffbe --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@@ -274,19 -273,26 +274,28 @@@ UUID_EXTRA_OBJS = @UUID_EXTRA_OBJS LD = @LD@ with_gnu_ld = @with_gnu_ld@ - # We want -L for libpgport.a and libpgcommon.a to be first in LDFLAGS. We - # also need LDFLAGS to be a "recursively expanded" variable, else adjustments - # to rpathdir don't work right. So we must NOT do LDFLAGS := something, - # meaning this has to be done first and elsewhere we must only do LDFLAGS += - # something. + # It's critical that within LDFLAGS, all -L switches pointing to build-tree + # directories come before any -L switches pointing to external directories. + # Otherwise it's possible for, e.g., a platform-provided copy of libpq.so + # to get linked in place of the one we've built. Therefore we adopt the + # convention that the first component of LDFLAGS is an extra variable + # LDFLAGS_INTERNAL, and -L and -l switches for PG's own libraries must be + # put into LDFLAGS_INTERNAL, so they will appear ahead of those for external + # libraries. + # + # We need LDFLAGS and LDFLAGS_INTERNAL to be "recursively expanded" variables, + # else adjustments to, e.g., rpathdir don't work right. So we must NOT do + # "LDFLAGS := something" anywhere, ditto for LDFLAGS_INTERNAL. + # These initial assignments must be "=" type, and elsewhere we must only do + # "LDFLAGS += something" or "LDFLAGS_INTERNAL += something". +# PGXC_BEGIN ifdef PGXS - LDFLAGS = -L$(libdir) + LDFLAGS_INTERNAL = -L$(libdir) else - LDFLAGS = -L$(top_builddir)/src/port -L$(top_builddir)/src/common + LDFLAGS_INTERNAL = -L$(top_builddir)/src/port -L$(top_builddir)/src/common endif +# PGXC_END - LDFLAGS += @LDFLAGS@ + LDFLAGS = $(LDFLAGS_INTERNAL) @LDFLAGS@ LDFLAGS_EX = @LDFLAGS_EX@ # LDFLAGS_SL might have already been assigned by calling makefile diff --cc src/backend/access/transam/xact.c index 85bbe7f25f,9004e38e6d..35d22ac082 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@@ -5427,9 -4542,7 +5427,10 @@@ CommitSubTransaction(void AtEOSubXact_HashTables(true, s->nestingLevel); AtEOSubXact_PgStat(true, s->nestingLevel); AtSubCommit_Snapshot(s->nestingLevel); +#ifdef XCP + AtSubCommit_WaitedXids(); +#endif + AtEOSubXact_ApplyLauncher(true, s->nestingLevel); /* * We need to restore the upper transaction's read-only state, in case the @@@ -5583,9 -4696,7 +5584,10 @@@ AbortSubTransaction(void AtEOSubXact_HashTables(false, s->nestingLevel); AtEOSubXact_PgStat(false, s->nestingLevel); AtSubAbort_Snapshot(s->nestingLevel); +#ifdef XCP + AtSubAbort_WaitedXids(); +#endif + AtEOSubXact_ApplyLauncher(false, s->nestingLevel); } /* diff --cc src/backend/commands/copy.c index 650b113aaa,05e05b8fb5..eb3dc995a2 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@@ -2990,16 -2807,14 +2994,17 @@@ CopyFrom(CopyState cstate * tuples inserted by an INSERT command. */ processed++; + } - if (saved_resultRelInfo) - { - resultRelInfo = saved_resultRelInfo; - estate->es_result_relation_info = resultRelInfo; - } + /* Restore the saved ResultRelInfo */ + if (saved_resultRelInfo) + { + resultRelInfo = saved_resultRelInfo; + estate->es_result_relation_info = resultRelInfo; } +#ifdef PGXC + } +#endif } /* Flush any remaining buffered tuples */ diff --cc src/backend/commands/matview.c index 685c227c96,875da730c7..11d0ef9e11 --- a/src/backend/commands/matview.c +++ b/src/backend/commands/matview.c @@@ -638,14 -598,11 +606,13 @@@ refresh_by_match_merge(Oid matviewOid, matviewname = quote_qualified_identifier(get_namespace_name(RelationGetNamespace(matviewRel)), RelationGetRelationName(matviewRel)); tempRel = heap_open(tempOid, NoLock); - tempname = quote_qualified_identifier(get_namespace_name(RelationGetNamespace(tempRel)), + tempschema = get_namespace_name(RelationGetNamespace(tempRel)); + tempname = quote_qualified_identifier(tempschema, RelationGetRelationName(tempRel)); - diffname = make_temptable_name_n(tempname, 2); + diffname = make_temptable_name_n(RelationGetRelationName(tempRel), 2); + qualified_diffname = quote_qualified_identifier(tempschema, diffname); relnatts = matviewRel->rd_rel->relnatts; - usedForQual = (bool *) palloc0(sizeof(bool) * relnatts); /* Open SPI context. */ if (SPI_connect() != SPI_OK_CONNECT) diff --cc src/backend/executor/nodeModifyTable.c index 4272370aff,7de4568b03..b30e9d5c11 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@@ -276,101 -278,8 +279,7 @@@ ExecInsert(ModifyTableState *mtstate * get information on the (current) result relation */ resultRelInfo = estate->es_result_relation_info; - - /* Determine the partition to heap_insert the tuple into */ - if (mtstate->mt_partition_dispatch_info) - { - int leaf_part_index; - TupleConversionMap *map; - - /* - * Away we go ... If we end up not finding a partition after all, - * ExecFindPartition() does not return and errors out instead. - * Otherwise, the returned value is to be used as an index into arrays - * mt_partitions[] and mt_partition_tupconv_maps[] that will get us - * the ResultRelInfo and TupleConversionMap for the partition, - * respectively. - */ - leaf_part_index = ExecFindPartition(resultRelInfo, - mtstate->mt_partition_dispatch_info, - slot, - estate); - Assert(leaf_part_index >= 0 && - leaf_part_index < mtstate->mt_num_partitions); - - /* - * Save the old ResultRelInfo and switch to the one corresponding to - * the selected partition. - */ - saved_resultRelInfo = resultRelInfo; - resultRelInfo = mtstate->mt_partitions + leaf_part_index; - - /* We do not yet have a way to insert into a foreign partition */ - if (resultRelInfo->ri_FdwRoutine) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot route inserted tuples to a foreign table"))); - - /* For ExecInsertIndexTuples() to work on the partition's indexes */ - estate->es_result_relation_info = resultRelInfo; - - /* - * If we're capturing transition tuples, we might need to convert from - * the partition rowtype to parent rowtype. - */ - if (mtstate->mt_transition_capture != NULL) - { - if (resultRelInfo->ri_TrigDesc && - (resultRelInfo->ri_TrigDesc->trig_insert_before_row || - resultRelInfo->ri_TrigDesc->trig_insert_instead_row)) - { - /* - * If there are any BEFORE or INSTEAD triggers on the - * partition, we'll have to be ready to convert their result - * back to tuplestore format. - */ - mtstate->mt_transition_capture->tcs_original_insert_tuple = NULL; - mtstate->mt_transition_capture->tcs_map = - mtstate->mt_transition_tupconv_maps[leaf_part_index]; - } - else - { - /* - * Otherwise, just remember the original unconverted tuple, to - * avoid a needless round trip conversion. - */ - mtstate->mt_transition_capture->tcs_original_insert_tuple = tuple; - mtstate->mt_transition_capture->tcs_map = NULL; - } - } - if (mtstate->mt_oc_transition_capture != NULL) - mtstate->mt_oc_transition_capture->tcs_map = - mtstate->mt_transition_tupconv_maps[leaf_part_index]; - - /* - * We might need to convert from the parent rowtype to the partition - * rowtype. - */ - map = mtstate->mt_partition_tupconv_maps[leaf_part_index]; - if (map) - { - Relation partrel = resultRelInfo->ri_RelationDesc; - - tuple = do_convert_tuple(tuple, map); - - /* - * We must use the partition's tuple descriptor from this point - * on, until we're finished dealing with the partition. Use the - * dedicated slot for that. - */ - slot = mtstate->mt_partition_tuple_slot; - Assert(slot != NULL); - ExecSetSlotDescriptor(slot, RelationGetDescr(partrel)); - ExecStoreTuple(tuple, slot, InvalidBuffer, true); - } - } - resultRelationDesc = resultRelInfo->ri_RelationDesc; - /* * If the result relation has OIDs, force the tuple's OID to zero so that * heap_insert will assign a fresh OID. Usually the OID already will be diff --cc src/backend/optimizer/plan/planner.c index 199301c6ba,1946f9ef96..93b275bd79 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@@ -3953,53 -3717,6 +3953,49 @@@ create_grouping_paths(PlannerInfo *root try_parallel_aggregation = true; } + /* + * The distributed aggregation however works even if there are no partial + * paths (when the distribution key is included in the grouping keys, we + * may simply push down the whole aggregate). + * + * XXX We currently don't even try to push down grouping sets, although we + * might do that when all grouping sets include the distribution key. But + * that seems like a fairly rare case, as in most cases there will be + * empty grouping set () aggregating all the data. So let's look into this + * optimization later. + */ + if (!grouped_rel->consider_parallel) + { + /* Not even parallel-safe. */ + try_distributed_aggregation = false; + } + else if (!parse->hasAggs && parse->groupClause == NIL) + { + /* + * We don't know how to do parallel aggregation unless we have either + * some aggregates or a grouping clause. + */ + try_distributed_aggregation = false; + } + else if (parse->groupingSets) + { + /* We don't know how to do grouping sets in parallel. */ + try_distributed_aggregation = false; + } + else if (agg_costs->hasNonPartial || agg_costs->hasNonSerial) + { + /* Insufficient support for partial mode. */ + try_distributed_aggregation = false; + } - else if (parse->hasTargetSRFs) - { - try_distributed_aggregation = false; - } + else + { + /* Everything looks good. */ + try_distributed_aggregation = true; + } + + /* Whenever parallel aggregation is allowed, distributed should be too. */ + Assert(!(try_parallel_aggregation && !try_distributed_aggregation)); + /* * Before generating paths for grouped_rel, we first generate any possible * partial paths; that way, later code can easily consider both parallel diff --cc src/backend/parser/parse_utilcmd.c index a898db50e0,b3367f0cd4..44ab471c62 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@@ -41,10 -39,8 +41,11 @@@ #include "catalog/pg_constraint_fn.h" #include "catalog/pg_opclass.h" #include "catalog/pg_operator.h" + #include "catalog/pg_statistic_ext.h" #include "catalog/pg_type.h" +#ifdef XCP +#include "catalog/pgxc_node.h" +#endif #include "commands/comment.h" #include "commands/defrem.h" #include "commands/sequence.h" diff --cc src/include/parser/analyze.h index 42435884fe,4ee20052f2..a9222e7d69 --- a/src/include/parser/analyze.h +++ b/src/include/parser/analyze.h @@@ -44,8 -43,7 +44,11 @@@ extern void applyLockingClause(Query *q LockClauseStrength strength, LockWaitPolicy waitPolicy, bool pushedDown); +#ifdef XCP +extern void ParseAnalyze_callback(ParseState *pstate, Query *query); +extern post_parse_analyze_hook_type prev_ParseAnalyze_callback; +#endif + extern List *BuildOnConflictExcludedTargetlist(Relation targetrel, + Index exclRelIndex); + #endif /* ANALYZE_H */ diff --cc src/include/pg_config.h.win32 index c89bd357bf,cb7c139c8c..83d08de8ec --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@@ -545,16 -564,16 +564,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 10.5" +#define PACKAGE_STRING "Postgres-XL 10r1beta1" /* Define to the version of this package. */ - #define PACKAGE_VERSION "10.3" + #define PACKAGE_VERSION "10.5" /* Define to the name of a signed 128-bit integer type. */ #undef PG_INT128_TYPE @@@ -563,19 -582,13 +582,19 @@@ #define PG_INT64_TYPE long long int /* PostgreSQL version as a string */ - #define PG_VERSION "10.3" + #define PG_VERSION "10.5" /* PostgreSQL version as a number */ - #define PG_VERSION_NUM 100003 + #define PG_VERSION_NUM 100005 /* 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/create_table.out index 8f8f2374d1,660398bdbe..6fc11f42e0 --- a/src/test/regress/expected/create_table.out +++ b/src/test/regress/expected/create_table.out @@@ -780,12 -757,24 +775,26 @@@ CREATE TABLE range_parted4_3 PARTITION c | integer | | | | plain | | Partition of: range_parted4 FOR VALUES FROM (6, 8, MINVALUE) TO (9, MAXVALUE, MAXVALUE) Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS NOT NULL) AND ((abs(a) > 6) OR ((abs(a) = 6) AND (abs(b) >= 8))) AND (abs(a) <= 9)) +Distribute By: HASH(a) +Location Nodes: ALL DATANODES DROP TABLE range_parted4; + -- user-defined operator class in partition key + CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql + AS $$ SELECT case WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 1 ELSE -1 END; $$; + CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS + OPERATOR 1 < (int4,int4), OPERATOR 2 <= (int4,int4), + OPERATOR 3 = (int4,int4), OPERATOR 4 >= (int4,int4), + OPERATOR 5 > (int4,int4), FUNCTION 1 my_int4_sort(int4,int4); + CREATE TABLE partkey_t (a int4) PARTITION BY RANGE (a test_int4_ops); + CREATE TABLE partkey_t_1 PARTITION OF partkey_t FOR VALUES FROM (0) TO (1000); + INSERT INTO partkey_t VALUES (100); + INSERT INTO partkey_t VALUES (200); -- cleanup DROP TABLE parted, list_parted, range_parted, list_parted2, range_parted2, range_parted3; + DROP TABLE partkey_t; + DROP OPERATOR CLASS test_int4_ops USING btree; + DROP FUNCTION my_int4_sort(int4,int4); -- comments on partitioned tables columns CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a); COMMENT ON TABLE parted_col_comment IS 'Am partitioned table'; @@@ -816,8 -803,30 +825,32 @@@ CREATE TABLE arrlp12 PARTITION OF arrl --------+-----------+-----------+----------+---------+----------+--------------+------------- a | integer[] | | | | extended | | Partition of: arrlp FOR VALUES IN ('{1}', '{2}') - Partition constraint: ((a IS NOT NULL) AND (((a)::anyarray OPERATOR(pg_catalog.=) '{1}'::integer[]) OR ((a)::anyarray OPERATOR(pg_catalog.=) '{2}'::integer[]))) + Partition constraint: ((a IS NOT NULL) AND ((a = '{1}'::integer[]) OR (a = '{2}'::integer[]))) +Distribute By: ROUND ROBIN +Location Nodes: ALL DATANODES DROP TABLE arrlp; + -- partition on boolean column + create table boolspart (a bool) partition by list (a); + create table boolspart_t partition of boolspart for values in (true); + create table boolspart_f partition of boolspart for values in (false); + \d+ boolspart + Table "public.boolspart" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description + --------+---------+-----------+----------+---------+---------+--------------+------------- + a | boolean | | | | plain | | + Partition key: LIST (a) + Partitions: boolspart_f FOR VALUES IN (false), + boolspart_t FOR VALUES IN (true) + + drop table boolspart; + -- partitions mixing temporary and permanent relations + create table perm_parted (a int) partition by list (a); + create temporary table temp_parted (a int) partition by list (a); + create table perm_part partition of temp_parted for values in (1, 2); -- error + ERROR: cannot create a permanent relation as partition of temporary relation "temp_parted" + create temp table temp_part partition of perm_parted for values in (1, 2); -- error + ERROR: cannot create a temporary relation as partition of permanent relation "perm_parted" + create temp table temp_part partition of temp_parted for values in (1, 2); -- ok + drop table perm_parted cascade; + drop table temp_parted cascade; diff --cc src/test/regress/expected/create_table_like.out index 697e19a29b,0d8438a9ab..555e8daadd --- a/src/test/regress/expected/create_table_like.out +++ b/src/test/regress/expected/create_table_like.out @@@ -250,8 -242,8 +252,10 @@@ Indexes "ctlt_all_expr_idx" btree ((a || b)) Check constraints: "ctlt1_a_check" CHECK (length(a) > 2) + Statistics objects: + "public"."ctlt_all_a_b_stat" (ndistinct, dependencies) ON a, b FROM ctlt_all +Distribute By: HASH(a) +Location Nodes: ALL DATANODES SELECT c.relname, objsubid, description FROM pg_description, pg_index i, pg_class c WHERE classoid = 'pg_class'::regclass AND objoid = i.indexrelid AND c.oid = i.indexrelid AND i.indrelid = 'ctlt_all'::regclass ORDER BY c.relname, objsubid; relname | objsubid | description diff --cc src/test/regress/expected/foreign_data.out index 1ba6f02c09,3418fefcca..2ac2698cb1 --- a/src/test/regress/expected/foreign_data.out +++ b/src/test/regress/expected/foreign_data.out @@@ -1601,23 -1995,42 +1601,35 @@@ ALTER TABLE pt2 ADD CONSTRAINT pt2chk1 Partition key: LIST (c1) Check constraints: "pt2chk1" CHECK (c1 > 0) +Distribute By: HASH(c1) +Location Nodes: ALL DATANODES \d+ pt2_1 - Foreign table "public.pt2_1" - Column | Type | Collation | Nullable | Default | FDW options | Storage | Stats target | Description ---------+---------+-----------+----------+---------+-------------+----------+--------------+------------- - c1 | integer | | not null | | | plain | | - c2 | text | | not null | | | extended | | - c3 | date | | not null | | | plain | | -Check constraints: - "p21chk" CHECK (c2 <> ''::text) -Server: s0 -FDW options: (delimiter ',', quote '"', "be quoted" 'value') - ALTER TABLE pt2 ATTACH PARTITION pt2_1 FOR VALUES IN (1); -- ERROR -ERROR: child table is missing constraint "pt2chk1" +ERROR: relation "pt2_1" does not exist ALTER FOREIGN TABLE pt2_1 ADD CONSTRAINT pt2chk1 CHECK (c1 > 0); +ERROR: relation "pt2_1" does not exist ALTER TABLE pt2 ATTACH PARTITION pt2_1 FOR VALUES IN (1); +ERROR: relation "pt2_1" does not exist -- TRUNCATE doesn't work on foreign tables, either directly or recursively TRUNCATE pt2_1; -- ERROR -ERROR: "pt2_1" is not a table +ERROR: relation "pt2_1" does not exist TRUNCATE pt2; -- ERROR -ERROR: "pt2_1" is not a table DROP FOREIGN TABLE pt2_1; +ERROR: foreign table "pt2_1" does not exist DROP TABLE pt2; + -- foreign table cannot be part of partition tree made of temporary + -- relations. + CREATE TEMP TABLE temp_parted (a int) PARTITION BY LIST (a); + CREATE FOREIGN TABLE foreign_part PARTITION OF temp_parted + FOR VALUES IN (1, 2) SERVER s0; -- ERROR + ERROR: cannot create a permanent relation as partition of temporary relation "temp_parted" + CREATE FOREIGN TABLE foreign_part (a int) SERVER s0; + ALTER TABLE temp_parted ATTACH PARTITION foreign_part + FOR VALUES IN (1, 2); -- ERROR + ERROR: cannot attach a permanent relation as partition of temporary relation "temp_parted" + DROP FOREIGN TABLE foreign_part; + DROP TABLE temp_parted; -- Cleanup DROP SCHEMA foreign_schema CASCADE; DROP ROLE regress_test_role; -- ERROR diff --cc src/test/regress/expected/object_address.out index 75cc663889,d12bf01877..d6a930d5c8 --- a/src/test/regress/expected/object_address.out +++ b/src/test/regress/expected/object_address.out @@@ -271,7 -466,10 +271,10 @@@ SELECT (pg_identify_object(addr1.classi text search parser | addr_nsp | addr_ts_prs | addr_nsp.addr_ts_prs | t text search configuration | addr_nsp | addr_ts_conf | addr_nsp.addr_ts_conf | t text search template | addr_nsp | addr_ts_temp | addr_nsp.addr_ts_temp | t - (37 rows) + subscription | | addr_sub | addr_sub | t + publication | | addr_pub | addr_pub | t + publication relation | | | addr_nsp.gentable in publication addr_pub | t -(46 rows) ++(40 rows) --- --- Cleanup resources diff --cc src/test/regress/expected/plpgsql.out index b96e58b69b,0162102a19..b9a3138c05 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@@ -5996,7 -5979,34 +5996,29 @@@ ALTER TABLE alter_table_under_transitio DROP column name; UPDATE alter_table_under_transition_tables SET id = id; -ERROR: column "name" does not exist -LINE 1: SELECT (SELECT string_agg(id || '=' || name, ',') FROM d) - ^ -QUERY: SELECT (SELECT string_agg(id || '=' || name, ',') FROM d) -CONTEXT: PL/pgSQL function alter_table_under_transition_tables_upd_func() line 3 at RAISE -- + -- Test multiple reference to a transition table + -- + CREATE TABLE multi_test (i int); + INSERT INTO multi_test VALUES (1); + CREATE OR REPLACE FUNCTION multi_test_trig() RETURNS trigger + LANGUAGE plpgsql AS $$ + BEGIN + RAISE NOTICE 'count = %', (SELECT COUNT(*) FROM new_test); + RAISE NOTICE 'count union = %', + (SELECT COUNT(*) + FROM (SELECT * FROM new_test UNION ALL SELECT * FROM new_test) ss); + RETURN NULL; + END$$; + CREATE TRIGGER my_trigger AFTER UPDATE ON multi_test + REFERENCING NEW TABLE AS new_test OLD TABLE as old_test + FOR EACH STATEMENT EXECUTE PROCEDURE multi_test_trig(); + UPDATE multi_test SET i = i; + NOTICE: count = 1 + NOTICE: count union = 2 + DROP TABLE multi_test; + DROP FUNCTION multi_test_trig(); + -- -- Check type parsing and record fetching from partitioned tables -- CREATE TABLE partitioned_table (a int, b text) PARTITION BY LIST (a); diff --cc src/test/regress/expected/rules.out index 700eb0ebd9,99e01b9a25..f588fd819c --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@@ -2838,11 -2809,12 +2838,11 @@@ Rules ON UPDATE TO rules_src DO INSERT INTO rules_log (f1, f2, tag) VALUES (old.f1,old.f2,'old'::text), (new.f1,new.f2,'new'::text) r2 AS ON UPDATE TO rules_src DO VALUES (old.f1,old.f2,'old'::text), (new.f1,new.f2,'new'::text) - r3 AS - ON DELETE TO rules_src DO - NOTIFY rules_src_deletion +Distribute By: HASH(f1) +Location Nodes: ALL DATANODES -- - -- Ensure a aliased target relation for insert is correctly deparsed. + -- Ensure an aliased target relation for insert is correctly deparsed. -- create rule r4 as on insert to rules_src do instead insert into rules_log AS trgt SELECT NEW.* RETURNING trgt.f1, trgt.f2; create rule r5 as on update to rules_src do instead UPDATE rules_log AS trgt SET tag = 'updated' WHERE trgt.f1 = new.f1; diff --cc src/test/regress/expected/tsrf.out index e61a23e0b2,25be6b9ab1..044931c5cf --- a/src/test/regress/expected/tsrf.out +++ b/src/test/regress/expected/tsrf.out @@@ -421,10 -421,32 +421,32 @@@ SELECT dataa, datab b, generate_series( (24 rows) reset enable_hashagg; + -- case with degenerate ORDER BY + explain (verbose, costs off) + select 'foo' as f, generate_series(1,2) as g from few order by 1; + QUERY PLAN + ---------------------------------------------- + ProjectSet + Output: 'foo'::text, generate_series(1, 2) + -> Seq Scan on public.few + Output: id, dataa, datab + (4 rows) + + select 'foo' as f, generate_series(1,2) as g from few order by 1; + f | g + -----+--- + foo | 1 + foo | 2 + foo | 1 + foo | 2 + foo | 1 + foo | 2 + (6 rows) + -- data modification CREATE TABLE fewmore AS SELECT generate_series(1,3) AS data; -INSERT INTO fewmore VALUES(generate_series(4,5)); -SELECT * FROM fewmore; +INSERT INTO fewmore SELECT generate_series(4,5); +SELECT * FROM fewmore ORDER BY 1; data ------ 1 diff --cc src/test/regress/expected/xml.out index 197c5aba6f,3eb638ca25..7cd24c6701 --- a/src/test/regress/expected/xml.out +++ b/src/test/regress/expected/xml.out @@@ -1077,29 -1075,26 +1077,29 @@@ CREATE OR REPLACE VIEW public.xmltablev "xmltable".premier_name FROM ( SELECT xmldata.data FROM xmldata) x, - LATERAL XMLTABLE(('/ROWS/ROW'::text) PASSING (x.data) COLUMNS id integer PATH ('@id'::text), _id FOR ORDINALITY, country_name text PATH ('COUNTRY_NAME'::text) NOT NULL, country_id text PATH ('COUNTRY_ID'::text), region_id integer PATH ('REGION_ID'::text), size double precision PATH ('SIZE'::text), unit text PATH ('SIZE/@unit'::text), premier_name text DEFAULT ('not specified'::text) PATH ('PREMIER_NAME'::text)) + LATERAL XMLTABLE(('/ROWS/ROW'::text) PASSING (x.data) COLUMNS id integer PATH ('@id'::text), _id FOR ORDINALITY, country_name text PATH ('COUNTRY_NAME/text()'::text) NOT NULL, country_id text PATH ('COUNTRY_ID'::text), region_id integer PATH ('REGION_ID'::text), size double precision PATH ('SIZE'::text), unit text PATH ('SIZE/@unit'::text), premier_name text DEFAULT ('not specified'::text) PATH ('PREMIER_NAME'::text)) EXPLAIN (COSTS OFF) SELECT * FROM xmltableview1; - QUERY PLAN ------------------------------------------ + QUERY PLAN +----------------------------------------------------------- Nested Loop - -> Seq Scan on xmldata + -> Remote Subquery Scan on all (datanode_1,datanode_2) + -> Seq Scan on xmldata -> Table Function Scan on "xmltable" -(3 rows) +(4 rows) EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM xmltableview1; - QUERY PLAN - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Nested Loop Output: "xmltable".id, "xmltable"._id, "xmltable".country_name, "xmltable".country_id, "xmltable".region_id, "xmltable".size, "xmltable".unit, "xmltable".premier_name - -> Seq Scan on public.xmldata + -> Remote Subquery Scan on all (datanode_1,datanode_2) Output: xmldata.data + -> Seq Scan on public.xmldata + Output: xmldata.data -> Table Function Scan on "xmltable" Output: "xmltable".id, "xmltable"._id, "xmltable".country_name, "xmltable".country_id, "xmltable".region_id, "xmltable".size, "xmltable".unit, "xmltable".premier_name - Table Function Call: XMLTABLE(('/ROWS/ROW'::text) PASSING (xmldata.data) COLUMNS id integer PATH ('@id'::text), _id FOR ORDINALITY, country_name text PATH ('COUNTRY_NAME'::text) NOT NULL, country_id text PATH ('COUNTRY_ID'::text), region_id integer PATH ('REGION_ID'::text), size double precision PATH ('SIZE'::text), unit text PATH ('SIZE/@unit'::text), premier_name text DEFAULT ('not specified'::text) PATH ('PREMIER_NAME'::text)) - (9 rows) + Table Function Call: XMLTABLE(('/ROWS/ROW'::text) PASSING (xmldata.data) COLUMNS id integer PATH ('@id'::text), _id FOR ORDINALITY, country_name text PATH ('COUNTRY_NAME/text()'::text) NOT NULL, country_id text PATH ('COUNTRY_ID'::text), region_id integer PATH ('REGION_ID'::text), size double precision PATH ('SIZE'::text), unit text PATH ('SIZE/@unit'::text), premier_name text DEFAULT ('not specified'::text) PATH ('PREMIER_NAME'::text)) + (7 rows) -- XMLNAMESPACES tests SELECT * FROM XMLTABLE(XMLNAMESPACES('http://x.y' AS zz), diff --cc src/test/regress/expected/xml_1.out index 289062ae73,2053734f65..366911cdbb --- a/src/test/regress/expected/xml_1.out +++ b/src/test/regress/expected/xml_1.out @@@ -949,29 -947,26 +949,29 @@@ CREATE OR REPLACE VIEW public.xmltablev "xmltable".premier_name FROM ( SELECT xmldata.data FROM xmldata) x, - LATERAL XMLTABLE(('/ROWS/ROW'::text) PASSING (x.data) COLUMNS id integer PATH ('@id'::text), _id FOR ORDINALITY, country_name text PATH ('COUNTRY_NAME'::text) NOT NULL, country_id text PATH ('COUNTRY_ID'::text), region_id integer PATH ('REGION_ID'::text), size double precision PATH ('SIZE'::text), unit text PATH ('SIZE/@unit'::text), premier_name text DEFAULT ('not specified'::text) PATH ('PREMIER_NAME'::text)) + LATERAL XMLTABLE(('/ROWS/ROW'::text) PASSING (x.data) COLUMNS id integer PATH ('@id'::text), _id FOR ORDINALITY, country_name text PATH ('COUNTRY_NAME/text()'::text) NOT NULL, country_id text PATH ('COUNTRY_ID'::text), region_id integer PATH ('REGION_ID'::text), size double precision PATH ('SIZE'::text), unit text PATH ('SIZE/@unit'::text), premier_name text DEFAULT ('not specified'::text) PATH ('PREMIER_NAME'::text)) EXPLAIN (COSTS OFF) SELECT * FROM xmltableview1; - QUERY PLAN ------------------------------------------ + QUERY PLAN +----------------------------------------------------------- Nested Loop - -> Seq Scan on xmldata + -> Remote Subquery Scan on all (datanode_1,datanode_2) + -> Seq Scan on xmldata -> Table Function Scan on "xmltable" -(3 rows) +(4 rows) EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM xmltableview1; - QUERY PLAN - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Nested Loop Output: "xmltable".id, "xmltable"._id, "xmltable".country_name, "xmltable".country_id, "xmltable".region_id, "xmltable".size, "xmltable".unit, "xmltable".premier_name - -> Seq Scan on public.xmldata + -> Remote Subquery Scan on all (datanode_1,datanode_2) Output: xmldata.data + -> Seq Scan on public.xmldata + Output: xmldata.data -> Table Function Scan on "xmltable" Output: "xmltable".id, "xmltable"._id, "xmltable".country_name, "xmltable".country_id, "xmltable".region_id, "xmltable".size, "xmltable".unit, "xmltable".premier_name - Table Function Call: XMLTABLE(('/ROWS/ROW'::text) PASSING (xmldata.data) COLUMNS id integer PATH ('@id'::text), _id FOR ORDINALITY, country_name text PATH ('COUNTRY_NAME'::text) NOT NULL, country_id text PATH ('COUNTRY_ID'::text), region_id integer PATH ('REGION_ID'::text), size double precision PATH ('SIZE'::text), unit text PATH ('SIZE/@unit'::text), premier_name text DEFAULT ('not specified'::text) PATH ('PREMIER_NAME'::text)) - (9 rows) + Table Function Call: XMLTABLE(('/ROWS/ROW'::text) PASSING (xmldata.data) COLUMNS id integer PATH ('@id'::text), _id FOR ORDINALITY, country_name text PATH ('COUNTRY_NAME/text()'::text) NOT NULL, country_id text PATH ('COUNTRY_ID'::text), region_id integer PATH ('REGION_ID'::text), size double precision PATH ('SIZE'::text), unit text PATH ('SIZE/@unit'::text), premier_name text DEFAULT ('not specified'::text) PATH ('PREMIER_NAME'::text)) + (7 rows) -- XMLNAMESPACES tests SELECT * FROM XMLTABLE(XMLNAMESPACES('http://x.y' AS zz), diff --cc src/test/regress/sql/tsrf.sql index c672991f47,0a1e8e5666..03dd0df7d6 --- a/src/test/regress/sql/tsrf.sql +++ b/src/test/regress/sql/tsrf.sql @@@ -88,10 -88,15 +88,15 @@@ SELECT dataa, datab b, generate_series( SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab, g) ORDER BY g; reset enable_hashagg; + -- case with degenerate ORDER BY + explain (verbose, costs off) + select 'foo' as f, generate_series(1,2) as g from few order by 1; + select 'foo' as f, generate_series(1,2) as g from few order by 1; + -- data modification CREATE TABLE fewmore AS SELECT generate_series(1,3) AS data; -INSERT INTO fewmore VALUES(generate_series(4,5)); -SELECT * FROM fewmore; +INSERT INTO fewmore SELECT generate_series(4,5); +SELECT * FROM fewmore ORDER BY 1; -- SRFs are not allowed in UPDATE (they once were, but it was nonsense) UPDATE fewmore SET data = generate_series(4,9);