diff options
| -rw-r--r-- | src/backend/optimizer/path/allpaths.c | 8 | ||||
| -rw-r--r-- | src/backend/pgxc/plan/planner.c | 15 | ||||
| -rw-r--r-- | src/include/pgxc/locator.h | 1 |
3 files changed, 18 insertions, 6 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index d06e8e647a..d5acb48bb1 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -35,6 +35,8 @@ #include "parser/parse_clause.h" #include "parser/parsetree.h" #ifdef PGXC +#include "catalog/pg_namespace.h" +#include "catalog/pg_class.h" #include "pgxc/pgxc.h" #endif #include "rewrite/rewriteManip.h" @@ -262,11 +264,13 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) #ifdef PGXC /* * If we are on the coordinator, we always want to use - * the remote query path unless it is a pg_catalog table. + * the remote query path unless it is a pg_catalog table + * or a sequence relation. */ if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && - get_rel_namespace(rte->relid) != PG_CATALOG_NAMESPACE) + get_rel_namespace(rte->relid) != PG_CATALOG_NAMESPACE && + get_rel_relkind(rte->relid) != RELKIND_SEQUENCE) add_path(rel, create_remotequery_path(root, rel)); else { diff --git a/src/backend/pgxc/plan/planner.c b/src/backend/pgxc/plan/planner.c index 3dbb86063a..e6e842f549 100644 --- a/src/backend/pgxc/plan/planner.c +++ b/src/backend/pgxc/plan/planner.c @@ -1574,7 +1574,13 @@ get_plan_nodes_walker(Node *query_node, XCWalkerContext *context) if (get_rel_namespace(rte->relid) == PG_CATALOG_NAMESPACE) current_usage_type = TABLE_USAGE_TYPE_PGCATALOG; else - current_usage_type = TABLE_USAGE_TYPE_USER; + { + /* Check if this relation is a sequence */ + if (get_rel_relkind(rte->relid) == RELKIND_SEQUENCE) + current_usage_type = TABLE_USAGE_TYPE_SEQUENCE; + else + current_usage_type = TABLE_USAGE_TYPE_USER; + } } else if (rte->rtekind == RTE_FUNCTION) { @@ -1608,11 +1614,12 @@ get_plan_nodes_walker(Node *query_node, XCWalkerContext *context) } } - /* If we are just dealing with pg_catalog, just return. */ - if (table_usage_type == TABLE_USAGE_TYPE_PGCATALOG) + /* If we are just dealing with pg_catalog or a sequence, just return. */ + if (table_usage_type == TABLE_USAGE_TYPE_PGCATALOG || + table_usage_type == TABLE_USAGE_TYPE_SEQUENCE) { context->query_step->exec_nodes = makeNode(ExecNodes); - context->query_step->exec_nodes->tableusagetype = TABLE_USAGE_TYPE_PGCATALOG; + context->query_step->exec_nodes->tableusagetype = table_usage_type; context->exec_on_coord = true; return false; } diff --git a/src/include/pgxc/locator.h b/src/include/pgxc/locator.h index 5948faece6..3272ab6cb1 100644 --- a/src/include/pgxc/locator.h +++ b/src/include/pgxc/locator.h @@ -39,6 +39,7 @@ typedef enum { TABLE_USAGE_TYPE_NO_TABLE, TABLE_USAGE_TYPE_PGCATALOG, + TABLE_USAGE_TYPE_SEQUENCE, TABLE_USAGE_TYPE_USER, TABLE_USAGE_TYPE_USER_REPLICATED, /* based on a replicated table */ TABLE_USAGE_TYPE_MIXED |
