From b659a6559d7695c93eca0c6b06fcff6b94377819 Mon Sep 17 00:00:00 2001 From: Onder Kalaci Date: Fri, 2 Jan 2015 18:44:12 +0200 Subject: [PATCH] Regression tests for foreign tables This commit improves regression tests for foreign tables in pg_shard. --- expected/create_shards.out.tmpl | 11 +++++++++++ expected/modifications.out.tmpl | 4 ++-- sql/create_shards.sql.tmpl | 13 ++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/expected/create_shards.out.tmpl b/expected/create_shards.out.tmpl index 68addc4..c39d826 100644 --- a/expected/create_shards.out.tmpl +++ b/expected/create_shards.out.tmpl @@ -191,6 +191,7 @@ WARNING: could not create shard on "adeadhost:5432" (1 row) +\set VERBOSITY default SELECT storage, min_value, max_value FROM pgs_distribution_metadata.shard WHERE relation_id = 'foreign_table_to_distribute'::regclass ORDER BY (min_value COLLATE "C") ASC; @@ -214,3 +215,13 @@ SELECT storage, min_value, max_value FROM pgs_distribution_metadata.shard f | 805306357 | 1073741811 (16 rows) +-- cleanup foreign table, related shards and shard placements +DELETE FROM pgs_distribution_metadata.shard_placement + WHERE shard_id IN (SELECT shard_id FROM pgs_distribution_metadata.shard + WHERE relation_id = 'foreign_table_to_distribute'::regclass); + +DELETE FROM pgs_distribution_metadata.shard + WHERE relation_id = 'foreign_table_to_distribute'::regclass; + +DELETE FROM pgs_distribution_metadata.partition + WHERE relation_id = 'foreign_table_to_distribute'::regclass; diff --git a/expected/modifications.out.tmpl b/expected/modifications.out.tmpl index 500e998..4f08766 100644 --- a/expected/modifications.out.tmpl +++ b/expected/modifications.out.tmpl @@ -63,12 +63,12 @@ ERROR: cannot plan INSERT using row with NULL value in partition column INSERT INTO limit_orders VALUES (18811, 'BUD', 14962, '2014-04-05 08:32:16', 'sell', -5.00); WARNING: Bad result from localhost:$PGPORT -DETAIL: Remote message: new row for relation "limit_orders_10018" violates check constraint "limit_orders_limit_price_check" +DETAIL: Remote message: new row for relation "limit_orders_10034" violates check constraint "limit_orders_limit_price_check" ERROR: could not modify any active placements -- insert violating primary key constraint INSERT INTO limit_orders VALUES (32743, 'LUV', 5994, '2001-04-16 03:37:28', 'buy', 0.58); WARNING: Bad result from localhost:$PGPORT -DETAIL: Remote message: duplicate key value violates unique constraint "limit_orders_pkey_10019" +DETAIL: Remote message: duplicate key value violates unique constraint "limit_orders_pkey_10035" ERROR: could not modify any active placements -- queries with non-constant partition values are unsupported INSERT INTO limit_orders VALUES (random() * 100, 'ORCL', 152, '2011-08-25 11:50:45', diff --git a/sql/create_shards.sql.tmpl b/sql/create_shards.sql.tmpl index 6e2b755..8de9dd8 100644 --- a/sql/create_shards.sql.tmpl +++ b/sql/create_shards.sql.tmpl @@ -91,9 +91,20 @@ CREATE FOREIGN TABLE foreign_table_to_distribute SERVER fake_fdw_server; SELECT master_create_distributed_table('foreign_table_to_distribute', 'id'); - SELECT master_create_worker_shards('foreign_table_to_distribute', 16, 1); +\set VERBOSITY default SELECT storage, min_value, max_value FROM pgs_distribution_metadata.shard WHERE relation_id = 'foreign_table_to_distribute'::regclass ORDER BY (min_value COLLATE "C") ASC; + +-- cleanup foreign table, related shards and shard placements +DELETE FROM pgs_distribution_metadata.shard_placement + WHERE shard_id IN (SELECT shard_id FROM pgs_distribution_metadata.shard + WHERE relation_id = 'foreign_table_to_distribute'::regclass); + +DELETE FROM pgs_distribution_metadata.shard + WHERE relation_id = 'foreign_table_to_distribute'::regclass; + +DELETE FROM pgs_distribution_metadata.partition + WHERE relation_id = 'foreign_table_to_distribute'::regclass;