Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
f8f17f2a
Commit
f8f17f2a
authored
Aug 09, 2013
by
Andrew McDonnell
Browse files
Options
Browse Files
Download
Plain Diff
Fixes for dijkstra weights and added regression tests for several other issues
parents
0febfba5
db048e78
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
540 additions
and
123 deletions
+540
-123
mysql-test/suite/oqgraph/basic.result
mysql-test/suite/oqgraph/basic.result
+79
-63
mysql-test/suite/oqgraph/basic.test
mysql-test/suite/oqgraph/basic.test
+31
-59
mysql-test/suite/oqgraph/regression_1196020.result
mysql-test/suite/oqgraph/regression_1196020.result
+68
-0
mysql-test/suite/oqgraph/regression_1196020.test
mysql-test/suite/oqgraph/regression_1196020.test
+71
-0
mysql-test/suite/oqgraph/regression_1196027.result
mysql-test/suite/oqgraph/regression_1196027.result
+56
-0
mysql-test/suite/oqgraph/regression_1196027.test
mysql-test/suite/oqgraph/regression_1196027.test
+51
-0
mysql-test/suite/oqgraph/regression_1196036.result
mysql-test/suite/oqgraph/regression_1196036.result
+112
-0
mysql-test/suite/oqgraph/regression_1196036.test
mysql-test/suite/oqgraph/regression_1196036.test
+70
-0
storage/oqgraph/graphcore.cc
storage/oqgraph/graphcore.cc
+2
-1
No files found.
mysql-test/suite/oqgraph/basic.result
View file @
f8f17f2a
...
...
@@ -46,6 +46,22 @@ NULL 12 10 1 NULL NULL
SELECT count(*) FROM graph;
count(*)
13
# Return all edges when latch is NULL
SELECT * FROM graph where latch is NULL;
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
NULL 5 7 1 NULL NULL
NULL 9 9 1 NULL NULL
NULL 10 11 1 NULL NULL
NULL 11 12 1 NULL NULL
NULL 12 10 1 NULL NULL
# Return all vertices, and subsets of vertices
SELECT * FROM graph where latch='';
latch origid destid weight seq linkid
...
...
@@ -1018,37 +1034,37 @@ dijkstras 12 11 1 1 10
dijkstras 12 11 1 2 11
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
2
4 4
dijkstras 1 NULL
1
3 3
dijkstras 1 NULL
1
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
0
4 4
dijkstras 2 NULL
0
3 3
dijkstras 2 NULL
0
2 1
dijkstras 2 NULL
3
4 4
dijkstras 2 NULL
2
3 3
dijkstras 2 NULL
1
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
0
4 2
dijkstras 3 NULL
0
3 4
dijkstras 3 NULL
0
2 1
dijkstras 3 NULL
2
4 2
dijkstras 3 NULL
1
3 4
dijkstras 3 NULL
1
2 1
dijkstras 3 NULL 0 1 3
SELECT * FROM graph WHERE latch='dijkstras' AND origid=4;
latch origid destid weight seq linkid
dijkstras 4 NULL
0
4 2
dijkstras 4 NULL
0
3 1
dijkstras 4 NULL
0
2 3
dijkstras 4 NULL
3
4 2
dijkstras 4 NULL
2
3 1
dijkstras 4 NULL
1
2 3
dijkstras 4 NULL 0 1 4
SELECT * FROM graph WHERE latch='dijkstras' AND origid=5;
latch origid destid weight seq linkid
dijkstras 5 NULL
0
3 7
dijkstras 5 NULL
0
2 6
dijkstras 5 NULL
1
3 7
dijkstras 5 NULL
1
2 6
dijkstras 5 NULL 0 1 5
SELECT * FROM graph WHERE latch='dijkstras' AND origid=6;
latch origid destid weight seq linkid
dijkstras 6 NULL
0
3 7
dijkstras 6 NULL
0
2 5
dijkstras 6 NULL
2
3 7
dijkstras 6 NULL
1
2 5
dijkstras 6 NULL 0 1 6
SELECT * FROM graph WHERE latch='dijkstras' AND origid=7;
latch origid destid weight seq linkid
...
...
@@ -1060,18 +1076,18 @@ latch origid destid weight seq linkid
dijkstras 9 NULL 0 1 9
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10;
latch origid destid weight seq linkid
dijkstras 10 NULL
0
3 12
dijkstras 10 NULL
0
2 11
dijkstras 10 NULL
2
3 12
dijkstras 10 NULL
1
2 11
dijkstras 10 NULL 0 1 10
SELECT * FROM graph WHERE latch='dijkstras' AND origid=11;
latch origid destid weight seq linkid
dijkstras 11 NULL
0
3 10
dijkstras 11 NULL
0
2 12
dijkstras 11 NULL
2
3 10
dijkstras 11 NULL
1
2 12
dijkstras 11 NULL 0 1 11
SELECT * FROM graph WHERE latch='dijkstras' AND origid=12;
latch origid destid weight seq linkid
dijkstras 12 NULL
0
3 11
dijkstras 12 NULL
0
2 10
dijkstras 12 NULL
2
3 11
dijkstras 12 NULL
1
2 10
dijkstras 12 NULL 0 1 12
SELECT * FROM graph WHERE latch='dijkstras' AND origid=666;
latch origid destid weight seq linkid
...
...
@@ -1193,37 +1209,37 @@ latch origid destid weight seq linkid
1 12 11 1 2 11
SELECT * FROM graph WHERE latch='1' AND origid=1;
latch origid destid weight seq linkid
1 1 NULL
0
4 4
1 1 NULL
0
3 3
1 1 NULL
0
2 2
1 1 NULL
2
4 4
1 1 NULL
1
3 3
1 1 NULL
1
2 2
1 1 NULL 0 1 1
SELECT * FROM graph WHERE latch='1' AND origid=2;
latch origid destid weight seq linkid
1 2 NULL
0
4 4
1 2 NULL
0
3 3
1 2 NULL
0
2 1
1 2 NULL
3
4 4
1 2 NULL
2
3 3
1 2 NULL
1
2 1
1 2 NULL 0 1 2
SELECT * FROM graph WHERE latch='1' AND origid=3;
latch origid destid weight seq linkid
1 3 NULL
0
4 2
1 3 NULL
0
3 4
1 3 NULL
0
2 1
1 3 NULL
2
4 2
1 3 NULL
1
3 4
1 3 NULL
1
2 1
1 3 NULL 0 1 3
SELECT * FROM graph WHERE latch='1' AND origid=4;
latch origid destid weight seq linkid
1 4 NULL
0
4 2
1 4 NULL
0
3 1
1 4 NULL
0
2 3
1 4 NULL
3
4 2
1 4 NULL
2
3 1
1 4 NULL
1
2 3
1 4 NULL 0 1 4
SELECT * FROM graph WHERE latch='1' AND origid=5;
latch origid destid weight seq linkid
1 5 NULL
0
3 7
1 5 NULL
0
2 6
1 5 NULL
1
3 7
1 5 NULL
1
2 6
1 5 NULL 0 1 5
SELECT * FROM graph WHERE latch='1' AND origid=6;
latch origid destid weight seq linkid
1 6 NULL
0
3 7
1 6 NULL
0
2 5
1 6 NULL
2
3 7
1 6 NULL
1
2 5
1 6 NULL 0 1 6
SELECT * FROM graph WHERE latch='1' AND origid=7;
latch origid destid weight seq linkid
...
...
@@ -1235,18 +1251,18 @@ latch origid destid weight seq linkid
1 9 NULL 0 1 9
SELECT * FROM graph WHERE latch='1' AND origid=10;
latch origid destid weight seq linkid
1 10 NULL
0
3 12
1 10 NULL
0
2 11
1 10 NULL
2
3 12
1 10 NULL
1
2 11
1 10 NULL 0 1 10
SELECT * FROM graph WHERE latch='1' AND origid=11;
latch origid destid weight seq linkid
1 11 NULL
0
3 10
1 11 NULL
0
2 12
1 11 NULL
2
3 10
1 11 NULL
1
2 12
1 11 NULL 0 1 11
SELECT * FROM graph WHERE latch='1' AND origid=12;
latch origid destid weight seq linkid
1 12 NULL
0
3 11
1 12 NULL
0
2 10
1 12 NULL
2
3 11
1 12 NULL
1
2 10
1 12 NULL 0 1 12
SELECT * FROM graph WHERE latch='1' AND origid=666;
latch origid destid weight seq linkid
...
...
@@ -1331,14 +1347,14 @@ 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
2
4 4
dijkstras 1 NULL
1
3 3
dijkstras 1 NULL
1
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
1
2 22
dijkstras 21 NULL 0 1 21
SELECT * FROM graph WHERE latch='dijkstras' AND origid=22;
latch origid destid weight seq linkid
...
...
@@ -1346,29 +1362,29 @@ 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
3
5 17
dijkstras 1 NULL
2
4 4
dijkstras 1 NULL
1
3 3
dijkstras 1 NULL
1
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
3
6 17
dijkstras 1 NULL
3
5 16
dijkstras 1 NULL
2
4 4
dijkstras 1 NULL
1
3 3
dijkstras 1 NULL
1
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
4
7 18
dijkstras 1 NULL
3
6 17
dijkstras 1 NULL
3
5 16
dijkstras 1 NULL
2
4 4
dijkstras 1 NULL
1
3 3
dijkstras 1 NULL
1
2 2
dijkstras 1 NULL 0 1 1
SELECT * FROM graph WHERE latch='dijkstras' AND destid=1;
latch origid destid weight seq linkid
...
...
mysql-test/suite/oqgraph/basic.test
View file @
f8f17f2a
This diff is collapsed.
Click to expand it.
mysql-test/suite/oqgraph/regression_1196020.result
0 → 100644
View file @
f8f17f2a
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,
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);
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '2' AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '1' AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '2' AND destid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '1' AND destid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '2' AND origid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '1' AND origid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '2' AND destid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '1' AND destid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '' AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '0' AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch is NULL AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '' AND destid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '0' AND destid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch is NULL AND destid = 666;
latch origid destid weight seq linkid
DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;
mysql-test/suite/oqgraph/regression_1196020.test
0 → 100644
View file @
f8f17f2a
# Regression test for https://bugs.launchpad.net/oqgraph/+bug/1196020
#-- bug where select blah with origid = X where X does not exist, returns a row
#-- bug where select blah with destid = X where X does not exist, returns a row
--
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
);
# All the following should return no result because no vertex 666 exists in the graph
SELECT
*
FROM
graph
WHERE
latch
=
'breadth_first'
AND
origid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
=
'2'
AND
origid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
=
'dijkstras'
AND
origid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
=
'1'
AND
origid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
=
'breadth_first'
AND
destid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
=
'2'
AND
destid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
=
'dijkstras'
AND
destid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
=
'1'
AND
destid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
=
'breadth_first'
AND
origid
=
666
and
weight
=
1
;
SELECT
*
FROM
graph
WHERE
latch
=
'2'
AND
origid
=
666
and
weight
=
1
;
SELECT
*
FROM
graph
WHERE
latch
=
'dijkstras'
AND
origid
=
666
and
weight
=
1
;
SELECT
*
FROM
graph
WHERE
latch
=
'1'
AND
origid
=
666
and
weight
=
1
;
SELECT
*
FROM
graph
WHERE
latch
=
'breadth_first'
AND
destid
=
666
and
weight
=
1
;
SELECT
*
FROM
graph
WHERE
latch
=
'2'
AND
destid
=
666
and
weight
=
1
;
SELECT
*
FROM
graph
WHERE
latch
=
'dijkstras'
AND
destid
=
666
and
weight
=
1
;
SELECT
*
FROM
graph
WHERE
latch
=
'1'
AND
destid
=
666
and
weight
=
1
;
# Sanity check for no-search
SELECT
*
FROM
graph
WHERE
latch
=
''
AND
origid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
=
'0'
AND
origid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
is
NULL
AND
origid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
=
''
AND
destid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
=
'0'
AND
destid
=
666
;
SELECT
*
FROM
graph
WHERE
latch
is
NULL
AND
destid
=
666
;
DELETE
FROM
graph_base
;
FLUSH
TABLES
;
TRUNCATE
TABLE
graph_base
;
DROP
TABLE
graph_base
;
DROP
TABLE
graph
;
mysql-test/suite/oqgraph/regression_1196027.result
0 → 100644
View file @
f8f17f2a
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,
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);
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 1;
latch origid destid weight seq linkid
breadth_first NULL 1 1 2 2
breadth_first NULL 1 0 1 1
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 2;
latch origid destid weight seq linkid
breadth_first NULL 2 1 2 1
breadth_first NULL 2 0 1 2
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1;
latch origid destid weight seq linkid
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 1 2 1
breadth_first 2 NULL 0 1 2
SELECT * FROM graph WHERE latch = '2' AND destid = 1;
latch origid destid weight seq linkid
2 NULL 1 1 2 2
2 NULL 1 0 1 1
SELECT * FROM graph WHERE latch = '2' AND destid = 2;
latch origid destid weight seq linkid
2 NULL 2 1 2 1
2 NULL 2 0 1 2
SELECT * FROM graph WHERE latch = '2' AND origid = 1;
latch origid destid weight seq linkid
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 1 2 1
2 2 NULL 0 1 2
DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;
mysql-test/suite/oqgraph/regression_1196027.test
0 → 100644
View file @
f8f17f2a
# Regression test for https://bugs.launchpad.net/oqgraph/+bug/1196027
#-- These were returning NULL which is incorrect
#-- https://bugs.launchpad.net/oqgraph/+bug/1196027
--
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
);
# All the following should return no result because no vertex 666 exists in the graph
SELECT
*
FROM
graph
WHERE
latch
=
'breadth_first'
AND
destid
=
1
;
SELECT
*
FROM
graph
WHERE
latch
=
'breadth_first'
AND
destid
=
2
;
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
=
'2'
AND
destid
=
1
;
SELECT
*
FROM
graph
WHERE
latch
=
'2'
AND
destid
=
2
;
SELECT
*
FROM
graph
WHERE
latch
=
'2'
AND
origid
=
1
;
SELECT
*
FROM
graph
WHERE
latch
=
'2'
AND
origid
=
2
;
DELETE
FROM
graph_base
;
FLUSH
TABLES
;
TRUNCATE
TABLE
graph_base
;
DROP
TABLE
graph_base
;
DROP
TABLE
graph
;
mysql-test/suite/oqgraph/regression_1196036.result
0 → 100644
View file @
f8f17f2a
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 is NULL;
latch origid destid weight seq linkid
NULL 1 2 16 NULL NULL
NULL 2 1 16 NULL NULL
NULL 2 3 256 NULL NULL
NULL 3 2 256 NULL NULL
NULL 3 4 65536 NULL NULL
NULL 4 3 65536 NULL NULL
NULL 2 4 768 NULL NULL
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;
mysql-test/suite/oqgraph/regression_1196036.test
0 → 100644
View file @
f8f17f2a
# 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
is
NULL
;
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
;
storage/oqgraph/graphcore.cc
View file @
f8f17f2a
...
...
@@ -823,7 +823,8 @@ namespace open_query
EdgeWeight
(),
make_dijkstra_visitor
(
make_oqgraph_visit_dist
(
boost
::
make_assoc_property_map
(
p
),
d
,
boost
::
make_assoc_property_map
(
p
),
boost
::
make_assoc_property_map
(
d
),
static_cast
<
stack_cursor
*>
(
cursor
)
)
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment