diff --git a/test/regress/schedule/router b/test/regress/schedule/router index a37269604..d8501f0e9 100644 --- a/test/regress/schedule/router +++ b/test/regress/schedule/router @@ -10,3 +10,4 @@ test: single_shard_joins test: multishard test: error test: routing_hint +test: distinct diff --git a/test/regress/tests/router/expected/distinct.out b/test/regress/tests/router/expected/distinct.out new file mode 100644 index 000000000..391bb59b1 --- /dev/null +++ b/test/regress/tests/router/expected/distinct.out @@ -0,0 +1,57 @@ +\c spqr-console + + SQPR router admin console + Here you can configure your routing rules +------------------------------------------------ + You can find documentation here +https://github.com/pg-sharding/spqr/tree/master/docs + +ADD SHARDING RULE t1 COLUMNS id; + add sharding rule +---------------------------------------------------------------------- + created sharding rule t1 for table (*) with columns [id, hash: x->x] +(1 row) + +ADD KEY RANGE krid1 FROM 1 TO 11 ROUTE TO sh1; + add key range +-------------------------------- + created key range from 1 to 11 +(1 row) + +ADD KEY RANGE krid2 FROM 11 TO 101 ROUTE TO sh2; + add key range +---------------------------------- + created key range from 11 to 101 +(1 row) + +\c regress +CREATE TABLE test_dist(id int); +NOTICE: send query to shard(s) : sh1,sh2 +INSERT INTO test_dist(id) VALUES(5); +NOTICE: send query to shard(s) : sh1 +INSERT INTO test_dist(id) VALUES(5); +NOTICE: send query to shard(s) : sh1 +INSERT INTO test_dist(id) VALUES(5); +NOTICE: send query to shard(s) : sh1 +INSERT INTO test_dist(id) VALUES(5); +NOTICE: send query to shard(s) : sh1 +INSERT INTO test_dist(id) VALUES(5); +NOTICE: send query to shard(s) : sh1 +SELECT id FROM test_dist WHERE id=5; +NOTICE: send query to shard(s) : sh1 + id +---- + 5 + 5 + 5 + 5 + 5 +(5 rows) + +SELECT DISTINCT id FROM test_dist WHERE id=5; +NOTICE: send query to shard(s) : sh1 + id +---- + 5 +(1 row) + diff --git a/test/regress/tests/router/expected/routing_hint.out b/test/regress/tests/router/expected/routing_hint.out index dc05e7f19..511200b24 100644 --- a/test/regress/tests/router/expected/routing_hint.out +++ b/test/regress/tests/router/expected/routing_hint.out @@ -31,3 +31,22 @@ INSERT INTO test(id, age) VALUES (10, 16) /*sharding_key: 30*/; NOTICE: send query to shard(s) : sh2 INSERT INTO test(id, age) VALUES (10, 16) /*sharding_key: 3000*/; NOTICE: send query to shard(s) : sh1 +\c spqr-console + + SQPR router admin console + Here you can configure your routing rules +------------------------------------------------ + You can find documentation here +https://github.com/pg-sharding/spqr/tree/master/docs + +DROP KEY RANGE ALL; + drop key range +---------------- +(0 rows) + +DROP SHARDING RULE ALL; + drop sharding rule +-------------------------- + dropped sharding rule t1 +(1 row) + diff --git a/test/regress/tests/router/sql/distinct.sql b/test/regress/tests/router/sql/distinct.sql new file mode 100644 index 000000000..ecf466e1a --- /dev/null +++ b/test/regress/tests/router/sql/distinct.sql @@ -0,0 +1,16 @@ +\c spqr-console + +ADD SHARDING RULE t1 COLUMNS id; +ADD KEY RANGE krid1 FROM 1 TO 11 ROUTE TO sh1; +ADD KEY RANGE krid2 FROM 11 TO 101 ROUTE TO sh2; + +\c regress + +CREATE TABLE test_dist(id int); +INSERT INTO test_dist(id) VALUES(5); +INSERT INTO test_dist(id) VALUES(5); +INSERT INTO test_dist(id) VALUES(5); +INSERT INTO test_dist(id) VALUES(5); +INSERT INTO test_dist(id) VALUES(5); +SELECT id FROM test_dist WHERE id=5; +SELECT DISTINCT id FROM test_dist WHERE id=5; \ No newline at end of file diff --git a/test/regress/tests/router/sql/routing_hint.sql b/test/regress/tests/router/sql/routing_hint.sql index 241749883..eef3d5e6e 100644 --- a/test/regress/tests/router/sql/routing_hint.sql +++ b/test/regress/tests/router/sql/routing_hint.sql @@ -8,4 +8,7 @@ ADD KEY RANGE krid2 FROM 11 TO 101 ROUTE TO sh2; CREATE TABLE test(id int, age int); INSERT INTO test(id, age) VALUES (10, 16) /*sharding_key: 30*/; -INSERT INTO test(id, age) VALUES (10, 16) /*sharding_key: 3000*/; \ No newline at end of file +INSERT INTO test(id, age) VALUES (10, 16) /*sharding_key: 3000*/; +\c spqr-console +DROP KEY RANGE ALL; +DROP SHARDING RULE ALL; \ No newline at end of file