From: Pavan Deolasee Date: Thu, 13 Jul 2017 09:22:22 +0000 (+0530) Subject: Merge remote-tracking branch 'remotes/PGSQL/master' of PG 10 X-Git-Tag: XL_10_R1BETA1~229 X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=03162cb93078de77532bf08498d96345fe14ea68;p=postgres-xl.git Merge remote-tracking branch 'remotes/PGSQL/master' of PG 10 This merge includes all commits upto bc2d716ad09fceeb391c755f78c256ddac9d3b9f of PG 10. --- 03162cb93078de77532bf08498d96345fe14ea68 diff --cc configure index 338a398e8a,aff72eb008..60dca605f7 --- 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 10beta1 (Postgres-XL 10alpha1). -# Generated by GNU Autoconf 2.69 for PostgreSQL 10beta2. ++# Generated by GNU Autoconf 2.69 for PostgreSQL 10beta2 (Postgres-XL 10alpha1). # -# 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='10beta1 (Postgres-XL 10alpha1)' -PACKAGE_VERSION='10beta2' -PACKAGE_STRING='PostgreSQL 10beta2' -PACKAGE_BUGREPORT='pgsql-bugs@postgresql.org' ++PACKAGE_VERSION='10beta2 (Postgres-XL 10alpha1)' +PACKAGE_XC_VERSION='10alpha1' - PACKAGE_STRING='PostgreSQL 10beta1 (Postgres-XL 10alpha1)' ++PACKAGE_STRING='PostgreSQL 10beta2 (Postgres-XL 10alpha1)' +PACKAGE_BUGREPORT='bugs@postgres-xl.org' PACKAGE_URL='' ac_unique_file="src/backend/access/common/heaptuple.c" @@@ -1412,7 -1408,7 +1412,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 10beta1 (Postgres-XL 10alpha1) to adapt to many kinds of systems. -\`configure' configures PostgreSQL 10beta2 to adapt to many kinds of systems. ++\`configure' configures PostgreSQL 10beta2 (Postgres-XL 10alpha1) to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@@ -1477,7 -1473,7 +1477,7 @@@ f if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of PostgreSQL 10beta1 (Postgres-XL 10alpha1):";; - short | recursive ) echo "Configuration of PostgreSQL 10beta2:";; ++ short | recursive ) echo "Configuration of PostgreSQL 10beta2 (Postgres-XL 10alpha1):";; esac cat <<\_ACEOF @@@ -1636,7 -1632,7 +1636,7 @@@ f test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF - PostgreSQL configure 10beta1 (Postgres-XL 10alpha1) -PostgreSQL configure 10beta2 ++PostgreSQL configure 10beta2 (Postgres-XL 10alpha1) generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@@ -2347,7 -2343,7 +2347,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 10beta1 (Postgres-XL 10alpha1), which was -It was created by PostgreSQL $as_me 10beta2, which was ++It was created by PostgreSQL $as_me 10beta2 (Postgres-XL 10alpha1), which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@@ -17147,7 -17097,7 +17147,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 10beta1 (Postgres-XL 10alpha1), which was -This file was extended by PostgreSQL $as_me 10beta2, which was ++This file was extended by PostgreSQL $as_me 10beta2 (Postgres-XL 10alpha1), which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@@ -17217,7 -17167,7 +17217,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 10beta1 (Postgres-XL 10alpha1) -PostgreSQL config.status 10beta2 ++PostgreSQL config.status 10beta2 (Postgres-XL 10alpha1) configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --cc configure.in index ab71577598,72e5b17ea7..21c8384bf0 --- 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], [10beta1 (Postgres-XL 10alpha1)], [bugs@postgres-xl.org]) -AC_INIT([PostgreSQL], [10beta2], [pgsql-bugs@postgresql.org]) ++AC_INIT([PostgreSQL], [10beta2 (Postgres-XL 10alpha1)], [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 d4d5f4d4f2,b37dd33a2f..1b9a4b7c60 --- 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 10beta1): Postgres-XL 10alpha1 - PostgreSQL version (example: PostgreSQL 10beta2): PostgreSQL 10beta2 ++ PostgreSQL version (example: PostgreSQL 10beta2): Postgres-XL 10alpha1 Compiler used (example: gcc 3.3.5) : diff --cc src/backend/commands/copy.c index 3f692b6441,fc5f4f66ea..37d9a898cf --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@@ -1485,32 -1444,29 +1493,54 @@@ BeginCopy(ParseState *pstate cstate->num_partitions = num_partitions; cstate->partition_tupconv_maps = partition_tupconv_maps; cstate->partition_tuple_slot = partition_tuple_slot; + + /* + * If we are capturing transition tuples, they may need to be + * converted from partition format back to partitioned table + * format (this is only ever necessary if a BEFORE trigger + * modifies the tuple). + */ + if (cstate->transition_capture != NULL) + { + int i; + + cstate->transition_tupconv_maps = (TupleConversionMap **) + palloc0(sizeof(TupleConversionMap *) * + cstate->num_partitions); + for (i = 0; i < cstate->num_partitions; ++i) + { + cstate->transition_tupconv_maps[i] = + convert_tuples_by_name(RelationGetDescr(cstate->partitions[i].ri_RelationDesc), + RelationGetDescr(rel), + gettext_noop("could not convert row type")); + } + } } +#ifdef PGXC + /* Get copy statement and execution node information */ + if (IS_PGXC_COORDINATOR) + { + RemoteCopyData *remoteCopyState = (RemoteCopyData *) palloc0(sizeof(RemoteCopyData)); + List *attnums = CopyGetAttnums(tupDesc, cstate->rel, attnamelist); + + /* Setup correct COPY FROM/TO flag */ + remoteCopyState->is_from = is_from; + + /* Get execution node list */ + RemoteCopy_GetRelationLoc(remoteCopyState, + cstate->rel, + attnums); + /* Build remote query */ + RemoteCopy_BuildStatement(remoteCopyState, + cstate->rel, + GetRemoteCopyOptions(cstate), + attnamelist, + attnums); + + /* Then assign built structure */ + cstate->remoteCopyState = remoteCopyState; + } +#endif } else { diff --cc src/backend/commands/trigger.c index 8f6de3fc69,b502941b08..576fa19705 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@@ -100,12 -97,10 +101,13 @@@ static HeapTuple ExecCallTriggerFunc(Tr static void AfterTriggerSaveEvent(EState *estate, ResultRelInfo *relinfo, int event, bool row_trigger, HeapTuple oldtup, HeapTuple newtup, - List *recheckIndexes, Bitmapset *modifiedCols); + List *recheckIndexes, Bitmapset *modifiedCols, + TransitionCaptureState *transition_capture); static void AfterTriggerEnlargeQueryState(void); +#ifdef XCP +bool enable_datanode_row_triggers; +#endif /* * Create a trigger. Returns the address of the created trigger. diff --cc src/backend/nodes/outfuncs.c index ec1b467ce3,b0abe9ec10..6e83eeb219 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@@ -30,38 -29,11 +30,40 @@@ #include "nodes/extensible.h" #include "nodes/plannodes.h" #include "nodes/relation.h" +#ifdef XCP +#include "fmgr.h" +#include "miscadmin.h" +#include "catalog/namespace.h" +#include "pgxc/execRemote.h" +#include "utils/lsyscache.h" +#endif #include "utils/datum.h" +#ifdef PGXC +#include "pgxc/planner.h" +#endif + +#ifdef XCP +/* + * When we sending query plans between nodes we need to send OIDs of various + * objects - relations, data types, functions, etc. + * On different nodes OIDs of these objects may differ, so we need to send an + * identifier, depending on object type, allowing to lookup OID on target node. + * On the other hand we want to save space when storing rules, or in other cases + * when we need to encode and decode nodes on the same node. + * For now default format is not portable, as it is in original Postgres code. + * Later we may want to add extra parameter in nodeToString() function + */ +static bool portable_output = false; +void +set_portable_output(bool value) +{ + portable_output = value; +} +#endif #include "utils/rel.h" + static void outChar(StringInfo str, char c); + /* * Macros to simplify output of different kinds of fields. Use these diff --cc src/backend/postmaster/postmaster.c index d25ea8826a,95180b2ef5..583251b651 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@@ -136,10 -125,8 +136,11 @@@ #include "utils/datetime.h" #include "utils/dynamic_loader.h" #include "utils/memutils.h" + #include "utils/pidfile.h" #include "utils/ps_status.h" +#ifdef PGXC +#include "utils/resowner.h" +#endif #include "utils/timeout.h" #include "utils/varlena.h" diff --cc src/backend/replication/syncrep.c index 8211ceda20,77e80f1612..b832a342ea --- a/src/backend/replication/syncrep.c +++ b/src/backend/replication/syncrep.c @@@ -293,16 -293,12 +293,19 @@@ SyncRepWaitForLSN(XLogRecPtr lsn, bool * WalSender has checked our LSN and has removed us from queue. Clean up * state and leave. It's OK to reset these shared memory fields without * holding SyncRepLock, because any walsenders will ignore us anyway when - * we're not on the queue. + * we're not on the queue. We need a read barrier to make sure we see + * the changes to the queue link (this might be unnecessary without + * assertions, but better safe than sorry). */ + pg_read_barrier(); +#ifdef NOT_USED + /* + * We are hitting this Assert too often in our tests. This is a PG bug and + * has been reported to the list. But turn this off until it gets fixed in + * the upstream branch + */ Assert(SHMQueueIsDetached(&(MyProc->syncRepLinks))); +#endif MyProc->syncRepState = SYNC_REP_NOT_WAITING; MyProc->waitLSN = 0; diff --cc src/backend/utils/init/miscinit.c index dc622219f0,afbf8f8691..18adb61831 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@@ -54,11 -47,8 +54,12 @@@ #include "utils/builtins.h" #include "utils/guc.h" #include "utils/memutils.h" +#ifdef XCP +#include "utils/snapmgr.h" +#endif + #include "utils/pidfile.h" #include "utils/syscache.h" +#include "utils/lsyscache.h" #include "utils/varlena.h" diff --cc src/bin/psql/tab-complete.c index f1e1920c69,e9fdc908c7..cc8a5d0d97 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@@ -1546,39 -1531,19 +1546,31 @@@ psql_completion(const char *text, int s else COMPLETE_WITH_FUNCTION_ARG(prev2_wd); } + + /* ALTER NODE */ + else if (Matches2("ALTER", "NODE")) + COMPLETE_WITH_QUERY(Query_for_list_of_available_nodenames); + else if (Matches2("ALTER", "NODE")) + COMPLETE_WITH_CONST("WITH"); + else if (Matches3("ALTER", "NODE", "WITH")) + COMPLETE_WITH_CONST("("); + else if (Matches3("ALTER", "NODE", "WITH")) + + COMPLETE_WITH_LIST5("TYPE", "HOST", "PORT", "PRIMARY", "PREFERRED"); + /* ALTER PUBLICATION */ else if (Matches3("ALTER", "PUBLICATION", MatchAny)) - { COMPLETE_WITH_LIST5("ADD TABLE", "DROP TABLE", "OWNER TO", "RENAME TO", "SET"); - } /* ALTER PUBLICATION SET */ else if (Matches4("ALTER", "PUBLICATION", MatchAny, "SET")) - { COMPLETE_WITH_LIST2("(", "TABLE"); - } /* ALTER PUBLICATION SET ( */ else if (HeadMatches3("ALTER", "PUBLICATION", MatchAny) && TailMatches2("SET", "(")) - { COMPLETE_WITH_CONST("publish"); - } /* ALTER SUBSCRIPTION */ else if (Matches3("ALTER", "SUBSCRIPTION", MatchAny)) - { COMPLETE_WITH_LIST7("CONNECTION", "ENABLE", "DISABLE", "OWNER TO", "RENAME TO", "REFRESH PUBLICATION", "SET"); - } /* ALTER SUBSCRIPTION REFRESH PUBLICATION */ else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches2("REFRESH", "PUBLICATION")) diff --cc src/include/miscadmin.h index 58feafd919,dad98de98d..586922b579 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@@ -445,33 -429,7 +443,8 @@@ extern char *session_preload_libraries_ extern char *shared_preload_libraries_string; extern char *local_preload_libraries_string; - /* - * As of 9.1, the contents of the data-directory lock file are: - * - * line # - * 1 postmaster PID (or negative of a standalone backend's PID) - * 2 data directory path - * 3 postmaster start timestamp (time_t representation) - * 4 port number - * 5 first Unix socket directory path (empty if none) - * 6 first listen_address (IP address or "*"; empty if no TCP port) - * 7 shared memory key (not present on Windows) - * - * Lines 6 and up are added via AddToDataDirLockFile() after initial file - * creation. - * - * The socket lock file, if used, has the same contents as lines 1-5. - */ - #define LOCK_FILE_LINE_PID 1 - #define LOCK_FILE_LINE_DATA_DIR 2 - #define LOCK_FILE_LINE_START_TIME 3 - #define LOCK_FILE_LINE_PORT 4 - #define LOCK_FILE_LINE_SOCKET_DIR 5 - #define LOCK_FILE_LINE_LISTEN_ADDR 6 - #define LOCK_FILE_LINE_SHMEM_KEY 7 - extern void CreateDataDirLockFile(bool amPostmaster); +extern void ForgetLockFiles(void); extern void CreateSocketLockFile(const char *socketfile, bool amPostmaster, const char *socketDir); extern void TouchSocketLockFiles(void); diff --cc src/include/pg_config.h.win32 index d7cd0ac4f6,baf57fa969..16bfb3bc5c --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@@ -548,16 -548,16 +548,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 10beta2" +#define PACKAGE_STRING "Postgres-XL 10alpha1" /* Define to the version of this package. */ - #define PACKAGE_VERSION "10beta1" + #define PACKAGE_VERSION "10beta2" /* Define to the name of a signed 128-bit integer type. */ #undef PG_INT128_TYPE diff --cc src/test/regress/expected/domain.out index 00d33ea21e,5fe999e308..ac204c9eca --- a/src/test/regress/expected/domain.out +++ b/src/test/regress/expected/domain.out @@@ -107,35 -107,39 +107,39 @@@ INSERT INTO domarrtest values ('{2,2}' INSERT INTO domarrtest values (NULL, '{{"a","b","c"},{"d","e","f"}}'); INSERT INTO domarrtest values (NULL, '{{"toolong","b","c"},{"d","e","f"}}'); ERROR: value too long for type character varying(4) + INSERT INTO domarrtest (testint4arr[1], testint4arr[3]) values (11,22); -select * from domarrtest; +select * from domarrtest order by 1, 2; testint4arr | testchar4arr ---------------+--------------------- {2,2} | {{a,b},{c,d}} - {{2,2},{2,2}} | {{a,b}} {2,2} | {{a,b},{c,d},{e,f}} {2,2} | {{a},{c}} + {{2,2},{2,2}} | {{a,b}} | {{a,b,c},{d,e,f}} - (5 rows) + {11,NULL,22} | + (6 rows) -select testint4arr[1], testchar4arr[2:2] from domarrtest; +select testint4arr[1], testchar4arr[2:2] from domarrtest order by 1, 2; testint4arr | testchar4arr -------------+-------------- + 2 | {{c}} 2 | {{c,d}} - | {} 2 | {{c,d}} - 2 | {{c}} + | {} | {{d,e,f}} - (5 rows) + 11 | + (6 rows) -select array_dims(testint4arr), array_dims(testchar4arr) from domarrtest; +select array_dims(testint4arr), array_dims(testchar4arr) from domarrtest order by 1, 2; array_dims | array_dims ------------+------------ + [1:2] | [1:2][1:1] [1:2] | [1:2][1:2] - [1:2][1:2] | [1:1][1:2] [1:2] | [1:3][1:2] - [1:2] | [1:2][1:1] + [1:2][1:2] | [1:1][1:2] | [1:2][1:3] - (5 rows) + [1:3] | + (6 rows) COPY domarrtest FROM stdin; COPY domarrtest FROM stdin; -- fail @@@ -145,13 -149,25 +149,25 @@@ select * from domarrtest order by 1, 2 testint4arr | testchar4arr ---------------+--------------------- {2,2} | {{a,b},{c,d}} - {{2,2},{2,2}} | {{a,b}} {2,2} | {{a,b},{c,d},{e,f}} {2,2} | {{a},{c}} - | {{a,b,c},{d,e,f}} - {11,NULL,22} | + {{2,2},{2,2}} | {{a,b}} {3,4} | {q,w,e} ++ {11,NULL,22} | + | {{a,b,c},{d,e,f}} | - (7 rows) + (8 rows) + + update domarrtest set + testint4arr[1] = testint4arr[1] + 1, + testint4arr[3] = testint4arr[3] - 1 + where testchar4arr is null; + select * from domarrtest where testchar4arr is null; + testint4arr | testchar4arr + ------------------+-------------- + {12,NULL,21} | + {NULL,NULL,NULL} | + (2 rows) drop table domarrtest; drop domain domainint4arr restrict; diff --cc src/test/regress/sql/domain.sql index b81b5ba0a1,5ec128dd25..01d447c342 --- a/src/test/regress/sql/domain.sql +++ b/src/test/regress/sql/domain.sql @@@ -85,9 -85,10 +85,10 @@@ INSERT INTO domarrtest values ('{2,2}' INSERT INTO domarrtest values ('{2,2}', '{{"a"},{"c"}}'); INSERT INTO domarrtest values (NULL, '{{"a","b","c"},{"d","e","f"}}'); INSERT INTO domarrtest values (NULL, '{{"toolong","b","c"},{"d","e","f"}}'); + INSERT INTO domarrtest (testint4arr[1], testint4arr[3]) values (11,22); -select * from domarrtest; -select testint4arr[1], testchar4arr[2:2] from domarrtest; -select array_dims(testint4arr), array_dims(testchar4arr) from domarrtest; +select * from domarrtest order by 1, 2; +select testint4arr[1], testchar4arr[2:2] from domarrtest order by 1, 2; +select array_dims(testint4arr), array_dims(testchar4arr) from domarrtest order by 1, 2; COPY domarrtest FROM stdin; {3,4} {q,w,e} @@@ -98,8 -99,15 +99,15 @@@ COPY domarrtest FROM stdin; -- fai {3,4} {qwerty,w,e} \. -select * from domarrtest; +select * from domarrtest order by 1, 2; + update domarrtest set + testint4arr[1] = testint4arr[1] + 1, + testint4arr[3] = testint4arr[3] - 1 + where testchar4arr is null; + + select * from domarrtest where testchar4arr is null; + drop table domarrtest; drop domain domainint4arr restrict; drop domain domainchar4arr restrict;