Disable FQS for explicit cursor queries.
authorPavan Deolasee <[email protected]>
Wed, 12 Sep 2018 08:55:57 +0000 (14:25 +0530)
committerPavan Deolasee <[email protected]>
Wed, 12 Sep 2018 09:05:46 +0000 (14:35 +0530)
The FQS mechanism is not currently handling cursors well as seen by failures in
the 'combocid' test case. The regular planner handles it well though. So for
now disable FQS for such queries.

Also remove the restriction that TID scan cannot be performed by non-FQS
queries. Regression does not throw up any errors. So remove the restriction
unless we see a counter example.

Tomas Vondra commented that this works fine in XL 9.5, so most likely we might
be failing to send a proper snapshot to the datanodes. Further investigations
required.

src/backend/optimizer/util/pathnode.c
src/backend/parser/analyze.c
src/backend/pgxc/plan/planner.c
src/include/nodes/parsenodes.h

index 7fa74e33077df1bb5e55492d1ce3819fbf842713..5e060c765aec3e9b479f89098f9136ff7573258c 100644 (file)
@@ -2390,12 +2390,7 @@ create_tidscan_path(PlannerInfo *root, RelOptInfo *rel, List *tidquals,
 
        pathnode->tidquals = tidquals;
 
-#ifdef XCP
        set_scanpath_distribution(root, rel, (Path *) pathnode);
-       /* We may need to pass info about target node to support */
-       if (pathnode->path.distribution)
-               elog(ERROR, "could not perform TID scan on remote relation");
-#endif
 
        cost_tidscan(&pathnode->path, root, rel, tidquals,
                                 pathnode->path.param_info);
index fc865ac47af6935a4ea3ed931717e86ec1d61ee0..5ac1fefb0d189f1cdc121b300735be42c9e8e966 100644 (file)
@@ -2452,6 +2452,9 @@ transformDeclareCursorStmt(ParseState *pstate, DeclareCursorStmt *stmt)
                                (errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
                                 errmsg("cannot specify both SCROLL and NO SCROLL")));
 
+       /* Always disable FQS on cursors */
+       stmt->options |= CURSOR_OPT_NO_FQS;
+
        /* Transform contained query, not allowing SELECT INTO */
        query = transformStmt(pstate, stmt->query);
        stmt->query = (Node *) query;
index 9afb602359cf0f5595ba9778856a5bcc6234217f..a8b9f8a1457902ebff2325a035cf07398892c369 100644 (file)
@@ -287,6 +287,10 @@ pgxc_FQS_planner(Query *query, int cursorOptions, ParamListInfo boundParams)
        if (cursorOptions & CURSOR_OPT_SCROLL)
                return NULL;
 
+       /* Do not FQS cursor statements at all */
+       if (cursorOptions & CURSOR_OPT_NO_FQS)
+               return NULL;
+
        /* Do not FQS EXEC DIRECT statements */
        if (query->utilityStmt && IsA(query->utilityStmt, RemoteQuery))
        {
index 371fdcb5ce20434fde783c35e1b254c9acd103a1..aaa8e116b608f8b76aedafc632826f538e542941 100644 (file)
@@ -2667,6 +2667,7 @@ typedef struct SecLabelStmt
 #define CURSOR_OPT_GENERIC_PLAN 0x0040 /* force use of generic plan */
 #define CURSOR_OPT_CUSTOM_PLAN 0x0080  /* force use of custom plan */
 #define CURSOR_OPT_PARALLEL_OK 0x0100  /* parallel mode OK */
+#define CURSOR_OPT_NO_FQS              0x0200  /* do not use FQS */
 
 typedef struct DeclareCursorStmt
 {