#include "pgxc/pause.h"
#endif
-static void ExecUtilityStmtOnNodes(const char *queryString, ExecNodes *nodes,
+static void ExecUtilityStmtOnNodes(const char *queryString,
+ int stmt_location,
+ int stmt_len,
+ ExecNodes *nodes,
bool sentToRemote,
RemoteQueryExecType exec_type,
bool is_temp,
bool add_context);
static void ExecUtilityStmtOnNodesInternal(const char *queryString,
+ int stmt_location,
+ int stmt_len,
ExecNodes *nodes,
bool sentToRemote,
RemoteQueryExecType exec_type,
#ifdef PGXC
static void ExecDropStmt(DropStmt *stmt,
const char *queryString,
+ int stmt_location,
+ int stmt_len,
bool sentToRemote,
bool isTopLevel);
#else
/* Clean also remote Coordinators */
sprintf(query, "CLEAN CONNECTION TO ALL FOR DATABASE %s;",
quote_identifier(stmt->dbname));
- ExecUtilityStmtOnNodes(query, NULL, sentToRemote,
+ ExecUtilityStmtOnNodes(query, -1, 0, NULL, sentToRemote,
EXEC_ON_ALL_NODES, false, false);
}
break;
* connections, then clean local pooler
*/
if (IS_PGXC_COORDINATOR)
- ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote,
+ ExecUtilityStmtOnNodes(queryString, -1, 0, NULL, sentToRemote,
EXEC_ON_ALL_NODES, false, false);
CleanConnection((CleanConnStmt *) parsetree);
break;
* Send queryString to remote nodes, if needed.
*/
if (IS_PGXC_LOCAL_COORDINATOR)
- ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote,
+ ExecUtilityStmtOnNodes(queryString, pstmt->stmt_location,
+ pstmt->stmt_len, NULL, sentToRemote,
exec_type, is_temp, add_context);
}
if (IS_PGXC_LOCAL_COORDINATOR)
- ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote,
+ ExecUtilityStmtOnNodes(queryString, pstmt->stmt_location,
+ pstmt->stmt_len, NULL, sentToRemote,
exec_type, is_temp, add_context);
}
/*
sentToRemote,
completionTag);
else
- ExecDropStmt(stmt, queryString, sentToRemote, isTopLevel);
+ ExecDropStmt(stmt, queryString, pstmt->stmt_location,
+ pstmt->stmt_len, sentToRemote, isTopLevel);
}
break;
* Coordinator, if not already done so
*/
if (!sentToRemote)
- stmts = AddRemoteQueryNode(stmts, queryString, is_local
- ? EXEC_ON_NONE
+ stmts = AddRemoteQueryNode(stmts, queryString,
+ pstmt->stmt_location,
+ pstmt->stmt_len,
+ is_local ? EXEC_ON_NONE
: (is_temp ? EXEC_ON_DATANODES : EXEC_ON_ALL_NODES));
/* ... and do it */
relid,
&is_temp);
- stmts = AddRemoteQueryNode(stmts, queryString, exec_type);
+ stmts = AddRemoteQueryNode(stmts, queryString,
+ pstmt->stmt_location, pstmt->stmt_len,
+ exec_type);
}
}
break;
case T_DropStmt:
- ExecDropStmt((DropStmt *) parsetree, queryString, sentToRemote, isTopLevel);
+ ExecDropStmt((DropStmt *) parsetree, queryString,
+ pstmt->stmt_location, pstmt->stmt_len,
+ sentToRemote, isTopLevel);
/* no commands stashed for DROP */
commandCollected = true;
break;
#ifdef PGXC
ExecDropStmt(DropStmt *stmt,
const char *queryString,
+ int stmt_location,
+ int stmt_len,
bool sentToRemote,
bool isTopLevel)
#else
{
if (prevent_xact_chain)
SetRequireRemoteTransactionAutoCommit();
- ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote,
+ ExecUtilityStmtOnNodes(queryString, stmt_location,
+ stmt_len, NULL, sentToRemote,
exec_type, is_temp, false);
}
}
RemoveObjects(stmt);
#ifdef PGXC
if (IS_PGXC_LOCAL_COORDINATOR)
- ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote,
+ ExecUtilityStmtOnNodes(queryString, stmt_location,
+ stmt_len, NULL, sentToRemote,
exec_type, is_temp, false);
}
#endif
#ifdef PGXC
static void
-ExecUtilityStmtOnNodesInternal(const char *queryString, ExecNodes *nodes, bool sentToRemote,
- RemoteQueryExecType exec_type, bool is_temp)
+ExecUtilityStmtOnNodesInternal(const char *queryString,
+ int stmt_location,
+ int stmt_len,
+ ExecNodes *nodes,
+ bool sentToRemote,
+ RemoteQueryExecType exec_type,
+ bool is_temp)
{
/* Return if query is launched on no nodes */
if (exec_type == EXEC_ON_NONE)
RemoteQuery *step = makeNode(RemoteQuery);
step->combine_type = COMBINE_TYPE_SAME;
step->exec_nodes = nodes;
- step->sql_statement = pstrdup(queryString);
+ if (stmt_location == -1)
+ step->sql_statement = pstrdup(queryString);
+ else
+ step->sql_statement = pnstrdup(queryString + stmt_location,
+ stmt_len == 0 ? strlen(queryString) - stmt_location :
+ stmt_len);
step->exec_type = exec_type;
ExecRemoteUtility(step);
pfree(step->sql_statement);
* context message containing the failed node names.
*/
static void
-ExecUtilityStmtOnNodes(const char *queryString, ExecNodes *nodes,
- bool sentToRemote, RemoteQueryExecType exec_type,
- bool is_temp, bool add_context)
+ExecUtilityStmtOnNodes(const char *queryString,
+ int stmt_location,
+ int stmt_len,
+ ExecNodes *nodes,
+ bool sentToRemote,
+ RemoteQueryExecType exec_type,
+ bool is_temp,
+ bool add_context)
{
PG_TRY();
{
- ExecUtilityStmtOnNodesInternal(queryString, nodes, sentToRemote,
+ ExecUtilityStmtOnNodesInternal(queryString, stmt_location, stmt_len,
+ nodes, sentToRemote,
exec_type, is_temp);
}
PG_CATCH();