Skip to content

Instantly share code, notes, and snippets.

@onderkalaci
Created January 18, 2021 07:46
Show Gist options
  • Select an option

  • Save onderkalaci/8718b464b05511263ba63581c1185d96 to your computer and use it in GitHub Desktop.

Select an option

Save onderkalaci/8718b464b05511263ba63581c1185d96 to your computer and use it in GitHub Desktop.
SET citus.replication_model to statement ;
set citus.shard_replication_factor TO 2;
CREATE SCHEMA sc1;
CREATE TABLE sc1.test (a int);
SELECT create_distributed_table('sc1.test', 'a');
CREATE USER test_user;
SELECT run_command_on_workers($$CREATE USER test_user$$);
GRANT ALL ON SCHEMA sc1 TO test_user ;
GRANT INSERT ON sc1.test TO test_user ;
SELECT run_command_on_placements($$sc1.test$$, $$GRANT INSERT ON %s TO test_user ;$$);
update pg_dist_shard_placement set shardstate = 3 where nodeport = 9702;
SELECT master_copy_shard_placement(102369, 'localhost', 9701, 'localhost', 9702);
-- on community, GRANT statements are not issued to the shards
SELECT master_copy_shard_placement(102369, 'localhost', 9701, 'localhost', 9702);
NOTICE: issuing BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED;SELECT assign_distributed_transaction_id(0, 0, '2000-01-01 02:00:00+02');
DETAIL: on server onderkalaci@localhost:9702 connectionId: 1
NOTICE: issuing SELECT worker_apply_shard_ddl_command (102369, 'DROP TABLE IF EXISTS sc1.test CASCADE')
DETAIL: on server onderkalaci@localhost:9702 connectionId: 1
NOTICE: issuing SELECT worker_apply_shard_ddl_command (102369, 'CREATE TABLE sc1.test (a integer) USING heap')
DETAIL: on server onderkalaci@localhost:9702 connectionId: 1
NOTICE: issuing SELECT worker_apply_shard_ddl_command (102369, 'ALTER TABLE sc1.test OWNER TO onderkalaci')
DETAIL: on server onderkalaci@localhost:9702 connectionId: 1
NOTICE: issuing SELECT worker_append_table_to_shard ('sc1.test_102369', 'sc1.test_102369', 'localhost', 9701)
DETAIL: on server onderkalaci@localhost:9702 connectionId: 1
NOTICE: issuing COMMIT
DETAIL: on server onderkalaci@localhost:9702 connectionId: 1
master_copy_shard_placement
-----------------------------
(1 row)
Time: 61.511 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment