mirror of https://github.com/citusdata/citus.git
Handle pg_analyze_and_rewrite signature change
Now requires a RawStmt rather than any old Node. Methods to parse DDL into a list of Nodes now return a list of RawStmts; the old Nodes we expect are available as one of their fields. ParseTreeRawStmt is used in PostgreSQL 10 to obtain the RawStmt itself; the behavior of the old ParseTreeNode is preserved and it always returns a simple Node.pull/1439/head
parent
b2319011fe
commit
6a4cd9965c
|
@ -109,11 +109,16 @@ master_apply_delete_command(PG_FUNCTION_ARGS)
|
||||||
LOCKMODE lockMode = 0;
|
LOCKMODE lockMode = 0;
|
||||||
char partitionMethod = 0;
|
char partitionMethod = 0;
|
||||||
bool failOK = false;
|
bool failOK = false;
|
||||||
|
#if (PG_VERSION_NUM >= 100000)
|
||||||
|
RawStmt *rawStmt = (RawStmt *) ParseTreeRawStmt(queryString);
|
||||||
|
queryTreeNode = rawStmt->stmt;
|
||||||
|
#else
|
||||||
|
queryTreeNode = ParseTreeNode(queryString);
|
||||||
|
#endif
|
||||||
|
|
||||||
EnsureCoordinator();
|
EnsureCoordinator();
|
||||||
CheckCitusVersion(ERROR);
|
CheckCitusVersion(ERROR);
|
||||||
|
|
||||||
queryTreeNode = ParseTreeNode(queryString);
|
|
||||||
if (!IsA(queryTreeNode, DeleteStmt))
|
if (!IsA(queryTreeNode, DeleteStmt))
|
||||||
{
|
{
|
||||||
ereport(ERROR, (errmsg("query \"%s\" is not a delete statement",
|
ereport(ERROR, (errmsg("query \"%s\" is not a delete statement",
|
||||||
|
@ -144,7 +149,11 @@ master_apply_delete_command(PG_FUNCTION_ARGS)
|
||||||
CheckDistributedTable(relationId);
|
CheckDistributedTable(relationId);
|
||||||
EnsureTablePermissions(relationId, ACL_DELETE);
|
EnsureTablePermissions(relationId, ACL_DELETE);
|
||||||
|
|
||||||
|
#if (PG_VERSION_NUM >= 100000)
|
||||||
|
queryTreeList = pg_analyze_and_rewrite(rawStmt, queryString, NULL, 0, NULL);
|
||||||
|
#else
|
||||||
queryTreeList = pg_analyze_and_rewrite(queryTreeNode, queryString, NULL, 0);
|
queryTreeList = pg_analyze_and_rewrite(queryTreeNode, queryString, NULL, 0);
|
||||||
|
#endif
|
||||||
deleteQuery = (Query *) linitial(queryTreeList);
|
deleteQuery = (Query *) linitial(queryTreeList);
|
||||||
CheckTableCount(deleteQuery);
|
CheckTableCount(deleteQuery);
|
||||||
|
|
||||||
|
|
|
@ -85,12 +85,17 @@ master_modify_multiple_shards(PG_FUNCTION_ARGS)
|
||||||
List *prunedShardIntervalList = NIL;
|
List *prunedShardIntervalList = NIL;
|
||||||
List *taskList = NIL;
|
List *taskList = NIL;
|
||||||
int32 affectedTupleCount = 0;
|
int32 affectedTupleCount = 0;
|
||||||
|
#if (PG_VERSION_NUM >= 100000)
|
||||||
|
RawStmt *rawStmt = (RawStmt *) ParseTreeRawStmt(queryString);
|
||||||
|
queryTreeNode = rawStmt->stmt;
|
||||||
|
#else
|
||||||
|
queryTreeNode = ParseTreeNode(queryString);
|
||||||
|
#endif
|
||||||
|
|
||||||
EnsureCoordinator();
|
EnsureCoordinator();
|
||||||
CheckCitusVersion(ERROR);
|
CheckCitusVersion(ERROR);
|
||||||
|
|
||||||
|
|
||||||
queryTreeNode = ParseTreeNode(queryString);
|
|
||||||
if (IsA(queryTreeNode, DeleteStmt))
|
if (IsA(queryTreeNode, DeleteStmt))
|
||||||
{
|
{
|
||||||
DeleteStmt *deleteStatement = (DeleteStmt *) queryTreeNode;
|
DeleteStmt *deleteStatement = (DeleteStmt *) queryTreeNode;
|
||||||
|
@ -136,7 +141,11 @@ master_modify_multiple_shards(PG_FUNCTION_ARGS)
|
||||||
|
|
||||||
CheckDistributedTable(relationId);
|
CheckDistributedTable(relationId);
|
||||||
|
|
||||||
|
#if (PG_VERSION_NUM >= 100000)
|
||||||
|
queryTreeList = pg_analyze_and_rewrite(rawStmt, queryString, NULL, 0, NULL);
|
||||||
|
#else
|
||||||
queryTreeList = pg_analyze_and_rewrite(queryTreeNode, queryString, NULL, 0);
|
queryTreeList = pg_analyze_and_rewrite(queryTreeNode, queryString, NULL, 0);
|
||||||
|
#endif
|
||||||
modifyQuery = (Query *) linitial(queryTreeList);
|
modifyQuery = (Query *) linitial(queryTreeList);
|
||||||
|
|
||||||
if (modifyQuery->commandType != CMD_UTILITY)
|
if (modifyQuery->commandType != CMD_UTILITY)
|
||||||
|
|
|
@ -50,9 +50,14 @@ deparse_shard_query_test(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
Node *parsetree = (Node *) lfirst(parseTreeCell);
|
Node *parsetree = (Node *) lfirst(parseTreeCell);
|
||||||
ListCell *queryTreeCell = NULL;
|
ListCell *queryTreeCell = NULL;
|
||||||
|
List *queryTreeList = NIL;
|
||||||
|
|
||||||
List *queryTreeList = pg_analyze_and_rewrite(parsetree, queryStringChar,
|
#if (PG_VERSION_NUM >= 100000)
|
||||||
NULL, 0);
|
queryTreeList = pg_analyze_and_rewrite((RawStmt *) parsetree, queryStringChar,
|
||||||
|
NULL, 0, NULL);
|
||||||
|
#else
|
||||||
|
queryTreeList = pg_analyze_and_rewrite(parsetree, queryStringChar, NULL, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
foreach(queryTreeCell, queryTreeList)
|
foreach(queryTreeCell, queryTreeList)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1170,6 +1170,22 @@ ExecuteRemoteCommand(const char *nodeName, uint32 nodePort, StringInfo queryStri
|
||||||
*/
|
*/
|
||||||
Node *
|
Node *
|
||||||
ParseTreeNode(const char *ddlCommand)
|
ParseTreeNode(const char *ddlCommand)
|
||||||
|
{
|
||||||
|
Node *parseTreeNode = ParseTreeRawStmt(ddlCommand);
|
||||||
|
|
||||||
|
#if (PG_VERSION_NUM >= 100000)
|
||||||
|
parseTreeNode = ((RawStmt *) parseTreeNode)->stmt;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return parseTreeNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parses the given DDL command, and returns the tree node for parsed command.
|
||||||
|
*/
|
||||||
|
Node *
|
||||||
|
ParseTreeRawStmt(const char *ddlCommand)
|
||||||
{
|
{
|
||||||
Node *parseTreeNode = NULL;
|
Node *parseTreeNode = NULL;
|
||||||
List *parseTreeList = NULL;
|
List *parseTreeList = NULL;
|
||||||
|
|
|
@ -137,6 +137,7 @@ extern Datum CompareCall2(FmgrInfo *funcInfo, Datum leftArgument, Datum rightArg
|
||||||
|
|
||||||
/* Function declaration for parsing tree node */
|
/* Function declaration for parsing tree node */
|
||||||
extern Node * ParseTreeNode(const char *ddlCommand);
|
extern Node * ParseTreeNode(const char *ddlCommand);
|
||||||
|
extern Node * ParseTreeRawStmt(const char *ddlCommand);
|
||||||
|
|
||||||
/* Function declarations for applying distributed execution primitives */
|
/* Function declarations for applying distributed execution primitives */
|
||||||
extern Datum worker_fetch_partition_file(PG_FUNCTION_ARGS);
|
extern Datum worker_fetch_partition_file(PG_FUNCTION_ARGS);
|
||||||
|
|
Loading…
Reference in New Issue