diff --git a/src/test/regress/create_schedule b/src/test/regress/create_schedule index 4ccecc244..4a4688468 100644 --- a/src/test/regress/create_schedule +++ b/src/test/regress/create_schedule @@ -5,3 +5,4 @@ test: local_dist_join_load test: partitioned_indexes_create test: connectivity_checks test: sequences_create +test: index_create diff --git a/src/test/regress/expected/index_create.out b/src/test/regress/expected/index_create.out new file mode 100644 index 000000000..6e2876fa4 --- /dev/null +++ b/src/test/regress/expected/index_create.out @@ -0,0 +1,40 @@ +CREATE SCHEMA index_create; +SET search_path TO index_create; +CREATE TABLE test_tbl (a INT NOT NULL PRIMARY KEY, b text, c BIGINT); +CREATE UNIQUE INDEX CONCURRENTLY a_index ON test_tbl (a); +SELECT create_distributed_table('test_tbl','a'); + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +-- suppress the WARNING message: not propagating CLUSTER command to worker nodes +SET client_min_messages TO ERROR; +CLUSTER test_tbl USING test_tbl_pkey; +RESET client_min_messages; +BEGIN; + CREATE INDEX idx1 ON test_tbl (a) INCLUDE (b, c); + DROP TABLE test_tbl; +ROLLBACK; +CREATE INDEX idx1 ON test_tbl (a) INCLUDE (b, c) WHERE a > 10; +CREATE INDEX idx2 ON test_tbl (lower(b)); +CREATE TABLE partitioning_test(id int, time date) PARTITION BY RANGE (time); +-- create its partitions +CREATE TABLE partitioning_test_2009 PARTITION OF partitioning_test FOR VALUES FROM ('2009-01-01') TO ('2010-01-01'); +CREATE TABLE partitioning_test_2010 PARTITION OF partitioning_test FOR VALUES FROM ('2010-01-01') TO ('2011-01-01'); +-- create indexes on the parent +CREATE INDEX IF NOT EXISTS partitioned_idx_1 ON ONLY partitioning_test (id); +CREATE INDEX IF NOT EXISTS partitioned_idx_2 ON partitioning_test (id, time NULLS FIRST); +SELECT create_distributed_table('partitioning_test', 'id'); + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +-- create hash index on distributed partitioned table +CREATE INDEX partition_idx_hash ON partitioning_test USING hash (id); +-- change statistics of index +ALTER INDEX idx2 ALTER COLUMN 1 SET STATISTICS 1000; +-- test reindex +REINDEX INDEX idx1; +ALTER TABLE test_tbl REPLICA IDENTITY USING INDEX a_index; diff --git a/src/test/regress/sql/index_create.sql b/src/test/regress/sql/index_create.sql new file mode 100644 index 000000000..34ceb02a1 --- /dev/null +++ b/src/test/regress/sql/index_create.sql @@ -0,0 +1,41 @@ +CREATE SCHEMA index_create; +SET search_path TO index_create; + +CREATE TABLE test_tbl (a INT NOT NULL PRIMARY KEY, b text, c BIGINT); +CREATE UNIQUE INDEX CONCURRENTLY a_index ON test_tbl (a); +SELECT create_distributed_table('test_tbl','a'); + +-- suppress the WARNING message: not propagating CLUSTER command to worker nodes +SET client_min_messages TO ERROR; +CLUSTER test_tbl USING test_tbl_pkey; +RESET client_min_messages; + +BEGIN; + CREATE INDEX idx1 ON test_tbl (a) INCLUDE (b, c); + DROP TABLE test_tbl; +ROLLBACK; + +CREATE INDEX idx1 ON test_tbl (a) INCLUDE (b, c) WHERE a > 10; +CREATE INDEX idx2 ON test_tbl (lower(b)); + +CREATE TABLE partitioning_test(id int, time date) PARTITION BY RANGE (time); +-- create its partitions +CREATE TABLE partitioning_test_2009 PARTITION OF partitioning_test FOR VALUES FROM ('2009-01-01') TO ('2010-01-01'); +CREATE TABLE partitioning_test_2010 PARTITION OF partitioning_test FOR VALUES FROM ('2010-01-01') TO ('2011-01-01'); + +-- create indexes on the parent +CREATE INDEX IF NOT EXISTS partitioned_idx_1 ON ONLY partitioning_test (id); +CREATE INDEX IF NOT EXISTS partitioned_idx_2 ON partitioning_test (id, time NULLS FIRST); + +SELECT create_distributed_table('partitioning_test', 'id'); + +-- create hash index on distributed partitioned table +CREATE INDEX partition_idx_hash ON partitioning_test USING hash (id); + +-- change statistics of index +ALTER INDEX idx2 ALTER COLUMN 1 SET STATISTICS 1000; + +-- test reindex +REINDEX INDEX idx1; + +ALTER TABLE test_tbl REPLICA IDENTITY USING INDEX a_index;