diff options
author | Tomas Vondra | 2017-01-28 13:16:37 +0000 |
---|---|---|
committer | Tomas Vondra | 2017-01-28 16:13:30 +0000 |
commit | 0465a0f796e1b18f5656b5f9aedadc23a42b15db (patch) | |
tree | ee876cf87c635699636ed2fae5a694ece0e2269a | |
parent | 52a84dd12856fcaee218919d10b5f9f0ba870dbb (diff) |
minor fixes in 'cluster' regression suite (CREATE TABLE, extra .out files)
The 'CREATE TABLE clstr_tst' was wrong, as it needs to reference the
column and not the foreign key constraint. The table can't have a PK
on 'a' (does not include the distribution key), so remove that from
the expected list of constraints etc.
Also remove the unnecessary cluster_1.out and cluster_2.out files.
-rw-r--r-- | src/test/regress/expected/cluster.out | 15 | ||||
-rw-r--r-- | src/test/regress/expected/cluster_1.out | 381 | ||||
-rw-r--r-- | src/test/regress/expected/cluster_2.out | 374 | ||||
-rw-r--r-- | src/test/regress/sql/cluster.sql | 2 |
4 files changed, 8 insertions, 764 deletions
diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 4236b4e9e4..0113d648f9 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -3,11 +3,12 @@ -- CREATE TABLE clstr_tst_s (rf_a SERIAL PRIMARY KEY, b INT); -CREATE TABLE clstr_tst (a SERIAL PRIMARY KEY, +CREATE TABLE clstr_tst (a SERIAL, b INT, c TEXT, d TEXT, - CONSTRAINT clstr_tst_con FOREIGN KEY (b) REFERENCES clstr_tst_s); + CONSTRAINT clstr_tst_con FOREIGN KEY (b) REFERENCES clstr_tst_s) + DISTRIBUTE BY HASH (b); CREATE INDEX clstr_tst_b ON clstr_tst (b); CREATE INDEX clstr_tst_c ON clstr_tst (c); CREATE INDEX clstr_tst_c_b ON clstr_tst (c,b); @@ -247,11 +248,10 @@ ERROR: insert or update on table "clstr_tst" violates foreign key constraint "c DETAIL: Key (b)=(1111) is not present in table "clstr_tst_s". SELECT conname FROM pg_constraint WHERE conrelid = 'clstr_tst'::regclass ORDER BY 1; - conname ----------------- + conname +--------------- clstr_tst_con - clstr_tst_pkey -(2 rows) +(1 row) SELECT relname, relkind, EXISTS(SELECT 1 FROM pg_class WHERE oid = c.reltoastrelid) AS hastoast @@ -265,11 +265,10 @@ FROM pg_class c WHERE relname LIKE 'clstr_tst%' ORDER BY relname; clstr_tst_c | i | f clstr_tst_c_b | i | f clstr_tst_inh | r | t - clstr_tst_pkey | i | f clstr_tst_s | r | f clstr_tst_s_pkey | i | f clstr_tst_s_rf_a_seq | S | f -(11 rows) +(10 rows) -- Verify that indisclustered is correctly set SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 diff --git a/src/test/regress/expected/cluster_1.out b/src/test/regress/expected/cluster_1.out deleted file mode 100644 index bada9d61ff..0000000000 --- a/src/test/regress/expected/cluster_1.out +++ /dev/null @@ -1,381 +0,0 @@ --- --- CLUSTER --- -CREATE TABLE clstr_tst_s (rf_a SERIAL PRIMARY KEY, - b INT); -NOTICE: CREATE TABLE will create implicit sequence "clstr_tst_s_rf_a_seq" for serial column "clstr_tst_s.rf_a" -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_tst_s_pkey" for table "clstr_tst_s" -CREATE TABLE clstr_tst (a SERIAL PRIMARY KEY, - b INT, - c TEXT, - d TEXT, - CONSTRAINT clstr_tst_con FOREIGN KEY (b) REFERENCES clstr_tst_s); -NOTICE: CREATE TABLE will create implicit sequence "clstr_tst_a_seq" for serial column "clstr_tst.a" -ERROR: Hash/Modulo distributed table must include distribution column in index -CREATE INDEX clstr_tst_b ON clstr_tst (b); -ERROR: relation "clstr_tst" does not exist -CREATE INDEX clstr_tst_c ON clstr_tst (c); -ERROR: relation "clstr_tst" does not exist -CREATE INDEX clstr_tst_c_b ON clstr_tst (c,b); -ERROR: relation "clstr_tst" does not exist -CREATE INDEX clstr_tst_b_c ON clstr_tst (b,c); -ERROR: relation "clstr_tst" does not exist -INSERT INTO clstr_tst_s (b) VALUES (0); -INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; -INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; -INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; -INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; -INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; -CREATE TABLE clstr_tst_inh () INHERITS (clstr_tst); -ERROR: relation "clstr_tst" does not exist -INSERT INTO clstr_tst (b, c) VALUES (11, 'once'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (11, 'once'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (10, 'diez'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (10, 'diez'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (31, 'treinta y uno'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (31, 'treinta y uno'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (22, 'veintidos'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (22, 'veintidos'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (3, 'tres'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (3, 'tres'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (20, 'veinte'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (20, 'veinte'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (23, 'veintitres'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (23, 'veintitres'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (21, 'veintiuno'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (21, 'veintiuno'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (4, 'cuatro'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (4, 'cuatro'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (14, 'catorce'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (14, 'catorce'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (2, 'dos'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (2, 'dos'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (18, 'dieciocho'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (18, 'dieciocho'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (27, 'veintisiete'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (27, 'veintisiete'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (25, 'veinticinco'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (25, 'veinticinco'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (13, 'trece'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (13, 'trece'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (28, 'veintiocho'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (28, 'veintiocho'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (32, 'treinta y dos'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (32, 'treinta y dos'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (5, 'cinco'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (5, 'cinco'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (29, 'veintinueve'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (29, 'veintinueve'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (1, 'uno'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (1, 'uno'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (24, 'veinticuatro'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (24, 'veinticuatro'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (30, 'treinta'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (30, 'treinta'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (12, 'doce'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (12, 'doce'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (17, 'diecisiete'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (17, 'diecisiete'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (9, 'nueve'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (9, 'nueve'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (19, 'diecinueve'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (19, 'diecinueve'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (26, 'veintiseis'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (26, 'veintiseis'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (15, 'quince'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (15, 'quince'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (7, 'siete'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (7, 'siete'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (16, 'dieciseis'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (16, 'dieciseis'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (8, 'ocho'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (8, 'ocho'); - ^ --- This entry is needed to test that TOASTED values are copied correctly. -INSERT INTO clstr_tst (b, c, d) VALUES (6, 'seis', repeat('xyzzy', 100000)); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c, d) VALUES (6, 'seis', repeat('x... - ^ -CLUSTER clstr_tst_c ON clstr_tst; -ERROR: relation "clstr_tst" does not exist -SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a, b, c; -ERROR: relation "clstr_tst" does not exist -LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... - ^ -SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a; -ERROR: relation "clstr_tst" does not exist -LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... - ^ -SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY b; -ERROR: relation "clstr_tst" does not exist -LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... - ^ -SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY c; -ERROR: relation "clstr_tst" does not exist -LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... - ^ --- Verify that inheritance link still works -INSERT INTO clstr_tst_inh VALUES (0, 100, 'in child table'); -ERROR: relation "clstr_tst_inh" does not exist -LINE 1: INSERT INTO clstr_tst_inh VALUES (0, 100, 'in child table'); - ^ -SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a, b, c; -ERROR: relation "clstr_tst" does not exist -LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... - ^ --- Verify that foreign key link still works -INSERT INTO clstr_tst (b, c) VALUES (1111, 'this should fail'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (1111, 'this should fail... - ^ -SELECT conname FROM pg_constraint WHERE conrelid = 'clstr_tst'::regclass -ORDER BY 1; -ERROR: relation "clstr_tst" does not exist -LINE 1: ...ELECT conname FROM pg_constraint WHERE conrelid = 'clstr_tst... - ^ -SELECT relname, relkind, - EXISTS(SELECT 1 FROM pg_class WHERE oid = c.reltoastrelid) AS hastoast -FROM pg_class c WHERE relname LIKE 'clstr_tst%' ORDER BY relname; - relname | relkind | hastoast -----------------------+---------+---------- - clstr_tst_s | r | f - clstr_tst_s_pkey | i | f - clstr_tst_s_rf_a_seq | S | f -(3 rows) - --- Verify that indisclustered is correctly set -SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 -WHERE pg_class.oid=indexrelid - AND indrelid=pg_class_2.oid - AND pg_class_2.relname = 'clstr_tst' - AND indisclustered; - relname ---------- -(0 rows) - --- Try changing indisclustered -ALTER TABLE clstr_tst CLUSTER ON clstr_tst_b_c; -ERROR: relation "clstr_tst" does not exist -SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 -WHERE pg_class.oid=indexrelid - AND indrelid=pg_class_2.oid - AND pg_class_2.relname = 'clstr_tst' - AND indisclustered; - relname ---------- -(0 rows) - --- Try turning off all clustering -ALTER TABLE clstr_tst SET WITHOUT CLUSTER; -ERROR: relation "clstr_tst" does not exist -SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 -WHERE pg_class.oid=indexrelid - AND indrelid=pg_class_2.oid - AND pg_class_2.relname = 'clstr_tst' - AND indisclustered; - relname ---------- -(0 rows) - --- Verify that clustering all tables does in fact cluster the right ones -CREATE USER clstr_user; -CREATE TABLE clstr_1 (a INT PRIMARY KEY); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_1_pkey" for table "clstr_1" -CREATE TABLE clstr_2 (a INT PRIMARY KEY); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_2_pkey" for table "clstr_2" -CREATE TABLE clstr_3 (a INT PRIMARY KEY); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_3_pkey" for table "clstr_3" -ALTER TABLE clstr_1 OWNER TO clstr_user; -ALTER TABLE clstr_3 OWNER TO clstr_user; -GRANT SELECT ON clstr_2 TO clstr_user; -INSERT INTO clstr_1 VALUES (2); -INSERT INTO clstr_1 VALUES (1); -INSERT INTO clstr_2 VALUES (2); -INSERT INTO clstr_2 VALUES (1); -INSERT INTO clstr_3 VALUES (2); -INSERT INTO clstr_3 VALUES (1); --- "CLUSTER <tablename>" on a table that hasn't been clustered -CLUSTER clstr_2; -ERROR: there is no previously clustered index for table "clstr_2" -CLUSTER clstr_1_pkey ON clstr_1; -CLUSTER clstr_2 USING clstr_2_pkey; -SELECT * FROM clstr_1 UNION ALL - SELECT * FROM clstr_2 UNION ALL - SELECT * FROM clstr_3 - ORDER BY 1; - a ---- - 1 - 1 - 1 - 2 - 2 - 2 -(6 rows) - --- revert to the original state -DELETE FROM clstr_1; -DELETE FROM clstr_2; -DELETE FROM clstr_3; -INSERT INTO clstr_1 VALUES (2); -INSERT INTO clstr_1 VALUES (1); -INSERT INTO clstr_2 VALUES (2); -INSERT INTO clstr_2 VALUES (1); -INSERT INTO clstr_3 VALUES (2); -INSERT INTO clstr_3 VALUES (1); --- this user can only cluster clstr_1 and clstr_3, but the latter --- has not been clustered -SET SESSION AUTHORIZATION clstr_user; -CLUSTER; -SELECT * FROM clstr_1 UNION ALL - SELECT * FROM clstr_2 UNION ALL - SELECT * FROM clstr_3 - ORDER BY 1; - a ---- - 1 - 1 - 1 - 2 - 2 - 2 -(6 rows) - --- cluster a single table using the indisclustered bit previously set -DELETE FROM clstr_1; -INSERT INTO clstr_1 VALUES (2); -INSERT INTO clstr_1 VALUES (1); -CLUSTER clstr_1; -SELECT * FROM clstr_1 -ORDER BY 1; - a ---- - 1 - 2 -(2 rows) - --- Test MVCC-safety of cluster. There isn't much we can do to verify the --- results with a single backend... -CREATE TABLE clustertest (key int PRIMARY KEY); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clustertest_pkey" for table "clustertest" -INSERT INTO clustertest VALUES (10); -INSERT INTO clustertest VALUES (20); -INSERT INTO clustertest VALUES (30); -INSERT INTO clustertest VALUES (40); -INSERT INTO clustertest VALUES (50); --- Use a transaction so that updates are not committed when CLUSTER sees 'em -BEGIN; --- Test update where the old row version is found first in the scan -UPDATE clustertest SET key = 100 WHERE key = 10; -ERROR: Partition column can't be updated in current version --- Test update where the new row version is found first in the scan -UPDATE clustertest SET key = 35 WHERE key = 40; -ERROR: current transaction is aborted, commands ignored until end of transaction block --- Test longer update chain -UPDATE clustertest SET key = 60 WHERE key = 50; -ERROR: current transaction is aborted, commands ignored until end of transaction block -UPDATE clustertest SET key = 70 WHERE key = 60; -ERROR: current transaction is aborted, commands ignored until end of transaction block -UPDATE clustertest SET key = 80 WHERE key = 70; -ERROR: current transaction is aborted, commands ignored until end of transaction block -SELECT * FROM clustertest ORDER BY 1; -ERROR: current transaction is aborted, commands ignored until end of transaction block -CLUSTER clustertest_pkey ON clustertest; -ERROR: current transaction is aborted, commands ignored until end of transaction block -SELECT * FROM clustertest ORDER BY 1; -ERROR: current transaction is aborted, commands ignored until end of transaction block -COMMIT; -SELECT * FROM clustertest ORDER BY 1; - key ------ - 10 - 20 - 30 - 40 - 50 -(5 rows) - --- check that temp tables can be clustered --- Enforce use of COMMIT instead of 2PC for temporary objects -RESET SESSION AUTHORIZATION; -SET SESSION AUTHORIZATION clstr_user; -create temp table clstr_temp (col1 int primary key, col2 text); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_temp_pkey" for table "clstr_temp" -insert into clstr_temp values (2, 'two'), (1, 'one'); -cluster clstr_temp using clstr_temp_pkey; -select * from clstr_temp order by 1; - col1 | col2 -------+------ - 1 | one - 2 | two -(2 rows) - -drop table clstr_temp; --- clean up -\c - -DROP TABLE clustertest; -DROP TABLE clstr_1; -DROP TABLE clstr_2; -DROP TABLE clstr_3; -DROP USER clstr_user; diff --git a/src/test/regress/expected/cluster_2.out b/src/test/regress/expected/cluster_2.out deleted file mode 100644 index fe9e31f99d..0000000000 --- a/src/test/regress/expected/cluster_2.out +++ /dev/null @@ -1,374 +0,0 @@ --- --- CLUSTER --- -CREATE TABLE clstr_tst_s (rf_a SERIAL PRIMARY KEY, - b INT); -CREATE TABLE clstr_tst (a SERIAL PRIMARY KEY, - b INT, - c TEXT, - d TEXT, - CONSTRAINT clstr_tst_con FOREIGN KEY (b) REFERENCES clstr_tst_s); -ERROR: Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table. -CREATE INDEX clstr_tst_b ON clstr_tst (b); -ERROR: relation "clstr_tst" does not exist -CREATE INDEX clstr_tst_c ON clstr_tst (c); -ERROR: relation "clstr_tst" does not exist -CREATE INDEX clstr_tst_c_b ON clstr_tst (c,b); -ERROR: relation "clstr_tst" does not exist -CREATE INDEX clstr_tst_b_c ON clstr_tst (b,c); -ERROR: relation "clstr_tst" does not exist -INSERT INTO clstr_tst_s (b) VALUES (0); -INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; -INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; -INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; -INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; -INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s; -CREATE TABLE clstr_tst_inh () INHERITS (clstr_tst); -ERROR: relation "clstr_tst" does not exist -INSERT INTO clstr_tst (b, c) VALUES (11, 'once'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (11, 'once'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (10, 'diez'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (10, 'diez'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (31, 'treinta y uno'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (31, 'treinta y uno'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (22, 'veintidos'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (22, 'veintidos'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (3, 'tres'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (3, 'tres'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (20, 'veinte'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (20, 'veinte'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (23, 'veintitres'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (23, 'veintitres'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (21, 'veintiuno'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (21, 'veintiuno'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (4, 'cuatro'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (4, 'cuatro'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (14, 'catorce'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (14, 'catorce'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (2, 'dos'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (2, 'dos'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (18, 'dieciocho'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (18, 'dieciocho'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (27, 'veintisiete'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (27, 'veintisiete'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (25, 'veinticinco'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (25, 'veinticinco'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (13, 'trece'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (13, 'trece'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (28, 'veintiocho'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (28, 'veintiocho'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (32, 'treinta y dos'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (32, 'treinta y dos'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (5, 'cinco'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (5, 'cinco'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (29, 'veintinueve'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (29, 'veintinueve'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (1, 'uno'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (1, 'uno'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (24, 'veinticuatro'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (24, 'veinticuatro'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (30, 'treinta'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (30, 'treinta'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (12, 'doce'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (12, 'doce'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (17, 'diecisiete'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (17, 'diecisiete'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (9, 'nueve'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (9, 'nueve'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (19, 'diecinueve'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (19, 'diecinueve'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (26, 'veintiseis'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (26, 'veintiseis'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (15, 'quince'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (15, 'quince'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (7, 'siete'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (7, 'siete'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (16, 'dieciseis'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (16, 'dieciseis'); - ^ -INSERT INTO clstr_tst (b, c) VALUES (8, 'ocho'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (8, 'ocho'); - ^ --- This entry is needed to test that TOASTED values are copied correctly. -INSERT INTO clstr_tst (b, c, d) VALUES (6, 'seis', repeat('xyzzy', 100000)); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c, d) VALUES (6, 'seis', repeat('x... - ^ -CLUSTER clstr_tst_c ON clstr_tst; -ERROR: relation "clstr_tst" does not exist -SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a, b, c; -ERROR: relation "clstr_tst" does not exist -LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... - ^ -SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a; -ERROR: relation "clstr_tst" does not exist -LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... - ^ -SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY b; -ERROR: relation "clstr_tst" does not exist -LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... - ^ -SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY c; -ERROR: relation "clstr_tst" does not exist -LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... - ^ --- Verify that inheritance link still works -INSERT INTO clstr_tst_inh VALUES (0, 100, 'in child table'); -ERROR: relation "clstr_tst_inh" does not exist -LINE 1: INSERT INTO clstr_tst_inh VALUES (0, 100, 'in child table'); - ^ -SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a, b, c; -ERROR: relation "clstr_tst" does not exist -LINE 1: SELECT a,b,c,substring(d for 30), length(d) from clstr_tst O... - ^ --- Verify that foreign key link still works -INSERT INTO clstr_tst (b, c) VALUES (1111, 'this should fail'); -ERROR: relation "clstr_tst" does not exist -LINE 1: INSERT INTO clstr_tst (b, c) VALUES (1111, 'this should fail... - ^ -SELECT conname FROM pg_constraint WHERE conrelid = 'clstr_tst'::regclass -ORDER BY 1; -ERROR: relation "clstr_tst" does not exist -LINE 1: ...ELECT conname FROM pg_constraint WHERE conrelid = 'clstr_tst... - ^ -SELECT relname, relkind, - EXISTS(SELECT 1 FROM pg_class WHERE oid = c.reltoastrelid) AS hastoast -FROM pg_class c WHERE relname LIKE 'clstr_tst%' ORDER BY relname; - relname | relkind | hastoast -----------------------+---------+---------- - clstr_tst_s | r | f - clstr_tst_s_pkey | i | f - clstr_tst_s_rf_a_seq | S | f -(3 rows) - --- Verify that indisclustered is correctly set -SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 -WHERE pg_class.oid=indexrelid - AND indrelid=pg_class_2.oid - AND pg_class_2.relname = 'clstr_tst' - AND indisclustered; - relname ---------- -(0 rows) - --- Try changing indisclustered -ALTER TABLE clstr_tst CLUSTER ON clstr_tst_b_c; -ERROR: relation "clstr_tst" does not exist -SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 -WHERE pg_class.oid=indexrelid - AND indrelid=pg_class_2.oid - AND pg_class_2.relname = 'clstr_tst' - AND indisclustered; - relname ---------- -(0 rows) - --- Try turning off all clustering -ALTER TABLE clstr_tst SET WITHOUT CLUSTER; -ERROR: relation "clstr_tst" does not exist -SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 -WHERE pg_class.oid=indexrelid - AND indrelid=pg_class_2.oid - AND pg_class_2.relname = 'clstr_tst' - AND indisclustered; - relname ---------- -(0 rows) - --- Verify that clustering all tables does in fact cluster the right ones -CREATE USER clstr_user; -CREATE TABLE clstr_1 (a INT PRIMARY KEY); -CREATE TABLE clstr_2 (a INT PRIMARY KEY); -CREATE TABLE clstr_3 (a INT PRIMARY KEY); -ALTER TABLE clstr_1 OWNER TO clstr_user; -ALTER TABLE clstr_3 OWNER TO clstr_user; -GRANT SELECT ON clstr_2 TO clstr_user; -INSERT INTO clstr_1 VALUES (2); -INSERT INTO clstr_1 VALUES (1); -INSERT INTO clstr_2 VALUES (2); -INSERT INTO clstr_2 VALUES (1); -INSERT INTO clstr_3 VALUES (2); -INSERT INTO clstr_3 VALUES (1); --- "CLUSTER <tablename>" on a table that hasn't been clustered -CLUSTER clstr_2; -ERROR: there is no previously clustered index for table "clstr_2" -CLUSTER clstr_1_pkey ON clstr_1; -CLUSTER clstr_2 USING clstr_2_pkey; -SELECT * FROM clstr_1 UNION ALL - SELECT * FROM clstr_2 UNION ALL - SELECT * FROM clstr_3 - ORDER BY 1; - a ---- - 1 - 1 - 1 - 2 - 2 - 2 -(6 rows) - --- revert to the original state -DELETE FROM clstr_1; -DELETE FROM clstr_2; -DELETE FROM clstr_3; -INSERT INTO clstr_1 VALUES (2); -INSERT INTO clstr_1 VALUES (1); -INSERT INTO clstr_2 VALUES (2); -INSERT INTO clstr_2 VALUES (1); -INSERT INTO clstr_3 VALUES (2); -INSERT INTO clstr_3 VALUES (1); --- this user can only cluster clstr_1 and clstr_3, but the latter --- has not been clustered -SET SESSION AUTHORIZATION clstr_user; -CLUSTER; -SELECT * FROM clstr_1 UNION ALL - SELECT * FROM clstr_2 UNION ALL - SELECT * FROM clstr_3 - ORDER BY 1; - a ---- - 1 - 1 - 1 - 2 - 2 - 2 -(6 rows) - --- cluster a single table using the indisclustered bit previously set -DELETE FROM clstr_1; -INSERT INTO clstr_1 VALUES (2); -INSERT INTO clstr_1 VALUES (1); -CLUSTER clstr_1; -SELECT * FROM clstr_1 -ORDER BY 1; - a ---- - 1 - 2 -(2 rows) - --- Test MVCC-safety of cluster. There isn't much we can do to verify the --- results with a single backend... -CREATE TABLE clustertest (key int PRIMARY KEY); -INSERT INTO clustertest VALUES (10); -INSERT INTO clustertest VALUES (20); -INSERT INTO clustertest VALUES (30); -INSERT INTO clustertest VALUES (40); -INSERT INTO clustertest VALUES (50); --- Use a transaction so that updates are not committed when CLUSTER sees 'em -BEGIN; --- Test update where the old row version is found first in the scan -UPDATE clustertest SET key = 100 WHERE key = 10; -ERROR: could not plan this distributed update -DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL. --- Test update where the new row version is found first in the scan -UPDATE clustertest SET key = 35 WHERE key = 40; -ERROR: current transaction is aborted, commands ignored until end of transaction block --- Test longer update chain -UPDATE clustertest SET key = 60 WHERE key = 50; -ERROR: current transaction is aborted, commands ignored until end of transaction block -UPDATE clustertest SET key = 70 WHERE key = 60; -ERROR: current transaction is aborted, commands ignored until end of transaction block -UPDATE clustertest SET key = 80 WHERE key = 70; -ERROR: current transaction is aborted, commands ignored until end of transaction block -SELECT * FROM clustertest ORDER BY 1; -ERROR: current transaction is aborted, commands ignored until end of transaction block -CLUSTER clustertest_pkey ON clustertest; -ERROR: current transaction is aborted, commands ignored until end of transaction block -SELECT * FROM clustertest ORDER BY 1; -ERROR: current transaction is aborted, commands ignored until end of transaction block -COMMIT; -SELECT * FROM clustertest ORDER BY 1; - key ------ - 10 - 20 - 30 - 40 - 50 -(5 rows) - --- check that temp tables can be clustered --- Enforce use of COMMIT instead of 2PC for temporary objects -RESET SESSION AUTHORIZATION; -SET SESSION AUTHORIZATION clstr_user; -create temp table clstr_temp (col1 int primary key, col2 text); -insert into clstr_temp values (2, 'two'), (1, 'one'); -cluster clstr_temp using clstr_temp_pkey; -select * from clstr_temp order by 1; - col1 | col2 -------+------ - 1 | one - 2 | two -(2 rows) - -drop table clstr_temp; --- clean up -\c - -DROP TABLE clustertest; -DROP TABLE clstr_1; -DROP TABLE clstr_2; -DROP TABLE clstr_3; -DROP USER clstr_user; diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 68435a8427..098089bd8d 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -10,7 +10,7 @@ CREATE TABLE clstr_tst (a SERIAL, c TEXT, d TEXT, CONSTRAINT clstr_tst_con FOREIGN KEY (b) REFERENCES clstr_tst_s) - DISTRIBUTE BY (clstr_tst_con); + DISTRIBUTE BY HASH (b); CREATE INDEX clstr_tst_b ON clstr_tst (b); CREATE INDEX clstr_tst_c ON clstr_tst (c); |