-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support routing based purely on target list. (#1009)
- Loading branch information
Showing
8 changed files
with
147 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
test/regress/tests/router/expected/target_list_routing.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
\c spqr-console | ||
|
||
SPQR router admin console | ||
Here you can configure your routing rules | ||
------------------------------------------------ | ||
You can find documentation here | ||
https://github.com/pg-sharding/spqr/tree/master/docs | ||
|
||
CREATE DISTRIBUTION ds1 COLUMN TYPES integer; | ||
add distribution | ||
------------------------ | ||
distribution id -> ds1 | ||
(1 row) | ||
|
||
CREATE KEY RANGE kridi1 from 0 route to sh1 FOR DISTRIBUTION ds1; | ||
add key range | ||
--------------- | ||
bound -> 0 | ||
(1 row) | ||
|
||
CREATE KEY RANGE kridi2 from 11 route to sh2 FOR DISTRIBUTION ds1; | ||
add key range | ||
--------------- | ||
bound -> 11 | ||
(1 row) | ||
|
||
ALTER DISTRIBUTION ds1 ATTACH RELATION tlt1 DISTRIBUTION KEY i; | ||
attach table | ||
------------------------- | ||
relation name -> tlt1 | ||
distribution id -> ds1 | ||
(2 rows) | ||
|
||
\c regress | ||
CREATE SCHEMA sh2; | ||
NOTICE: send query to shard(s) : sh1,sh2,sh3,sh4 | ||
CREATE TABLE sh2.tlt1(i int, j int); | ||
NOTICE: send query to shard(s) : sh1,sh2,sh3,sh4 | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(1, 12); | ||
NOTICE: send query to shard(s) : sh1 | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(1, 12); | ||
NOTICE: send query to shard(s) : sh1 | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(2, 13); | ||
NOTICE: send query to shard(s) : sh1 | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(2, 13); | ||
NOTICE: send query to shard(s) : sh1 | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(12, 12); | ||
NOTICE: send query to shard(s) : sh2 | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(12, 14); | ||
NOTICE: send query to shard(s) : sh2 | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(122, 124); | ||
NOTICE: send query to shard(s) : sh2 | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(112, 124); | ||
NOTICE: send query to shard(s) : sh2 | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(113, 125); | ||
NOTICE: send query to shard(s) : sh2 | ||
select (select sum(j) from sh2.tlt1 where i = 112); | ||
NOTICE: send query to shard(s) : sh2 | ||
sum | ||
----- | ||
124 | ||
(1 row) | ||
|
||
select (select sum(j) from sh2.tlt1 where i = 112), (select sum(j) from sh2.tlt1 where sh2.tlt1.i = 113); | ||
NOTICE: send query to shard(s) : sh2 | ||
sum | sum | ||
-----+----- | ||
124 | 125 | ||
(1 row) | ||
|
||
select coalesce((select sum(j) from sh2.tlt1 where i = 1), 0), coalesce((select sum(j) from sh2.tlt1 where i = 2 and j not in (select 12)), 0); | ||
NOTICE: send query to shard(s) : sh1 | ||
coalesce | coalesce | ||
----------+---------- | ||
24 | 26 | ||
(1 row) | ||
|
||
DROP SCHEMA sh2 CASCADE; | ||
NOTICE: send query to shard(s) : sh1,sh2,sh3,sh4 | ||
\c spqr-console | ||
|
||
SPQR 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 DISTRIBUTION ALL CASCADE; | ||
drop distribution | ||
------------------------ | ||
distribution id -> ds1 | ||
(1 row) | ||
|
||
DROP KEY RANGE ALL; | ||
drop key range | ||
---------------- | ||
(0 rows) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
\c spqr-console | ||
CREATE DISTRIBUTION ds1 COLUMN TYPES integer; | ||
CREATE KEY RANGE kridi1 from 0 route to sh1 FOR DISTRIBUTION ds1; | ||
CREATE KEY RANGE kridi2 from 11 route to sh2 FOR DISTRIBUTION ds1; | ||
ALTER DISTRIBUTION ds1 ATTACH RELATION tlt1 DISTRIBUTION KEY i; | ||
|
||
\c regress | ||
|
||
CREATE SCHEMA sh2; | ||
CREATE TABLE sh2.tlt1(i int, j int); | ||
|
||
INSERT INTO sh2.tlt1 (i, j) VALUES(1, 12); | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(1, 12); | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(2, 13); | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(2, 13); | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(12, 12); | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(12, 14); | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(122, 124); | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(112, 124); | ||
INSERT INTO sh2.tlt1 (i, j) VALUES(113, 125); | ||
|
||
select (select sum(j) from sh2.tlt1 where i = 112); | ||
select (select sum(j) from sh2.tlt1 where i = 112), (select sum(j) from sh2.tlt1 where sh2.tlt1.i = 113); | ||
select coalesce((select sum(j) from sh2.tlt1 where i = 1), 0), coalesce((select sum(j) from sh2.tlt1 where i = 2 and j not in (select 12)), 0); | ||
|
||
DROP SCHEMA sh2 CASCADE; | ||
|
||
\c spqr-console | ||
DROP DISTRIBUTION ALL CASCADE; | ||
DROP KEY RANGE ALL; | ||
|