mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 21:12:26 +01:00
Regression test for 1196036 dijkstra weights
This commit is contained in:
parent
a70741243f
commit
55d9cfc848
2 changed files with 171 additions and 0 deletions
103
mysql-test/suite/oqgraph/regression_1196036.result
Normal file
103
mysql-test/suite/oqgraph/regression_1196036.result
Normal file
|
@ -0,0 +1,103 @@
|
|||
DROP TABLE IF EXISTS graph_base;
|
||||
DROP TABLE IF EXISTS graph;
|
||||
CREATE TABLE graph_base (
|
||||
from_id INT UNSIGNED NOT NULL,
|
||||
to_id INT UNSIGNED NOT NULL,
|
||||
weight FLOAT 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', WEIGHT='weight';
|
||||
INSERT INTO graph_base(from_id, to_id, weight) VALUES (1,2,16), (2,1,16);
|
||||
INSERT INTO graph_base(from_id, to_id, weight) VALUES (2,3,256), (3,2,256);
|
||||
INSERT INTO graph_base(from_id, to_id, weight) VALUES (3,4,65536), (4,3,65536);
|
||||
INSERT INTO graph_base(from_id, to_id, weight) VALUES (2,4,768);
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 1 NULL 784 4 4
|
||||
dijkstras 1 NULL 272 3 3
|
||||
dijkstras 1 NULL 16 2 2
|
||||
dijkstras 1 NULL 0 1 1
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 2 NULL 768 4 4
|
||||
dijkstras 2 NULL 256 3 3
|
||||
dijkstras 2 NULL 16 2 1
|
||||
dijkstras 2 NULL 0 1 2
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 3 NULL 1024 4 4
|
||||
dijkstras 3 NULL 272 3 1
|
||||
dijkstras 3 NULL 256 2 2
|
||||
dijkstras 3 NULL 0 1 3
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 1;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras NULL 1 784 4 4
|
||||
dijkstras NULL 1 272 3 3
|
||||
dijkstras NULL 1 16 2 2
|
||||
dijkstras NULL 1 0 1 1
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 2;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras NULL 2 768 4 4
|
||||
dijkstras NULL 2 256 3 3
|
||||
dijkstras NULL 2 16 2 1
|
||||
dijkstras NULL 2 0 1 2
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 3;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras NULL 3 1024 4 4
|
||||
dijkstras NULL 3 272 3 1
|
||||
dijkstras NULL 3 256 2 2
|
||||
dijkstras NULL 3 0 1 3
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and destid=3;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 1 3 NULL 0 1
|
||||
dijkstras 1 3 16 1 2
|
||||
dijkstras 1 3 256 2 3
|
||||
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 16 1 2
|
||||
dijkstras 1 4 768 2 4
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=1;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=16;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 1 NULL 16 2 2
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=16;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 2 NULL 16 2 1
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=16;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=784;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 1 NULL 784 4 4
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=784;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=784;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=256;
|
||||
latch origid destid weight seq linkid
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=256;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 2 NULL 256 3 3
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=256;
|
||||
latch origid destid weight seq linkid
|
||||
dijkstras 3 NULL 256 2 2
|
||||
DELETE FROM graph_base;
|
||||
FLUSH TABLES;
|
||||
TRUNCATE TABLE graph_base;
|
||||
DROP TABLE graph_base;
|
||||
DROP TABLE graph;
|
68
mysql-test/suite/oqgraph/regression_1196036.test
Normal file
68
mysql-test/suite/oqgraph/regression_1196036.test
Normal file
|
@ -0,0 +1,68 @@
|
|||
# Regression test for https://bugs.launchpad.net/oqgraph/+bug/1196036
|
||||
#-- bug with Djikstras algorithm - find reachable vertices (origid=X) returns weight=0 instead of weight=count of hops
|
||||
--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,
|
||||
weight FLOAT 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', WEIGHT='weight';
|
||||
|
||||
|
||||
INSERT INTO graph_base(from_id, to_id, weight) VALUES (1,2,16), (2,1,16);
|
||||
INSERT INTO graph_base(from_id, to_id, weight) VALUES (2,3,256), (3,2,256);
|
||||
INSERT INTO graph_base(from_id, to_id, weight) VALUES (3,4,65536), (4,3,65536);
|
||||
INSERT INTO graph_base(from_id, to_id, weight) VALUES (2,4,768);
|
||||
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1;
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2;
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3;
|
||||
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 1;
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 2;
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 3;
|
||||
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and destid=3;
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and destid=4;
|
||||
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=1; # <-- should return nothing
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=1; # <-- should return nothing
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=1; # <-- should return nothing
|
||||
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=16;
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=16;
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=16; # <-- should return nothing
|
||||
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=784;
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=784; # <-- should return nothing
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=784; # <-- should return nothing
|
||||
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=256; # <-- should return nothing
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=256;
|
||||
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=256;
|
||||
|
||||
DELETE FROM graph_base;
|
||||
FLUSH TABLES;
|
||||
TRUNCATE TABLE graph_base;
|
||||
|
||||
DROP TABLE graph_base;
|
||||
DROP TABLE graph;
|
||||
|
Loading…
Reference in a new issue