Commit 6f12d8b3 authored by Andrew McDonnell's avatar Andrew McDonnell

iRenamed no_search to '' and finished making all tests self-consistent and...

iRenamed no_search to '' and finished making all tests self-consistent and match somewhat to http://openquery.com/graph/doc and added bug references to tests
parents 73f1cd66 1c6cccea
......@@ -26,6 +26,152 @@ 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);
# Return all edges
SELECT * FROM graph;
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
# Currently count should be 13
SELECT count(*) FROM graph;
count(*)
13
# Return all vertices, and subsets of vertices
SELECT * FROM graph where latch='';
latch origid destid weight seq linkid
NULL NULL NULL NULL 1
NULL NULL NULL NULL 2
NULL NULL NULL NULL 3
NULL NULL NULL NULL 4
NULL NULL NULL NULL 5
NULL NULL NULL NULL 6
NULL NULL NULL NULL 7
NULL NULL NULL NULL 9
NULL NULL NULL NULL 10
NULL NULL NULL NULL 11
NULL NULL NULL NULL 12
# Currently count should be 11
SELECT count(*) FROM graph where latch='';
count(*)
11
SELECT * FROM graph where latch='' and linkid = 2;
latch origid destid weight seq linkid
NULL NULL NULL NULL 2
SELECT * FROM graph where latch='' and (linkid > 2 and linkid < 6);
latch origid destid weight seq linkid
NULL NULL NULL NULL 3
NULL NULL NULL NULL 4
NULL NULL NULL NULL 5
SELECT * FROM graph where latch='' and linkid = NULL;
latch origid destid weight seq linkid
SELECT * FROM graph where latch='' and linkid = 666;
latch origid destid weight seq linkid
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = 1;
from to
1 3
1 2
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = 2;
from to
2 1
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = 4;
from to
4 3
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = 9;
from to
9 9
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = 10;
from to
10 11
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = NULL;
from to
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = 666;
from to
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = 1;
from to
3 1
2 1
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = 2;
from to
1 2
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = 4;
from to
3 4
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = 9;
from to
9 9
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = 10;
from to
12 10
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = NULL;
from to
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = 666;
from to
SELECT * FROM graph where latch='0';
latch origid destid weight seq linkid
0 NULL NULL NULL NULL 1
0 NULL NULL NULL NULL 2
0 NULL NULL NULL NULL 3
0 NULL NULL NULL NULL 4
0 NULL NULL NULL NULL 5
0 NULL NULL NULL NULL 6
0 NULL NULL NULL NULL 7
0 NULL NULL NULL NULL 9
0 NULL NULL NULL NULL 10
0 NULL NULL NULL NULL 11
0 NULL NULL NULL NULL 12
SELECT count(*) FROM graph where latch='0';
count(*)
11
SELECT * FROM graph where latch='0' and linkid = 2;
latch origid destid weight seq linkid
0 NULL NULL NULL NULL 2
SELECT * FROM graph where latch='0' and (linkid > 2 and linkid < 6);
latch origid destid weight seq linkid
0 NULL NULL NULL NULL 3
0 NULL NULL NULL NULL 4
0 NULL NULL NULL NULL 5
SELECT origid as `from`, linkid as `to` FROM graph where latch='0' and origid = 1;
from to
1 3
1 2
SELECT origid as `from`, linkid as `to` FROM graph where latch='0' and origid = 2;
from to
2 1
SELECT origid as `from`, linkid as `to` FROM graph where latch='0' and origid = 4;
from to
4 3
SELECT origid as `from`, linkid as `to` FROM graph where latch='0' and origid = 9;
from to
9 9
SELECT origid as `from`, linkid as `to` FROM graph where latch='0' and origid = 10;
from to
10 11
SELECT linkid as `from`, destid as `to` FROM graph where latch='0' and destid = 1;
from to
3 1
2 1
SELECT linkid as `from`, destid as `to` FROM graph where latch='0' and destid = 2;
from to
1 2
SELECT linkid as `from`, destid as `to` FROM graph where latch='0' and destid = 4;
from to
3 4
SELECT linkid as `from`, destid as `to` FROM graph where latch='0' and destid = 9;
from to
9 9
SELECT linkid as `from`, destid as `to` FROM graph where latch='0' and destid = 10;
from to
12 10
# Breadth-first search tests
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1;
latch origid destid weight seq linkid
......@@ -262,9 +408,105 @@ SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 12 AND (weight =
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 destid = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 3;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 4;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 5;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 6;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 7;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 8;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 9;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 10;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 11;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 12;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 1 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 2 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 3 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 4 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 5 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 6 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 7 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 8 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 9 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 10 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 11 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 12 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 1 and weight = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 2 and weight = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 3 and weight = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 4 and weight = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 5 and weight = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 6 and weight = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 7 and weight = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 8 and weight = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 9 and weight = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 10 and weight = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 11 and weight = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 12 and weight = 2;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 1 and weight = 3;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 2 and weight = 3;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 3 and weight = 3;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 4 and weight = 3;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 5 and weight = 3;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 6 and weight = 3;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 7 and weight = 3;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 8 and weight = 3;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 9 and weight = 3;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 10 and weight = 3;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 11 and weight = 3;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 12 and weight = 3;
latch origid destid weight seq linkid
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;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = NULL;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND weight = 1;
latch origid destid weight seq linkid
......
......@@ -69,36 +69,59 @@ SELECT count(*) FROM graph;
# FIXME - this is currently returning empty instead of all edges
#--echo # Return all edges - in v2, NULL latch should do this, but v3 now returns nothing...
#--https://bugs.launchpad.net/oqgraph/+bug/1196021
#SELECT * FROM graph where latch=NULL;
--echo # Return all vertices, and subsets of vertices
SELECT * FROM graph where latch='no_search';
SELECT * FROM graph where latch='';
--echo # Currently count should be 11
SELECT count(*) FROM graph where latch='no_search';
SELECT count(*) FROM graph where latch='';
#-- get a subset of vertices
SELECT * FROM graph where latch='no_search' and linkid = 2;
SELECT * FROM graph where latch='no_search' and (linkid > 2 and linkid < 6);
SELECT * FROM graph where latch='' and linkid = 2;
SELECT * FROM graph where latch='' and (linkid > 2 and linkid < 6);
SELECT * FROM graph where latch='' and linkid = NULL;
SELECT * FROM graph where latch='' and linkid = 666;
#-- Query out-edges for vertex (no_search AND origid=N)
SELECT origid as `from`, linkid as `to` FROM graph where latch='no_search' and origid = 1;
SELECT origid as `from`, linkid as `to` FROM graph where latch='no_search' and origid = 2;
SELECT origid as `from`, linkid as `to` FROM graph where latch='no_search' and origid = 4;
SELECT origid as `from`, linkid as `to` FROM graph where latch='no_search' and origid = 9;
SELECT origid as `from`, linkid as `to` FROM graph where latch='no_search' and origid = 10;
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = 1;
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = 2;
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = 4;
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = 9;
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = 10;
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = NULL;
SELECT origid as `from`, linkid as `to` FROM graph where latch='' and origid = 666;
#-- Query in-edges for vertex (no_search AND destid=N)
#-- linkid will have the other end
SELECT linkid as `from`, destid as `to` FROM graph where latch='no_search' and destid = 1;
SELECT linkid as `from`, destid as `to` FROM graph where latch='no_search' and destid = 2;
SELECT linkid as `from`, destid as `to` FROM graph where latch='no_search' and destid = 4;
SELECT linkid as `from`, destid as `to` FROM graph where latch='no_search' and destid = 9;
SELECT linkid as `from`, destid as `to` FROM graph where latch='no_search' and destid = 10;
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = 1;
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = 2;
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = 4;
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = 9;
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = 10;
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = NULL;
SELECT linkid as `from`, destid as `to` FROM graph where latch='' and destid = 666;
# The following returns a result that makes no sense...
#-- what happens when we combined orig and dest?
#SELECT * FROM graph where latch='no_search' and origid = 1;
#SELECT * FROM graph where latch='no_search' and destid = 2;
#SELECT * FROM graph where latch='no_search' and origid=1 and destid = 2;
#-- Bug https://bugs.launchpad.net/oqgraph/+bug/1195778
#SELECT * FROM graph where latch='' and origid = 1;
#SELECT * FROM graph where latch='' and destid = 2;
#SELECT * FROM graph where latch='' and origid=1 and destid = 2;
SELECT * FROM graph where latch='0';
SELECT count(*) FROM graph where latch='0';
SELECT * FROM graph where latch='0' and linkid = 2;
SELECT * FROM graph where latch='0' and (linkid > 2 and linkid < 6);
SELECT origid as `from`, linkid as `to` FROM graph where latch='0' and origid = 1;
SELECT origid as `from`, linkid as `to` FROM graph where latch='0' and origid = 2;
SELECT origid as `from`, linkid as `to` FROM graph where latch='0' and origid = 4;
SELECT origid as `from`, linkid as `to` FROM graph where latch='0' and origid = 9;
SELECT origid as `from`, linkid as `to` FROM graph where latch='0' and origid = 10;
SELECT linkid as `from`, destid as `to` FROM graph where latch='0' and destid = 1;
SELECT linkid as `from`, destid as `to` FROM graph where latch='0' and destid = 2;
SELECT linkid as `from`, destid as `to` FROM graph where latch='0' and destid = 4;
SELECT linkid as `from`, destid as `to` FROM graph where latch='0' and destid = 9;
SELECT linkid as `from`, destid as `to` FROM graph where latch='0' and destid = 10;
--echo # Breadth-first search tests
#-- We are asking "Is there a path from node 'origid' to (all) other nodes?"
......@@ -116,12 +139,14 @@ 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...?
#-- https://bugs.launchpad.net/oqgraph/+bug/1196020
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...?
#-- https://bugs.launchpad.net/oqgraph/+bug/1196020
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
......@@ -165,7 +190,6 @@ 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;
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;
......@@ -192,9 +216,61 @@ SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 10 AND (weight =
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);
#-- 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;
#-- now do it in reverse - using destid find originating vertices
#-- FIXME - currently these are returning NULL which is incorrect
#-- https://bugs.launchpad.net/oqgraph/+bug/1196027
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 destid = 3;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 4;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 5;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 6;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 7;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 8;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 9;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 10;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 11;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 12;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 1 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 2 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 3 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 4 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 5 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 6 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 7 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 8 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 9 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 10 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 11 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 12 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 1 and weight = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 2 and weight = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 3 and weight = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 4 and weight = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 5 and weight = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 6 and weight = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 7 and weight = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 8 and weight = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 9 and weight = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 10 and weight = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 11 and weight = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 12 and weight = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 1 and weight = 3;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 2 and weight = 3;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 3 and weight = 3;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 4 and weight = 3;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 5 and weight = 3;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 6 and weight = 3;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 7 and weight = 3;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 8 and weight = 3;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 9 and weight = 3;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 10 and weight = 3;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 11 and weight = 3;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 12 and weight = 3;
#-- These return empty sets - origid or destid 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 = NULL;
SELECT * FROM graph WHERE latch = 'breadth_first' AND weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first';
......@@ -207,12 +283,14 @@ 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...?
#-- https://bugs.launchpad.net/oqgraph/+bug/1196020
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...?
#-- https://bugs.launchpad.net/oqgraph/+bug/1196020
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;
......
......@@ -34,51 +34,19 @@ 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);
# No Search/0 - result should return same rows as inserted for origid,destid,weight
# FIXME - THIS CODE IS CURRENTLY BROKEN - see https://bugs.launchpad.net/oqgraph/+bug/1195778
SELECT * FROM graph WHERE latch='no_search';
latch origid destid weight seq linkid
no_search NULL NULL NULL NULL 1
no_search NULL NULL NULL NULL 2
no_search NULL NULL NULL NULL 3
no_search NULL NULL NULL NULL 4
no_search NULL NULL NULL NULL 5
no_search NULL NULL NULL NULL 6
SELECT * FROM graph WHERE latch='no_search' and destid=2 and origid=1;
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='no_search' and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='no_search' and destid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='no_search' and origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='no_search' and origid=NULL;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='0' ;
# Expect no result, because of autocast
SELECT * FROM graph WHERE latch=0 ;
latch origid destid weight seq linkid
0 NULL NULL NULL NULL 1
0 NULL NULL NULL NULL 2
0 NULL NULL NULL NULL 3
0 NULL NULL NULL NULL 4
0 NULL NULL NULL NULL 5
0 NULL NULL NULL NULL 6
SELECT * FROM graph WHERE latch='0' and destid=2 and origid=1;
SELECT * FROM graph WHERE latch=0 and destid=2 and origid=1;
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='0' and origid=1;
SELECT * FROM graph WHERE latch=0 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='0' and destid=1;
SELECT * FROM graph WHERE latch=0 and destid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='0' and origid=666;
SELECT * FROM graph WHERE latch=0 and origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='0' and origid=NULL;
SELECT * FROM graph WHERE latch=0 and origid=NULL;
latch origid destid weight seq linkid
# Expect no result, because of autocast
SELECT * FROM graph WHERE latch=1 ;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=1 and destid=2 and origid=1;
......@@ -188,59 +156,6 @@ Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=NULL;
latch origid destid weight seq linkid
# Expect no result, because of autocast and deprecated syntax
# Allows 0 and NULL to have same effect
SELECT * FROM graph WHERE latch=0;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and destid=2 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and destid=1;
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=0 and origid=NULL;
latch origid destid weight seq linkid
# Expect no result, because of NULL latch
SELECT * FROM graph WHERE latch=NULL;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=NULL and destid=2 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=NULL and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=NULL and destid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=NULL and origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=NULL and origid=NULL;
latch origid destid weight seq linkid
# With no latch, original data in origid and destid columns
SELECT * FROM graph;
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;
latch origid destid weight seq linkid
NULL 1 2 1 NULL NULL
SELECT * FROM graph WHERE origid=1;
latch origid destid weight seq linkid
NULL 1 2 1 NULL NULL
NULL 1 3 1 NULL NULL
SELECT * FROM graph WHERE destid=1;
latch origid destid weight seq linkid
NULL 2 1 1 NULL NULL
NULL 3 1 1 NULL NULL
SELECT * FROM graph WHERE origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE origid=NULL;
latch origid destid weight seq linkid
INSERT INTO graph_base(from_id, to_id) VALUES (1,2);
ERROR 23000: Duplicate entry '1-2' for key 'PRIMARY'
DELETE FROM graph_base;
......
......@@ -45,22 +45,13 @@ 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 - see https://bugs.launchpad.net/oqgraph/+bug/1195778
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=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;
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;
......@@ -108,35 +99,18 @@ 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?
#--echo # Expect no result, because of NULL latch
#-- FIXME - in v2 according to http://openquery.com/graph/doc NULL latch should
#-- FIXME - return same as select * from graph;
#--https://bugs.launchpad.net/oqgraph/+bug/1196021
#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;
#-- what happens if we have two links the same? primay key violation...
--error 1062
INSERT INTO graph_base(from_id, to_id) VALUES (1,2);
......
......@@ -48,6 +48,11 @@ CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, dest
DESCRIBE oqtable;
ERROR 42S02: Table 'test.bogus' doesn't exist
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( 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='not_backing';
# Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( 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='backing', DESTID='id2';
# Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)'
DESCRIBE oqtable;
......
......@@ -78,15 +78,14 @@ CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, dest
--error 1146
DESCRIBE oqtable;
# FIXME - I dont know what this test was for
# FIXME - Are we checking that the backing tbale has a primary key etc., or doesn't it matter?
# invalid table reference
#--disable_warnings
#DROP TABLE IF EXISTS oqtable;
#--enable_warnings
#CREATE TABLE oqtable ( 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='not_backing';
#--error 1296
#DESCRIBE oqtable;
# Table exists but no orig or dest specified
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( 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='not_backing';
--echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)'
--error 1296
DESCRIBE oqtable;
# missing origid
--disable_warnings
......
......@@ -81,7 +81,7 @@ static MYSQL_SYSVAR_BOOL(allow_create_integer_latch, g_allow_create_integer_latc
// In the future this needs to be refactactored to live somewhere else
struct oqgraph_latch_op_table { const char *key; int latch; };
static const oqgraph_latch_op_table latch_ops_table[] = {
{ "no_search", oqgraph::NO_SEARCH } ,
{ "", oqgraph::NO_SEARCH } , // suggested by Arjen, use empty string instead of no_search
{ "dijkstras", oqgraph::DIJKSTRAS } ,
{ "breadth_first", oqgraph::BREADTH_FIRST } ,
{ NULL, -1 }
......@@ -786,7 +786,7 @@ static int parse_latch_string_to_legacy_int(const String& value, int &latch)
char *eptr;
unsigned long int v = strtoul( latchValue.c_ptr_safe(), &eptr, 10);
if (!*eptr) {
// we had an unsigned number; remember 0 is valid too (nosearch))
// we had an unsigned number; remember 0 is valid too ('vertices' aka 'no_search'))
if (v >= 0 && v < oqgraph::NUM_SEARCH_OP) {
latch = v;
return true;
......@@ -996,7 +996,7 @@ int ha_oqgraph::rnd_next(byte *buf)
{
int res;
open_query::row row;
if (!(res= graph->fetch_row(row)))
if (!(res= graph->fetch_row(row))) // FIXME - this called after DELETE FROM graph_base; hangs...
res= fill_record(buf, row);
table->status= res ? STATUS_NOT_FOUND: 0;
return error_code(res);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment