citus/src/test/regress/expected/multi_utilities.out

67 lines
1.8 KiB
Plaintext

-- ===================================================================
-- test utility statement functionality
-- ===================================================================
CREATE TABLE sharded_table ( name text, id bigint );
SELECT master_create_distributed_table('sharded_table', 'id', 'hash');
master_create_distributed_table
---------------------------------
(1 row)
SELECT master_create_worker_shards('sharded_table', 2, 1);
master_create_worker_shards
-----------------------------
(1 row)
-- COPY out is supported with distributed tables
COPY sharded_table TO STDOUT;
COPY (SELECT COUNT(*) FROM sharded_table) TO STDOUT;
0
-- cursors may not involve distributed tables
DECLARE all_sharded_rows CURSOR FOR SELECT * FROM sharded_table;
ERROR: DECLARE CURSOR can only be used in transaction blocks
-- verify PREPARE functionality
PREPARE sharded_insert AS INSERT INTO sharded_table VALUES ('adam', 1);
PREPARE sharded_update AS UPDATE sharded_table SET name = 'bob' WHERE id = 1;
PREPARE sharded_delete AS DELETE FROM sharded_table WHERE id = 1;
PREPARE sharded_query AS SELECT name FROM sharded_table WHERE id = 1;
EXECUTE sharded_query;
name
------
(0 rows)
EXECUTE sharded_insert;
EXECUTE sharded_query;
name
------
adam
(1 row)
EXECUTE sharded_update;
EXECUTE sharded_query;
name
------
bob
(1 row)
EXECUTE sharded_delete;
EXECUTE sharded_query;
name
------
(0 rows)
-- try to drop shards with where clause
SELECT master_apply_delete_command('DELETE FROM sharded_table WHERE id > 0');
ERROR: cannot delete from distributed table
DETAIL: Delete statements on hash-partitioned tables with where clause is not supported
-- drop all shards
SELECT master_apply_delete_command('DELETE FROM sharded_table');
master_apply_delete_command
-----------------------------
2
(1 row)
-- drop table
DROP TABLE sharded_table;