1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

move oqgraph and sphinx suites into storage/*/mysql-test/

This commit is contained in:
Sergei Golubchik
2013-12-16 13:32:03 +01:00
parent c1a6522875
commit ce2fabe442
49 changed files with 4 additions and 2 deletions

View File

@ -177,14 +177,12 @@ my @DEFAULT_SUITES= qw(
maria-
multi_source-
optimizer_unfixed_bugs-
oqgraph-
parts-
percona-
perfschema-
plugins-
roles-
rpl-
sphinx-
sys_vars-
unit-
vcol-

File diff suppressed because it is too large Load Diff

View File

@ -1,640 +0,0 @@
--disable_warnings
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
DROP TABLE IF EXISTS graph2;
--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';
#--
#-- 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 # Return all edges
#-- we note that when weight is NULL it defaults to 1
SELECT * FROM graph;
--echo # Currently count should be 13
SELECT count(*) FROM graph;
--echo # Return all edges when latch is NULL - this is different to latch='' and same as no where clause
SELECT * FROM graph where latch is NULL;
--echo # Return all vertices, and subsets of vertices
SELECT * FROM graph where latch='';
SELECT * FROM graph where latch='0';
--echo # Currently count should be 11
SELECT count(*) FROM graph where latch='';
#-- get a subset of vertices
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='' 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='' 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?
#-- 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?"
#-- 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
#-- linkid is the other end
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;
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8; # <-- note, should return nothing
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;
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 666; # <-- note, should return nothing
#-- 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;
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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;
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; # <-- note, should return nothing
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 = '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); # <-- note, should return nothing
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);
#-- now do it in reverse - using destid find originating vertices
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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';
#-- 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;
SELECT * FROM graph WHERE latch = '2' AND origid = 8; # <-- note, should return nothing
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;
SELECT * FROM graph WHERE latch = '2' AND origid = 666; # <-- note, should return nothing
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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;
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); # <-- note, should return nothing
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);
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 destid = 3;
SELECT * FROM graph WHERE latch = '2' AND destid = 4;
SELECT * FROM graph WHERE latch = '2' AND destid = 5;
SELECT * FROM graph WHERE latch = '2' AND destid = 6;
SELECT * FROM graph WHERE latch = '2' AND destid = 7;
SELECT * FROM graph WHERE latch = '2' AND destid = 8; # <-- note, should return nothing
SELECT * FROM graph WHERE latch = '2' AND destid = 9;
SELECT * FROM graph WHERE latch = '2' AND destid = 10;
SELECT * FROM graph WHERE latch = '2' AND destid = 11;
SELECT * FROM graph WHERE latch = '2' AND destid = 12;
SELECT * FROM graph WHERE latch = '2' AND destid = 1 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 2 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 3 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 4 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 5 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 6 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 7 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 8 and weight = 1; # <-- note, should return nothing
SELECT * FROM graph WHERE latch = '2' AND destid = 9 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 10 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 11 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 12 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 1 and weight = 2;
SELECT * FROM graph WHERE latch = '2' AND destid = 2 and weight = 2;
SELECT * FROM graph WHERE latch = '2' AND destid = 3 and weight = 2;
SELECT * FROM graph WHERE latch = '2' AND destid = 4 and weight = 2;
SELECT * FROM graph WHERE latch = '2' AND destid = 5 and weight = 2;
SELECT * FROM graph WHERE latch = '2' AND destid = 6 and weight = 2;
SELECT * FROM graph WHERE latch = '2' AND destid = 7 and weight = 2;
SELECT * FROM graph WHERE latch = '2' AND destid = 8 and weight = 2; # <-- note, should return nothing
SELECT * FROM graph WHERE latch = '2' AND destid = 9 and weight = 2;
SELECT * FROM graph WHERE latch = '2' AND destid = 10 and weight = 2;
SELECT * FROM graph WHERE latch = '2' AND destid = 11 and weight = 2;
SELECT * FROM graph WHERE latch = '2' AND destid = 12 and weight = 2;
SELECT * FROM graph WHERE latch = '2' AND destid = 1 and weight = 3;
SELECT * FROM graph WHERE latch = '2' AND destid = 2 and weight = 3;
SELECT * FROM graph WHERE latch = '2' AND destid = 3 and weight = 3;
SELECT * FROM graph WHERE latch = '2' AND destid = 4 and weight = 3;
SELECT * FROM graph WHERE latch = '2' AND destid = 5 and weight = 3;
SELECT * FROM graph WHERE latch = '2' AND destid = 6 and weight = 3;
SELECT * FROM graph WHERE latch = '2' AND destid = 7 and weight = 3;
SELECT * FROM graph WHERE latch = '2' AND destid = 8 and weight = 3; # <-- note, should return nothing
SELECT * FROM graph WHERE latch = '2' AND destid = 9 and weight = 3;
SELECT * FROM graph WHERE latch = '2' AND destid = 10 and weight = 3;
SELECT * FROM graph WHERE latch = '2' AND destid = 11 and weight = 3;
SELECT * FROM graph WHERE latch = '2' AND destid = 12 and weight = 3;
#-- 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 = NULL;
SELECT * FROM graph WHERE latch = '2' AND weight = 1;
SELECT * FROM graph WHERE latch = '2';
--echo # Dijkstras algorithm tests
#-- We ask 'What is the shortest 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;
#-- 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;
#-- 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;
#-- reachable vertices
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 origid=4;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=5;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=6;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=7;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=8; # <-- note, should return nothing
SELECT * FROM graph WHERE latch='dijkstras' AND origid=9;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=11;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=12;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=666; # <-- note, should return nothing
#-- originating vertices
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 destid=4;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=5;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=6;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=7;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=8; # <-- note, should return nothing
SELECT * FROM graph WHERE latch='dijkstras' AND destid=9;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=10;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=11;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=12;
--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; # <-- note, should return nothing
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;
SELECT * FROM graph WHERE latch='1' AND origid=1;
SELECT * FROM graph WHERE latch='1' AND origid=2;
SELECT * FROM graph WHERE latch='1' AND origid=3;
SELECT * FROM graph WHERE latch='1' AND origid=4;
SELECT * FROM graph WHERE latch='1' AND origid=5;
SELECT * FROM graph WHERE latch='1' AND origid=6;
SELECT * FROM graph WHERE latch='1' AND origid=7;
SELECT * FROM graph WHERE latch='1' AND origid=8; # <-- note, should return nothing
SELECT * FROM graph WHERE latch='1' AND origid=9;
SELECT * FROM graph WHERE latch='1' AND origid=10;
SELECT * FROM graph WHERE latch='1' AND origid=11;
SELECT * FROM graph WHERE latch='1' AND origid=12;
SELECT * FROM graph WHERE latch='1' AND origid=666; # <-- note, should return nothing
SELECT * FROM graph WHERE latch='1' AND destid=1;
SELECT * FROM graph WHERE latch='1' AND destid=2;
SELECT * FROM graph WHERE latch='1' AND destid=3;
SELECT * FROM graph WHERE latch='1' AND destid=4;
SELECT * FROM graph WHERE latch='1' AND destid=5;
SELECT * FROM graph WHERE latch='1' AND destid=6;
SELECT * FROM graph WHERE latch='1' AND destid=7;
SELECT * FROM graph WHERE latch='1' AND destid=8; # <-- note, should return nothing
SELECT * FROM graph WHERE latch='1' AND destid=9;
SELECT * FROM graph WHERE latch='1' AND destid=10;
SELECT * FROM graph WHERE latch='1' AND destid=11;
SELECT * FROM graph WHERE latch='1' AND destid=12;
#-- 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;
#-- add some extra and check
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;
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);
--echo # And delete all references to node 5
DELETE FROM graph_base WHERE from_id=5;
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 (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;
DROP TABLE graph;
#-- Reminder - the basic spec is at http://openquery.com/graph/doc
#-- Query edges stored in graph engine (latch=NULL)
#-- SELECT * FROM foo;
#-- Results:
#-- vertex id for origin of edge in origid column.
#-- vertex id for destination of edge in destid column.
#-- weight of edge in weight column.
#-- Essentially this returns the values (origid,destid pairs with optional weight) you put in, in this mode OQGRAPH looks very close to a real table. But it also does nothing special, it's just store/retrieve for those columns. The other columns will be returned as NULL.
#--
#-- Query vertices stored in graph engine (latch=0)
#-- SELECT * FROM foo WHERE latch = 0;
#-- Results:
#-- vertex id in linkid column
#--
#-- Query out-edges for vertex (latch=0 AND origid=N)
#-- SELECT * FROM foo WHERE latch = 0 AND origid = 2;
#-- Results:
#-- vertex id in linkid column
#-- edge weight in weight column
#--
#-- Query in-edges for vertex (latch=0 AND destid=N)
#-- SELECT * FROM foo WHERE latch = 0 AND destid = 6;
#-- Results:
#-- vertex id in linkid column
#-- edge weight in weight column
#--
#-- Dijkstra's shortest path algorithm (latch=1)
#-- Find shortest path:
#-- SELECT * FROM foo WHERE latch = 1 AND origid = 1 AND destid = 6;
#-- Results:
#-- latch, origid, destid are same as input.
#-- vertex id of the current step in linkid column.
#-- weight of traversed edge in weight column.
#-- step counter in seq column, so you can sort and use the result (starting at step 0).
#-- Example: SELECT GROUP_CONCAT(linkid ORDER BY seq) ...
#--
#-- Find reachable vertices:
#-- SELECT * FROM foo WHERE latch = 1 AND origid = 1;
#-- Results:
#-- latch, origid, destid are same as input.
#-- vertex id in linkid column.
#-- aggregate of weights in weight column.
#--
#-- Find originating vertices:
#-- SELECT * FROM foo WHERE latch = 1 AND destid = 6;
#-- Results:
#-- latch, origid, destid are same as input.
#-- vertex id in linkid column.
#-- aggregate of weights in weight column.
#--
#-- Breadth-first search (latch=2, assumes that each vertex is weight 1)
#-- Find shortest path:
#-- SELECT * FROM foo WHERE latch = 2 AND origid = 1 AND destid = 6;
#-- Results:
#-- vertex id in linkid column.
#-- weight column = 1 for each hop.
#--
#-- Find reachable vertices:
#-- SELECT * FROM foo WHERE latch = 2 AND origid = 1;
#-- Results:
#-- vertex id in linkid column.
#-- computed number of hops in weight column.
#--
#-- Find originating vertices:
#-- SELECT * FROM foo WHERE latch = 2 AND destid = 6;
#-- Results:
#-- vertex id in linkid column.
#-- computed number of hops in weight column.

View File

@ -1,214 +0,0 @@
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,
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);
# Expect no result, because of autocast
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 is NULL;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=1 ;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=1 and destid=2 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=1 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=1 and destid=1;
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=1 and origid is NULL;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=2 ;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=2 and destid=2 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=2 and origid=1;
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 origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=2 and origid is NULL;
latch origid destid weight seq linkid
# Should this return an error? it seems we treat it as just another bogus latch
SELECT * FROM graph WHERE latch='ThisExceeds32Characters456789012';
latch origid destid weight seq linkid
# Expect no result, because of invalid latch
SELECT * FROM graph WHERE latch='bogus';
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='bogus' and destid=2 and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='bogus' and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='bogus' and destid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='bogus' and origid=666;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='bogus' and origid is NULL;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='666';
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='666' and destid=2 and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='666' and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='666' and destid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='666' and origid=666;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='666' and origid is NULL;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='-1';
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='-1' and destid=2 and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='-1' and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='-1' and destid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='-1' and origid=666;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='-1' and origid is NULL;
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 〄';
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and destid=2 and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and destid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=666;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid is NULL;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
# 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
SELECT * FROM graph WHERE latch is NULL and destid=2 and origid=1;
latch origid destid weight seq linkid
NULL 1 2 1 3 1
NULL 1 2 1 2 3
NULL 1 2 1 1 2
SELECT * FROM graph WHERE latch is NULL and origid=1;
latch origid destid weight seq linkid
NULL 1 NULL 1 2 3
NULL 1 NULL 1 1 2
SELECT * FROM graph WHERE latch is NULL and destid=1;
latch origid destid weight seq linkid
NULL NULL 1 1 2 3
NULL NULL 1 1 1 2
SELECT * FROM graph WHERE latch is NULL and origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch is NULL and origid is NULL;
latch origid destid weight seq linkid
NULL NULL NULL NULL NULL 1
NULL NULL NULL NULL NULL 2
NULL NULL NULL NULL NULL 3
NULL NULL NULL NULL NULL 4
NULL NULL NULL NULL NULL 5
NULL NULL NULL NULL NULL 6
INSERT INTO graph_base(from_id, to_id) VALUES (1,2);
ERROR 23000: Duplicate entry '1-2' for key 'PRIMARY'
DELETE FROM graph_base;
SELECT * FROM graph;
latch origid destid weight seq linkid
FLUSH TABLES;
TRUNCATE TABLE graph_base;
SELECT * FROM graph;
latch origid destid weight seq linkid
DROP TABLE graph_base;
FLUSH TABLES;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6;
ERROR 42S02: Table 'test.graph_base' doesn't exist
DROP TABLE graph;

View File

@ -1,137 +0,0 @@
--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 # 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 is 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 is 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 is 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 is 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 is 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 is 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 is NULL;
#--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
--echo # Return all edges when latch is NULL
SELECT * FROM graph WHERE latch is NULL;
SELECT * FROM graph WHERE latch is NULL and destid=2 and origid=1;
SELECT * FROM graph WHERE latch is NULL and origid=1;
SELECT * FROM graph WHERE latch is NULL and destid=1;
SELECT * FROM graph WHERE latch is NULL and origid=666;
SELECT * FROM graph WHERE latch is NULL and origid is 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);
DELETE FROM graph_base;
#-- Uncomment the following after fixing https://bugs.launchpad.net/oqgraph/+bug/1195735
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!
#-- For now dont report a separate bug as it may be a manifestation of https://bugs.launchpad.net/oqgraph/+bug/1195735
SELECT * FROM graph;
#-- Expect error if we pull the table out from under
DROP TABLE graph_base;
FLUSH TABLES;
--error S42S02
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6;
DROP TABLE graph;

View File

@ -1,127 +0,0 @@
DROP TABLE IF EXISTS not_backing;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS oqtable;
CREATE TABLE `not_backing` (
id int(10) unsigned NOT NULL DEFAULT '0',
id2 int(10) unsigned NOT NULL DEFAULT '0',
info varchar(20) DEFAULT NULL,
KEY name (info)
) DEFAULT CHARSET=latin1;
CREATE TABLE backing (
id int(10) unsigned NOT NULL DEFAULT '0',
id2 int(10) unsigned NOT NULL DEFAULT '0',
parent int(10) unsigned DEFAULT NULL,
weight real(10,4) NOT NULL DEFAULT 0.0,
info varchar(20) DEFAULT NULL,
not_id_type varchar(20) DEFAULT NULL,
not_weight_type varchar(20) DEFAULT NULL,
PRIMARY KEY (id),
KEY name (info)
) DEFAULT CHARSET=latin1;
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;
# Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table 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, ORIGID='id', DESTID='id2';
# Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table 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='', ORIGID='id', DESTID='id2';
# Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table 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='', ORIGID='id';
# Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table 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='', DESTID='id2';
# Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table 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='bogus', ORIGID='id', DESTID='id2';
# Expect: 'Table 'test.bogus' doesn't exist''
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;
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',ORIGID='', DESTID='id2';
# 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',ORIGID='bogus', DESTID='id2';
# Expect Invalid OQGRAPH backing store ('/oqtable'.origid attribute not set to a valid column of 'backing')'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store ('oqtable.origid' attribute not set to a valid column of 'backing')' 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',ORIGID='not_id_type', DESTID='id2';
# Expect 'Column 'backing.not_id_type' is not a not-null integer type'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Column 'backing.not_id_type' (origid) is not a not-null integer type' 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',ORIGID='id';
# Expect 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid 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',ORIGID='id',DESTID='';
# Expect 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid 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',ORIGID='id',DESTID='bogus';
# Expect Invalid OQGRAPH backing store ('/oqtable'.destid attribute not set to a valid column of 'backing')'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store ('oqtable.destid' attribute not set to a valid column of 'backing')' 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',ORIGID='id',DESTID='not_id_type';
# Expect 'Column 'backing.not_id_type' is not a not-null integer type'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Column 'backing.not_id_type' (destid) is not a not-null integer type or is a different type to origi' 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',ORIGID='id',DESTID='id';
# Expect 'Invalid OQGRAPH backing store ('/oqtable'.destid attribute set to same column as origid attribute)'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store ('oqtable.destid' attribute set to same column as origid attribute)' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch varchar(32) NULL 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',ORIGID='id',DESTID='id2',WEIGHT='';
# Expect 'Invalid OQGRAPH backing store ('/oqtable'.weight attribute not set to a valid column of 'backing')'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store ('oqtable.weight' attribute not set to a valid column of 'backing')' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch varchar(32) NULL 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',ORIGID='id',DESTID='id2',WEIGHT='bogus';
# Expect 'Invalid OQGRAPH backing store ('/oqtable'.weight attribute not set to a valid column of 'backing')'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store ('oqtable.weight' attribute not set to a valid column of 'backing')' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch varchar(32) NULL 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',ORIGID='id',DESTID='id2',WEIGHT='not_weight_type';
# Expect 'Column 'backing.not_weight_type' is not a not-null real type'
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Column 'backing.not_weight_type' (weight) is not a not-null real type' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch varchar(32) NULL 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',ORIGID='id',DESTID='id2',WEIGHT='weight';
DESCRIBE oqtable;
Field Type Null Key Default Extra
latch varchar(32) YES MUL NULL
origid bigint(20) unsigned YES NULL
destid bigint(20) unsigned YES NULL
weight double YES NULL
seq bigint(20) unsigned YES NULL
linkid bigint(20) unsigned YES NULL
DROP TABLE IF EXISTS oqtable;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS not_backing;

View File

@ -1,220 +0,0 @@
--disable_warnings
DROP TABLE IF EXISTS not_backing;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE `not_backing` (
id int(10) unsigned NOT NULL DEFAULT '0',
id2 int(10) unsigned NOT NULL DEFAULT '0',
info varchar(20) DEFAULT NULL,
KEY name (info)
) DEFAULT CHARSET=latin1;
CREATE TABLE backing (
id int(10) unsigned NOT NULL DEFAULT '0',
id2 int(10) unsigned NOT NULL DEFAULT '0',
parent int(10) unsigned DEFAULT NULL,
weight real(10,4) NOT NULL DEFAULT 0.0,
info varchar(20) DEFAULT NULL,
not_id_type varchar(20) DEFAULT NULL,
not_weight_type varchar(20) DEFAULT NULL,
PRIMARY KEY (id),
KEY name (info)
) DEFAULT CHARSET=latin1;
# oqgraph v2 create table should fail (missing attributes)
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;
--echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
--error 1296
DESCRIBE oqtable;
# no 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, ORIGID='id', DESTID='id2';
--echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
--error 1296
DESCRIBE oqtable;
# empty 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='', ORIGID='id', DESTID='id2';
--echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
--error 1296
DESCRIBE oqtable;
# empty 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='', ORIGID='id';
--echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
--error 1296
DESCRIBE oqtable;
# empty 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='', DESTID='id2';
--echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)'
--error 1296
DESCRIBE oqtable;
# non-existent 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='bogus', ORIGID='id', DESTID='id2';
--echo # Expect: 'Table 'test.bogus' doesn't exist''
--disable_warnings
--error 1146
DESCRIBE oqtable;
--enable_warnings
# 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
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='backing', DESTID='id2';
--echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)'
--error 1296
DESCRIBE oqtable;
# empty origid
--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='backing',ORIGID='', DESTID='id2';
--echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)'
--error 1296
DESCRIBE oqtable;
# invalid origid 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='backing',ORIGID='bogus', DESTID='id2';
--echo # Expect Invalid OQGRAPH backing store ('/oqtable'.origid attribute not set to a valid column of 'backing')'
--error 1296
DESCRIBE oqtable;
# wrong type origid
--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='backing',ORIGID='not_id_type', DESTID='id2';
--echo # Expect 'Column 'backing.not_id_type' is not a not-null integer type'
--error 1296
DESCRIBE oqtable;
# missing destid
--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='backing',ORIGID='id';
--echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)'
--error 1296
DESCRIBE oqtable;
# empty destid
--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='backing',ORIGID='id',DESTID='';
--echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)'
--error 1296
DESCRIBE oqtable;
# invalid destid 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='backing',ORIGID='id',DESTID='bogus';
--echo # Expect Invalid OQGRAPH backing store ('/oqtable'.destid attribute not set to a valid column of 'backing')'
--error 1296
DESCRIBE oqtable;
# wrong type destid
--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='backing',ORIGID='id',DESTID='not_id_type';
--echo # Expect 'Column 'backing.not_id_type' is not a not-null integer type'
--error 1296
DESCRIBE oqtable;
# same origid and destid
--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='backing',ORIGID='id',DESTID='id';
--echo # Expect 'Invalid OQGRAPH backing store ('/oqtable'.destid attribute set to same column as origid attribute)'
--error 1296
DESCRIBE oqtable;
# invalid weight reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL 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',ORIGID='id',DESTID='id2',WEIGHT='';
--echo # Expect 'Invalid OQGRAPH backing store ('/oqtable'.weight attribute not set to a valid column of 'backing')'
--error 1296
DESCRIBE oqtable;
# invalid weight reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL 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',ORIGID='id',DESTID='id2',WEIGHT='bogus';
--echo # Expect 'Invalid OQGRAPH backing store ('/oqtable'.weight attribute not set to a valid column of 'backing')'
--error 1296
DESCRIBE oqtable;
# wrong type weight
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL 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',ORIGID='id',DESTID='id2',WEIGHT='not_weight_type';
--echo # Expect 'Column 'backing.not_weight_type' is not a not-null real type'
--error 1296
DESCRIBE oqtable;
# all valid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch varchar(32) NULL 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',ORIGID='id',DESTID='id2',WEIGHT='weight';
DESCRIBE oqtable;
#-- Expect an error if we attempt to use a view as the backing store
#-- 'VIEWs are not supported for an OQGRAPH backing store.'
#-- TODO
#-- TODO - what happens if we make two tables with the same backing store?
#-- TODO - what happens if data_table is a TEMPORARY table?
# cleanup
--disable_warnings
DROP TABLE IF EXISTS oqtable;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS not_backing;
--enable_warnings

View File

@ -1,150 +0,0 @@
DROP TABLE IF EXISTS not_backing;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS oqtable;
CREATE TABLE `not_backing` (
id int(10) unsigned NOT NULL DEFAULT '0',
info varchar(20) DEFAULT NULL,
KEY name (info)
) DEFAULT CHARSET=latin1;
CREATE TABLE backing (
id int(10) unsigned NOT NULL DEFAULT '0',
nullparent int(10) unsigned DEFAULT NULL,
parent int(10) unsigned DEFAULT 1 NOT NULL,
weight real(10,4) NOT NULL DEFAULT 0.0,
info varchar(20) DEFAULT NULL,
not_id_type varchar(20) DEFAULT NULL,
not_weight_type varchar(20) DEFAULT NULL,
PRIMARY KEY (id),
KEY name (info)
) DEFAULT CHARSET=latin1;
SET GLOBAL oqgraph_allow_create_integer_latch=true;
The next warnings 1287 are expected
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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;
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='bogus';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
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 SMALLINT UNSIGNED 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='Ω Ohms Tennis Ball 〄';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
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 SMALLINT UNSIGNED 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', ORIGID='id';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
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 SMALLINT UNSIGNED 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',ORIGID='bogus';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='not_id_type';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='bogus';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store ('oqtable.destid' attribute not set to a valid column of 'backing')' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='not_id_type';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Column 'backing.not_id_type' (destid) is not a not-null integer type or is a different type to origi' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='bogus',DESTID='id';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store ('oqtable.origid' attribute not set to a valid column of 'backing')' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='not_id_type',DESTID='id';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Column 'backing.not_id_type' (origid) is not a not-null integer type' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='id';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store ('oqtable.destid' attribute set to same column as origid attribute)' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='parent',WEIGHT='bogus';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Invalid OQGRAPH backing store ('oqtable.weight' attribute not set to a valid column of 'backing')' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='parent',WEIGHT='not_weight_type';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Column 'backing.not_weight_type' (weight) is not a not-null real type' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='nullparent',DESTID='id',WEIGHT='weight';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Column 'backing.nullparent' (origid) is not a not-null integer type' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='nullparent',WEIGHT='weight';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
ERROR HY000: Got error -1 'Column 'backing.nullparent' (destid) is not a not-null integer type or is a different type to origid' from OQGRAPH
DROP TABLE IF EXISTS oqtable;
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='parent',WEIGHT='weight';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
DESCRIBE oqtable;
Field Type Null Key Default Extra
latch smallint(5) unsigned YES MUL NULL
origid bigint(20) unsigned YES NULL
destid bigint(20) unsigned YES NULL
weight double YES NULL
seq bigint(20) unsigned YES NULL
linkid bigint(20) unsigned YES NULL
DROP TABLE IF EXISTS oqtable;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS not_backing;
SET GLOBAL oqgraph_allow_create_integer_latch=false;

View File

@ -1,202 +0,0 @@
--disable_warnings
DROP TABLE IF EXISTS not_backing;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE `not_backing` (
id int(10) unsigned NOT NULL DEFAULT '0',
info varchar(20) DEFAULT NULL,
KEY name (info)
) DEFAULT CHARSET=latin1;
CREATE TABLE backing (
id int(10) unsigned NOT NULL DEFAULT '0',
nullparent int(10) unsigned DEFAULT NULL,
parent int(10) unsigned DEFAULT 1 NOT NULL,
weight real(10,4) NOT NULL DEFAULT 0.0,
info varchar(20) DEFAULT NULL,
not_id_type varchar(20) DEFAULT NULL,
not_weight_type varchar(20) DEFAULT NULL,
PRIMARY KEY (id),
KEY name (info)
) DEFAULT CHARSET=latin1;
# Here we enable scaffolding to let us create a deprecated table
# so we can check that the new code will still allow queries to be performed
# on a legacy database
# It should still generate a warning (1287) - but I dont know how to test for that
#
# latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future
# release. Please use 'latch VARCHAR(32) NULL' instead
#
SET GLOBAL oqgraph_allow_create_integer_latch=true;
--echo The next warnings 1287 are expected
# oqgraph v2 create table should fail (missing attributes)
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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;
--error 1296
DESCRIBE oqtable;
# attributes test
# empty table reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='';
--error 1296
DESCRIBE oqtable;
# non-existent table reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='bogus';
--error 1296
DESCRIBE oqtable;
# UTF in table name, make sure it doesnt crash
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='Ω Ohms Tennis Ball 〄';
--error 1296
DESCRIBE oqtable;
# Invalid backing table (backing table has no primary key)
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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', ORIGID='id';
--error 1296
DESCRIBE oqtable;
# table with empty origid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='';
--error 1296
DESCRIBE oqtable;
# invalid origid reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='bogus';
--error 1296
DESCRIBE oqtable;
# wrong type origid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='not_id_type';
--error 1296
DESCRIBE oqtable;
# missing destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id';
--error 1296
DESCRIBE oqtable;
# empty destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='';
--error 1296
DESCRIBE oqtable;
# invalid destid reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='bogus';
--error 1296
DESCRIBE oqtable;
# wrong type destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='not_id_type';
--error 1296
DESCRIBE oqtable;
# invalid origid with valid destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='bogus',DESTID='id';
--error 1296
DESCRIBE oqtable;
# wrong type origid with valid destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='not_id_type',DESTID='id';
--error 1296
DESCRIBE oqtable;
# same origid and destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='id';
--error 1296
DESCRIBE oqtable;
# invalid weight reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='parent',WEIGHT='bogus';
--error 1296
DESCRIBE oqtable;
# wrong type weight
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='parent',WEIGHT='not_weight_type';
--error 1296
DESCRIBE oqtable;
# NULLABLE ORIGID
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='nullparent',DESTID='id',WEIGHT='weight';
--error 1296
DESCRIBE oqtable;
# NULLABLE DESTID
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='nullparent',WEIGHT='weight';
--error 1296
DESCRIBE oqtable;
# all valid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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',ORIGID='id',DESTID='parent',WEIGHT='weight';
DESCRIBE oqtable;
# cleanup
--disable_warnings
DROP TABLE IF EXISTS oqtable;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS not_backing;
--enable_warnings
SET GLOBAL oqgraph_allow_create_integer_latch=false;

View File

@ -1,31 +0,0 @@
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);
INSERT INTO graph_base(from_id, to_id) VALUES (3,2), (2,3);
INSERT INTO graph_base(from_id, to_id) VALUES (1,3), (3,1);
insert into graph values (NULL, 1, 2, 3.0, NULL, NULL);
ERROR HY000: Table 'graph' is read only
delete from graph;
ERROR HY000: Table 'graph' is read only
truncate graph;
ERROR HY000: Table 'graph' is read only
update graph set origid=123;
ERROR HY000: Table 'graph' is read only
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,48 +0,0 @@
--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);
INSERT INTO graph_base(from_id, to_id) VALUES (3,2), (2,3);
INSERT INTO graph_base(from_id, to_id) VALUES (1,3), (3,1);
# -- check readonly'ness
--error 1036
insert into graph values (NULL, 1, 2, 3.0, NULL, NULL);
--error 1036
delete from graph;
--error 1036
truncate graph;
# This was hitting bug https://bugs.launchpad.net/oqgraph/+bug/1233113
--error 1036
update graph set origid=123;
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,42 +0,0 @@
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
DROP TABLE IF EXISTS graph2;
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);
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
select * from graph where latch is null and origid=1;
latch origid destid weight seq linkid
NULL 1 NULL 1 2 3
NULL 1 NULL 1 1 2
select * from graph where latch is null and destid=2;
latch origid destid weight seq linkid
NULL NULL 2 1 1 1
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,39 +0,0 @@
--disable_warnings
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
DROP TABLE IF EXISTS graph2;
--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);
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);
select * from graph where latch is null;
select * from graph where latch is null and origid=1;
select * from graph where latch is null and destid=2;
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,99 +0,0 @@
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;
The next error 140 + 1005 is expected
CREATE TABLE graph (
latch SMALLINT UNSIGNED 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';
ERROR HY000: Can't create table `test`.`graph` (errno: 140 "Wrong create options")
SET GLOBAL oqgraph_allow_create_integer_latch=true;
The next warning 1287 is expected
CREATE TABLE graph (
latch SMALLINT UNSIGNED 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';
Warnings:
Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead
SET GLOBAL oqgraph_allow_create_integer_latch=false;
The next error 140 + 1005 is expected
CREATE TABLE graph_again (
latch SMALLINT UNSIGNED 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';
ERROR HY000: Can't create table `test`.`graph_again` (errno: 140 "Wrong create options")
# Populating base table
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);
# Exercising latch==2
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
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 = 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
# Exercising latch==1
SELECT * FROM graph WHERE latch=1 AND origid=1 AND destid=6;
latch origid destid weight seq linkid
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=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
# Adding new row to base table
INSERT INTO graph_base (from_id,to_id) VALUES (4,6);
# Deleting rows from base table
DELETE FROM graph_base WHERE from_id=5;
DELETE FROM graph_base WHERE from_id=3 AND to_id=5;
# Execising latch==1 on new data
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
DROP TABLE IF EXISTS graph;
DROP TABLE IF EXISTS graph_base;

View File

@ -1,106 +0,0 @@
--disable_warnings
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
--enable_warnings
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;
# Backwards compatibility test
# First we ensure the scaffolding is disabled (default situation)
# and check we cant create a table with an integer latch
# Assume this is the default, so dont explicity set false yet:
# SET GLOBAL oqgraph_allow_create_integer_latch=false;
--echo The next error 140 + 1005 is expected
--error 140
--error 1005
CREATE TABLE graph (
latch SMALLINT UNSIGNED 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';
# Here we enable scaffolding to let us create a deprecated table
# so we can check that the new code will still allow queries to be performed
# on a legacy database
# It should still generate a warning (1287) - but I dont know how to test for that
#
# latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future
# release. Please use 'latch VARCHAR(32) NULL' instead
#
SET GLOBAL oqgraph_allow_create_integer_latch=true;
--echo The next warning 1287 is expected
CREATE TABLE graph (
latch SMALLINT UNSIGNED 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';
# Prevent further tables being create this way again
# and make sure the set is effective ...
SET GLOBAL oqgraph_allow_create_integer_latch=false;
--echo The next error 140 + 1005 is expected
--error 140
--error 1005
CREATE TABLE graph_again (
latch SMALLINT UNSIGNED 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';
# Regression test expected v2 behaviour in this situation
--echo # Populating base table
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 # Exercising latch==2
SELECT * FROM graph WHERE latch = 2 AND origid = 1 AND weight = 1;
SELECT * FROM graph WHERE latch = 2 AND origid = 1 AND weight = 2;
SELECT * FROM graph WHERE latch = 2 AND origid = 1 AND (weight = 1 OR weight = 2);
--echo # Exercising latch==1
SELECT * FROM graph WHERE latch=1 AND origid=1 AND destid=6;
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=0 and destid=2 and origid=1;
--echo # Adding new row to base table
INSERT INTO graph_base (from_id,to_id) VALUES (4,6);
--echo # Deleting rows from base table
DELETE FROM graph_base WHERE from_id=5;
DELETE FROM graph_base WHERE from_id=3 AND to_id=5;
--echo # Execising latch==1 on new data
SELECT * FROM graph WHERE latch=1 AND origid=1 AND destid=6;
SELECT * FROM graph WHERE latch=1 AND origid=6 AND destid=1;
# FIXME - if the following DROPs are missing then mysql will segfault on exit
# indicating an ordering dependency on destruction somewhere...
DROP TABLE IF EXISTS graph;
DROP TABLE IF EXISTS graph_base;

View File

@ -1,44 +0,0 @@
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,
another_id INT UNSIGNED NOT NULL DEFAULT 1,
w DOUBLE NOT NULL DEFAULT 1,
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='w';
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 (1,4), (4,1);
INSERT INTO graph_base(from_id, to_id) VALUES (3,4), (4,3);
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 1 4 1 NULL NULL
NULL 4 1 1 NULL NULL
NULL 3 4 1 NULL NULL
NULL 4 3 1 NULL NULL
SELECT * FROM graph WHERE latch='1' and destid=2 and origid=1;
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 destid=2 and origid=1 order by seq;
latch origid destid weight seq linkid
1 1 2 NULL 0 1
1 1 2 1 1 2
DROP TABLE graph;
DROP TABLE graph_base;

View File

@ -1,46 +0,0 @@
# Regression test for https://bugs.launchpad.net/oqgraph/+bug/1133093
# Reproduce bug where order by seq crashes
--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,
another_id INT UNSIGNED NOT NULL DEFAULT 1,
w DOUBLE NOT NULL DEFAULT 1,
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='w';
# -- do some stuff
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 (1,4), (4,1);
INSERT INTO graph_base(from_id, to_id) VALUES (3,4), (4,3);
SELECT * from graph;
SELECT * FROM graph WHERE latch='1' and destid=2 and origid=1;
SELECT * FROM graph WHERE latch='1' and destid=2 and origid=1 order by seq;
DROP TABLE graph;
DROP TABLE graph_base;
# Probably a separate issue: if the test is exited without dropping the tables at all
# then there is a memory leak reported

View File

@ -1,46 +0,0 @@
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,
another_id INT UNSIGNED NOT NULL DEFAULT 1,
w DOUBLE NOT NULL DEFAULT 1,
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='w';
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 (1,4), (4,1);
INSERT INTO graph_base(from_id, to_id) VALUES (3,4), (4,3);
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 1 4 1 NULL NULL
NULL 4 1 1 NULL NULL
NULL 3 4 1 NULL NULL
NULL 4 3 1 NULL NULL
SELECT * FROM graph WHERE destid=2 and origid=1;
latch origid destid weight seq linkid
NULL 1 2 1 NULL NULL
alter table graph ORIGID = 'another_id';
ERROR HY000: Storage engine OQGRAPH of the table `test`.`graph` doesn't have this option
alter table graph ORIGID = 'something_else';
ERROR HY000: Storage engine OQGRAPH of the table `test`.`graph` doesn't have this option
DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,59 +0,0 @@
# Regression test for https://bugs.launchpad.net/oqgraph/+bug/1134355
#--reproduce bug where renaming a column in the graph crashes instead of returning an error
--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,
another_id INT UNSIGNED NOT NULL DEFAULT 1,
w DOUBLE NOT NULL DEFAULT 1,
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='w';
# -- do some stuff
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 (1,4), (4,1);
INSERT INTO graph_base(from_id, to_id) VALUES (3,4), (4,3);
SELECT * from graph;
SELECT * FROM graph WHERE destid=2 and origid=1;
# We cant do this anyway because of read onlyness of table.... 1036 == read only
# In any case I changed the flags to make alter unsupported; later we can try and work out why the core doesnt help us clean up properly
# --error 1036
--error 1031
alter table graph ORIGID = 'another_id';
# But we need that to hold even in an invalid situation!
# -- bug was: the following alter table would crash, instead of returning error 1296
# -- currently following may not crash, but does with the previous error 1036 causing statement present
# 'attribute not set to a valid column of 'xxx' - note currently truncating to graph_b instead of graph_base for some reason...
#--error 1296
--error 1031
alter table graph ORIGID = 'something_else';
DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,32 +0,0 @@
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);
One select of any clauses at all on graph here caused a hang on the select after the DELETE FROM
SELECT * FROM graph WHERE destid=2 and origid=1;
latch origid destid weight seq linkid
NULL 1 2 1 NULL NULL
DELETE FROM graph_base;
SELECT * from graph;
latch origid destid weight seq linkid
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;

View File

@ -1,44 +0,0 @@
# 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;

View File

@ -1,68 +0,0 @@
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;

View File

@ -1,71 +0,0 @@
# 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;

View File

@ -1,56 +0,0 @@
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;

View File

@ -1,51 +0,0 @@
# 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;

View File

@ -1,103 +0,0 @@
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;

View File

@ -1,68 +0,0 @@
# 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;

File diff suppressed because it is too large Load Diff

View File

@ -1,548 +0,0 @@
--disable_warnings
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
DROP TABLE IF EXISTS graph2;
--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';
#--
#-- 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 # Return all edges
#-- we note that when weight is NULL it defaults to 1
SELECT * FROM graph;
--echo # Currently count should be 13
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
--echo # Return all edges when latch is NULL - this is different to latch='' and same as no where clause
SELECT * FROM graph where latch is NULL;
--echo # Return all vertices, and subsets of vertices
SELECT * FROM graph where latch='';
SELECT * FROM graph where latch='0';
--echo # Currently count should be 11
SELECT count(*) FROM graph where latch='';
#-- get a subset of vertices
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='' 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='' 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?
#-- 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?"
#-- 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
#-- linkid is the other end
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;
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8; # <-- note, should return nothing
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;
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 666; # <-- note, should return nothing
#-- 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;
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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;
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; # <-- note, should return nothing
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 = '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); # <-- note, should return nothing
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);
#-- now do it in reverse - using destid find originating vertices
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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';
#-- 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;
SELECT * FROM graph WHERE latch = '2' AND origid = 8; # <-- note, should return nothing
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;
SELECT * FROM graph WHERE latch = '2' AND origid = 666; # <-- note, should return nothing
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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; # <-- note, should return nothing
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;
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); # <-- note, should return nothing
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);
SELECT * FROM graph WHERE latch = '2' AND destid = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 12;
SELECT * FROM graph WHERE latch = '2' AND destid = 1 and weight = 1;
#-- 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 = NULL;
SELECT * FROM graph WHERE latch = '2' AND weight = 1;
SELECT * FROM graph WHERE latch = '2';
--echo # Dijkstras algorithm tests
#-- We ask 'What is the shortest 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;
#-- 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;
#-- 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;
#-- reachable vertices
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 origid=4;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=5;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=6;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=7;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=8; # <-- note, should return nothing
SELECT * FROM graph WHERE latch='dijkstras' AND origid=9;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=11;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=12;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=666; # <-- note, should return nothing
#-- originating vertices
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 destid=4;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=5;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=6;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=7;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=8; # <-- note, should return nothing
SELECT * FROM graph WHERE latch='dijkstras' AND destid=9;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=10;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=11;
SELECT * FROM graph WHERE latch='dijkstras' AND destid=12;
--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; # <-- note, should return nothing
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;
SELECT * FROM graph WHERE latch='1' AND origid=1;
SELECT * FROM graph WHERE latch='1' AND origid=2;
SELECT * FROM graph WHERE latch='1' AND origid=3;
SELECT * FROM graph WHERE latch='1' AND origid=4;
SELECT * FROM graph WHERE latch='1' AND origid=5;
SELECT * FROM graph WHERE latch='1' AND origid=6;
SELECT * FROM graph WHERE latch='1' AND origid=7;
SELECT * FROM graph WHERE latch='1' AND origid=8; # <-- note, should return nothing
SELECT * FROM graph WHERE latch='1' AND origid=9;
SELECT * FROM graph WHERE latch='1' AND origid=10;
SELECT * FROM graph WHERE latch='1' AND origid=11;
SELECT * FROM graph WHERE latch='1' AND origid=12;
SELECT * FROM graph WHERE latch='1' AND origid=666; # <-- note, should return nothing
SELECT * FROM graph WHERE latch='1' AND destid=1;
SELECT * FROM graph WHERE latch='1' AND destid=2;
SELECT * FROM graph WHERE latch='1' AND destid=3;
SELECT * FROM graph WHERE latch='1' AND destid=4;
SELECT * FROM graph WHERE latch='1' AND destid=5;
SELECT * FROM graph WHERE latch='1' AND destid=6;
SELECT * FROM graph WHERE latch='1' AND destid=7;
SELECT * FROM graph WHERE latch='1' AND destid=8; # <-- note, should return nothing
SELECT * FROM graph WHERE latch='1' AND destid=9;
SELECT * FROM graph WHERE latch='1' AND destid=10;
SELECT * FROM graph WHERE latch='1' AND destid=11;
SELECT * FROM graph WHERE latch='1' AND destid=12;
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
#-- 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;
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
#-- add some extra and check
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;
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);
SELECT * FROM graph;
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
--echo # And delete all references to node 5
DELETE FROM graph_base WHERE from_id=5;
DELETE FROM graph_base WHERE from_id=3 AND to_id=5;
#-- The following queries would currently return incorrect results
#-- 6 rows instead of 21
#-- Maybe manifestation of https://bugs.launchpad.net/oqgraph/+bug/796647
#-- SELECT count(*) FROM graph;
#-- SELECT count(*) FROM graph_base;
--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 (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;
#-- The following line would hang mysqld currently, see bug https://bugs.launchpad.net/oqgraph/+bug/1195735
#-- SELECT * FROM graph;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,25 +0,0 @@
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);
INSERT INTO graph_base(from_id, to_id) VALUES (3,2), (2,3);
INSERT INTO graph_base(from_id, to_id) VALUES (1,3), (3,1);
update graph set origid=123;
ERROR HY000: Table 'graph' is read only
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,38 +0,0 @@
--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);
INSERT INTO graph_base(from_id, to_id) VALUES (3,2), (2,3);
INSERT INTO graph_base(from_id, to_id) VALUES (1,3), (3,1);
# The following line crashes when MTR run with --gdb, see bug https://bugs.launchpad.net/oqgraph/+bug/1233113
--error 1036
update graph set origid=123;
# Otherwise, MTR hangs on the next line
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,40 +0,0 @@
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
CREATE TABLE graph_base (
von INT NOT NULL,
nach INT NOT NULL,
weight DOUBLE NOT NULL,
PRIMARY KEY (von,nach),
INDEX (von)
) 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='von' DESTID='nach' WEIGHT='weight';
INSERT INTO graph_base(von,nach,weight) VALUES (3,5,2), (5,4,1), (5,6,1);
SELECT * FROM graph_base;
von nach weight
3 5 2
5 4 1
5 6 1
SELECT * FROM graph;
latch origid destid weight seq linkid
NULL 3 5 2 NULL NULL
NULL 5 4 1 NULL NULL
NULL 5 6 1 NULL NULL
INSERT INTO graph_base(von,nach,weight) VALUES (6,3,1);
SELECT * FROM graph;
latch origid destid weight seq linkid
NULL 3 5 2 NULL NULL
NULL 5 4 1 NULL NULL
NULL 5 6 1 NULL NULL
NULL 6 3 1 NULL NULL
FLUSH TABLES;
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,43 +0,0 @@
--disable_warnings
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
--enable_warnings
# Create the backing store
CREATE TABLE graph_base (
von INT NOT NULL,
nach INT NOT NULL,
weight DOUBLE NOT NULL,
PRIMARY KEY (von,nach),
INDEX (von)
) 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='von' DESTID='nach' WEIGHT='weight';
INSERT INTO graph_base(von,nach,weight) VALUES (3,5,2), (5,4,1), (5,6,1);
SELECT * FROM graph_base;
SELECT * FROM graph;
INSERT INTO graph_base(von,nach,weight) VALUES (6,3,1);
SELECT * FROM graph;
FLUSH TABLES;
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,221 +0,0 @@
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);
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);
SELECT count(*) FROM graph;
count(*)
8
SELECT count(*) FROM graph_base;
count(*)
8
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);
SELECT count(*) FROM graph;
count(*)
13
SELECT count(*) FROM graph_base;
count(*)
13
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 count(*) FROM graph;
count(*)
16
SELECT count(*) FROM graph_base;
count(*)
16
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);
INSERT INTO graph_base(from_id, to_id) VALUES (10,11);
SELECT count(*) FROM graph;
count(*)
18
SELECT count(*) FROM graph_base;
count(*)
18
INSERT INTO graph_base(from_id, to_id) VALUES (21,22);
INSERT INTO graph_base(from_id, to_id) VALUES (4,17);
INSERT INTO graph_base(from_id, to_id) VALUES (4,16);
INSERT INTO graph_base(from_id, to_id) VALUES (17,18);
INSERT INTO graph_base (from_id,to_id) VALUES (4,6);
SELECT count(*) FROM graph;
count(*)
23
SELECT count(*) FROM graph_base;
count(*)
23
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 15 1 NULL NULL
NULL 11 12 1 NULL NULL
NULL 12 10 1 NULL NULL
NULL 11 13 1 NULL NULL
NULL 10 14 1 NULL NULL
NULL 14 13 1 NULL NULL
NULL 15 13 1 NULL NULL
NULL 10 11 1 NULL NULL
NULL 21 22 1 NULL NULL
NULL 4 17 1 NULL NULL
NULL 4 16 1 NULL NULL
NULL 17 18 1 NULL NULL
NULL 4 6 1 NULL NULL
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 15
0 NULL NULL NULL NULL 11
0 NULL NULL NULL NULL 12
0 NULL NULL NULL NULL 13
0 NULL NULL NULL NULL 14
0 NULL NULL NULL NULL 21
0 NULL NULL NULL NULL 22
0 NULL NULL NULL NULL 17
0 NULL NULL NULL NULL 16
0 NULL NULL NULL NULL 18
SELECT * from graph_base;
from_id to_id
1 2
1 3
2 1
3 1
3 4
4 3
4 6
4 16
4 17
5 6
5 7
6 5
9 9
10 11
10 14
10 15
11 12
11 13
12 10
14 13
15 13
17 18
21 22
# And delete all references to node 5
DELETE FROM graph_base WHERE from_id=5;
DELETE FROM graph_base WHERE from_id=3 AND to_id=5;
# This is currently bogus:
SELECT count(*) FROM graph;
count(*)
21
SELECT count(*) FROM graph_base;
count(*)
21
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 6 5 1 NULL NULL
NULL 9 9 1 NULL NULL
NULL 10 15 1 NULL NULL
NULL 11 12 1 NULL NULL
NULL 12 10 1 NULL NULL
NULL 11 13 1 NULL NULL
NULL 10 14 1 NULL NULL
NULL 14 13 1 NULL NULL
NULL 15 13 1 NULL NULL
NULL 10 11 1 NULL NULL
NULL 21 22 1 NULL NULL
NULL 4 17 1 NULL NULL
NULL 4 16 1 NULL NULL
NULL 17 18 1 NULL NULL
NULL 4 6 1 NULL NULL
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 6
0 NULL NULL NULL NULL 5
0 NULL NULL NULL NULL 9
0 NULL NULL NULL NULL 10
0 NULL NULL NULL NULL 15
0 NULL NULL NULL NULL 11
0 NULL NULL NULL NULL 12
0 NULL NULL NULL NULL 13
0 NULL NULL NULL NULL 14
0 NULL NULL NULL NULL 21
0 NULL NULL NULL NULL 22
0 NULL NULL NULL NULL 17
0 NULL NULL NULL NULL 16
0 NULL NULL NULL NULL 18
SELECT * from graph_base;
from_id to_id
1 2
1 3
2 1
3 1
3 4
4 3
4 6
4 16
4 17
6 5
9 9
10 11
10 14
10 15
11 12
11 13
12 10
14 13
15 13
17 18
21 22
DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,97 +0,0 @@
--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);
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);
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
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);
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
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 count(*) FROM graph;
SELECT count(*) FROM graph_base;
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);
INSERT INTO graph_base(from_id, to_id) VALUES (10,11);
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
INSERT INTO graph_base(from_id, to_id) VALUES (21,22);
INSERT INTO graph_base(from_id, to_id) VALUES (4,17);
INSERT INTO graph_base(from_id, to_id) VALUES (4,16);
INSERT INTO graph_base(from_id, to_id) VALUES (17,18);
INSERT INTO graph_base (from_id,to_id) VALUES (4,6);
#-- Without this when the line immediately after gets executed
#-- we get a segfault
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
SELECT * from graph;
SELECT * from graph where latch='0';
SELECT * from graph_base;
--echo # And delete all references to node 5
DELETE FROM graph_base WHERE from_id=5;
DELETE FROM graph_base WHERE from_id=3 AND to_id=5;
#-- The following queries would currently return incorrect results
#-- 6 rows instead of 21
#-- Maybe manifestation of https://bugs.launchpad.net/oqgraph/+bug/796647
--echo # This is currently bogus:
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
SELECT * from graph;
SELECT * from graph where latch='0';
SELECT * from graph_base;
DELETE FROM graph_base;
#-- The following line would hang mysqld currently, see bug https://bugs.launchpad.net/oqgraph/+bug/1195735
#-- SELECT * FROM graph;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,127 +0,0 @@
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 count(*) FROM graph;
count(*)
2
SELECT count(*) FROM graph_base;
count(*)
2
INSERT INTO graph_base(from_id, to_id) VALUES (12,10);
SELECT count(*) FROM graph;
count(*)
3
SELECT count(*) FROM graph_base;
count(*)
3
INSERT INTO graph_base(from_id, to_id) VALUES (14,13);
SELECT count(*) FROM graph;
count(*)
4
SELECT count(*) FROM graph_base;
count(*)
4
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);
INSERT INTO graph_base(from_id, to_id) VALUES (10,11);
SELECT count(*) FROM graph;
count(*)
7
SELECT count(*) FROM graph_base;
count(*)
7
INSERT INTO graph_base(from_id, to_id) VALUES (21,22);
INSERT INTO graph_base (from_id,to_id) VALUES (4,6);
SELECT count(*) FROM graph;
count(*)
9
SELECT count(*) FROM graph_base;
count(*)
9
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 12
0 NULL NULL NULL NULL 10
0 NULL NULL NULL NULL 14
0 NULL NULL NULL NULL 13
0 NULL NULL NULL NULL 15
0 NULL NULL NULL NULL 11
0 NULL NULL NULL NULL 21
0 NULL NULL NULL NULL 22
0 NULL NULL NULL NULL 4
0 NULL NULL NULL NULL 6
SELECT * FROM graph_base;
from_id to_id
1 2
2 1
4 6
10 11
10 15
12 10
14 13
15 13
21 22
# And delete all references to node 2
DELETE FROM graph_base WHERE from_id=2;
DELETE FROM graph_base WHERE to_id=2;
SELECT count(*) FROM graph;
count(*)
7
SELECT count(*) FROM graph_base;
count(*)
7
SELECT * FROM graph where latch='0';
latch origid destid weight seq linkid
0 NULL NULL NULL NULL 12
0 NULL NULL NULL NULL 10
0 NULL NULL NULL NULL 14
0 NULL NULL NULL NULL 13
0 NULL NULL NULL NULL 15
0 NULL NULL NULL NULL 11
0 NULL NULL NULL NULL 21
0 NULL NULL NULL NULL 22
0 NULL NULL NULL NULL 4
0 NULL NULL NULL NULL 6
SELECT * FROM graph_base;
from_id to_id
4 6
10 11
10 15
12 10
14 13
15 13
21 22
DELETE FROM graph_base;
SELECT count(*) FROM graph;
count(*)
0
SELECT count(*) FROM graph_base;
count(*)
0
SELECT * FROM graph where latch='0';
latch origid destid weight seq linkid
SELECT * FROM graph_base;
from_id to_id
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,84 +0,0 @@
--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);
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
INSERT INTO graph_base(from_id, to_id) VALUES (12,10);
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
INSERT INTO graph_base(from_id, to_id) VALUES (14,13);
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
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);
INSERT INTO graph_base(from_id, to_id) VALUES (10,11);
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
INSERT INTO graph_base(from_id, to_id) VALUES (21,22);
INSERT INTO graph_base (from_id,to_id) VALUES (4,6);
#-- Without this when the line immediately after gets executed
#-- we get a segfault
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
SELECT * FROM graph where latch='0';
SELECT * FROM graph_base;
--echo # And delete all references to node 2
DELETE FROM graph_base WHERE from_id=2;
DELETE FROM graph_base WHERE to_id=2;
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
SELECT * FROM graph where latch='0';
SELECT * FROM graph_base;
DELETE FROM graph_base;
SELECT count(*) FROM graph;
SELECT count(*) FROM graph_base;
SELECT * FROM graph where latch='0';
SELECT * FROM graph_base;
#-- The following line would hang mysqld currently, see bug https://bugs.launchpad.net/oqgraph/+bug/1195735
#-- SELECT * FROM graph;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;

View File

@ -1,28 +0,0 @@
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;
latch origid destid weight seq linkid
NULL 1 2 1 NULL NULL
NULL 2 1 1 NULL NULL
DROP TABLE graph_base;
FLUSH TABLES;
SELECT * FROM graph;
ERROR 42S02: Table 'test.graph_base' doesn't exist
DROP TABLE graph;

View File

@ -1,38 +0,0 @@
--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);
SELECT * FROM graph;
DROP TABLE graph_base;
FLUSH TABLES; # <-- without this, we still had it open so never see error...
--error S42S02
SELECT * FROM graph;
DROP TABLE graph;
# gdb script:
# bre ha_oqgraph::rnd_init
# ignore 1 1
# run

View File

@ -1,111 +0,0 @@
DROP TABLE IF EXISTS rsb, rsb_graph;
CREATE TABLE rsb (
f INT UNSIGNED NOT NULL,
t INT UNSIGNED NOT NULL,
weight FLOAT NOT NULL,
PRIMARY KEY (`f`,`t`),
KEY `t` (`t`)
) ENGINE=MyISAM;
CREATE TABLE rsb_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='rsb' origid='f' destid='t' weight='weight';
DROP PROCEDURE IF EXISTS randnotx|
CREATE PROCEDURE randnotx (INOUT rseed INT, IN items INT, IN x INT, OUT rval INT) DETERMINISTIC
BEGIN
REPEAT
# Simple LCG (BSD)
SET rseed = (rseed * 1103515245 + 12345) & 2147483647;
SET rval = ((rseed >> 16) & 32767) MOD items;
UNTIL rval <> x
END REPEAT;
END;|
DROP PROCEDURE IF EXISTS randgraphproc|
CREATE PROCEDURE randgraphproc (IN items INT, IN friends INT, IN fanof INT, IN maxweight INT) DETERMINISTIC
BEGIN
DECLARE i,j,weight,rseed,rval INT;
SET rseed = items;
SET i = 0;
WHILE i < items DO
SET j = 0;
WHILE j < (friends + fanof) DO
CALL randnotx(rseed,items,i,rval);
IF (maxweight > 0) THEN
CALL randnotx(rseed,items,-1,weight);
SET weight = weight MOD maxweight;
ELSE
SET weight = 0;
END IF;
INSERT IGNORE rsb VALUES (i,rval,weight);
IF (j < friends) THEN
INSERT IGNORE rsb VALUES (rval,i,weight);
END IF;
SET j = j + 1;
END WHILE;
SET i = i + 1;
END WHILE;
END;|
CALL randgraphproc(10000,5,2,3);
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=1 AND destid=20;
GROUP_CONCAT(linkid ORDER BY seq)
1,5378,9993,8029,5613,9338,3730,7694,3546,9658,2825,6157,6461,1246,8678,8811,20
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=1 AND destid=77;
GROUP_CONCAT(linkid ORDER BY seq)
1,5378,9993,8029,5613,9338,3730,7694,3546,2367,9994,3130,9577,7992,7995,53,8735,8654,9850,587,177,6509,8447,6927,6690,5454,1277,77
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=1 AND destid=203;
GROUP_CONCAT(linkid ORDER BY seq)
1,5378,9993,8597,6078,2632,8846,6514,3189,8336,3327,4653,203
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=1595 AND destid=8358;
GROUP_CONCAT(linkid ORDER BY seq)
1595,6255,7652,394,1532,3451,5615,9737,5886,8214,7462,6984,5822,5711,6363,2743,8584,7759,8683,7525,1874,212,5923,2399,3138,740,932,8358
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=1 AND destid=9999;
GROUP_CONCAT(linkid ORDER BY seq)
1,5378,9993,8597,6078,2632,7381,6403,9177,1637,9762,2610,319,1310,3579,9999
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=6841 AND destid=615;
GROUP_CONCAT(linkid ORDER BY seq)
6841,2979,9109,8306,7777,620,9982,8535,8151,6118,8654,9428,611,9696,3082,7219,9868,615
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=369 AND destid=1845;
GROUP_CONCAT(linkid ORDER BY seq)
369,4586,6078,8597,9993,8029,5613,2993,1637,9177,3451,5615,9104,4004,2818,8311,8996,9023,9975,3847,4988,4480,6739,7520,6040,4585,7632,3956,1319,2427,6606,3443,9114,2907,1130,2389,8613,1534,4856,6961,6636,9136,7504,2777,8273,8215,7681,8859,1480,7167,663,3433,4719,3773,1845
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=73 AND destid=914;
GROUP_CONCAT(linkid ORDER BY seq)
73,4247,9061,9994,3130,8274,9298,8790,8465,712,9028,646,1255,7384,6554,3193,914
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=12345 AND destid=500;
GROUP_CONCAT(linkid ORDER BY seq)
NULL
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=300 AND destid=54321;
GROUP_CONCAT(linkid ORDER BY seq)
NULL
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND origid=1;
COUNT(*)
10000
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND origid=8365;
COUNT(*)
10000
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND origid=976;
COUNT(*)
10000
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND origid=74;
COUNT(*)
10000
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND destid=1;
COUNT(*)
10000
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND destid=9999;
COUNT(*)
10000
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND destid=52;
COUNT(*)
10000
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND destid=6483;
COUNT(*)
10000
DROP TABLE rsb_graph, rsb;
DROP PROCEDURE randgraphproc;
DROP PROCEDURE randnotx;

View File

@ -1,131 +0,0 @@
--disable_warnings
DROP TABLE IF EXISTS rsb, rsb_graph;
--enable_warnings
CREATE TABLE rsb (
f INT UNSIGNED NOT NULL,
t INT UNSIGNED NOT NULL,
weight FLOAT NOT NULL,
PRIMARY KEY (`f`,`t`),
KEY `t` (`t`)
) ENGINE=MyISAM;
CREATE TABLE rsb_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='rsb' origid='f' destid='t' weight='weight';
# this graph generator is designed to be deterministic
# (so we don't need to ship a large test dataset)
# --source suite/oqgraph/randgraphproc.inc
# SQL implementation of randsocial.c for OQGRAPH
# Copyright (C) 2013 by Arjen Lentz <arjen@openquery.com> for Open Query
# GPL v2+ licensed with the rest of OQGRAPH
# for use in mysql-test
# 2013-03-01 first implementation based on randsocial.c in old oqgraph v2 tree
delimiter |;
--disable_warnings
DROP PROCEDURE IF EXISTS randnotx|
--enable_warnings
CREATE PROCEDURE randnotx (INOUT rseed INT, IN items INT, IN x INT, OUT rval INT) DETERMINISTIC
BEGIN
REPEAT
# Simple LCG (BSD)
SET rseed = (rseed * 1103515245 + 12345) & 2147483647;
SET rval = ((rseed >> 16) & 32767) MOD items;
UNTIL rval <> x
END REPEAT;
END;|
# this procedure is deterministic with its private seeded random generator
--disable_warnings
DROP PROCEDURE IF EXISTS randgraphproc|
--enable_warnings
CREATE PROCEDURE randgraphproc (IN items INT, IN friends INT, IN fanof INT, IN maxweight INT) DETERMINISTIC
BEGIN
DECLARE i,j,weight,rseed,rval INT;
SET rseed = items;
SET i = 0;
WHILE i < items DO
SET j = 0;
WHILE j < (friends + fanof) DO
CALL randnotx(rseed,items,i,rval);
IF (maxweight > 0) THEN
CALL randnotx(rseed,items,-1,weight);
SET weight = weight MOD maxweight;
ELSE
SET weight = 0;
END IF;
INSERT IGNORE rsb VALUES (i,rval,weight);
IF (j < friends) THEN
INSERT IGNORE rsb VALUES (rval,i,weight);
END IF;
SET j = j + 1;
END WHILE;
SET i = i + 1;
END WHILE;
END;|
DELIMITER ;|
# generate social graph of 10000 people having 5 friends (two-way) and being fan of 2 others (one-way)), max weight 3
CALL randgraphproc(10000,5,2,3);
# some random paths
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=1 AND destid=20;
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=1 AND destid=77;
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=1 AND destid=203;
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=1595 AND destid=8358;
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=1 AND destid=9999;
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=6841 AND destid=615;
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=369 AND destid=1845;
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=73 AND destid=914;
# nonexistent origin
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=12345 AND destid=500;
# noexistent destination
SELECT GROUP_CONCAT(linkid ORDER BY seq) FROM rsb_graph WHERE latch='dijkstras' AND origid=300 AND destid=54321;
# how many possible destinations from here
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND origid=1;
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND origid=8365;
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND origid=976;
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND origid=74;
# how many possible sources to here
# this doesn't appear to work right now in v3 ? #if 0 in code. check with Antony
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND destid=1;
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND destid=9999;
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND destid=52;
SELECT COUNT(*) FROM rsb_graph WHERE latch='dijkstras' AND destid=6483;
# breadth first
# other algorithms
# joins
# cleaning up our tables
DROP TABLE rsb_graph, rsb;
# cleaning up procs from randgraphproc.inc
DROP PROCEDURE randgraphproc;
DROP PROCEDURE randnotx;

View File

@ -1 +0,0 @@
--plugin-load-add=$HA_OQGRAPH_SO --enable-oqgraph

View File

@ -1,9 +0,0 @@
package My::Suite::OQGraph;
@ISA = qw(My::Suite);
return "No OQGraph" unless $ENV{HA_OQGRAPH_SO} or
$::mysqld_variables{'oqgraph'} eq "ON";
bless { };

View File

@ -1,30 +0,0 @@
!include include/default_my.cnf
[source src1]
type = xmlpipe2
xmlpipe_command = cat @ENV.MTR_SUITE_DIR/testdata.xml
[index test1]
source = src1
docinfo = extern
charset_type = utf-8
path = @ENV.MYSQLTEST_VARDIR/searchd/test1
[indexer]
mem_limit = 32M
[searchd]
read_timeout = 5
max_children = 30
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
log = @ENV.MYSQLTEST_VARDIR/searchd/sphinx-searchd.log
query_log = @ENV.MYSQLTEST_VARDIR/searchd/sphinx-query.log
#log-error = @ENV.MYSQLTEST_VARDIR/searchd/sphinx.log
pid_file = @ENV.MYSQLTEST_VARDIR/run/searchd.pid
port = @ENV.SPHINXSEARCH_PORT
[ENV]
SPHINXSEARCH_PORT = @OPT.port

View File

@ -1,56 +0,0 @@
create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://127.0.0.1:SPHINXSEARCH_PORT/*";
select * from ts where q='test';
id w q
1 2 test
2 2 test
4 1 test
drop table ts;
create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://127.0.0.1:SPHINXSEARCH_PORT/*";
select * from ts where q='test;filter=gid,1;mode=extended';
id w q
1 2421 test;filter=gid,1;mode=extended
2 2421 test;filter=gid,1;mode=extended
select * from ts where q='test|one;mode=extended';
id w q
1 3595 test|one;mode=extended
2 2460 test|one;mode=extended
4 1471 test|one;mode=extended
select * from ts where q='test;offset=1;limit=1';
id w q
2 2 test;offset=1;limit=1
alter table ts connection="sphinx://127.0.0.1:SPHINXSEARCH_PORT/test1";
select id, w from ts where q='one';
id w
1 2
drop table ts;
create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, gid int not null, _sph_count int not null, index(q) ) engine=sphinx connection="sphinx://127.0.0.1:SPHINXSEARCH_PORT/test1";
select * from ts;
id w q gid _sph_count
select * from ts where q='';
id w q gid _sph_count
1 1 1 0
2 1 1 0
3 1 2 0
4 1 2 0
select * from ts where q=';groupby=attr:gid';
id w q gid _sph_count
3 1 ;groupby=attr:gid 2 2
1 1 ;groupby=attr:gid 1 2
explain select * from ts where q=';groupby=attr:gid';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE ts ref q q 257 const 3 Using where with pushed condition
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch='index_condition_pushdown=off';
explain select * from ts where q=';groupby=attr:gid';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE ts ref q q 257 const 3 Using where with pushed condition
SET optimizer_switch=@save_optimizer_switch;
drop table ts;
show status like "sphinx_total%";
Variable_name Value
Sphinx_total 2
Sphinx_total_found 2
show status like "sphinx_word%";
Variable_name Value
Sphinx_word_count 0
Sphinx_words

View File

@ -1,34 +0,0 @@
--replace_result $SPHINXSEARCH_PORT SPHINXSEARCH_PORT
eval create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://127.0.0.1:$SPHINXSEARCH_PORT/*";
select * from ts where q='test';
drop table ts;
--replace_result $SPHINXSEARCH_PORT SPHINXSEARCH_PORT
eval create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://127.0.0.1:$SPHINXSEARCH_PORT/*";
select * from ts where q='test;filter=gid,1;mode=extended';
select * from ts where q='test|one;mode=extended';
select * from ts where q='test;offset=1;limit=1';
--replace_result $SPHINXSEARCH_PORT SPHINXSEARCH_PORT
eval alter table ts connection="sphinx://127.0.0.1:$SPHINXSEARCH_PORT/test1";
select id, w from ts where q='one';
drop table ts;
--replace_result $SPHINXSEARCH_PORT SPHINXSEARCH_PORT
eval create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, gid int not null, _sph_count int not null, index(q) ) engine=sphinx connection="sphinx://127.0.0.1:$SPHINXSEARCH_PORT/test1";
select * from ts;
select * from ts where q='';
select * from ts where q=';groupby=attr:gid';
explain select * from ts where q=';groupby=attr:gid';
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch='index_condition_pushdown=off';
explain select * from ts where q=';groupby=attr:gid';
SET optimizer_switch=@save_optimizer_switch;
drop table ts;
#
# Don't show sphinx error as this is different between sphinx versions
# show status like "sphinx_error%";
show status like "sphinx_total%";
show status like "sphinx_word%";

View File

@ -1 +0,0 @@
--plugin-load-add=$HA_SPHINX_SO --sphinx

View File

@ -1,118 +0,0 @@
package My::Suite::Sphinx;
use My::SafeProcess;
use My::File::Path;
use mtr_report;
@ISA = qw(My::Suite);
############# initialization ######################
sub locate_sphinx_binary {
my ($name)= @_;
my $res;
my @list= map "$_/$name", split /:/, $ENV{PATH};
my $env_override= $ENV{"SPHINXSEARCH_\U$name"};
@list= ($env_override) if $env_override;
for (@list) { return $_ if -x $_; }
}
# Look for Sphinx binaries.
my $exe_sphinx_indexer = &locate_sphinx_binary('indexer');
my $exe_sphinx_searchd = &locate_sphinx_binary('searchd');
return "No Sphinx" unless $exe_sphinx_indexer and $exe_sphinx_searchd;
return "No SphinxSE" unless $ENV{HA_SPHINX_SO} or
$::mysqld_variables{'sphinx'} eq "ON";
{
local $_ = `"$exe_sphinx_searchd" --help`;
mtr_verbose("tool: $exe_sphinx_searchd\n$_");
my $ver = sprintf "%04d.%04d.%04d", (/([0-9]+)\.([0-9]+)(?:\.([0-9]+))?/);
return "Sphinx 2.0.4 or later is needed (found $ver) " unless $ver ge '0002.0000.0004';
}
############# action methods ######################
sub write_sphinx_conf {
my ($config) = @_; # My::Config
my $res;
foreach my $group ($config->groups()) {
my $name= $group->{name};
# Only the ones relevant to Sphinx search.
next unless ($name eq 'indexer' or $name eq 'searchd' or
$name =~ /^(source|index) \w+$/);
$res .= "$name\n{\n";
foreach my $option ($group->options()) {
$res .= $option->name();
my $value= $option->value();
if (defined $value) {
$res .= "=$value";
}
$res .= "\n";
}
$res .= "}\n\n";
}
$res;
}
sub searchd_start {
my ($sphinx, $test) = @_; # My::Config::Group, My::Test
return unless $exe_sphinx_indexer and $exe_sphinx_searchd;
# First we must run the indexer to create the data.
my $sphinx_data_dir= "$::opt_vardir/" . $sphinx->name();
mkpath($sphinx_data_dir);
my $sphinx_log= $sphinx->value('#log-error');
my $sphinx_config= "$::opt_vardir/my_sphinx.conf";
my $cmd= "\"$exe_sphinx_indexer\" --config \"$sphinx_config\" test1 > \"$sphinx_log\" 2>&1";
&::mtr_verbose("cmd: $cmd");
system $cmd;
# Then start the searchd daemon.
my $args;
&::mtr_init_args(\$args);
&::mtr_add_arg($args, "--config");
&::mtr_add_arg($args, $sphinx_config);
&::mtr_add_arg($args, "--console");
&::mtr_add_arg($args, "--pidfile");
$sphinx->{'proc'}= My::SafeProcess->new
(
name => 'sphinx-' . $sphinx->name(),
path => $exe_sphinx_searchd,
args => \$args,
output => $sphinx_log,
error => $sphinx_log,
append => 1,
nocore => 1,
);
&::mtr_verbose("Started $sphinx->{proc}");
}
sub searchd_wait {
my ($sphinx) = @_; # My::Config::Group
return not &::sleep_until_file_created($sphinx->value('pid_file'), 20,
$sphinx->{'proc'})
}
############# declaration methods ######################
sub config_files() {
( 'my_sphinx.conf' => \&write_sphinx_conf )
}
sub servers {
( qr/^searchd$/ => {
SORT => 400,
START => \&searchd_start,
WAIT => \&searchd_wait,
}
)
}
############# return an object ######################
bless { };

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<sphinx:docset>
<sphinx:schema>
<sphinx:field name="title"/>
<sphinx:field name="content"/>
<sphinx:attr name="gid" type="int"/>
</sphinx:schema>
<sphinx:document id="1">
<title>test one</title>
<content>this is my test document number one. also checking search within phrases.</content>
<gid>1</gid>
</sphinx:document>
<sphinx:document id="2">
<title>test two</title>
<content>this is my test document number two</content>
<gid>1</gid>
</sphinx:document>
<sphinx:document id="3">
<title>another doc</title>
<content>this is another group</content>
<gid>2</gid>
</sphinx:document>
<sphinx:document id="4">
<title>doc number four</title>
<content>this is to test groups</content>
<gid>2</gid>
</sphinx:document>
</sphinx:docset>