mirror of https://github.com/citusdata/citus.git
73 lines
2.8 KiB
Plaintext
73 lines
2.8 KiB
Plaintext
--
|
|
-- MULTI_TABLE_DDL
|
|
--
|
|
-- Tests around changing the schema and dropping of a distributed table
|
|
CREATE TABLE testtableddl(somecol int, distributecol text NOT NULL);
|
|
SELECT master_create_distributed_table('testtableddl', 'distributecol', 'append');
|
|
master_create_distributed_table
|
|
---------------------------------
|
|
|
|
(1 row)
|
|
|
|
-- verify that the citus extension can't be dropped while distributed tables exist
|
|
DROP EXTENSION citus;
|
|
WARNING: could not clean the metadata cache on DROP EXTENSION command
|
|
HINT: Reconnect to the server again.
|
|
ERROR: cannot drop extension citus because other objects depend on it
|
|
DETAIL: table testtableddl depends on extension citus
|
|
HINT: Use DROP ... CASCADE to drop the dependent objects too.
|
|
-- verify that the distribution column can't have its type changed
|
|
ALTER TABLE testtableddl ALTER COLUMN distributecol TYPE text;
|
|
ERROR: cannot execute ALTER TABLE command involving partition column
|
|
-- verify that the distribution column can't be dropped
|
|
ALTER TABLE testtableddl DROP COLUMN distributecol;
|
|
ERROR: cannot execute ALTER TABLE command involving partition column
|
|
-- verify that the table cannot be dropped in a transaction block
|
|
BEGIN;
|
|
DROP TABLE testtableddl;
|
|
ERROR: DROP distributed table cannot run inside a transaction block
|
|
CONTEXT: SQL statement "SELECT master_drop_all_shards(v_obj.objid, v_obj.schema_name, v_obj.object_name)"
|
|
PL/pgSQL function citus_drop_trigger() line 15 at PERFORM
|
|
ROLLBACK;
|
|
-- verify that the table can be dropped
|
|
DROP TABLE testtableddl;
|
|
-- verify that the table can dropped even if shards exist
|
|
CREATE TABLE testtableddl(somecol int, distributecol text NOT NULL);
|
|
SELECT master_create_distributed_table('testtableddl', 'distributecol', 'append');
|
|
master_create_distributed_table
|
|
---------------------------------
|
|
|
|
(1 row)
|
|
|
|
SELECT 1 FROM master_create_empty_shard('testtableddl');
|
|
?column?
|
|
----------
|
|
1
|
|
(1 row)
|
|
|
|
DROP TABLE testtableddl;
|
|
-- ensure no metadata of distributed tables are remaining
|
|
SELECT * FROM pg_dist_partition;
|
|
logicalrelid | partmethod | partkey
|
|
--------------+------------+---------
|
|
(0 rows)
|
|
|
|
SELECT * FROM pg_dist_shard;
|
|
logicalrelid | shardid | shardstorage | shardalias | shardminvalue | shardmaxvalue
|
|
--------------+---------+--------------+------------+---------------+---------------
|
|
(0 rows)
|
|
|
|
SELECT * FROM pg_dist_shard_placement;
|
|
shardid | shardstate | shardlength | nodename | nodeport
|
|
---------+------------+-------------+----------+----------
|
|
(0 rows)
|
|
|
|
-- check that the extension now can be dropped (and recreated). We reconnect
|
|
-- before creating the extension to expire extension specific variables which
|
|
-- are cached for performance.
|
|
DROP EXTENSION citus;
|
|
WARNING: could not clean the metadata cache on DROP EXTENSION command
|
|
HINT: Reconnect to the server again.
|
|
\c
|
|
CREATE EXTENSION citus;
|