From 9b1112f7d6c384c3bd04d432e337b523bc75f032 Mon Sep 17 00:00:00 2001 From: Metin Doslu Date: Thu, 22 Jun 2017 18:00:05 +0300 Subject: [PATCH] attempt to error out unsupported queries --- .../planner/multi_router_planner.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/backend/distributed/planner/multi_router_planner.c b/src/backend/distributed/planner/multi_router_planner.c index a8cab8b5d..942f76996 100644 --- a/src/backend/distributed/planner/multi_router_planner.c +++ b/src/backend/distributed/planner/multi_router_planner.c @@ -2400,6 +2400,39 @@ RouterSelectQuery(Query *originalQuery, RelationRestrictionContext *restrictionC *relationShardList = lappend(*relationShardList, relationShard); } + if (UpdateFromQuery(originalQuery)) + { + StringInfo errorMessage = makeStringInfo(); + StringInfo errorHint = makeStringInfo(); + const char *targetCountType = NULL; + bool errorOut = false; + + if (RelationPrunesToMultipleShards(*relationShardList)) + { + targetCountType = "multiple"; + errorOut = true; + } + else if (!shardsPresent) + { + targetCountType = "no"; + errorOut = true; + } + + if (errorOut) + { + appendStringInfo(errorMessage, "cannot run UPDATE command which targets %s " + "shards", targetCountType); + + appendStringInfo(errorHint, "Make sure the value for partition column " + "falls into a single shard."); + + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("%s", errorMessage->data), + errhint("%s", errorHint->data))); + } + } + + /* * We bail out if there are RTEs that prune multiple shards above, but * there can also be multiple RTEs that reference the same relation.