Merge pull request #644 from citusdata/fix/fix_73_master_apply_delete_command_with_schema

Fix master_apply_delete_command with schema
pull/655/head
Burak Yücesoy 2016-07-21 15:13:39 +03:00 committed by GitHub
commit fdd6c57bdf
3 changed files with 63 additions and 0 deletions

View File

@ -113,6 +113,13 @@ master_apply_delete_command(PG_FUNCTION_ARGS)
relationName = deleteStatement->relation->relname; relationName = deleteStatement->relation->relname;
relationId = RangeVarGetRelid(deleteStatement->relation, NoLock, failOK); relationId = RangeVarGetRelid(deleteStatement->relation, NoLock, failOK);
/* schema-prefix if it is not specified already */
if (schemaName == NULL)
{
Oid schemaId = get_rel_namespace(relationId);
schemaName = get_namespace_name(schemaId);
}
CheckDistributedTable(relationId); CheckDistributedTable(relationId);
EnsureTablePermissions(relationId, ACL_DELETE); EnsureTablePermissions(relationId, ACL_DELETE);

View File

@ -801,3 +801,28 @@ SELECT * FROM pg_dist_shard_placement WHERE shardid = 1190000;
1190000 | 1 | 0 | localhost | 57637 1190000 | 1 | 0 | localhost | 57637
(2 rows) (2 rows)
-- test master_apply_delete_command with schemas
SET search_path TO public;
SELECT master_apply_delete_command('DELETE FROM test_schema_support.nation_append') ;
master_apply_delete_command
-----------------------------
1
(1 row)
-- verify shard is dropped
\c - - - :worker_1_port
\d test_schema_support.nation_append_119*
\c - - - :master_port
-- test with search_path is set
SET search_path TO test_schema_support;
\COPY nation_append FROM STDIN with delimiter '|';
SELECT master_apply_delete_command('DELETE FROM nation_append') ;
master_apply_delete_command
-----------------------------
1
(1 row)
-- verify shard is dropped
\c - - - :worker_1_port
\d test_schema_support.nation_append_119*
\c - - - :master_port

View File

@ -516,3 +516,34 @@ SELECT master_copy_shard_placement(1190000, 'localhost', :worker_2_port, 'localh
-- verify shardstate -- verify shardstate
SELECT * FROM pg_dist_shard_placement WHERE shardid = 1190000; SELECT * FROM pg_dist_shard_placement WHERE shardid = 1190000;
-- test master_apply_delete_command with schemas
SET search_path TO public;
SELECT master_apply_delete_command('DELETE FROM test_schema_support.nation_append') ;
-- verify shard is dropped
\c - - - :worker_1_port
\d test_schema_support.nation_append_119*
\c - - - :master_port
-- test with search_path is set
SET search_path TO test_schema_support;
\COPY nation_append FROM STDIN with delimiter '|';
0|ALGERIA|0| haggle. carefully final deposits detect slyly agai
1|ARGENTINA|1|al foxes promise slyly according to the regular accounts. bold requests alon
2|BRAZIL|1|y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special
3|CANADA|1|eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold
4|EGYPT|4|y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d
5|ETHIOPIA|0|ven packages wake quickly. regu
\.
SELECT master_apply_delete_command('DELETE FROM nation_append') ;
-- verify shard is dropped
\c - - - :worker_1_port
\d test_schema_support.nation_append_119*
\c - - - :master_port