You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
(28) |
Jun
(12) |
Jul
(11) |
Aug
(12) |
Sep
(5) |
Oct
(19) |
Nov
(14) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(18) |
Feb
(30) |
Mar
(115) |
Apr
(89) |
May
(50) |
Jun
(44) |
Jul
(22) |
Aug
(13) |
Sep
(11) |
Oct
(30) |
Nov
(28) |
Dec
(39) |
2012 |
Jan
(38) |
Feb
(18) |
Mar
(43) |
Apr
(91) |
May
(108) |
Jun
(46) |
Jul
(37) |
Aug
(44) |
Sep
(33) |
Oct
(29) |
Nov
(36) |
Dec
(15) |
2013 |
Jan
(35) |
Feb
(611) |
Mar
(5) |
Apr
(55) |
May
(30) |
Jun
(28) |
Jul
(458) |
Aug
(34) |
Sep
(9) |
Oct
(39) |
Nov
(22) |
Dec
(32) |
2014 |
Jan
(16) |
Feb
(16) |
Mar
(42) |
Apr
(179) |
May
(7) |
Jun
(6) |
Jul
(9) |
Aug
|
Sep
(4) |
Oct
|
Nov
(3) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
11
(2) |
12
(5) |
13
(3) |
14
|
15
|
16
|
17
|
18
|
19
|
20
(2) |
21
|
22
|
23
|
24
|
25
(1) |
26
(1) |
27
(2) |
28
(2) |
29
|
30
|
31
|
|
|
|
|
|
From: Michael P. <mic...@us...> - 2011-01-25 05:29:17
|
Project "Postgres-XC". The branch, ha_support has been created at 497b27848af35363b745dbce20d2b8cb806c43dc (commit) - Log ----------------------------------------------------------------- commit 497b27848af35363b745dbce20d2b8cb806c43dc Author: Michael P <mic...@us...> Date: Tue Jan 25 14:15:25 2011 +0900 Support for EXECUTE DIRECT EXECUTE DIRECT is a utility query allowing to launch queries directly on targetted PGXC nodes. EXECUTE DIRECT ON (COORDINATOR num | NODE num) 'query'; This implementation contains the following use restrictions: - only a superuser is allowed to use it - DML queries (DELETE, INSERT, UPDATE) cannot be launched with it (easy to break data consistency) - utilities cannot be launched launched on local coordinator - utilities cannot be launched inside a transaction block (though SELECT queries in EXECUTE DIRECT keep the same visibility if used in a transaction block). - only one query can be launched at a time - query can be launched on a unique node This feature will be used to have a look at 2PC catalog data when nodes crash and to clean up 2PC transactions on targetted nodes. Ex: EXECUTE DIRECT ON NODE 1 'SELECT * from pg_prepared_xact()'; EXECUTE DIRECT ON COORDINATOR 2 'COMMIT PREPARED ''foo'''; diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 0e9aa43..cb7a1a8 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -264,8 +264,9 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) * If we are on the coordinator, we always want to use * the remote query path unless it is a pg_catalog table. */ - if (IS_PGXC_COORDINATOR - && get_rel_namespace(rte->relid) != PG_CATALOG_NAMESPACE) + if (IS_PGXC_COORDINATOR && + !IsConnFromCoord() && + get_rel_namespace(rte->relid) != PG_CATALOG_NAMESPACE) add_path(rel, create_remotequery_path(root, rel)); else { diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 5b2e03f..40777bf 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -41,8 +41,10 @@ #include "rewrite/rewriteManip.h" #ifdef PGXC #include "pgxc/pgxc.h" +#include "access/gtm.h" #include "pgxc/planner.h" #include "tcop/tcopprot.h" +#include "pgxc/poolmgr.h" #endif #include "utils/rel.h" @@ -2066,9 +2068,160 @@ transformExplainStmt(ParseState *pstate, ExplainStmt *stmt) static Query * transformExecDirectStmt(ParseState *pstate, ExecDirectStmt *stmt) { - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("Support for EXECUTE DIRECT is temporary broken"))); + Query *result = makeNode(Query); + bool is_coordinator = stmt->coordinator; + char *query = stmt->query; + List *nodelist = stmt->nodes; + ListCell *nodeitem; + RemoteQuery *step = makeNode(RemoteQuery); + bool is_local = false; + List *raw_parsetree_list; + ListCell *raw_parsetree_item; + + if (list_length(nodelist) > 1) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Support for EXECUTE DIRECT on multiple nodes is not available yet"))); + + if (!superuser()) + ereport(ERROR, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + errmsg("must be superuser to use EXECUTE DIRECT"))); + + /* Check if execute direct is local and if node number is correct*/ + foreach(nodeitem, nodelist) + { + int nodenum = intVal(lfirst(nodeitem)); + + if (nodenum < 1 || + (!is_coordinator && nodenum > NumDataNodes) || + (is_coordinator && nodenum > NumCoords)) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Node Number %d is incorrect", nodenum))); + + if (nodenum == PGXCNodeId && is_coordinator) + is_local = true; + } + + /* Transform the query into a raw parse list */ + raw_parsetree_list = pg_parse_query(query); + + /* EXECUTE DIRECT can just be executed with a single query */ + if (list_length(raw_parsetree_list) > 1) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("EXECUTE DIRECT cannot execute multiple queries"))); + + /* + * Analyze the Raw parse tree + * EXECUTE DIRECT is restricted to one-step usage + */ + foreach(raw_parsetree_item, raw_parsetree_list) + { + Node *parsetree = (Node *) lfirst(raw_parsetree_item); + result = parse_analyze(parsetree, query, NULL, 0); + } + + /* Needed by planner */ + result->sql_statement = pstrdup(query); + + /* Default list of parameters to set */ + step->is_single_step = true; + step->sql_statement = NULL; + step->exec_nodes = NULL; + step->combine_type = COMBINE_TYPE_NONE; + step->simple_aggregates = NIL; + step->sort = NULL; + step->distinct = NULL; + step->read_only = true; + step->force_autocommit = false; + step->cursor = NULL; + step->exec_type = EXEC_ON_DATANODES; + step->paramval_data = NULL; + step->paramval_len = 0; + + step->relname = NULL; + step->remotejoin = false; + step->partitioned_replicated = false; + step->reduce_level = 0; + step->base_tlist = NIL; + step->outer_alias = NULL; + step->inner_alias = NULL; + step->outer_reduce_level = 0; + step->inner_reduce_level = 0; + step->outer_relids = NULL; + step->inner_relids = NULL; + step->inner_statement = NULL; + step->outer_statement = NULL; + step->join_condition = NULL; + + /* Change the list of nodes that will be executed for the query and others */ + step->exec_nodes = (ExecNodes *) palloc(sizeof(ExecNodes)); + step->exec_nodes->primarynodelist = NIL; + step->exec_nodes->nodelist = NIL; + step->exec_nodes->expr = NIL; + step->force_autocommit = false; + step->combine_type = COMBINE_TYPE_SAME; + step->read_only = true; + step->exec_direct_type = EXEC_DIRECT_NONE; + + /* Set up EXECUTE DIRECT flag */ + if (is_local) + { + if (result->commandType == CMD_UTILITY) + step->exec_direct_type = EXEC_DIRECT_LOCAL_UTILITY; + else + step->exec_direct_type = EXEC_DIRECT_LOCAL; + } + else + { + if (result->commandType == CMD_UTILITY) + step->exec_direct_type = EXEC_DIRECT_UTILITY; + else if (result->commandType == CMD_SELECT) + step->exec_direct_type = EXEC_DIRECT_SELECT; + else if (result->commandType == CMD_INSERT) + step->exec_direct_type = EXEC_DIRECT_INSERT; + else if (result->commandType == CMD_UPDATE) + step->exec_direct_type = EXEC_DIRECT_UPDATE; + else if (result->commandType == CMD_DELETE) + step->exec_direct_type = EXEC_DIRECT_DELETE; + } + + /* + * Features not yet supported + * DML can be launched without errors but this could compromise data + * consistency, so block it. + */ + if (step->exec_direct_type == EXEC_DIRECT_DELETE + || step->exec_direct_type == EXEC_DIRECT_UPDATE + || step->exec_direct_type == EXEC_DIRECT_INSERT) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("EXECUTE DIRECT cannot execute DML queries"))); + if (step->exec_direct_type == EXEC_DIRECT_LOCAL_UTILITY) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("EXECUTE DIRECT cannot execute locally utility queries"))); + + /* Build Execute Node list */ + foreach(nodeitem, nodelist) + { + int nodenum = intVal(lfirst(nodeitem)); + step->exec_nodes->nodelist = lappend_int(step->exec_nodes->nodelist, nodenum); + } + + step->sql_statement = pstrdup(query); + + if (is_coordinator) + step->exec_type = EXEC_ON_COORDS; + else + step->exec_type = EXEC_ON_DATANODES; + + /* Associate newly-created RemoteQuery node to the returned Query result */ + result->utilityStmt = (Node *) step; + + return result; } #endif diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 0c76d7a..1ed5686 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -6534,16 +6534,17 @@ opt_analyze: /***************************************************************************** * * QUERY: - * EXECUTE DIRECT ON (COORDINATOR | NODE num, ...) query + * EXECUTE DIRECT ON (COORDINATOR num, ... | NODE num, ...) query * *****************************************************************************/ -ExecDirectStmt: EXECUTE DIRECT ON COORDINATOR DirectStmt +ExecDirectStmt: EXECUTE DIRECT ON COORDINATOR coord_list DirectStmt { ExecDirectStmt *n = makeNode(ExecDirectStmt); n->coordinator = TRUE; n->nodes = NIL; - |