Disallow master_apply_delete_command on hash distributed table

Delete operation is blocked for any table distributed by hash using master_apply_delete_command. Suggested master_modify_multiple_shards command as a hint.
pull/1246/head
Burak Velioglu 2017-02-20 17:08:44 +03:00 committed by velioglu
parent b8e4763a1a
commit 49812ddfa0
2 changed files with 11 additions and 10 deletions

View File

@ -145,12 +145,14 @@ master_apply_delete_command(PG_FUNCTION_ARGS)
deleteCriteria = eval_const_expressions(NULL, whereClause); deleteCriteria = eval_const_expressions(NULL, whereClause);
partitionMethod = PartitionMethod(relationId); partitionMethod = PartitionMethod(relationId);
if ((partitionMethod == DISTRIBUTE_BY_HASH) && (deleteCriteria != NULL)) if (partitionMethod == DISTRIBUTE_BY_HASH)
{ {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot delete from distributed table"), errmsg("cannot delete from hash distributed table with this "
"command"),
errdetail("Delete statements on hash-partitioned tables " errdetail("Delete statements on hash-partitioned tables "
"with where clause is not supported"))); "are not supported with master_apply_delete_command."),
errhint("Use master_modify_multiple_shards command instead.")));
} }
else if (partitionMethod == DISTRIBUTE_BY_NONE) else if (partitionMethod == DISTRIBUTE_BY_NONE)
{ {

View File

@ -55,15 +55,14 @@ EXECUTE sharded_query;
-- try to drop shards with where clause -- try to drop shards with where clause
SELECT master_apply_delete_command('DELETE FROM sharded_table WHERE id > 0'); SELECT master_apply_delete_command('DELETE FROM sharded_table WHERE id > 0');
ERROR: cannot delete from distributed table ERROR: cannot delete from hash distributed table with this command
DETAIL: Delete statements on hash-partitioned tables with where clause is not supported DETAIL: Delete statements on hash-partitioned tables are not supported with master_apply_delete_command.
HINT: Use master_modify_multiple_shards command instead.
-- drop all shards -- drop all shards
SELECT master_apply_delete_command('DELETE FROM sharded_table'); SELECT master_apply_delete_command('DELETE FROM sharded_table');
master_apply_delete_command ERROR: cannot delete from hash distributed table with this command
----------------------------- DETAIL: Delete statements on hash-partitioned tables are not supported with master_apply_delete_command.
2 HINT: Use master_modify_multiple_shards command instead.
(1 row)
-- lock shard metadata: take some share locks and exclusive locks -- lock shard metadata: take some share locks and exclusive locks
BEGIN; BEGIN;
SELECT lock_shard_metadata(5, ARRAY[999001, 999002, 999002]); SELECT lock_shard_metadata(5, ARRAY[999001, 999002, 999002]);