mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 21:12:26 +01:00
Extend permutations tested in basic test, move edge cases to separate test, and add regression test for bug 1195735
This commit is contained in:
parent
1b4164c18a
commit
af6cbf055d
4 changed files with 1149 additions and 117 deletions
|
@ -1,19 +1,6 @@
|
|||
DROP TABLE IF EXISTS graph_base;
|
||||
DROP TABLE IF EXISTS graph;
|
||||
DROP TABLE IF EXISTS graph2;
|
||||
CREATE TABLE graph2 (
|
||||
latch VARCHAR(32) NULL,
|
||||
origid BIGINT UNSIGNED NULL,
|
||||
destid BIGINT UNSIGNED NULL,
|
||||
weight DOUBLE NULL,
|
||||
seq BIGINT UNSIGNED NULL,
|
||||
linkid BIGINT UNSIGNED NULL,
|
||||
KEY (latch, origid, destid) USING HASH,
|
||||
KEY (latch, destid, origid) USING HASH
|
||||
) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
|
||||
SELECT * FROM graph2 WHERE latch='dijkstras' AND origid=1 AND destid=6;
|
||||
ERROR 42S02: Table 'test.graph_base' doesn't exist
|
||||
DROP TABLE graph2;
|
||||
CREATE TABLE graph_base (
|
||||
from_id INT UNSIGNED NOT NULL,
|
||||
to_id INT UNSIGNED NOT NULL,
|
||||
|
@ -34,93 +21,681 @@ INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);
|
|||
INSERT INTO graph_base(from_id, to_id) VALUES (1,3), (3,1);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (3,4), (4,3);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (5,6), (6,5);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (5,7);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (9,9);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (10,11);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (11,12);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (12,10);
|
||||
# Breadth-first search tests
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 1 NULL 2 4 4
|
||||
breadth_first 1 NULL 1 3 3
|
||||
breadth_first 1 NULL 1 2 2
|
||||
breadth_first 1 NULL 0 1 1
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 2;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 2 NULL 3 4 4
|
||||
breadth_first 2 NULL 2 3 3
|
||||
breadth_first 2 NULL 1 2 1
|
||||
breadth_first 2 NULL 0 1 2
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 3;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 3 NULL 2 4 2
|
||||
breadth_first 3 NULL 1 3 4
|
||||
breadth_first 3 NULL 1 2 1
|
||||
breadth_first 3 NULL 0 1 3
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 4;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 4 NULL 3 4 2
|
||||
breadth_first 4 NULL 2 3 1
|
||||
breadth_first 4 NULL 1 2 3
|
||||
breadth_first 4 NULL 0 1 4
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 5;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 5 NULL 1 3 7
|
||||
breadth_first 5 NULL 1 2 6
|
||||
breadth_first 5 NULL 0 1 5
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 6;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 6 NULL 2 3 7
|
||||
breadth_first 6 NULL 1 2 5
|
||||
breadth_first 6 NULL 0 1 6
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 7;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 7 NULL 0 1 7
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 8 NULL 0 1 8
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 9;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 9 NULL 0 1 9
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 10;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 10 NULL 2 3 12
|
||||
breadth_first 10 NULL 1 2 11
|
||||
breadth_first 10 NULL 0 1 10
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 11;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 11 NULL 2 3 10
|
||||
breadth_first 11 NULL 1 2 12
|
||||
breadth_first 11 NULL 0 1 11
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 12;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 12 NULL 2 3 11
|
||||
breadth_first 12 NULL 1 2 10
|
||||
breadth_first 12 NULL 0 1 12
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 666;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 666 NULL 0 1 666
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 1 NULL 1 3 3
|
||||
breadth_first 1 NULL 1 2 2
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 2 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 2 NULL 1 2 1
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 3 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 3 NULL 1 3 4
|
||||
breadth_first 3 NULL 1 2 1
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 4 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 4 NULL 1 2 3
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 5 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 5 NULL 1 3 7
|
||||
breadth_first 5 NULL 1 2 6
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 6 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 6 NULL 1 2 5
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 7 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 9 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 10 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 10 NULL 1 2 11
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 11 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 11 NULL 1 2 12
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 12 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 12 NULL 1 2 10
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND weight = 1;
|
||||
count(*)
|
||||
2
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 2 AND weight = 1;
|
||||
count(*)
|
||||
1
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 3 AND weight = 1;
|
||||
count(*)
|
||||
2
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 4 AND weight = 1;
|
||||
count(*)
|
||||
1
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 5 AND weight = 1;
|
||||
count(*)
|
||||
2
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 6 AND weight = 1;
|
||||
count(*)
|
||||
1
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 7 AND weight = 1;
|
||||
count(*)
|
||||
0
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 8 AND weight = 1;
|
||||
count(*)
|
||||
0
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 9 AND weight = 1;
|
||||
count(*)
|
||||
0
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 10 AND weight = 1;
|
||||
count(*)
|
||||
1
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 11 AND weight = 1;
|
||||
count(*)
|
||||
1
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 12 AND weight = 1;
|
||||
count(*)
|
||||
1
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 1 NULL 2 4 4
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 2 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 2 NULL 2 3 3
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 3 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 3 NULL 2 4 2
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 4 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 4 NULL 2 3 1
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 5 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 6 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 6 NULL 2 3 7
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 7 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 9 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 10 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 10 NULL 2 3 12
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 11 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 11 NULL 2 3 10
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 12 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 12 NULL 2 3 11
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 2 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 2 NULL 3 4 4
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 3 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 4 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 4 NULL 3 4 2
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 5 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 6 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 7 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 9 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 10 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 11 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 12 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 1 NULL 2 4 4
|
||||
breadth_first 1 NULL 1 3 3
|
||||
breadth_first 1 NULL 1 2 2
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 2 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 2 NULL 2 3 3
|
||||
breadth_first 2 NULL 1 2 1
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 3 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 3 NULL 2 4 2
|
||||
breadth_first 3 NULL 1 3 4
|
||||
breadth_first 3 NULL 1 2 1
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 4 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 4 NULL 2 3 1
|
||||
breadth_first 4 NULL 1 2 3
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 5 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 5 NULL 1 3 7
|
||||
breadth_first 5 NULL 1 2 6
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 6 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 6 NULL 2 3 7
|
||||
breadth_first 6 NULL 1 2 5
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 7 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 9 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 10 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 10 NULL 2 3 12
|
||||
breadth_first 10 NULL 1 2 11
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 11 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 11 NULL 2 3 10
|
||||
breadth_first 11 NULL 1 2 12
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 12 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 12 NULL 2 3 11
|
||||
breadth_first 12 NULL 1 2 10
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = NULL;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first';
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 1;
|
||||
latch origid destid weight seq linkid
|
||||
2 1 NULL 2 4 4
|
||||
2 1 NULL 1 3 3
|
||||
2 1 NULL 1 2 2
|
||||
2 1 NULL 0 1 1
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 2;
|
||||
latch origid destid weight seq linkid
|
||||
2 2 NULL 3 4 4
|
||||
2 2 NULL 2 3 3
|
||||
2 2 NULL 1 2 1
|
||||
2 2 NULL 0 1 2
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 3;
|
||||
latch origid destid weight seq linkid
|
||||
2 3 NULL 2 4 2
|
||||
2 3 NULL 1 3 4
|
||||
2 3 NULL 1 2 1
|
||||
2 3 NULL 0 1 3
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 4;
|
||||
latch origid destid weight seq linkid
|
||||
2 4 NULL 3 4 2
|
||||
2 4 NULL 2 3 1
|
||||
2 4 NULL 1 2 3
|
||||
2 4 NULL 0 1 4
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 5;
|
||||
latch origid destid weight seq linkid
|
||||
2 5 NULL 1 3 7
|
||||
2 5 NULL 1 2 6
|
||||
2 5 NULL 0 1 5
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 6;
|
||||
latch origid destid weight seq linkid
|
||||
2 6 NULL 2 3 7
|
||||
2 6 NULL 1 2 5
|
||||
2 6 NULL 0 1 6
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 7;
|
||||
latch origid destid weight seq linkid
|
||||
2 7 NULL 0 1 7
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 8;
|
||||
latch origid destid weight seq linkid
|
||||
2 8 NULL 0 1 8
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 9;
|
||||
latch origid destid weight seq linkid
|
||||
2 9 NULL 0 1 9
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 10;
|
||||
latch origid destid weight seq linkid
|
||||
2 10 NULL 2 3 12
|
||||
2 10 NULL 1 2 11
|
||||
2 10 NULL 0 1 10
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 11;
|
||||
latch origid destid weight seq linkid
|
||||
2 11 NULL 2 3 10
|
||||
2 11 NULL 1 2 12
|
||||
2 11 NULL 0 1 11
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 12;
|
||||
latch origid destid weight seq linkid
|
||||
2 12 NULL 2 3 11
|
||||
2 12 NULL 1 2 10
|
||||
2 12 NULL 0 1 12
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 666;
|
||||
latch origid destid weight seq linkid
|
||||
2 666 NULL 0 1 666
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 1 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
2 1 NULL 1 3 3
|
||||
2 1 NULL 1 2 2
|
||||
# Expect no result, because of autocast and deprecated syntax
|
||||
SELECT * FROM graph WHERE latch = 2 AND origid = 1 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 2 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
# Expect no result between 1,6 because no connection exists
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6;
|
||||
2 2 NULL 1 2 1
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 3 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=6;
|
||||
2 3 NULL 1 3 4
|
||||
2 3 NULL 1 2 1
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 4 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
# Expect result between 4,1 because connection exists via 3
|
||||
2 4 NULL 1 2 3
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 5 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
2 5 NULL 1 3 7
|
||||
2 5 NULL 1 2 6
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 6 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
2 6 NULL 1 2 5
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 7 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 8 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 9 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 10 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
2 10 NULL 1 2 11
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 11 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
2 11 NULL 1 2 12
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 12 AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
2 12 NULL 1 2 10
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 1 AND weight = 1;
|
||||
count(*)
|
||||
2
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 2 AND weight = 1;
|
||||
count(*)
|
||||
1
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 3 AND weight = 1;
|
||||
count(*)
|
||||
2
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 4 AND weight = 1;
|
||||
count(*)
|
||||
1
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 5 AND weight = 1;
|
||||
count(*)
|
||||
2
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 6 AND weight = 1;
|
||||
count(*)
|
||||
1
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 7 AND weight = 1;
|
||||
count(*)
|
||||
0
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 8 AND weight = 1;
|
||||
count(*)
|
||||
0
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 9 AND weight = 1;
|
||||
count(*)
|
||||
0
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 10 AND weight = 1;
|
||||
count(*)
|
||||
1
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 11 AND weight = 1;
|
||||
count(*)
|
||||
1
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 12 AND weight = 1;
|
||||
count(*)
|
||||
1
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 1 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
2 1 NULL 2 4 4
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 2 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
2 2 NULL 2 3 3
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 3 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
2 3 NULL 2 4 2
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 4 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
2 4 NULL 2 3 1
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 5 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 6 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
2 6 NULL 2 3 7
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 7 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 8 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 9 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 10 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
2 10 NULL 2 3 12
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 11 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
2 11 NULL 2 3 10
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 12 AND weight = 2;
|
||||
latch origid destid weight seq linkid
|
||||
2 12 NULL 2 3 11
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 1 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 2 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
2 2 NULL 3 4 4
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 3 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 4 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
2 4 NULL 3 4 2
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 5 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 6 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 7 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 8 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 9 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 10 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 11 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 12 AND weight = 3;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 1 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
2 1 NULL 2 4 4
|
||||
2 1 NULL 1 3 3
|
||||
2 1 NULL 1 2 2
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 2 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
2 2 NULL 2 3 3
|
||||
2 2 NULL 1 2 1
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 3 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
2 3 NULL 2 4 2
|
||||
2 3 NULL 1 3 4
|
||||
2 3 NULL 1 2 1
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 4 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
2 4 NULL 2 3 1
|
||||
2 4 NULL 1 2 3
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 5 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
2 5 NULL 1 3 7
|
||||
2 5 NULL 1 2 6
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 6 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
2 6 NULL 2 3 7
|
||||
2 6 NULL 1 2 5
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 7 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 8 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 9 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 10 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
2 10 NULL 2 3 12
|
||||
2 10 NULL 1 2 11
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 11 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
2 11 NULL 2 3 10
|
||||
2 11 NULL 1 2 12
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 12 AND (weight = 1 or weight = 2);
|
||||
latch origid destid weight seq linkid
|
||||
2 12 NULL 2 3 11
|
||||
2 12 NULL 1 2 10
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = NULL;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND destid = 1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2' AND weight = 1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = '2';
|
||||
latch origid destid weight seq linkid
|
||||
# Dijkstras algorithm tests
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=1;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 1 1 NULL 0 1
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=2;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 1 2 NULL 0 1
|
||||
dijkstras 1 2 1 1 2
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=2 AND destid=1;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 2 1 NULL 0 2
|
||||
dijkstras 2 1 1 1 1
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=4;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 1 4 NULL 0 1
|
||||
dijkstras 1 4 1 1 3
|
||||
dijkstras 1 4 1 2 4
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=4;
|
||||
latch origid destid weight seq linkid
|
||||
1 1 4 NULL 0 1
|
||||
1 1 4 1 1 3
|
||||
1 1 4 1 2 4
|
||||
# and the reverse direction
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=4 AND destid=1;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 4 1 NULL 0 4
|
||||
dijkstras 4 1 1 1 3
|
||||
dijkstras 4 1 1 2 1
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=5;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=666;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=5 AND destid=7;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 5 7 NULL 0 5
|
||||
dijkstras 5 7 1 1 7
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=7 AND destid=5;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10 AND destid=11;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 10 11 NULL 0 10
|
||||
dijkstras 10 11 1 1 11
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10 AND destid=12;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 10 12 NULL 0 10
|
||||
dijkstras 10 12 1 1 11
|
||||
dijkstras 10 12 1 2 12
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=11 AND destid=10;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 11 10 NULL 0 11
|
||||
dijkstras 11 10 1 1 12
|
||||
dijkstras 11 10 1 2 10
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=11 AND destid=12;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 11 12 NULL 0 11
|
||||
dijkstras 11 12 1 1 12
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=12 AND destid=10;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 12 10 NULL 0 12
|
||||
dijkstras 12 10 1 1 10
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=12 AND destid=11;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 12 11 NULL 0 12
|
||||
dijkstras 12 11 1 1 10
|
||||
dijkstras 12 11 1 2 11
|
||||
# legacy string number
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=1;
|
||||
latch origid destid weight seq linkid
|
||||
1 1 1 NULL 0 1
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=2;
|
||||
latch origid destid weight seq linkid
|
||||
1 1 2 NULL 0 1
|
||||
1 1 2 1 1 2
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=2 AND destid=1;
|
||||
latch origid destid weight seq linkid
|
||||
1 2 1 NULL 0 2
|
||||
1 2 1 1 1 1
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=4;
|
||||
latch origid destid weight seq linkid
|
||||
1 1 4 NULL 0 1
|
||||
1 1 4 1 1 3
|
||||
1 1 4 1 2 4
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=4 AND destid=1;
|
||||
latch origid destid weight seq linkid
|
||||
1 4 1 NULL 0 4
|
||||
1 4 1 1 1 3
|
||||
1 4 1 1 2 1
|
||||
SELECT * FROM graph WHERE latch='no_search' and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=5;
|
||||
latch origid destid weight seq linkid
|
||||
no_search 1 2 1 3 1
|
||||
no_search 1 2 1 2 3
|
||||
no_search 1 2 1 1 2
|
||||
SELECT * FROM graph WHERE latch='0' and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=666;
|
||||
latch origid destid weight seq linkid
|
||||
0 1 2 1 3 1
|
||||
0 1 2 1 2 3
|
||||
0 1 2 1 1 2
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first';
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=5 AND destid=7;
|
||||
latch origid destid weight seq linkid
|
||||
# Expect no result, because of invalid latch
|
||||
SELECT * FROM graph WHERE latch='bogus';
|
||||
1 5 7 NULL 0 5
|
||||
1 5 7 1 1 7
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=7 AND destid=5;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch=666;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=10 AND destid=11;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch='bogus' and destid=2 and origid=1;
|
||||
1 10 11 NULL 0 10
|
||||
1 10 11 1 1 11
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=10 AND destid=12;
|
||||
latch origid destid weight seq linkid
|
||||
Warnings:
|
||||
Warning 1210 Incorrect arguments to OQGRAPH latch
|
||||
# Make sure we dont crash if someone passed in a UTF string
|
||||
SELECT * FROM graph WHERE latch='Ohms Ω Tennis Ball 〄';
|
||||
1 10 12 NULL 0 10
|
||||
1 10 12 1 1 11
|
||||
1 10 12 1 2 12
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=11 AND destid=10;
|
||||
latch origid destid weight seq linkid
|
||||
# Expect no result, because of autocast and deprecated syntax
|
||||
SELECT * FROM graph WHERE latch=0 and destid=2 and origid=1;
|
||||
1 11 10 NULL 0 11
|
||||
1 11 10 1 1 12
|
||||
1 11 10 1 2 10
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=11 AND destid=12;
|
||||
latch origid destid weight seq linkid
|
||||
# Expect no result, because of NULL latch
|
||||
SELECT * FROM graph WHERE latch=NULL and destid=2 and origid=1;
|
||||
1 11 12 NULL 0 11
|
||||
1 11 12 1 1 12
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=12 AND destid=10;
|
||||
latch origid destid weight seq linkid
|
||||
# With no latch, original data, filtered by destid, etc if present
|
||||
SELECT * FROM graph;
|
||||
1 12 10 NULL 0 12
|
||||
1 12 10 1 1 10
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=12 AND destid=11;
|
||||
latch origid destid weight seq linkid
|
||||
NULL 1 2 1 NULL NULL
|
||||
NULL 2 1 1 NULL NULL
|
||||
NULL 1 3 1 NULL NULL
|
||||
NULL 3 1 1 NULL NULL
|
||||
NULL 3 4 1 NULL NULL
|
||||
NULL 4 3 1 NULL NULL
|
||||
NULL 5 6 1 NULL NULL
|
||||
NULL 6 5 1 NULL NULL
|
||||
SELECT * FROM graph WHERE destid=2 and origid=1;
|
||||
1 12 11 NULL 0 12
|
||||
1 12 11 1 1 10
|
||||
1 12 11 1 2 11
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (11,13);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (10,14);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (14,13);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10 AND destid=13;
|
||||
latch origid destid weight seq linkid
|
||||
NULL 1 2 1 NULL NULL
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND (weight = 1 OR weight = 2);
|
||||
dijkstras 10 13 NULL 0 10
|
||||
dijkstras 10 13 1 1 11
|
||||
dijkstras 10 13 1 2 13
|
||||
DELETE FROM graph_base where from_id=10 and to_id=11;
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (10,15);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (15,13);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10 AND destid=13;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 10 13 NULL 0 10
|
||||
dijkstras 10 13 1 1 14
|
||||
dijkstras 10 13 1 2 13
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (10,11);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10 AND destid=13;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 10 13 NULL 0 10
|
||||
dijkstras 10 13 1 1 11
|
||||
dijkstras 10 13 1 2 13
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 1 NULL 0 4 4
|
||||
dijkstras 1 NULL 0 3 3
|
||||
dijkstras 1 NULL 0 2 2
|
||||
dijkstras 1 NULL 0 1 1
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (21,22);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=21;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 21 NULL 0 2 22
|
||||
dijkstras 21 NULL 0 1 21
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=22;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 22 NULL 0 1 22
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (4,17);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 1 NULL 0 5 17
|
||||
dijkstras 1 NULL 0 4 4
|
||||
dijkstras 1 NULL 0 3 3
|
||||
dijkstras 1 NULL 0 2 2
|
||||
dijkstras 1 NULL 0 1 1
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (4,16);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 1 NULL 0 6 17
|
||||
dijkstras 1 NULL 0 5 16
|
||||
dijkstras 1 NULL 0 4 4
|
||||
dijkstras 1 NULL 0 3 3
|
||||
dijkstras 1 NULL 0 2 2
|
||||
dijkstras 1 NULL 0 1 1
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (17,18);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 1 NULL 0 7 18
|
||||
dijkstras 1 NULL 0 6 17
|
||||
dijkstras 1 NULL 0 5 16
|
||||
dijkstras 1 NULL 0 4 4
|
||||
dijkstras 1 NULL 0 3 3
|
||||
dijkstras 1 NULL 0 2 2
|
||||
dijkstras 1 NULL 0 1 1
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND destid=1;
|
||||
latch origid destid weight seq linkid
|
||||
breadth_first 1 NULL 2 4 4
|
||||
breadth_first 1 NULL 1 3 3
|
||||
breadth_first 1 NULL 1 2 2
|
||||
# Now we add a connection from 4->6
|
||||
INSERT INTO graph_base (from_id,to_id) VALUES (4,6);
|
||||
# And delete all references to node 5
|
||||
|
@ -133,13 +708,19 @@ dijkstras 1 6 NULL 0 1
|
|||
dijkstras 1 6 1 1 3
|
||||
dijkstras 1 6 1 2 4
|
||||
dijkstras 1 6 1 3 6
|
||||
# but not 6>4>3>1
|
||||
# but not 6>4>3>1 (so no result)
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=6 AND destid=1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=6;
|
||||
latch origid destid weight seq linkid
|
||||
1 1 6 NULL 0 1
|
||||
1 1 6 1 1 3
|
||||
1 1 6 1 2 4
|
||||
1 1 6 1 3 6
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=6 AND destid=1;
|
||||
latch origid destid weight seq linkid
|
||||
DELETE FROM graph_base;
|
||||
FLUSH TABLES;
|
||||
TRUNCATE TABLE graph_base;
|
||||
DROP TABLE graph_base;
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6;
|
||||
ERROR 42S02: Table 'test.graph_base' doesn't exist
|
||||
DROP TABLE graph;
|
||||
|
|
|
@ -4,21 +4,6 @@ DROP TABLE IF EXISTS graph;
|
|||
DROP TABLE IF EXISTS graph2;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE graph2 (
|
||||
latch VARCHAR(32) NULL,
|
||||
origid BIGINT UNSIGNED NULL,
|
||||
destid BIGINT UNSIGNED NULL,
|
||||
weight DOUBLE NULL,
|
||||
seq BIGINT UNSIGNED NULL,
|
||||
linkid BIGINT UNSIGNED NULL,
|
||||
KEY (latch, origid, destid) USING HASH,
|
||||
KEY (latch, destid, origid) USING HASH
|
||||
) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
|
||||
# Because the backing store graph_base doesnt exist yet, the select should fail
|
||||
--error S42S02
|
||||
SELECT * FROM graph2 WHERE latch='dijkstras' AND origid=1 AND destid=6;
|
||||
DROP TABLE graph2;
|
||||
|
||||
# Create the backing store
|
||||
CREATE TABLE graph_base (
|
||||
from_id INT UNSIGNED NOT NULL,
|
||||
|
@ -39,55 +24,318 @@ CREATE TABLE graph (
|
|||
KEY (latch, destid, origid) USING HASH
|
||||
) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
|
||||
|
||||
#--
|
||||
#-- ASCII art graph of this test data
|
||||
#-- +-->(2)
|
||||
#-- ( )<---+
|
||||
#-- (1)
|
||||
#-- ( )<---+
|
||||
#-- +-->(3)<------->(4)
|
||||
#--
|
||||
#-- (7)<----------(5)<--------->(6) (9)
|
||||
#--
|
||||
#-- +--->(11)
|
||||
#-- | |
|
||||
#-- (10) |
|
||||
#-- ^ v
|
||||
#-- +----(12)
|
||||
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (1,3), (3,1);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (3,4), (4,3);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (5,6), (6,5);
|
||||
|
||||
#-- extra unidirected node
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (5,7);
|
||||
|
||||
#-- isolated node with no loop - disallowed
|
||||
#-- so origid 8 below should return an empty rowset
|
||||
#-- INSERT INTO graph_base(from_id, to_id) VALUES (8,NULL);
|
||||
|
||||
#-- isolated node with a (undirected) loop
|
||||
#-- we have no way of representing a directed loop on an isolated node, is this valid in pure graph theory?
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (9,9);
|
||||
|
||||
#-- directed _cyclic_ graph triangle?
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (10,11);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (11,12);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (12,10);
|
||||
|
||||
--echo # Breadth-first search tests
|
||||
#-- We are asking "Is there a path from node 'origid' to (all) other nodes?"
|
||||
#-- We return a row for each other node that is reachable, with its id in 'linkid'
|
||||
#-- and the weight calculated as "How many _directed_ hops to get there"
|
||||
#-- If there is no path from origid to another node then there is no row for that linkid
|
||||
#-- We include 'origid' in the set of reachable nodes i.e. as a 'loop', with weight 0
|
||||
#-- 'seq' is the counted distance of the search, thus, the loop link will always have seq 1
|
||||
#-- if there are two reachable neighbours, they will have seq 2,3 and so on
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 2;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 3;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 4;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 5;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 6;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 7;
|
||||
#-- FIXME This is returning one result set, suspect this is a bug...?
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 9;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 10;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 11;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 12;
|
||||
#-- FIXME This is returning one result set, suspect this is a bug...?
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 666;
|
||||
#-- The above results can then be filtered by weight, so the results should be a subset for the corresponding origid above
|
||||
#-- so effectively, `AND weight=1` returns the neighbours of origid in linkid
|
||||
#<----- orig test harness - still returns (breadth_first 1 NULL 1 3 3), (breadth_first 1 NULL 1 2 2)
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND weight = 1;
|
||||
# The next works, we allow stringized latch integer to ease migration
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 1 AND weight = 1;
|
||||
# Expect the next to return no results, due to autocast and use of deprecated syntax...
|
||||
--echo # Expect no result, because of autocast and deprecated syntax
|
||||
SELECT * FROM graph WHERE latch = 2 AND origid = 1 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 2 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 3 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 4 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 5 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 6 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 7 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 9 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 10 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 11 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 12 AND weight = 1;
|
||||
#-- so effectively, `count(... AND weight=1)` returns the number of _reachable_ immediate neighbours
|
||||
#-- included because it allows human to quickly eyeball against the visual ASCII graph for correctness...
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 2 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 3 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 4 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 5 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 6 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 7 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 8 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 9 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 10 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 11 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = 'breadth_first' AND origid = 12 AND weight = 1;
|
||||
#-- so effectively, `AND weight=2` returns the second-level neighbours of origid in linkid
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 2 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 3 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 4 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 5 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 6 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 7 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 9 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 10 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 11 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 12 AND weight = 2;
|
||||
|
||||
--echo # Expect no result between 1,6 because no connection exists
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=6;
|
||||
--echo # Expect result between 4,1 because connection exists via 3
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=4;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=4;
|
||||
--echo # and the reverse direction
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=4 AND destid=1;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=4 AND destid=1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 2 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 3 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 4 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 5 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 6 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 7 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 9 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 10 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 11 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 12 AND weight = 3;
|
||||
|
||||
SELECT * FROM graph WHERE latch='no_search' and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch='0' and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 2 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 3 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 4 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 5 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 6 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 7 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 9 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 10 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 11 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 12 AND (weight = 1 or weight = 2);
|
||||
|
||||
#--breadth first with no orig id etc
|
||||
#-- These return empty sets - origid must be specified and non null to get a result set
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = NULL;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first';
|
||||
|
||||
--echo # Expect no result, because of invalid latch
|
||||
SELECT * FROM graph WHERE latch='bogus';
|
||||
SELECT * FROM graph WHERE latch=666;
|
||||
SELECT * FROM graph WHERE latch='bogus' and destid=2 and origid=1;
|
||||
#-- Repeat the above with legacy string
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 3;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 4;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 5;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 6;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 7;
|
||||
#-- FIXME This is returning one result set, suspect this is a bug...?
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 8;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 9;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 10;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 11;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 12;
|
||||
#-- FIXME This is returning one result set, suspect this is a bug...?
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 666;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 1 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 2 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 3 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 4 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 5 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 6 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 7 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 8 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 9 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 10 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 11 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 12 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 1 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 2 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 3 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 4 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 5 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 6 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 7 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 8 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 9 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 10 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 11 AND weight = 1;
|
||||
SELECT count(*) FROM graph WHERE latch = '2' AND origid = 12 AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 1 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 2 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 3 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 4 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 5 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 6 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 7 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 8 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 9 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 10 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 11 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 12 AND weight = 2;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 1 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 2 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 3 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 4 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 5 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 6 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 7 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 8 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 9 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 10 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 11 AND weight = 3;
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 12 AND weight = 3;
|
||||
|
||||
--echo # Make sure we dont crash if someone passed in a UTF string
|
||||
SELECT * FROM graph WHERE latch='Ohms Ω Tennis Ball 〄';
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 1 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 2 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 3 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 4 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 5 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 6 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 7 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 8 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 9 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 10 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 11 AND (weight = 1 or weight = 2);
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = 12 AND (weight = 1 or weight = 2);
|
||||
|
||||
#-- These return empty sets - origid must be specified and non null to get a result set
|
||||
SELECT * FROM graph WHERE latch = '2' AND origid = NULL;
|
||||
SELECT * FROM graph WHERE latch = '2' AND destid = 1;
|
||||
SELECT * FROM graph WHERE latch = '2' AND weight = 1;
|
||||
SELECT * FROM graph WHERE latch = '2';
|
||||
|
||||
|
||||
--echo # Expect no result, because of autocast and deprecated syntax
|
||||
SELECT * FROM graph WHERE latch=0 and destid=2 and origid=1;
|
||||
--echo # Dijkstras algorithm tests
|
||||
#-- We ask 'What is the path (if any) between 'origid' and 'destid'
|
||||
#-- This returns the number of directed hops +1 (for the starting node)
|
||||
#-- 'weight' is NULL for the starting point, or 1
|
||||
#-- 'linkid' is the way point id
|
||||
#-- 'seq' is the distance of the waypoint from the start (counting from zero)
|
||||
#-- the default order returned is waypoints out from the start
|
||||
#-- zero hop (1 row)
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=1;
|
||||
#-- one hop
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=2;
|
||||
#-- one hop in reverse
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=2 AND destid=1;
|
||||
#-- two hops (via 3)
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=4;
|
||||
#-- two hops in reverse direction
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=4 AND destid=1;
|
||||
#-- no result (no connection)
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=5;
|
||||
#-- no result (no destination exists)
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=666;
|
||||
|
||||
--echo # Expect no result, because of NULL latch
|
||||
SELECT * FROM graph WHERE latch=NULL and destid=2 and origid=1;
|
||||
#-- one hop on a unidirected link
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=5 AND destid=7;
|
||||
#-- zero hop in reverse direction on a unidirected link
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=7 AND destid=5;
|
||||
|
||||
--echo # With no latch, original data, filtered by destid, etc if present
|
||||
SELECT * FROM graph;
|
||||
SELECT * FROM graph WHERE destid=2 and origid=1;
|
||||
#-- Trickery - what about the cyclic loop?
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10 AND destid=11;
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10 AND destid=12;
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=11 AND destid=10;
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=11 AND destid=12;
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=12 AND destid=10;
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=12 AND destid=11;
|
||||
|
||||
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND (weight = 1 OR weight = 2);
|
||||
--echo # legacy string number
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=1;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=2;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=2 AND destid=1;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=4;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=4 AND destid=1;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=5;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=666;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=5 AND destid=7;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=7 AND destid=5;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=10 AND destid=11;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=10 AND destid=12;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=11 AND destid=10;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=11 AND destid=12;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=12 AND destid=10;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=12 AND destid=11;
|
||||
|
||||
#-- What if we add two equally valid two-hop paths?
|
||||
#--
|
||||
#--
|
||||
#-- +--->(14)----------+
|
||||
#-- | v
|
||||
#-- | +--->(11)---->(13)
|
||||
#-- | | |
|
||||
#-- +-(10) |
|
||||
#-- ^ v
|
||||
#-- +----(12)
|
||||
#--
|
||||
#-- We note it chooses 10,11,13 but will it always?
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (11,13);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (10,14);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (14,13);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10 AND destid=13;
|
||||
DELETE FROM graph_base where from_id=10 and to_id=11;
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (10,15);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (15,13);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10 AND destid=13;
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (10,11);
|
||||
#-- We note is _appears_ to use the lowered valued node id if there are two equal paths
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10 AND destid=13;
|
||||
|
||||
#-- Unspecified arguments:
|
||||
#-- If destid unspecified, it returns all possible destinations
|
||||
#-- Destinations further away are returned first
|
||||
#-- Note also, weight==0 (as opposed to 1 or NULL in all other cases)
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (21,22);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=21;
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=22;
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (4,17);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (4,16);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (17,18);
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
|
||||
#-- If origid unspecified, it returns no result - i.e. origid is mandatory
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND destid=1;
|
||||
|
||||
--echo # Now we add a connection from 4->6
|
||||
INSERT INTO graph_base (from_id,to_id) VALUES (4,6);
|
||||
|
@ -98,18 +346,17 @@ DELETE FROM graph_base WHERE from_id=3 AND to_id=5;
|
|||
|
||||
--echo # which means there is a path in one direction only 1>3>4>6
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6;
|
||||
--echo # but not 6>4>3>1
|
||||
--echo # but not 6>4>3>1 (so no result)
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=6 AND destid=1;
|
||||
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=6;
|
||||
SELECT * FROM graph WHERE latch='1' AND origid=6 AND destid=1;
|
||||
|
||||
|
||||
DELETE FROM graph_base;
|
||||
FLUSH TABLES;
|
||||
TRUNCATE TABLE graph_base;
|
||||
|
||||
DROP TABLE graph_base;
|
||||
|
||||
# Expect error if we pull the table out from under
|
||||
--error S42S02
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6;
|
||||
|
||||
DROP TABLE graph;
|
||||
|
||||
|
|
160
mysql-test/suite/oqgraph/boundary_conditions.test
Normal file
160
mysql-test/suite/oqgraph/boundary_conditions.test
Normal file
|
@ -0,0 +1,160 @@
|
|||
--disable_warnings
|
||||
DROP TABLE IF EXISTS graph_base;
|
||||
DROP TABLE IF EXISTS graph;
|
||||
DROP TABLE IF EXISTS graph2;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE graph2 (
|
||||
latch VARCHAR(32) NULL,
|
||||
origid BIGINT UNSIGNED NULL,
|
||||
destid BIGINT UNSIGNED NULL,
|
||||
weight DOUBLE NULL,
|
||||
seq BIGINT UNSIGNED NULL,
|
||||
linkid BIGINT UNSIGNED NULL,
|
||||
KEY (latch, origid, destid) USING HASH,
|
||||
KEY (latch, destid, origid) USING HASH
|
||||
) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
|
||||
# Because the backing store graph_base doesnt exist yet, the select should fail
|
||||
--error S42S02
|
||||
SELECT * FROM graph2 WHERE latch='dijkstras' AND origid=1 AND destid=6;
|
||||
DROP TABLE graph2;
|
||||
|
||||
# Create the backing store
|
||||
CREATE TABLE graph_base (
|
||||
from_id INT UNSIGNED NOT NULL,
|
||||
to_id INT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (from_id,to_id),
|
||||
INDEX (to_id)
|
||||
) ENGINE=MyISAM;
|
||||
|
||||
|
||||
CREATE TABLE graph (
|
||||
latch VARCHAR(32) NULL,
|
||||
origid BIGINT UNSIGNED NULL,
|
||||
destid BIGINT UNSIGNED NULL,
|
||||
weight DOUBLE NULL,
|
||||
seq BIGINT UNSIGNED NULL,
|
||||
linkid BIGINT UNSIGNED NULL,
|
||||
KEY (latch, origid, destid) USING HASH,
|
||||
KEY (latch, destid, origid) USING HASH
|
||||
) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
|
||||
|
||||
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (1,3), (3,1);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (3,4), (4,3);
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (5,6), (6,5);
|
||||
|
||||
--echo # No Search/0 - result should return same rows as inserted for origid,destid,weight
|
||||
--echo # FIXME - THIS CODE IS CURRENTLY BROKEN
|
||||
SELECT * FROM graph WHERE latch='no_search';
|
||||
SELECT * FROM graph WHERE latch='no_search' and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch='no_search' and origid=1;
|
||||
SELECT * FROM graph WHERE latch='no_search' and destid=1;
|
||||
SELECT * FROM graph WHERE latch='no_search' and origid=666;
|
||||
SELECT * FROM graph WHERE latch='no_search' and origid=NULL;
|
||||
SELECT * FROM graph WHERE latch='0' ;
|
||||
SELECT * FROM graph WHERE latch='0' and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch='0' and origid=1;
|
||||
SELECT * FROM graph WHERE latch='0' and destid=1;
|
||||
SELECT * FROM graph WHERE latch='0' and origid=666;
|
||||
SELECT * FROM graph WHERE latch='0' and origid=NULL;
|
||||
|
||||
--echo # Expect no result, because of autocast
|
||||
SELECT * FROM graph WHERE latch=1 ;
|
||||
SELECT * FROM graph WHERE latch=1 and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch=1 and origid=1;
|
||||
SELECT * FROM graph WHERE latch=1 and destid=1;
|
||||
SELECT * FROM graph WHERE latch=1 and origid=666;
|
||||
SELECT * FROM graph WHERE latch=1 and origid=NULL;
|
||||
SELECT * FROM graph WHERE latch=2 ;
|
||||
SELECT * FROM graph WHERE latch=2 and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch=2 and destid=1;
|
||||
SELECT * FROM graph WHERE latch=2 and origid=666;
|
||||
SELECT * FROM graph WHERE latch=2 and origid=NULL;
|
||||
|
||||
--echo # Should this return an error? it seems we treat it as just another bogus latch
|
||||
SELECT * FROM graph WHERE latch='ThisExceeds32Characters456789012';
|
||||
--echo # Expect no result, because of invalid latch
|
||||
SELECT * FROM graph WHERE latch='bogus';
|
||||
SELECT * FROM graph WHERE latch='bogus' and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch='bogus' and origid=1;
|
||||
SELECT * FROM graph WHERE latch='bogus' and destid=1;
|
||||
SELECT * FROM graph WHERE latch='bogus' and origid=666;
|
||||
SELECT * FROM graph WHERE latch='bogus' and origid=NULL;
|
||||
#-- Note the next line couter-intuitively produces no warning
|
||||
SELECT * FROM graph WHERE latch='666';
|
||||
SELECT * FROM graph WHERE latch='666' and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch='666' and origid=1;
|
||||
SELECT * FROM graph WHERE latch='666' and destid=1;
|
||||
SELECT * FROM graph WHERE latch='666' and origid=666;
|
||||
#-- Note the next line couter-intuitively produces no warning
|
||||
SELECT * FROM graph WHERE latch='666' and origid=NULL;
|
||||
SELECT * FROM graph WHERE latch='-1';
|
||||
SELECT * FROM graph WHERE latch='-1' and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch='-1' and origid=1;
|
||||
SELECT * FROM graph WHERE latch='-1' and destid=1;
|
||||
SELECT * FROM graph WHERE latch='-1' and origid=666;
|
||||
SELECT * FROM graph WHERE latch='-1' and origid=NULL;
|
||||
|
||||
--echo # Make sure we dont crash if someone passed in a UTF string
|
||||
#-- Note the next line couter-intuitively produces no warning
|
||||
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄';
|
||||
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=1;
|
||||
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and destid=1;
|
||||
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=666;
|
||||
#-- Note the next line couter-intuitively produces no warning
|
||||
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=NULL;
|
||||
|
||||
--echo # Expect no result, because of autocast and deprecated syntax
|
||||
--echo # Allows 0 and NULL to have same effect
|
||||
#-- Note the next line couter-intuitively produces no warning
|
||||
SELECT * FROM graph WHERE latch=0;
|
||||
SELECT * FROM graph WHERE latch=0 and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch=0 and origid=1;
|
||||
SELECT * FROM graph WHERE latch=0 and destid=1;
|
||||
SELECT * FROM graph WHERE latch=0 and origid=666;
|
||||
#-- Note the next line couter-intuitively produces no warning
|
||||
SELECT * FROM graph WHERE latch=0 and origid=NULL;
|
||||
|
||||
--echo # Expect no result, because of NULL latch
|
||||
SELECT * FROM graph WHERE latch=NULL;
|
||||
SELECT * FROM graph WHERE latch=NULL and destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE latch=NULL and origid=1;
|
||||
SELECT * FROM graph WHERE latch=NULL and destid=1;
|
||||
SELECT * FROM graph WHERE latch=NULL and origid=666;
|
||||
SELECT * FROM graph WHERE latch=NULL and origid=NULL;
|
||||
|
||||
--echo # With no latch, original data in origid and destid columns
|
||||
#-- Note, weight==1 in this case
|
||||
SELECT * FROM graph;
|
||||
SELECT * FROM graph WHERE destid=2 and origid=1;
|
||||
SELECT * FROM graph WHERE origid=1;
|
||||
SELECT * FROM graph WHERE destid=1;
|
||||
SELECT * FROM graph WHERE origid=666;
|
||||
SELECT * FROM graph WHERE origid=NULL;
|
||||
|
||||
#-- what happens if we have two links the same?
|
||||
--error 1062
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (1,2);
|
||||
|
||||
DELETE FROM graph_base;
|
||||
#-- Uncomment the following after fixing https://bugs.launchpad.net/oqgraph/+bug/1195735
|
||||
#-- FIXME SELECT * FROM graph;
|
||||
|
||||
FLUSH TABLES;
|
||||
|
||||
TRUNCATE TABLE graph_base;
|
||||
#-- Uncomment the following after fixing https://bugs.launchpad.net/oqgraph/+bug/xxxxxxx - Causes the later select to not fail!
|
||||
#-- FIXME SELECT * FROM graph;
|
||||
|
||||
#-- Expect error if we pull the table out from under
|
||||
DROP TABLE graph_base;
|
||||
|
||||
--error S42S02
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6;
|
||||
|
||||
DROP TABLE graph;
|
||||
|
44
mysql-test/suite/oqgraph/regression_1195735.test
Normal file
44
mysql-test/suite/oqgraph/regression_1195735.test
Normal file
|
@ -0,0 +1,44 @@
|
|||
# Regression test for https://bugs.launchpad.net/oqgraph/+bug/1195735
|
||||
#--reproduce bug where select * from graph after delete from graph_base hangs the server
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS graph_base;
|
||||
DROP TABLE IF EXISTS graph;
|
||||
--enable_warnings
|
||||
|
||||
# Create the backing store
|
||||
CREATE TABLE graph_base (
|
||||
from_id INT UNSIGNED NOT NULL,
|
||||
to_id INT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (from_id,to_id),
|
||||
INDEX (to_id)
|
||||
) ENGINE=MyISAM;
|
||||
|
||||
|
||||
CREATE TABLE graph (
|
||||
latch VARCHAR(32) NULL,
|
||||
origid BIGINT UNSIGNED NULL,
|
||||
destid BIGINT UNSIGNED NULL,
|
||||
weight DOUBLE NULL,
|
||||
seq BIGINT UNSIGNED NULL,
|
||||
linkid BIGINT UNSIGNED NULL,
|
||||
KEY (latch, origid, destid) USING HASH,
|
||||
KEY (latch, destid, origid) USING HASH
|
||||
) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
|
||||
|
||||
|
||||
INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);
|
||||
|
||||
--echo One select of any clauses at all on graph here caused a hang on the select after the DELETE FROM
|
||||
#-- even this if it is the only one - but it doesnt hang here ... SELECT * FROM graph;
|
||||
SELECT * FROM graph WHERE destid=2 and origid=1;
|
||||
|
||||
DELETE FROM graph_base;
|
||||
#-- Bug 1195735 hangs on the next line
|
||||
SELECT * from graph;
|
||||
FLUSH TABLES;
|
||||
TRUNCATE TABLE graph_base;
|
||||
DROP TABLE graph_base;
|
||||
--error S42S02
|
||||
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6;
|
||||
DROP TABLE graph;
|
||||
|
Loading…
Reference in a new issue