From c162755cc516f9f19827e420c34daa0773b11e9f Mon Sep 17 00:00:00 2001 From: Onur Tirtir Date: Thu, 13 Feb 2020 16:11:40 +0300 Subject: [PATCH] enable local execution for TRUNCATE command on distributed & reference tables --- src/backend/distributed/master/master_truncate.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/backend/distributed/master/master_truncate.c b/src/backend/distributed/master/master_truncate.c index d6d4d56e0..795b822a1 100644 --- a/src/backend/distributed/master/master_truncate.c +++ b/src/backend/distributed/master/master_truncate.c @@ -73,7 +73,15 @@ citus_truncate_trigger(PG_FUNCTION_ARGS) { List *taskList = TruncateTaskList(relationId); - ExecuteUtilityTaskListWithoutResults(taskList); + /* + * If it is a local placement of a distributed table or a reference table, + * then execute TRUNCATE command locally. + */ + bool localExecutionSupported = true; + + UseCoordinatedTransaction(); + + ExecuteUtilityTaskListWithoutResults(taskList, localExecutionSupported); } PG_RETURN_DATUM(PointerGetDatum(NULL));