diff options
59 files changed, 318 insertions, 255 deletions
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c index 40be1579ed..b81bddf3c1 100644 --- a/src/backend/access/common/heaptuple.c +++ b/src/backend/access/common/heaptuple.c @@ -69,6 +69,7 @@ #include "access/tuptoaster.h" #include "executor/tuptable.h" #ifdef XCP +#include "lib/stringinfo.h" #include "utils/memutils.h" #endif diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 31fec2a365..0f866f0fa5 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5456,6 +5456,10 @@ getRecordTimestamp(XLogRecord *record, TimestampTz *recordXtime) static bool recoveryStopsBefore(XLogRecord *record) { +#ifdef PGXC + bool stopsAtThisBarrier = false; + char *recordBarrierId = NULL; +#endif bool stopsHere = false; uint8 record_info; bool isCommit; diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index beb3843c19..17e2e83744 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -383,7 +383,7 @@ AuxiliaryProcessMain(int argc, char *argv[]) { #ifdef PGXC /* Initialize pooler flag before creating PGPROC structure */ - if (auxType == PoolerProcess) + if (MyAuxProcType == PoolerProcess) PGXCPoolerProcessIam(); #endif diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index af4791bf58..fdffa6a6db 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -168,9 +168,9 @@ static const Oid object_classes[MAX_OCLASS] = { ForeignServerRelationId, /* OCLASS_FOREIGN_SERVER */ UserMappingRelationId, /* OCLASS_USER_MAPPING */ DefaultAclRelationId, /* OCLASS_DEFACL */ - ExtensionRelationId /* OCLASS_EXTENSION */ + ExtensionRelationId, /* OCLASS_EXTENSION */ #ifdef PGXC - ,PgxcClassRelationId /* OCLASS_PGXCCLASS */ + PgxcClassRelationId, /* OCLASS_PGXCCLASS */ #endif EventTriggerRelationId /* OCLASS_EVENT_TRIGGER */ }; diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index fe11f70ff1..21a4df6e9c 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -200,7 +200,7 @@ static FormData_pg_attribute a7 = { * at the Coordinator */ static FormData_pg_attribute a8 = { - 0, {"xc_node_id"}, INT4OID, 0, sizeof(int4), + 0, {"xc_node_id"}, INT4OID, 0, sizeof(int32), XC_NodeIdAttributeNumber, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }; diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c index 61b282bcf7..11a196bff3 100644 --- a/src/backend/catalog/pg_aggregate.c +++ b/src/backend/catalog/pg_aggregate.c @@ -297,7 +297,7 @@ AggregateCreate(const char *aggName, */ fnArgs[0] = aggCollectType; fnArgs[1] = aggTransType; - collectfn = lookup_agg_function(aggcollectfnName, 2, fnArgs, + collectfn = lookup_agg_function(aggcollectfnName, 2, fnArgs, variadicArgType, &rettype); if (rettype != aggCollectType) ereport(ERROR, @@ -316,7 +316,7 @@ AggregateCreate(const char *aggName, */ fnArgs[0] = aggTransType; fnArgs[1] = aggTransType; - collectfn = lookup_agg_function(aggcollectfnName, 2, fnArgs, + collectfn = lookup_agg_function(aggcollectfnName, 2, fnArgs, variadicArgType, &rettype); if (rettype != aggTransType) ereport(ERROR, diff --git a/src/backend/catalog/pgxc_class.c b/src/backend/catalog/pgxc_class.c index 1543a45342..297010be9f 100644 --- a/src/backend/catalog/pgxc_class.c +++ b/src/backend/catalog/pgxc_class.c @@ -12,6 +12,7 @@ #include "postgres.h" #include "access/heapam.h" +#include "access/htup_details.h" #include "catalog/dependency.h" #include "catalog/indexing.h" #include "catalog/namespace.h" diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index b073fe5aed..bf21ef9a65 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -3030,10 +3030,10 @@ analyze_rel_coordinator(Relation onerel, bool inh, int attr_cnt, Datum value; bool isnull; int colnum = 1; - int2 attnum; + int16 attnum; // float4 reltuples; float4 nullfrac; - int4 width; + int32 width; float4 distinct; VacAttrStats *stats = NULL; @@ -3070,7 +3070,7 @@ analyze_rel_coordinator(Relation onerel, bool inh, int attr_cnt, /* Detailed statistics */ for (i = 1; i <= STATISTIC_NUM_SLOTS; i++) { - int2 kind; + int16 kind; float4 *numbers; Datum *values; int nnumbers, nvalues; diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index e2b2756bff..183f8485a3 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -834,7 +834,6 @@ DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed) bool is_from = stmt->is_from; bool pipe = (stmt->filename == NULL); Relation rel; - uint64 processed; #ifdef XCP int oldSeqRangeVal = SequenceRangeVal; #endif diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c index 96f926cbb2..e4cfcd282c 100644 --- a/src/backend/commands/event_trigger.c +++ b/src/backend/commands/event_trigger.c @@ -995,6 +995,11 @@ EventTriggerSupportsObjectClass(ObjectClass objclass) case OCLASS_USER_MAPPING: case OCLASS_DEFACL: case OCLASS_EXTENSION: +#ifdef PGXC + case OCLASS_PGXC_CLASS: + case OCLASS_PGXC_NODE: + case OCLASS_PGXC_GROUP: +#endif return true; case MAX_OCLASS: diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 108d637fcf..1a7675c673 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -536,12 +536,12 @@ DefineIndex(Oid relationId, #ifdef PGXC /* Make sure we can locally enforce the index */ - if (IS_PGXC_COORDINATOR && (primary || unique)) + if (IS_PGXC_COORDINATOR && (stmt->primary || stmt->unique)) { ListCell *elem; bool isSafe = false; - foreach(elem, attributeList) + foreach(elem, stmt->indexParams) { IndexElem *key = (IndexElem *) lfirst(elem); @@ -569,8 +569,8 @@ DefineIndex(Oid relationId, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), errmsg("Unique index of partitioned table must contain the hash/modulo distribution column."))); /* create index still, just that it won't be unique */ - unique = false; - isconstraint = false; + stmt->unique = false; + stmt->isconstraint = false; } else ereport(ERROR, diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index 67db471307..a223995c2f 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -39,6 +39,7 @@ #include "pgxc/nodemgr.h" #include "pgxc/execRemote.h" #include "catalog/pgxc_node.h" +#include "utils/resowner_private.h" #endif /* diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 86e59b40cc..cf453cae03 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -11934,6 +11934,6 @@ DropTableThrowErrorExternal(RangeVar *relation, ObjectType removeType, bool miss break; } - DropErrorMsgNonExistent(relation->relname, relkind, missing_ok); + DropErrorMsgNonExistent(relation, relkind, missing_ok); } #endif diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index f0c435ee9d..5e4455df3f 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -1662,12 +1662,14 @@ vacuum_rel_coordinator(Relation onerel) idx_frozenxid = InvalidTransactionId; } /* save changes */ + /* !!TODO Get multi-xid from remote nodes */ vac_update_relstats(Irel[i], (BlockNumber) idx_pages, (double) idx_tuples, 0, false, - idx_frozenxid); + idx_frozenxid, + InvalidMultiXactId); } } } @@ -1690,7 +1692,8 @@ vacuum_rel_coordinator(Relation onerel) (double) num_tuples, visibilitymap_count(onerel), hasindex, - min_frozenxid); + min_frozenxid, + InvalidMultiXactId); } } #endif diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c index a1677211ef..a3ebbee195 100644 --- a/src/backend/executor/nodeWindowAgg.c +++ b/src/backend/executor/nodeWindowAgg.c @@ -110,6 +110,9 @@ typedef struct WindowStatePerAggData /* Oids of transition functions */ Oid transfn_oid; Oid invtransfn_oid; /* may be InvalidOid */ +#ifdef PGXC + Oid collectfn_oid; +#endif Oid finalfn_oid; /* may be InvalidOid */ /* diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index fc025e31f7..63213fc048 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -51,7 +51,7 @@ static Portal SPI_cursor_open_internal(const char *name, SPIPlanPtr plan, #ifdef PGXC static void _SPI_pgxc_prepare_plan(const char *src, List *src_parsetree, - SPIPlanPtr plan, ParamListInfo boundParams); + SPIPlanPtr plan); #endif static void _SPI_prepare_plan(const char *src, SPIPlanPtr plan); @@ -404,7 +404,7 @@ SPI_execute_direct(const char *remote_sql, char *nodename) plan.cursor_options = 0; /* Now pass the ExecDirectStmt parsetree node */ - _SPI_pgxc_prepare_plan(execdirect.data, list_make1(stmt), &plan, NULL); + _SPI_pgxc_prepare_plan(execdirect.data, list_make1(stmt), &plan); res = _SPI_execute_plan(&plan, NULL, InvalidSnapshot, InvalidSnapshot, false, true, 0); @@ -1857,7 +1857,7 @@ static void _SPI_prepare_plan(const char *src, SPIPlanPtr plan) { #ifdef PGXC - _SPI_pgxc_prepare_plan(src, NULL, plan, boundParams); + _SPI_pgxc_prepare_plan(src, NULL, plan); } /* @@ -1867,7 +1867,7 @@ _SPI_prepare_plan(const char *src, SPIPlanPtr plan) * transparent to the user. */ static void -_SPI_pgxc_prepare_plan(const char *src, List *src_parsetree, SPIPlanPtr plan, ParamListInfo boundParams) +_SPI_pgxc_prepare_plan(const char *src, List *src_parsetree, SPIPlanPtr plan) { #endif List *raw_parsetree_list; diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index 50c1a92748..0dbbf51972 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -2273,8 +2273,10 @@ List* get_parsed_hba(void) { FILE *file; List *hba_lines = NIL; List *hba_line_nums = NIL; + List *hba_raw_lines = NIL; ListCell *line, - *line_num; + *line_num, + *raw_line; List *new_parsed_lines = NIL; bool ok = true; MemoryContext linecxt; @@ -2294,10 +2296,10 @@ List* get_parsed_hba(void) { * the initial startup. If it happens on reload, we just keep the old * version around. */ - return false; + return NULL; } - linecxt = tokenize_file(HbaFileName, file, &hba_lines, &hba_line_nums); + linecxt = tokenize_file(HbaFileName, file, &hba_lines, &hba_line_nums, &hba_raw_lines); FreeFile(file); /* Now parse all the lines */ @@ -2307,11 +2309,11 @@ List* get_parsed_hba(void) { ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_MAXSIZE); oldcxt = MemoryContextSwitchTo(hbacxt); - forboth(line, hba_lines, line_num, hba_line_nums) + forthree(line, hba_lines, line_num, hba_line_nums, raw_line, hba_raw_lines) { HbaLine *newline; - if ((newline = parse_hba_line(lfirst(line), lfirst_int(line_num))) == NULL) + if ((newline = parse_hba_line(lfirst(line), lfirst_int(line_num), lfirst(raw_line))) == NULL) { /* * Parse error in the file, so indicate there's a problem. NB: a diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 3ba89d23eb..ad2ebd935b 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -2335,11 +2335,8 @@ _readFunctionScan(void) { READ_SCAN_FIELDS(FunctionScan); - READ_NODE_FIELD(funcexpr); - READ_NODE_FIELD(funccolnames); - READ_NODE_FIELD(funccoltypes); - READ_NODE_FIELD(funccoltypmods); - READ_NODE_FIELD(funccolcollations); + READ_NODE_FIELD(functions); + READ_BOOL_FIELD(funcordinality); READ_DONE(); } diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index f87a36efaf..88afebb99b 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -46,6 +46,7 @@ #include "parser/parse_clause.h" #include "parser/parsetree.h" #ifdef PGXC +#include "access/htup_details.h" #include "access/gtm.h" #include "parser/parse_coerce.h" #include "pgxc/pgxc.h" @@ -1925,7 +1926,7 @@ create_remotescan_plan(PlannerInfo *root, subplan = create_plan_recurse(root, best_path->subpath); /* We don't want any excess columns in the remote tuples */ - disuse_physical_tlist(subplan, best_path->subpath); + disuse_physical_tlist(root, subplan, best_path->subpath); plan = make_remotesubplan(root, subplan, best_path->path.distribution, @@ -1967,7 +1968,7 @@ find_push_down_plan_int(PlannerInfo *root, Plan *plan, bool force, Plan **parent if (parent && IsA(plan, SubqueryScan)) { Plan *subplan = ((SubqueryScan *)plan)->subplan; - Plan *remote_plan = find_push_down_plan_int(root, ((SubqueryScan *)plan)->subplan, force, + RemoteSubplan *remote_plan = find_push_down_plan_int(root, ((SubqueryScan *)plan)->subplan, force, &((SubqueryScan *)plan)->subplan); /* @@ -1975,7 +1976,7 @@ find_push_down_plan_int(PlannerInfo *root, Plan *plan, bool force, Plan **parent * subquery plan, then we must also update the link stored in the * RelOptInfo corresponding to this subquery */ - if ((remote_plan == subplan) && parent) + if ((((Plan *)remote_plan) == subplan) && parent) { Assert(root); RelOptInfo *rel = find_base_rel(root, ((SubqueryScan *)plan)->scan.scanrelid); diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index 099939b3d7..88c6d23c27 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -1002,6 +1002,9 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte, case RTE_RELATION: case RTE_JOIN: case RTE_CTE: +#ifdef XCP + case RTE_REMOTE_DUMMY: +#endif /* these can't contain any lateral references */ break; } @@ -1648,6 +1651,9 @@ replace_vars_in_jointree(Node *jtnode, case RTE_RELATION: case RTE_JOIN: case RTE_CTE: +#ifdef XCP + case RTE_REMOTE_DUMMY: +#endif /* these shouldn't be marked LATERAL */ Assert(false); break; diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 9ab2083c27..2dbf7f6619 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -113,6 +113,7 @@ static void transformLockingClause(ParseState *pstate, Query *qry, #ifdef XCP static void ParseAnalyze_rtable_walk(List *rtable); +static void ParseAnalyze_substitute_func(FuncExpr *funcexpr); #endif /* @@ -2965,59 +2966,69 @@ static void ParseAnalyze_rtable_walk(List *rtable) { ListCell *item; - StringInfoData buf; if (!IsUnderPostmaster || superuser()) return; - initStringInfo(&buf); foreach(item, rtable) { RangeTblEntry *rte = (RangeTblEntry *) lfirst(item); - resetStringInfo(&buf); - if (rte->rtekind == RTE_FUNCTION && - get_func_namespace(((FuncExpr *) rte->funcexpr)->funcid) == - PG_CATALOG_NAMESPACE) + if (rte->rtekind == RTE_FUNCTION) { - Oid funcid = InvalidOid; + ListCell *lc; + foreach(lc, rte->functions) + { + RangeTblFunction *rtfunc = (RangeTblFunction *) lfirst(lc); + ParseAnalyze_substitute_func((FuncExpr *) rtfunc->funcexpr); + } + } + else if (rte->rtekind == RTE_SUBQUERY) /* recurse for subqueries */ + ParseAnalyze_rtable_walk(rte->subquery->rtable); + } +} - FuncExpr *funcexpr = (FuncExpr *) rte->funcexpr; - const char *funcname = get_func_name(funcexpr->funcid); +static void +ParseAnalyze_substitute_func(FuncExpr *funcexpr) +{ + StringInfoData buf; + initStringInfo(&buf); - /* Check if the funcname is in storm_catalog_remap_string */ - appendStringInfoString(&buf, funcname); - appendStringInfoChar(&buf, ','); + if (get_func_namespace(funcexpr->funcid) == PG_CATALOG_NAMESPACE) + { + Oid funcid = InvalidOid; + const char *funcname = get_func_name(funcexpr->funcid); - elog(DEBUG2, "the constructed name is %s", buf.data); + /* Check if the funcname is in storm_catalog_remap_string */ + appendStringInfoString(&buf, funcname); + appendStringInfoChar(&buf, ','); - /* - * The unqualified function name should be satisfied from the - * storm_catalog appropriately. Just provide a warning for now if - * it is not.. - */ - if (strstr(storm_catalog_remap_string, buf.data)) - { - Oid *argtypes = NULL; - int nargs; + elog(DEBUG2, "the constructed name is %s", buf.data); - get_func_signature(funcexpr->funcid, &argtypes, &nargs); - funcid = get_funcid(funcname, buildoidvector(argtypes, nargs), - STORM_CATALOG_NAMESPACE); - } - else - continue; + /* + * The unqualified function name should be satisfied from the + * storm_catalog appropriately. Just provide a warning for now if + * it is not.. + */ + if (strstr(storm_catalog_remap_string, buf.data)) + { + Oid *argtypes = NULL; + int nargs; + + get_func_signature(funcexpr->funcid, &argtypes, &nargs); + funcid = get_funcid(funcname, buildoidvector(argtypes, nargs), + STORM_CATALOG_NAMESPACE); + } + else + return; - if (get_func_namespace(funcid) != STORM_CATALOG_NAMESPACE) - ereport(WARNING, + if (get_func_namespace(funcid) != STORM_CATALOG_NAMESPACE) + ereport(WARNING, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), errmsg("Entry (%s) present in storm_catalog_remap_string " - "but object not picked from STORM_CATALOG", funcname))); - else /* change the funcid to the storm_catalog one */ - funcexpr->funcid = funcid; - } - else if (rte->rtekind == RTE_SUBQUERY) /* recurse for subqueries */ - ParseAnalyze_rtable_walk(rte->subquery->rtable); + "but object not picked from STORM_CATALOG", funcname))); + else /* change the funcid to the storm_catalog one */ + funcexpr->funcid = funcid; } } #endif diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 6a39dc8c41..5931e2847e 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -598,7 +598,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); OBJECT_P OF OFF OFFSET OIDS ON ONLY OPERATOR OPTION OPTIONS OR ORDER ORDINALITY OUT_P OUTER_P OVER OVERLAPS OVERLAY OWNED OWNER - PARSER PARTIAL PARTITION PASSING PASSWORD PLACING PLANS POSITION + PARSER PARTIAL PARTITION PASSING PASSWORD PAUSE PLACING PLANS POSITION /* PGXC_BEGIN */ PRECEDING PRECISION PREFERRED PRESERVE PREPARE PREPARED PRIMARY /* PGXC_END */ diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index ae708a6da5..9e81051893 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -1352,7 +1352,7 @@ build_aggregate_fnexprs(Oid *agg_input_types, args, InvalidOid, agg_input_collation, - COERCE_DONTCARE); + COERCE_EXPLICIT_CALL); } else *collectfnexpr = NULL; diff --git a/src/backend/pgxc/cluster/pause.c b/src/backend/pgxc/cluster/pause.c index e5b4a000a3..164dafa0e8 100644 --- a/src/backend/pgxc/cluster/pause.c +++ b/src/backend/pgxc/cluster/pause.c @@ -472,7 +472,7 @@ ReleaseClusterLock(bool exclusive) * Decrement our count. If a PAUSE is waiting inside AcquireClusterLock * elsewhere, it will wake out of sleep and do the needful */ - if (clinfo->cl_process_count > 0); + if (clinfo->cl_process_count > 0) clinfo->cl_process_count--; } SpinLockRelease(&clinfo->cl_mutex); diff --git a/src/backend/pgxc/copy/remotecopy.c b/src/backend/pgxc/copy/remotecopy.c index f9a9f20b77..b5256f219c 100644 --- a/src/backend/pgxc/copy/remotecopy.c +++ b/src/backend/pgxc/copy/remotecopy.c @@ -21,6 +21,7 @@ #include "postgres.h" #include "miscadmin.h" #include "lib/stringinfo.h" +#include "nodes/pg_list.h" #include "optimizer/planner.h" #include "pgxc/pgxcnode.h" #include "pgxc/postgresql_fdw.h" diff --git a/src/backend/pgxc/locator/locator.c b/src/backend/pgxc/locator/locator.c index 96e6716fc4..9b98c38f05 100644 --- a/src/backend/pgxc/locator/locator.c +++ b/src/backend/pgxc/locator/locator.c @@ -1025,7 +1025,7 @@ RelationBuildLocator(Relation rel) pcrel = heap_open(PgxcClassRelationId, AccessShareLock); pcscan = systable_beginscan(pcrel, PgxcClassPgxcRelIdIndexId, true, - SnapshotNow, 1, &skey); + SnapshotSelf, 1, &skey); htup = systable_getnext(pcscan); if (!HeapTupleIsValid(htup)) diff --git a/src/backend/pgxc/nodemgr/groupmgr.c b/src/backend/pgxc/nodemgr/groupmgr.c index f16f4ec54b..b63b8cf44f 100644 --- a/src/backend/pgxc/nodemgr/groupmgr.c +++ b/src/backend/pgxc/nodemgr/groupmgr.c @@ -14,12 +14,14 @@ #include "miscadmin.h" #include "access/heapam.h" +#include "access/htup_details.h" #include "catalog/catalog.h" #include "catalog/indexing.h" #include "catalog/pg_type.h" #include "catalog/pgxc_node.h" #include "catalog/pgxc_group.h" #include "nodes/parsenodes.h" +#include "nodes/pg_list.h" #include "utils/builtins.h" #include "utils/rel.h" #include "utils/syscache.h" diff --git a/src/backend/pgxc/nodemgr/nodemgr.c b/src/backend/pgxc/nodemgr/nodemgr.c index 7fcf072786..7ff9fdabac 100644 --- a/src/backend/pgxc/nodemgr/nodemgr.c +++ b/src/backend/pgxc/nodemgr/nodemgr.c @@ -14,6 +14,7 @@ #include "access/hash.h" #include "access/heapam.h" +#include "access/htup_details.h" #include "catalog/catalog.h" #include "catalog/indexing.h" #include "catalog/pgxc_node.h" @@ -327,7 +328,7 @@ PgxcNodeListAndCount(void) * 3) Complete primary/preferred node information */ rel = heap_open(PgxcNodeRelationId, AccessShareLock); - scan = heap_beginscan(rel, SnapshotNow, 0, NULL); + scan = heap_beginscan(rel, SnapshotSelf, 0, NULL); while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { Form_pgxc_node nodeForm = (Form_pgxc_node) GETSTRUCT(tuple); diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index e42a99d8a3..3ecca730e9 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -480,7 +480,7 @@ create_tuple_desc(char *msg_body, size_t len) msg_body += 2; /* Get the OID type and mode type from typename */ - parseTypeString(typname, &oidtypeid, NULL); + parseTypeString(typname, &oidtypeid, NULL, false); TupleDescInitEntry(result, attnum, attname, oidtypeid, typmod, 0); } @@ -8001,7 +8001,7 @@ determine_param_types(Plan *plan, struct find_params_context *context) break; case T_FunctionScan: - if (expression_tree_walker((Node *) ((FunctionScan *) plan)->funcexpr, + if (expression_tree_walker((Node *) ((FunctionScan *) plan)->functions, determine_param_types_walker, (void *) context)) return true; diff --git a/src/backend/pgxc/pool/poolcomm.c b/src/backend/pgxc/pool/poolcomm.c index 591aff0a39..4a3c755e7d 100644 --- a/src/backend/pgxc/pool/poolcomm.c +++ b/src/backend/pgxc/pool/poolcomm.c @@ -121,7 +121,7 @@ Lock_AF_UNIX(unsigned short port, const char *unixSocketName) { POOLER_UNIXSOCK_PATH(sock_path, port, unixSocketName); - CreateSocketLockFile(sock_path, true); + CreateSocketLockFile(sock_path, true, ""); unlink(sock_path); diff --git a/src/backend/pgxc/pool/poolmgr.c b/src/backend/pgxc/pool/poolmgr.c index cd76143350..8fc49c2016 100644 --- a/src/backend/pgxc/pool/poolmgr.c +++ b/src/backend/pgxc/pool/poolmgr.c @@ -410,20 +410,53 @@ GetPoolManagerHandle(void) return; #endif - /* Connect to the pooler */ - fdsock = pool_connect(PoolerPort, UnixSocketDir); - if (fdsock < 0) +#ifdef HAVE_UNIX_SOCKETS + if (Unix_socket_directories) { - int saved_errno = errno; + char *rawstring; + List *elemlist; + ListCell *l; + int success = 0; - ereport(ERROR, - (errcode(ERRCODE_CONNECTION_FAILURE), - errmsg("failed to connect to pool manager: %m"))); - errno = saved_errno; -#ifndef XCP - return NULL; -#endif + /* Need a modifiable copy of Unix_socket_directories */ + rawstring = pstrdup(Unix_socket_directories); + + /* Parse string into list of directories */ + if (!SplitDirectoriesString(rawstring, ',', &elemlist)) + { + /* syntax error in list */ + ereport(FATAL, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("invalid list syntax in parameter \"%s\"", + "unix_socket_directories"))); + } + + foreach(l, elemlist) + { + char *socketdir = (char *) lfirst(l); + int saved_errno; + + /* Connect to the pooler */ + fdsock = pool_connect(PoolerPort, socketdir); + if (fdsock < 0) + { + saved_errno = errno; + ereport(WARNING, + (errmsg("could not create Unix-domain socket in directory \"%s\"", + socketdir))); + } + else + break; + } + + if (!success && elemlist != NIL) + ereport(ERROR, + (errmsg("failed to connect to pool manager: %m"))); + + list_free_deep(elemlist); + pfree(rawstring); } +#endif /* Allocate handle */ /* @@ -2706,20 +2739,68 @@ PoolerLoop(void) StringInfoData input_message; #ifdef XCP time_t last_maintenance = (time_t) 0; + int nfds; + fd_set rfds; #endif - server_fd = pool_listen(PoolerPort, UnixSocketDir); - if (server_fd == -1) + FD_ZERO(&rfds); + +#ifdef HAVE_UNIX_SOCKETS + if (Unix_socket_directories) { - /* log error */ - return; + char *rawstring; + List *elemlist; + ListCell *l; + int success = 0; + + /* Need a modifiable copy of Unix_socket_directories */ + rawstring = pstrdup(Unix_socket_directories); + + /* Parse string into list of directories */ + if (!SplitDirectoriesString(rawstring, ',', &elemlist)) + { + /* syntax error in list */ + ereport(FATAL, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("invalid list syntax in parameter \"%s\"", + "unix_socket_directories"))); + } + + nfds = 0; + foreach(l, elemlist) + { + char *socketdir = (char *) lfirst(l); + int saved_errno; + + /* Connect to the pooler */ + server_fd = pool_listen(PoolerPort, socketdir); + if (server_fd < 0) + { + saved_errno = errno; + ereport(WARNING, + (errmsg("could not create Unix-domain socket in directory \"%s\"", + socketdir))); + } + else + { + /* watch for incoming connections */ + FD_SET(server_fd, &rfds); + nfds = Max(nfds, server_fd); + } + } + + if (!success && elemlist != NIL) + ereport(ERROR, + (errmsg("failed to connect to pool manager: %m"))); + + list_free_deep(elemlist); + pfree(rawstring); } +#endif initStringInfo(&input_message); for (;;) { - int nfds; - fd_set rfds; int retval; int i; @@ -2730,12 +2811,6 @@ PoolerLoop(void) if (!PostmasterIsAlive()) exit(1); - /* watch for incoming connections */ - FD_ZERO(&rfds); - FD_SET(server_fd, &rfds); - - nfds = server_fd; - /* watch for incoming messages */ for (i = 0; i < agentCount; i++) { diff --git a/src/backend/pgxc/pool/poolutils.c b/src/backend/pgxc/pool/poolutils.c index e383845101..9b4cbd7601 100644 --- a/src/backend/pgxc/pool/poolutils.c +++ b/src/backend/pgxc/pool/poolutils.c @@ -24,6 +24,7 @@ #include "pgxc/pgxc.h" #include "nodes/nodes.h" +#include "nodes/pg_list.h" #include "pgxc/poolmgr.h" #include "pgxc/locator.h" #include "pgxc/nodemgr.h" diff --git a/src/backend/pgxc/squeue/squeue.c b/src/backend/pgxc/squeue/squeue.c index fbe20d4a23..02d11d2430 100644 --- a/src/backend/pgxc/squeue/squeue.c +++ b/src/backend/pgxc/squeue/squeue.c @@ -26,6 +26,7 @@ #include "catalog/pgxc_node.h" #include "commands/prepare.h" #include "executor/executor.h" +#include "nodes/pg_list.h" #include "pgxc/nodemgr.h" #include "pgxc/pgxc.h" #include "pgxc/pgxcnode.h" diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c index 00b5b838d7..1fd9706914 100644 --- a/src/backend/replication/logical/decode.c +++ b/src/backend/replication/logical/decode.c @@ -132,6 +132,10 @@ LogicalDecodingProcessRecord(LogicalDecodingContext *ctx, XLogRecord *record) case RM_GIST_ID: case RM_SEQ_ID: case RM_SPGIST_ID: +#ifdef PGXC + case RM_BARRIER_ID: +#endif + break; case RM_NEXT_ID: elog(ERROR, "unexpected RM_NEXT_ID rmgr_id: %u", (RmgrIds) buf.record.xl_rmid); diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c index 6807c44679..a00564a002 100644 --- a/src/backend/rewrite/rewriteHandler.c +++ b/src/backend/rewrite/rewriteHandler.c @@ -3800,9 +3800,8 @@ QueryRewriteCTAS(Query *parsetree) deparse_query(cparsetree, &cquery, NIL); /* Finally, fire off the query to run the DDL */ - ProcessUtility(cparsetree->utilityStmt, cquery.data, NULL, true, NULL, - false, - NULL); + ProcessUtility(cparsetree->utilityStmt, cquery.data, PROCESS_UTILITY_QUERY, + NULL, NULL, false, NULL); /* * Now fold the CTAS statement into an INSERT INTO statement. The diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index f1c2e2bdb8..2395852fec 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -974,7 +974,7 @@ LockAcquireExtendedXC(const LOCKTAG *locktag, status = STATUS_FOUND; else status = LockCheckConflicts(lockMethodTable, lockmode, - lock, proclock); + lock, proclock, MyProc); if (status == STATUS_OK) { @@ -1319,7 +1319,8 @@ int LockCheckConflicts(LockMethod lockMethodTable, LOCKMODE lockmode, LOCK *lock, - PROCLOCK *proclock) + PROCLOCK *proclock, + PGPROC *proc) { int numLockModes = lockMethodTable->numLockModes; LOCKMASK myLocks; diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 771ebc9255..ac372831f0 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -1036,7 +1036,8 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable) LockCheckConflicts(lockMethodTable, lockmode, lock, - proclock) == STATUS_OK) + proclock, + MyProc) == STATUS_OK) { /* Skip the wait and just grant myself the lock. */ GrantLock(lock, proclock, lockmode); @@ -1502,7 +1503,8 @@ ProcLockWakeup(LockMethod lockMethodTable, LOCK *lock) LockCheckConflicts(lockMethodTable, lockmode, lock, - proc->waitProcLock) == STATUS_OK) + proc->waitProcLock, + proc) == STATUS_OK) { /* OK to waken */ GrantLock(lock, proc->waitProcLock, lockmode); diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 0604369e13..e88f61bb19 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -1457,7 +1457,7 @@ exec_parse_message(const char *query_string, /* string to execute */ /* we don't expect type mod */ for (cnt_param = 0; cnt_param < numParams; cnt_param++) parseTypeString(paramTypeNames[cnt_param], ¶mTypes[cnt_param], - NULL); + NULL, false); } #endif /* PGXC */ @@ -1746,7 +1746,7 @@ exec_plan_message(const char *query_string, /* source of the query */ /* we don't expect type mod */ for (cnt_param = 0; cnt_param < numParams; cnt_param++) parseTypeString(paramTypeNames[cnt_param], ¶mTypes[cnt_param], - NULL); + NULL, false); } diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index 04f17ac8eb..23b303fcbd 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -591,7 +591,7 @@ PortalStart(Portal portal, ParamListInfo params, /* No special ability is needed */ eflags = 0; /* Must set snapshot before starting executor. */ - if (use_active_snapshot) + if (snapshot) PushActiveSnapshot(GetActiveSnapshot()); else PushActiveSnapshot(GetTransactionSnapshot()); diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 91408998f9..d09564f060 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -118,7 +118,15 @@ static void ProcessUtilitySlow(Node *parsetree, bool sentToRemote, #endif /* PGXC */ char *completionTag); + +#ifdef PGXC +static void ExecDropStmt(DropStmt *stmt, + const char *queryString, + bool sentToRemote, + bool isTopLevel); +#else static void ExecDropStmt(DropStmt *stmt, bool isTopLevel); +#endif /* @@ -421,7 +429,6 @@ standard_ProcessUtility(Node *parsetree, pgxc_lock_for_utility_stmt(parsetree); } #endif -+ check_xact_readonly(parsetree); @@ -1242,7 +1249,11 @@ standard_ProcessUtility(Node *parsetree, #endif completionTag); else +#ifdef PGXC + ExecDropStmt(stmt, queryString, sentToRemote, isTopLevel); +#else ExecDropStmt(stmt, isTopLevel); +#endif } break; @@ -1546,7 +1557,6 @@ ProcessUtilitySlow(Node *parsetree, PoolManagerSetCommand(POOL_CMD_TEMP, NULL); #endif #endif -+ /* Create the table itself */ relOid = DefineRelation((CreateStmt *) stmt, @@ -2221,7 +2231,11 @@ ProcessUtilitySlow(Node *parsetree, #endif case T_DropStmt: +#ifdef PGXC + ExecDropStmt((DropStmt *) parsetree, queryString, sentToRemote, isTopLevel); +#else ExecDropStmt((DropStmt *) parsetree, isTopLevel); +#endif break; case T_RenameStmt: @@ -2281,7 +2295,14 @@ ProcessUtilitySlow(Node *parsetree, * Dispatch function for DropStmt */ static void +#ifdef PGXC +ExecDropStmt(DropStmt *stmt, + const char *queryString, + bool sentToRemote, + bool isTopLevel) +#else ExecDropStmt(DropStmt *stmt, bool isTopLevel) +#endif { switch (stmt->removeType) { @@ -2302,7 +2323,7 @@ ExecDropStmt(DropStmt *stmt, bool isTopLevel) RemoteQueryExecType exec_type = EXEC_ON_ALL_NODES; /* Check restrictions on objects dropped */ - DropStmtPreTreatment((DropStmt *) parsetree, queryString, sentToRemote, + DropStmtPreTreatment((DropStmt *) stmt, queryString, sentToRemote, &is_temp, &exec_type); #endif RemoveRelations(stmt); @@ -2321,7 +2342,7 @@ ExecDropStmt(DropStmt *stmt, bool isTopLevel) RemoteQueryExecType exec_type = EXEC_ON_ALL_NODES; /* Check restrictions on objects dropped */ - DropStmtPreTreatment((DropStmt *) parsetree, queryString, sentToRemote, + DropStmtPreTreatment((DropStmt *) stmt, queryString, sentToRemote, &is_temp, &exec_type); #endif RemoveObjects(stmt); diff --git a/src/backend/utils/adt/pseudotypes.c b/src/backend/utils/adt/pseudotypes.c index 25ca02211d..cd9660c3fb 100644 --- a/src/backend/utils/adt/pseudotypes.c +++ b/src/backend/utils/adt/pseudotypes.c @@ -33,6 +33,7 @@ #include "utils/rangetypes.h" #ifdef XCP #include "access/htup.h" +#include "access/htup_details.h" #include "catalog/pg_type.h" #include "utils/lsyscache.h" #include "utils/syscache.h" diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index e38d5f18c6..20e6f80d82 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -4340,7 +4340,7 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, void deparse_query(Query *query, StringInfo buf, List *parentnamespace) { - get_query_def(query, buf, parentnamespace, NULL, 0, 0); + get_query_def(query, buf, parentnamespace, NULL, 0, 0, 0); } /* code borrowed from get_insert_query_def */ @@ -4364,7 +4364,7 @@ get_query_def_from_valuesList(Query *query, StringInfo buf) * consistent results. Note we assume it's OK to scribble on the passed * querytree! */ - AcquireRewriteLocks(query, false); + AcquireRewriteLocks(query, false, false); context.buf = buf; context.namespaces = NIL; @@ -4373,11 +4373,10 @@ get_query_def_from_valuesList(Query *query, StringInfo buf) context.varprefix = (list_length(query->rtable) != 1); context.prettyFlags = 0; context.indentLevel = 0; -#ifdef PGXC -#ifndef XCP + context.wrapColumn = 0; +#ifndef XCP context.finalise_aggs = query->qry_finalise_aggs; -#endif /* XCP */ -#endif /* PGXC */ +#endif dpns.rtable = query->rtable; dpns.ctes = query->cteList; @@ -4473,7 +4472,8 @@ get_query_def_from_valuesList(Query *query, StringInfo buf) { /* Add the SELECT */ get_query_def(select_rte->subquery, buf, NIL, NULL, - context.prettyFlags, context.indentLevel); + context.prettyFlags, context.wrapColumn, + context.indentLevel); } else if (values_rte) { @@ -9095,7 +9095,7 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) */ appendStringInfo(buf, " %s", quote_identifier(rte->eref->aliasname)); - gavealias = true; + printalias = true; } #endif else if (rte->rtekind == RTE_FUNCTION) diff --git a/src/backend/utils/resowner/resowner.c b/src/backend/utils/resowner/resowner.c index 024d7ad911..fba60a20b9 100644 --- a/src/backend/utils/resowner/resowner.c +++ b/src/backend/utils/resowner/resowner.c @@ -21,6 +21,9 @@ #include "postgres.h" #include "access/hash.h" +#ifdef PGXC +#include "commands/prepare.h" +#endif #include "storage/predicate.h" #include "storage/proc.h" #include "utils/memutils.h" @@ -415,7 +418,7 @@ ResourceOwnerReleaseInternal(ResourceOwner owner, char *stmt = owner->stmts + ((owner->nstmts - 1) * CNAME_MAXLEN); if (isCommit) PrintPreparedStmtLeakWarning(stmt); - DropPreparedStatement(stmt); + DropPreparedStatement(stmt, false); } #endif diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index f63f6193c2..e3a5ed800d 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -3817,7 +3817,7 @@ main(int argc, char *argv[]) break; #ifdef PGXC case 12: - nodename = xstrdup(optarg); + nodename = pg_strdup(optarg); break; #endif default: diff --git a/src/bin/initgtm/initgtm.c b/src/bin/initgtm/initgtm.c index d779fff6b9..dd451d66e3 100644 --- a/src/bin/initgtm/initgtm.c +++ b/src/bin/initgtm/initgtm.c @@ -71,7 +71,6 @@ static char *gtm_host = "localhost"; static char bin_path[MAXPGPATH]; static char backend_exec[MAXPGPATH]; -static void *pg_malloc(size_t size); static char *xstrdup(const char *s); static char **replace_token(char **lines, const char *token, const char *replacement); @@ -104,26 +103,6 @@ static int CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo); #define DIR_SEP "\\" #endif -/* - * routines to check mem allocations and fail noisily. - * - * Note that we can't call exit_nicely() on a memory failure, as it calls - * rmtree() which needs memory allocation. So we just exit with a bang. - */ -static void * -pg_malloc(size_t size) -{ - void *result; - - result = malloc(size); - if (!result) - { - fprintf(stderr, _("%s: out of memory\n"), progname); - exit(1); - } - return result; -} - static char * xstrdup(const char *s) { @@ -626,13 +605,6 @@ check_ok(void) } } -/* Hack to suppress a warning about %x from some versions of gcc */ -static inline size_t -my_strftime(char *s, size_t max, const char *fmt, const struct tm * tm) -{ - return strftime(s, max, fmt, tm); -} - #ifdef WIN32 /* diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index a9a938ac5c..2300fb1df3 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -2416,9 +2416,6 @@ describeOneTableDetails(const char *schemaname, const char *dist_by = _("Distribute By"); const char *loc_nodes = _("Location Nodes"); - /* Only one tuple should be returned */ - psql_assert(tuples == 1); - /* Print distribution method */ printfPQExpBuffer(&buf, "%s: %s", dist_by, PQgetvalue(result, 0, 0)); diff --git a/src/common/relpath.c b/src/common/relpath.c index a5d1bc5adb..e4c64f685d 100644 --- a/src/common/relpath.c +++ b/src/common/relpath.c @@ -23,6 +23,9 @@ #include "common/relpath.h" #include "storage/backendid.h" +#ifdef PGXC +#include "pgxc/pgxc.h" +#endif /* * Lookup table of fork name by fork number. diff --git a/src/gtm/gtm_ctl/gtm_ctl.c b/src/gtm/gtm_ctl/gtm_ctl.c index af9b4aa25c..1f50c3b383 100644 --- a/src/gtm/gtm_ctl/gtm_ctl.c +++ b/src/gtm/gtm_ctl/gtm_ctl.c @@ -289,10 +289,10 @@ start_gtm(void) strncat(gtm_app_path, gtm_app, MAXPGPATH - len - 1); if (log_file != NULL) - len = snprintf(cmd, MAXPGPATH - 1, SYSTEMQUOTE "\"%s\" %s%s -l %s &" SYSTEMQUOTE, + len = snprintf(cmd, MAXPGPATH - 1, "\"%s\" %s%s -l %s &" , gtm_app_path, gtmdata_opt, gtm_opts, log_file); else - len = snprintf(cmd, MAXPGPATH - 1, SYSTEMQUOTE "\"%s\" %s%s < \"%s\" 2>&1 &" SYSTEMQUOTE, + len = snprintf(cmd, MAXPGPATH - 1, "\"%s\" %s%s < \"%s\" 2>&1 &" , gtm_app_path, gtmdata_opt, gtm_opts, DEVNULL); if (len >= MAXPGPATH - 1) diff --git a/src/gtm/main/gtm_txn.c b/src/gtm/main/gtm_txn.c index 7f1289c9d9..80be45c798 100644 --- a/src/gtm/main/gtm_txn.c +++ b/src/gtm/main/gtm_txn.c @@ -364,7 +364,7 @@ GTM_RemoveAllTransInfos(uint32 client_id, int backend_id) uint32 GTMGetLastClientIdentifier(void) { - gtm_ListCell *cell, *prev; + gtm_ListCell *cell; uint32 last_client_id = 0; /* @@ -392,7 +392,7 @@ GTMGetLastClientIdentifier(void) uint32 GTMGetFirstClientIdentifier(void) { - gtm_ListCell *cell, *prev; + gtm_ListCell *cell; uint32 first_client_id = UINT32_MAX; /* diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h index 43c580ce41..a960bd9b29 100644 --- a/src/include/catalog/pg_aggregate.h +++ b/src/include/catalog/pg_aggregate.h @@ -151,11 +151,11 @@ typedef FormData_pg_aggregate *Form_pg_aggregate; /* avg */ DATA(insert ( 2100 n 0 int8_avg_accum numeric_avg_collect numeric_avg int8_avg_accum int8_accum_inv numeric_avg f f 0 2281 2281 128 2281 128 _null_ _null_ _null_ )); -DATA(insert ( 2101 n 0 int4_avg_accum int8_avg_collect int8_avg int4_avg_accum int4_avg_accum_inv int8_avg f f 0 1016 1016 0 1016 0 "{0,0}" "{0,0} "{0,0}" )); -DATA(insert ( 2102 n 0 int2_avg_accum int8_avg_collect int8_avg int2_avg_accum int2_avg_accum_inv int8_avg f f 0 1016 1016 0 1016 0 "{0,0}" "{0,0} "{0,0}" )); +DATA(insert ( 2101 n 0 int4_avg_accum int8_avg_collect int8_avg int4_avg_accum int4_avg_accum_inv int8_avg f f 0 1016 1016 0 1016 0 "{0,0}" "{0,0}" "{0,0}" )); +DATA(insert ( 2102 n 0 int2_avg_accum int8_avg_collect int8_avg int2_avg_accum int2_avg_accum_inv int8_avg f f 0 1016 1016 0 1016 0 "{0,0}" "{0,0}" "{0,0}" )); DATA(insert ( 2103 n 0 numeric_avg_accum numeric_avg_collect numeric_avg numeric_avg_accum numeric_accum_inv numeric_avg f f 0 2281 2281 128 2281 128 _null_ _null_ _null_ )); -DATA(insert ( 2104 n 0 float4_accum float8_collect float8_avg - - - f f 0 1022 1022 0 0 0 "{0,0,0}" "{0,0,0} _null_ )); -DATA(insert ( 2105 n 0 float8_accum float8_collect float8_avg - - - f f 0 1022 1022 0 0 0 "{0,0,0}" "{0,0,0} _null_ )); +DATA(insert ( 2104 n 0 float4_accum float8_collect float8_avg - - - f f 0 1022 1022 0 0 0 "{0,0,0}" "{0,0,0}" _null_ )); +DATA(insert ( 2105 n 0 float8_accum float8_collect float8_avg - - - f f 0 1022 1022 0 0 0 "{0,0,0}" "{0,0,0}" _null_ )); DATA(insert ( 2106 n 0 interval_accum interval_collect interval_avg interval_accum interval_accum_inv interval_avg f f 0 1187 1187 0 1187 0 "{0 second,0 second}" "{0 second,0 second}" "{0 second,0 second}" )); /* sum */ @@ -220,8 +220,8 @@ DATA(insert ( 2803 n 0 int8inc int8_sum_to_int8 - int8inc int8dec - DATA(insert ( 2718 n 0 int8_accum numeric_collect numeric_var_pop int8_accum int8_accum_inv numeric_var_pop f f 0 2281 2281 128 2281 128 _null_ _null_ _null_ )); DATA(insert ( 2719 n 0 int4_accum numeric_collect numeric_var_pop int4_accum int4_accum_inv numeric_var_pop f f 0 2281 2281 128 2281 128 _null_ _null_ _null_ )); DATA(insert ( 2720 n 0 int2_accum numeric_collect numeric_var_pop int2_accum int2_accum_inv numeric_var_pop f f 0 2281 2281 128 2281 128 _null_ _null_ _null_ )); -DATA(insert ( 2721 n 0 float4_accum float8_collect float8_var_pop - - - f f 0 1022 1022 0 0 0 "{0,0,0}" "{0,0,0} _null_ )); -DATA(insert ( 2722 n 0 float8_accum float8_collect float8_var_pop - - - f f 0 1022 1022 0 0 0 "{0,0,0}" "{0,0,0} _null_ )); +DATA(insert ( 2721 n 0 float4_accum float8_collect float8_var_pop - - - f f 0 1022 1022 0 0 0 "{0,0,0}" "{0,0,0}" _null_ )); +DATA(insert ( 2722 n 0 float8_accum float8_collect float8_var_pop - - - f f 0 1022 1022 0 0 0 "{0,0,0}" "{0,0,0}" _null_ )); DATA(insert ( 2723 n 0 numeric_accum numeric_collect numeric_var_pop numeric_accum numeric_accum_inv numeric_var_pop f f 0 2281 2281 128 2281 128 _null_ _null_ _null_ )); /* var_samp */ diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 76f147d6c6..2eed6e9d7e 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -2516,19 +2516,19 @@ DESCR("aggregate final function"); DATA(insert OID = 3535 ( string_agg_transfn PGNSP PGUID 12 1 0 0 0 f f f f f f i 3 0 2281 "2281 25 25" _null_ _null_ _null_ _null_ string_agg_transfn _null_ _null_ _null_ )); DESCR("aggregate transition function"); #ifdef PGXC -DATA(insert OID = 2966 ( float8_collect PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1022 "1022 1022" _null_ _null_ _null_ _null_ float8_collect _null_ _null_ _null_ )); +DATA(insert OID = 6000 ( float8_collect PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1022 "1022 1022" _null_ _null_ _null_ _null_ float8_collect _null_ _null_ _null_ )); DESCR("aggregate collection function"); -DATA(insert OID = 2964 ( numeric_avg_collect PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1231 "1231 1231" _null_ _null_ _null_ _null_ numeric_avg_collect _null_ _null_ _null_ )); +DATA(insert OID = 6001 ( numeric_avg_collect PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1231 "1231 1231" _null_ _null_ _null_ _null_ numeric_avg_collect _null_ _null_ _null_ )); DESCR("aggregate collection function"); -DATA(insert OID = 2968 ( numeric_collect PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1231 "1231 1231" _null_ _null_ _null_ _null_ numeric_collect _null_ _null_ _null_ )); +DATA(insert OID = 6002 ( numeric_collect PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1231 "1231 1231" _null_ _null_ _null_ _null_ numeric_collect _null_ _null_ _null_ )); DESCR("aggregate collection function"); -DATA(insert OID = 2967 ( interval_collect PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1187 "1187 1187" _null_ _null_ _null_ _null_ interval_collect _null_ _null_ _null_ )); +DATA(insert OID = 6003 ( interval_collect PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1187 "1187 1187" _null_ _null_ _null_ _null_ interval_collect _null_ _null_ _null_ )); DESCR("aggregate transition function"); -DATA(insert OID = 2965 ( int8_avg_collect PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1016 "1016 1016" _null_ _null_ _null_ _null_ int8_avg_collect _null_ _null_ _null_ )); +DATA(insert OID = 6004 ( int8_avg_collect PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1016 "1016 1016" _null_ _null_ _null_ _null_ int8_avg_collect _null_ _null_ _null_ )); DESCR("AVG(int) collection function"); -DATA(insert OID = 2996 ( int8_sum_to_int8 PGNSP PGUID 12 1 0 0 0 f f f f f f i 2 0 20 "20 20" _null_ _null_ _null_ _null_ int8_sum_to_int8 _null_ _null_ _null_ )); +DATA(insert OID = 6005 ( int8_sum_to_int8 PGNSP PGUID 12 1 0 0 0 f f f f f f i 2 0 20 "20 20" _null_ _null_ _null_ _null_ int8_sum_to_int8 _null_ _null_ _null_ )); DESCR("SUM(int) collection function"); -DATA(insert OID = 2995 ( float8_regr_collect PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1022 "1022 1022" _null_ _null_ _null_ _null_ float8_regr_collect _null_ _null_ _null_ )); +DATA(insert OID = 6006 ( float8_regr_collect PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1022 "1022 1022" _null_ _null_ _null_ _null_ float8_regr_collect _null_ _null_ _null_ )); DESCR("REGR_...(double, double) collection function"); #endif DATA(insert OID = 3536 ( string_agg_finalfn PGNSP PGUID 12 1 0 0 0 f f f f f f i 1 0 25 "2281" _null_ _null_ _null_ _null_ string_agg_finalfn _null_ _null_ _null_ )); @@ -5057,18 +5057,18 @@ DATA(insert OID = 3993 ( dense_rank_final PGNSP PGUID 12 1 0 2276 0 f f f f f f DESCR("aggregate final function"); #ifdef PGXC -DATA(insert OID = 3200 ( pgxc_pool_check PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 16 "" _null_ _null_ _null_ _null_ pgxc_pool_check _null_ _null_ _null_ )); +DATA(insert OID = 6007 ( pgxc_pool_check PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 16 "" _null_ _null_ _null_ _null_ pgxc_pool_check _null_ _null_ _null_ )); DESCR("check connection information consistency in pooler"); -DATA(insert OID = 3201 ( pgxc_pool_reload PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 16 "" _null_ _null_ _null_ _null_ pgxc_pool_reload _null_ _null_ _null_ )); +DATA(insert OID = 6008 ( pgxc_pool_reload PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 16 "" _null_ _null_ _null_ _null_ pgxc_pool_reload _null_ _null_ _null_ )); DESCR("reload connection information in pooler and reload server sessions"); -DATA(insert OID = 3202 ( pgxc_node_str PGNSP PGUID 12 1 0 0 0 f f f f t f s 0 0 19 "" _null_ _null_ _null_ _null_ pgxc_node_str _null_ _null_ _null_ )); +DATA(insert OID = 6009 ( pgxc_node_str PGNSP PGUID 12 1 0 0 0 f f f f t f s 0 0 19 "" _null_ _null_ _null_ _null_ pgxc_node_str _null_ _null_ _null_ )); DESCR("get the name of the node"); -DATA(insert OID = 3203 ( pgxc_is_committed PGNSP PGUID 12 1 1 0 0 f f f f t t s 1 0 16 "28" _null_ _null_ _null_ _null_ pgxc_is_committed _null_ _null_ _null_ )); +DATA(insert OID = 6010 ( pgxc_is_committed PGNSP PGUID 12 1 1 0 0 f f f f t t s 1 0 16 "28" _null_ _null_ _null_ _null_ pgxc_is_committed _null_ _null_ _null_ )); DESCR("is given GXID committed or aborted?"); -DATA(insert OID = 3205 ( pgxc_lock_for_backup PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 16 "" _null_ _null_ _null_ _null_ pgxc_lock_for_backup _null_ _null_ _null_ )); +DATA(insert OID = 6011 ( pgxc_lock_for_backup PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 16 "" _null_ _null_ _null_ _null_ pgxc_lock_for_backup _null_ _null_ _null_ )); DESCR("lock the cluster for taking backup"); #ifdef XCP -DATA(insert OID = 3204 ( stormdb_promote_standby PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 2278 "" _null_ _null_ _null_ _null_ stormdb_promote_standby _null_ _null_ _null_ )); +DATA(insert OID = 6012 ( stormdb_promote_standby PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 2278 "" _null_ _null_ _null_ _null_ stormdb_promote_standby _null_ _null_ _null_ )); DESCR("touch trigger file on a standby machine to end replication"); #endif #endif diff --git a/src/include/catalog/pgxc_class.h b/src/include/catalog/pgxc_class.h index cb540bf584..164dbd9afc 100644 --- a/src/include/catalog/pgxc_class.h +++ b/src/include/catalog/pgxc_class.h @@ -12,9 +12,9 @@ CATALOG(pgxc_class,9001) BKI_WITHOUT_OIDS { Oid pcrelid; /* Table Oid */ char pclocatortype; /* Type of distribution */ - int2 pcattnum; /* Column number of distribution */ - int2 pchashalgorithm; /* Hashing algorithm */ - int2 pchashbuckets; /* Number of buckets */ + int16 pcattnum; /* Column number of distribution */ + int16 pchashalgorithm; /* Hashing algorithm */ + int16 pchashbuckets; /* Number of buckets */ /* VARIABLE LENGTH FIELDS: */ oidvector nodeoids; /* List of nodes used by table */ diff --git a/src/include/catalog/pgxc_node.h b/src/include/catalog/pgxc_node.h index e272243956..c55633cddd 100644 --- a/src/include/catalog/pgxc_node.h +++ b/src/include/catalog/pgxc_node.h @@ -36,7 +36,7 @@ CATALOG(pgxc_node,9015) BKI_SHARED_RELATION /* * Port number of the node to connect to */ - int4 node_port; + int32 node_port; /* * Host name of IP address of the node to connect to @@ -56,7 +56,7 @@ CATALOG(pgxc_node,9015) BKI_SHARED_RELATION /* * Node identifier to be used at places where a fixed length node identification is required */ - int4 node_id; + int32 node_id; } FormData_pgxc_node; typedef FormData_pgxc_node *Form_pgxc_node; diff --git a/src/include/gtm/assert.h b/src/include/gtm/assert.h index 2a2f47dcab..5e6425c934 100644 --- a/src/include/gtm/assert.h +++ b/src/include/gtm/assert.h @@ -18,57 +18,5 @@ extern bool assert_enabled; -/* - * USE_ASSERT_CHECKING, if defined, turns on all the assertions. - * - plai 9/5/90 - * - * It should _NOT_ be defined in releases or in benchmark copies - */ - -/* - * Trap - * Generates an exception if the given condition is true. - */ -#define Trap(condition, errorType) \ - do { \ - if ((assert_enabled) && (condition)) \ - ExceptionalCondition(CppAsString(condition), (errorType), \ - __FILE__, __LINE__); \ - } while (0) - -/* - * TrapMacro is the same as Trap but it's intended for use in macros: - * - * #define foo(x) (AssertMacro(x != 0) && bar(x)) - * - * Isn't CPP fun? - */ -#define TrapMacro(condition, errorType) \ - ((bool) ((! assert_enabled) || ! (condition) || \ - (ExceptionalCondition(CppAsString(condition), (errorType), \ - __FILE__, __LINE__)))) - -#ifndef USE_ASSERT_CHECKING -#define Assert(condition) -#define AssertMacro(condition) ((void)true) -#define AssertArg(condition) -#define AssertState(condition) -#else -#define Assert(condition) \ - Trap(!(condition), "FailedAssertion") - -#define AssertMacro(condition) \ - ((void) TrapMacro(!(condition), "FailedAssertion")) - -#define AssertArg(condition) \ - Trap(!(condition), "BadArgument") - -#define AssertState(condition) \ - Trap(!(condition), "BadState") -#endif /* USE_ASSERT_CHECKING */ - -extern int ExceptionalCondition(const char *conditionName, - const char *errorType, - const char *fileName, int lineNumber); - #endif + diff --git a/src/include/gtm/pqsignal.h b/src/include/gtm/pqsignal.h index 9992791b23..c6d346e913 100644 --- a/src/include/gtm/pqsignal.h +++ b/src/include/gtm/pqsignal.h @@ -40,8 +40,6 @@ int pqsigsetmask(int mask); #endif #endif -typedef void (*pqsigfunc) (int); - extern void pqinitmask(void); extern pqsigfunc pqsignal(int signo, pqsigfunc func); diff --git a/src/include/pgxc/barrier.h b/src/include/pgxc/barrier.h index 1ed9ffb445..084cc7f151 100644 --- a/src/include/pgxc/barrier.h +++ b/src/include/pgxc/barrier.h @@ -13,8 +13,8 @@ *------------------------------------------------------------------------- */ -#ifndef BARRIER_H -#define BARRIER_H +#ifndef PGXC_BARRIER_H +#define PGXC_BARRIER_H #include "access/xlog.h" #include "access/xlogdefs.h" diff --git a/src/include/storage/barrier.h b/src/include/storage/barrier.h index bc61de0ff1..2bef2eb6ad 100644 --- a/src/include/storage/barrier.h +++ b/src/include/storage/barrier.h @@ -75,7 +75,7 @@ extern slock_t dummy_spinlock; * "lock; addl" has worked for longer than "mfence". */ #define pg_memory_barrier() \ - __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory") + __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory", "cc") #define pg_read_barrier() pg_compiler_barrier() #define pg_write_barrier() pg_compiler_barrier() #elif defined(__x86_64__) /* 64 bit x86 */ @@ -89,7 +89,7 @@ extern slock_t dummy_spinlock; * do those things, a compiler barrier should be enough. */ #define pg_memory_barrier() \ - __asm__ __volatile__ ("lock; addl $0,0(%%rsp)" : : : "memory") + __asm__ __volatile__ ("lock; addl $0,0(%%rsp)" : : : "memory", "cc") #define pg_read_barrier() pg_compiler_barrier() #define pg_write_barrier() pg_compiler_barrier() #elif defined(__ia64__) || defined(__ia64) diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h index 8efed564f5..4cc9527284 100644 --- a/src/include/storage/lock.h +++ b/src/include/storage/lock.h @@ -520,7 +520,7 @@ extern void AtPrepare_Locks(void); extern void PostPrepare_Locks(TransactionId xid); extern int LockCheckConflicts(LockMethod lockMethodTable, LOCKMODE lockmode, - LOCK *lock, PROCLOCK *proclock); + LOCK *lock, PROCLOCK *proclock, PGPROC *proc); extern void GrantLock(LOCK *lock, PROCLOCK *proclock, LOCKMODE lockmode); extern void GrantAwaitedLock(void); extern void RemoveFromWaitQueue(PGPROC *proc, uint32 hashcode); diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 3a79f77a0e..d44511a1a3 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -396,7 +396,7 @@ stop_gtm(void) fflush(stderr); snprintf(buf, sizeof(buf), - SYSTEMQUOTE "\"%s/gtm_ctl\" stop -Z gtm -D \"%s/%s\" -m fast" SYSTEMQUOTE, + "\"%s/gtm_ctl\" stop -Z gtm -D \"%s/%s\" -m fast", bindir, temp_install, data_folder); r = system(buf); if (r != 0) @@ -422,7 +422,7 @@ stop_node(PGXCNodeTypeNum node) fflush(stderr); snprintf(buf, sizeof(buf), - SYSTEMQUOTE "\"%s/pg_ctl\" stop -D \"%s/%s\" -s -m fast" SYSTEMQUOTE, + "\"%s/pg_ctl\" stop -D \"%s/%s\" -s -m fast", bindir, temp_install, data_folder); r = system(buf); if (r != 0) @@ -625,7 +625,7 @@ calculate_node_port(PGXCNodeTypeNum node, bool is_main) * Check if there is a postmaster running already. */ snprintf(buf, sizeof(buf), - SYSTEMQUOTE "\"%s/psql\" -p %d -X postgres <%s 2>%s" SYSTEMQUOTE, + "\"%s/psql\" -p %d -X postgres <%s 2>%s", bindir, port_number, DEVNULL, DEVNULL); for (i = 0; i < 16; i++) @@ -738,7 +738,7 @@ start_node(PGXCNodeTypeNum node, bool is_coord, bool is_main) /* Case of a GTM start */ header(_("starting GTM process")); snprintf(buf, sizeof(buf), - SYSTEMQUOTE "\"%s/gtm\" -D \"%s/%s\" -p %d -x 10000 > \"%s/log/gtm.log\" 2>&1" SYSTEMQUOTE, + "\"%s/gtm\" -D \"%s/%s\" -p %d -x 10000 > \"%s/log/gtm.log\" 2>&1", bindir, temp_install, data_folder, port_number, outputdir); } @@ -747,7 +747,7 @@ start_node(PGXCNodeTypeNum node, bool is_coord, bool is_main) /* Case of normal nodes, start the node */ if (is_main) snprintf(buf, sizeof(buf), - SYSTEMQUOTE "\"%s/postgres\" %s -i -p %d -D \"%s/%s\"%s -c \"listen_addresses=%s\" > \"%s/log/postmaster_%d.log\" 2>&1" SYSTEMQUOTE, + "\"%s/postgres\" %s -i -p %d -D \"%s/%s\"%s -c \"listen_addresses=%s\" > \"%s/log/postmaster_%d.log\" 2>&1", bindir, is_coord ? "--coordinator" : "--datanode", port_number, @@ -758,7 +758,7 @@ start_node(PGXCNodeTypeNum node, bool is_coord, bool is_main) node); else snprintf(buf, sizeof(buf), - SYSTEMQUOTE "\"%s/postgres\" %s -i -p %d -D \"%s/%s\"%s > \"%s/log/postmaster_%d.log\" 2>&1" SYSTEMQUOTE, + "\"%s/postgres\" %s -i -p %d -D \"%s/%s\"%s > \"%s/log/postmaster_%d.log\" 2>&1", bindir, is_coord ? "--coordinator" : "--datanode", port_number, @@ -800,7 +800,7 @@ initdb_node(PGXCNodeTypeNum node) if (node == PGXC_GTM) { snprintf(buf, sizeof(buf), - SYSTEMQUOTE "\"%s/initgtm\" -Z gtm -D \"%s/%s\" --noclean%s > \"%s/log/initgtm.log\" 2>&1" SYSTEMQUOTE, + "\"%s/initgtm\" -Z gtm -D \"%s/%s\" --noclean%s > \"%s/log/initgtm.log\" 2>&1", bindir, temp_install, data_folder, debug ? " --debug" : "", outputdir); @@ -813,7 +813,7 @@ initdb_node(PGXCNodeTypeNum node) else { snprintf(buf, sizeof(buf), - SYSTEMQUOTE "\"%s/initdb\" --nodename %s -D \"%s/%s\" -L \"%s\" --noclean%s%s > \"%s/log/initdb.log\" 2>&1" SYSTEMQUOTE, + "\"%s/initdb\" --nodename %s -D \"%s/%s\" -L \"%s\" --noclean%s%s > \"%s/log/initdb.log\" 2>&1", bindir, (char *)get_node_name(node), temp_install, data_folder, datadir, debug ? " --debug" : "", nolocale ? " --no-locale" : "", @@ -909,7 +909,7 @@ psql_command_node(const char *database, PGXCNodeTypeNum node, const char *query, /* And now we can build and execute the shell command */ snprintf(psql_cmd, sizeof(psql_cmd), - SYSTEMQUOTE "\"%s%spsql\" -X -p %d -c \"%s\" \"%s\"" SYSTEMQUOTE, + "\"%s%spsql\" -X -p %d -c \"%s\" \"%s\"", psqldir ? psqldir : "", psqldir ? "/" : "", get_port_number(node), @@ -1050,7 +1050,7 @@ check_node_running(PGXCNodeTypeNum node) char buf[MAXPGPATH * 4]; snprintf(buf, sizeof(buf), - SYSTEMQUOTE "\"%s/psql\" -p %d -X postgres <%s 2>%s" SYSTEMQUOTE, + "\"%s/psql\" -p %d -X postgres <%s 2>%s", bindir, get_port_number(node), DEVNULL, DEVNULL); return system(buf) == 0; @@ -2733,7 +2733,6 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc int i; int option_index; char buf[MAXPGPATH * 4]; - char buf2[MAXPGPATH * 4]; progname = get_progname(argv[0]); set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_regress")); |