mirror of https://github.com/citusdata/citus.git
197 lines
13 KiB
Plaintext
197 lines
13 KiB
Plaintext
--
|
|
-- MULTI_INDEX_STATEMENTS
|
|
--
|
|
-- Check that we can run CREATE INDEX and DROP INDEX statements on distributed
|
|
-- tables. We increase the logging verbosity to verify that commands are
|
|
-- propagated to all worker shards.
|
|
SET client_min_messages TO DEBUG2;
|
|
--
|
|
-- CREATE INDEX
|
|
--
|
|
-- Verify that we can create different types of indexes
|
|
CREATE INDEX lineitem_orderkey_index ON lineitem (l_orderkey);
|
|
DEBUG: applied command on shard 102014 on node localhost:57638
|
|
DEBUG: applied command on shard 102014 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57638
|
|
DEBUG: building index "lineitem_orderkey_index" on table "lineitem"
|
|
CREATE INDEX lineitem_partkey_desc_index ON lineitem (l_partkey DESC);
|
|
DEBUG: applied command on shard 102014 on node localhost:57638
|
|
DEBUG: applied command on shard 102014 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57638
|
|
DEBUG: building index "lineitem_partkey_desc_index" on table "lineitem"
|
|
CREATE INDEX lineitem_partial_index ON lineitem (l_shipdate)
|
|
WHERE l_shipdate < '1995-01-01';
|
|
DEBUG: applied command on shard 102014 on node localhost:57638
|
|
DEBUG: applied command on shard 102014 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57638
|
|
DEBUG: building index "lineitem_partial_index" on table "lineitem"
|
|
CREATE INDEX lineitem_orderkey_hash_index ON lineitem USING hash (l_partkey);
|
|
DEBUG: applied command on shard 102014 on node localhost:57638
|
|
DEBUG: applied command on shard 102014 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57638
|
|
WARNING: hash indexes are not WAL-logged and their use is discouraged
|
|
DEBUG: building index "lineitem_orderkey_hash_index" on table "lineitem"
|
|
-- Verify that all indexes got created on the master node
|
|
SELECT * FROM pg_indexes WHERE tablename = 'lineitem' ORDER BY indexname;
|
|
schemaname | tablename | indexname | tablespace | indexdef
|
|
------------+-----------+------------------------------+------------+------------------------------------------------------------------------------------------------------------------
|
|
public | lineitem | lineitem_orderkey_hash_index | | CREATE INDEX lineitem_orderkey_hash_index ON lineitem USING hash (l_partkey)
|
|
public | lineitem | lineitem_orderkey_index | | CREATE INDEX lineitem_orderkey_index ON lineitem USING btree (l_orderkey)
|
|
public | lineitem | lineitem_partial_index | | CREATE INDEX lineitem_partial_index ON lineitem USING btree (l_shipdate) WHERE (l_shipdate < '01-01-1995'::date)
|
|
public | lineitem | lineitem_partkey_desc_index | | CREATE INDEX lineitem_partkey_desc_index ON lineitem USING btree (l_partkey DESC)
|
|
public | lineitem | lineitem_pkey | | CREATE UNIQUE INDEX lineitem_pkey ON lineitem USING btree (l_orderkey, l_linenumber)
|
|
public | lineitem | lineitem_time_index | | CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate)
|
|
(6 rows)
|
|
|
|
-- Verify that we error out on unsupported statement types
|
|
CREATE INDEX CONCURRENTLY try_index ON lineitem (l_orderkey);
|
|
ERROR: creating indexes concurrently on distributed tables is currently unsupported
|
|
CREATE UNIQUE INDEX try_index ON lineitem (l_orderkey);
|
|
ERROR: creating unique indexes on distributed tables is currently unsupported
|
|
CREATE INDEX try_index ON lineitem (l_orderkey) TABLESPACE newtablespace;
|
|
ERROR: specifying tablespaces with CREATE INDEX statements is currently unsupported
|
|
-- Verify that we error out in case of postgres errors on supported statement
|
|
-- types.
|
|
CREATE INDEX lineitem_orderkey_index ON lineitem (l_orderkey);
|
|
WARNING: could not receive query results from localhost:57638
|
|
DETAIL: Client error: relation "lineitem_orderkey_index_102014" already exists
|
|
ERROR: could not execute DDL command on worker node shards
|
|
CREATE INDEX try_index ON lineitem USING gist (l_orderkey);
|
|
WARNING: could not receive query results from localhost:57638
|
|
DETAIL: Client error: data type bigint has no default operator class for access method "gist"
|
|
ERROR: could not execute DDL command on worker node shards
|
|
CREATE INDEX try_index ON lineitem (non_existent_column);
|
|
WARNING: could not receive query results from localhost:57638
|
|
DETAIL: Client error: column "non_existent_column" does not exist
|
|
ERROR: could not execute DDL command on worker node shards
|
|
-- Verify that none of failed indexes got created on the master node
|
|
SELECT * FROM pg_indexes WHERE tablename = 'lineitem' ORDER BY indexname;
|
|
schemaname | tablename | indexname | tablespace | indexdef
|
|
------------+-----------+------------------------------+------------+------------------------------------------------------------------------------------------------------------------
|
|
public | lineitem | lineitem_orderkey_hash_index | | CREATE INDEX lineitem_orderkey_hash_index ON lineitem USING hash (l_partkey)
|
|
public | lineitem | lineitem_orderkey_index | | CREATE INDEX lineitem_orderkey_index ON lineitem USING btree (l_orderkey)
|
|
public | lineitem | lineitem_partial_index | | CREATE INDEX lineitem_partial_index ON lineitem USING btree (l_shipdate) WHERE (l_shipdate < '01-01-1995'::date)
|
|
public | lineitem | lineitem_partkey_desc_index | | CREATE INDEX lineitem_partkey_desc_index ON lineitem USING btree (l_partkey DESC)
|
|
public | lineitem | lineitem_pkey | | CREATE UNIQUE INDEX lineitem_pkey ON lineitem USING btree (l_orderkey, l_linenumber)
|
|
public | lineitem | lineitem_time_index | | CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate)
|
|
(6 rows)
|
|
|
|
--
|
|
-- DROP INDEX
|
|
--
|
|
-- Verify that we can't drop multiple indexes in a single command
|
|
DROP INDEX lineitem_orderkey_index, lineitem_partial_index;
|
|
ERROR: cannot drop multiple distributed objects in a single command
|
|
HINT: Try dropping each object in a separate DROP command.
|
|
-- Verify that we error out on the CONCURRENTLY clause
|
|
DROP INDEX CONCURRENTLY lineitem_orderkey_index;
|
|
ERROR: dropping indexes concurrently on distributed tables is currently unsupported
|
|
-- Verify that we can succesfully drop indexes
|
|
DROP INDEX lineitem_orderkey_index;
|
|
DEBUG: applied command on shard 102014 on node localhost:57638
|
|
DEBUG: applied command on shard 102014 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57638
|
|
DEBUG: EventTriggerInvoke 16541
|
|
DROP INDEX lineitem_partkey_desc_index;
|
|
DEBUG: applied command on shard 102014 on node localhost:57638
|
|
DEBUG: applied command on shard 102014 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57638
|
|
DEBUG: EventTriggerInvoke 16541
|
|
DROP INDEX lineitem_partial_index;
|
|
DEBUG: applied command on shard 102014 on node localhost:57638
|
|
DEBUG: applied command on shard 102014 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57638
|
|
DEBUG: EventTriggerInvoke 16541
|
|
-- Verify that we handle if exists statements correctly
|
|
DROP INDEX non_existent_index;
|
|
ERROR: index "non_existent_index" does not exist
|
|
DROP INDEX IF EXISTS non_existent_index;
|
|
NOTICE: index "non_existent_index" does not exist, skipping
|
|
DROP INDEX IF EXISTS lineitem_orderkey_hash_index;
|
|
DEBUG: applied command on shard 102014 on node localhost:57638
|
|
DEBUG: applied command on shard 102014 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57637
|
|
DEBUG: applied command on shard 102013 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57638
|
|
DEBUG: applied command on shard 102012 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57637
|
|
DEBUG: applied command on shard 102011 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57638
|
|
DEBUG: applied command on shard 102010 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57637
|
|
DEBUG: applied command on shard 102009 on node localhost:57638
|
|
DEBUG: EventTriggerInvoke 16541
|
|
DROP INDEX lineitem_orderkey_hash_index;
|
|
ERROR: index "lineitem_orderkey_hash_index" does not exist
|
|
-- Verify that all the indexes are also dropped from the master node
|
|
SELECT * FROM pg_indexes WHERE tablename = 'lineitem' ORDER BY indexname;
|
|
schemaname | tablename | indexname | tablespace | indexdef
|
|
------------+-----------+---------------------+------------+--------------------------------------------------------------------------------------
|
|
public | lineitem | lineitem_pkey | | CREATE UNIQUE INDEX lineitem_pkey ON lineitem USING btree (l_orderkey, l_linenumber)
|
|
public | lineitem | lineitem_time_index | | CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate)
|
|
(2 rows)
|
|
|