Skip to content

Commit

Permalink
Regression tests for foreign tables
Browse files Browse the repository at this point in the history
This commit improves regression tests for foreign tables
in pg_shard.
  • Loading branch information
onderkalaci committed Jan 2, 2015
1 parent a3dc6d0 commit b659a65
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
11 changes: 11 additions & 0 deletions expected/create_shards.out.tmpl
Expand Up @@ -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;
Expand All @@ -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;
4 changes: 2 additions & 2 deletions expected/modifications.out.tmpl
Expand Up @@ -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',
Expand Down
13 changes: 12 additions & 1 deletion sql/create_shards.sql.tmpl
Expand Up @@ -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;

0 comments on commit b659a65

Please sign in to comment.