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

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

iRenamed no_search to '' and finished making all tests self-consistent and match somewhat to http://openquery.com/graph/doc and added bug references to tests
parents 73f1cd66 1c6cccea
This diff is collapsed.
This diff is collapsed.
...@@ -34,51 +34,19 @@ INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1); ...@@ -34,51 +34,19 @@ INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);
INSERT INTO graph_base(from_id, to_id) VALUES (1,3), (3,1); INSERT INTO graph_base(from_id, to_id) VALUES (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 (3,4), (4,3);
INSERT INTO graph_base(from_id, to_id) VALUES (5,6), (6,5); INSERT INTO graph_base(from_id, to_id) VALUES (5,6), (6,5);
# No Search/0 - result should return same rows as inserted for origid,destid,weight # Expect no result, because of autocast
# FIXME - THIS CODE IS CURRENTLY BROKEN - see https://bugs.launchpad.net/oqgraph/+bug/1195778 SELECT * FROM graph WHERE latch=0 ;
SELECT * FROM graph WHERE latch='no_search';
latch origid destid weight seq linkid
no_search NULL NULL NULL NULL 1
no_search NULL NULL NULL NULL 2
no_search NULL NULL NULL NULL 3
no_search NULL NULL NULL NULL 4
no_search NULL NULL NULL NULL 5
no_search NULL NULL NULL NULL 6
SELECT * FROM graph WHERE latch='no_search' and destid=2 and origid=1;
latch origid destid weight seq linkid
no_search 1 2 1 3 1
no_search 1 2 1 2 3
no_search 1 2 1 1 2
SELECT * FROM graph WHERE latch='no_search' and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='no_search' and destid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='no_search' and origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='no_search' and origid=NULL;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='0' ;
latch origid destid weight seq linkid latch origid destid weight seq linkid
0 NULL NULL NULL NULL 1 SELECT * FROM graph WHERE latch=0 and destid=2 and origid=1;
0 NULL NULL NULL NULL 2
0 NULL NULL NULL NULL 3
0 NULL NULL NULL NULL 4
0 NULL NULL NULL NULL 5
0 NULL NULL NULL NULL 6
SELECT * FROM graph WHERE latch='0' and destid=2 and origid=1;
latch origid destid weight seq linkid latch origid destid weight seq linkid
0 1 2 1 3 1 SELECT * FROM graph WHERE latch=0 and origid=1;
0 1 2 1 2 3
0 1 2 1 1 2
SELECT * FROM graph WHERE latch='0' and origid=1;
latch origid destid weight seq linkid latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='0' and destid=1; SELECT * FROM graph WHERE latch=0 and destid=1;
latch origid destid weight seq linkid latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='0' and origid=666; SELECT * FROM graph WHERE latch=0 and origid=666;
latch origid destid weight seq linkid latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='0' and origid=NULL; SELECT * FROM graph WHERE latch=0 and origid=NULL;
latch origid destid weight seq linkid latch origid destid weight seq linkid
# Expect no result, because of autocast
SELECT * FROM graph WHERE latch=1 ; SELECT * FROM graph WHERE latch=1 ;
latch origid destid weight seq linkid latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=1 and destid=2 and origid=1; SELECT * FROM graph WHERE latch=1 and destid=2 and origid=1;
...@@ -188,59 +156,6 @@ Warnings: ...@@ -188,59 +156,6 @@ Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=NULL; SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=NULL;
latch origid destid weight seq linkid latch origid destid weight seq linkid
# Expect no result, because of autocast and deprecated syntax
# Allows 0 and NULL to have same effect
SELECT * FROM graph WHERE latch=0;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and destid=2 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and destid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and origid=NULL;
latch origid destid weight seq linkid
# Expect no result, because of NULL latch
SELECT * FROM graph WHERE latch=NULL;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=NULL and destid=2 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=NULL and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=NULL and destid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=NULL and origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=NULL and origid=NULL;
latch origid destid weight seq linkid
# With no latch, original data in origid and destid columns
SELECT * FROM graph;
latch origid destid weight seq linkid
NULL 1 2 1 NULL NULL
NULL 2 1 1 NULL NULL
NULL 1 3 1 NULL NULL
NULL 3 1 1 NULL NULL
NULL 3 4 1 NULL NULL
NULL 4 3 1 NULL NULL
NULL 5 6 1 NULL NULL
NULL 6 5 1 NULL NULL
SELECT * FROM graph WHERE destid=2 and origid=1;
latch origid destid weight seq linkid
NULL 1 2 1 NULL NULL
SELECT * FROM graph WHERE origid=1;
latch origid destid weight seq linkid
NULL 1 2 1 NULL NULL
NULL 1 3 1 NULL NULL
SELECT * FROM graph WHERE destid=1;
latch origid destid weight seq linkid
NULL 2 1 1 NULL NULL
NULL 3 1 1 NULL NULL
SELECT * FROM graph WHERE origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE origid=NULL;
latch origid destid weight seq linkid
INSERT INTO graph_base(from_id, to_id) VALUES (1,2); INSERT INTO graph_base(from_id, to_id) VALUES (1,2);
ERROR 23000: Duplicate entry '1-2' for key 'PRIMARY' ERROR 23000: Duplicate entry '1-2' for key 'PRIMARY'
DELETE FROM graph_base; DELETE FROM graph_base;
......
...@@ -45,22 +45,13 @@ INSERT INTO graph_base(from_id, to_id) VALUES (1,3), (3,1); ...@@ -45,22 +45,13 @@ INSERT INTO graph_base(from_id, to_id) VALUES (1,3), (3,1);
INSERT INTO graph_base(from_id, to_id) VALUES (3,4), (4,3); INSERT INTO graph_base(from_id, to_id) VALUES (3,4), (4,3);
INSERT INTO graph_base(from_id, to_id) VALUES (5,6), (6,5); INSERT INTO graph_base(from_id, to_id) VALUES (5,6), (6,5);
--echo # No Search/0 - result should return same rows as inserted for origid,destid,weight
--echo # FIXME - THIS CODE IS CURRENTLY BROKEN - see https://bugs.launchpad.net/oqgraph/+bug/1195778
SELECT * FROM graph WHERE latch='no_search';
SELECT * FROM graph WHERE latch='no_search' and destid=2 and origid=1;
SELECT * FROM graph WHERE latch='no_search' and origid=1;
SELECT * FROM graph WHERE latch='no_search' and destid=1;
SELECT * FROM graph WHERE latch='no_search' and origid=666;
SELECT * FROM graph WHERE latch='no_search' and origid=NULL;
SELECT * FROM graph WHERE latch='0' ;
SELECT * FROM graph WHERE latch='0' and destid=2 and origid=1;
SELECT * FROM graph WHERE latch='0' and origid=1;
SELECT * FROM graph WHERE latch='0' and destid=1;
SELECT * FROM graph WHERE latch='0' and origid=666;
SELECT * FROM graph WHERE latch='0' and origid=NULL;
--echo # Expect no result, because of autocast --echo # Expect no result, because of autocast
SELECT * FROM graph WHERE latch=0 ;
SELECT * FROM graph WHERE latch=0 and destid=2 and origid=1;
SELECT * FROM graph WHERE latch=0 and origid=1;
SELECT * FROM graph WHERE latch=0 and destid=1;
SELECT * FROM graph WHERE latch=0 and origid=666;
SELECT * FROM graph WHERE latch=0 and origid=NULL;
SELECT * FROM graph WHERE latch=1 ; SELECT * FROM graph WHERE latch=1 ;
SELECT * FROM graph WHERE latch=1 and destid=2 and origid=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 origid=1;
...@@ -108,35 +99,18 @@ SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=666; ...@@ -108,35 +99,18 @@ SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=666;
#-- Note the next line couter-intuitively produces no warning #-- Note the next line couter-intuitively produces no warning
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=NULL; SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=NULL;
--echo # Expect no result, because of autocast and deprecated syntax #--echo # Expect no result, because of NULL latch
--echo # Allows 0 and NULL to have same effect #-- FIXME - in v2 according to http://openquery.com/graph/doc NULL latch should
#-- Note the next line couter-intuitively produces no warning #-- FIXME - return same as select * from graph;
SELECT * FROM graph WHERE latch=0; #--https://bugs.launchpad.net/oqgraph/+bug/1196021
SELECT * FROM graph WHERE latch=0 and destid=2 and origid=1; #SELECT * FROM graph WHERE latch=NULL;
SELECT * FROM graph WHERE latch=0 and origid=1; #SELECT * FROM graph WHERE latch=NULL and destid=2 and origid=1;
SELECT * FROM graph WHERE latch=0 and destid=1; #SELECT * FROM graph WHERE latch=NULL and origid=1;
SELECT * FROM graph WHERE latch=0 and origid=666; #SELECT * FROM graph WHERE latch=NULL and destid=1;
#-- Note the next line couter-intuitively produces no warning #SELECT * FROM graph WHERE latch=NULL and origid=666;
SELECT * FROM graph WHERE latch=0 and origid=NULL; #SELECT * FROM graph WHERE latch=NULL and origid=NULL;
--echo # Expect no result, because of NULL latch #-- what happens if we have two links the same? primay key violation...
SELECT * FROM graph WHERE latch=NULL;
SELECT * FROM graph WHERE latch=NULL and destid=2 and origid=1;
SELECT * FROM graph WHERE latch=NULL and origid=1;
SELECT * FROM graph WHERE latch=NULL and destid=1;
SELECT * FROM graph WHERE latch=NULL and origid=666;
SELECT * FROM graph WHERE latch=NULL and origid=NULL;
--echo # With no latch, original data in origid and destid columns
#-- Note, weight==1 in this case
SELECT * FROM graph;
SELECT * FROM graph WHERE destid=2 and origid=1;
SELECT * FROM graph WHERE origid=1;
SELECT * FROM graph WHERE destid=1;
SELECT * FROM graph WHERE origid=666;
SELECT * FROM graph WHERE origid=NULL;
#-- what happens if we have two links the same?
--error 1062 --error 1062
INSERT INTO graph_base(from_id, to_id) VALUES (1,2); INSERT INTO graph_base(from_id, to_id) VALUES (1,2);
......
...@@ -48,6 +48,11 @@ CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, dest ...@@ -48,6 +48,11 @@ CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, dest
DESCRIBE oqtable; DESCRIBE oqtable;
ERROR 42S02: Table 'test.bogus' doesn't exist ERROR 42S02: Table 'test.bogus' doesn't exist
DROP TABLE IF EXISTS oqtable; 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'; 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)' # Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)'
DESCRIBE oqtable; DESCRIBE oqtable;
......
...@@ -78,15 +78,14 @@ CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, dest ...@@ -78,15 +78,14 @@ CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, dest
--error 1146 --error 1146
DESCRIBE oqtable; DESCRIBE oqtable;
# FIXME - I dont know what this test was for # Table exists but no orig or dest specified
# FIXME - Are we checking that the backing tbale has a primary key etc., or doesn't it matter? --disable_warnings
# invalid table reference DROP TABLE IF EXISTS oqtable;
#--disable_warnings --enable_warnings
#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';
#--enable_warnings --echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)'
#CREATE TABLE oqtable ( latch varchar(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY #(latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='not_backing'; --error 1296
#--error 1296 DESCRIBE oqtable;
#DESCRIBE oqtable;
# missing origid # missing origid
--disable_warnings --disable_warnings
......
...@@ -81,7 +81,7 @@ static MYSQL_SYSVAR_BOOL(allow_create_integer_latch, g_allow_create_integer_latc ...@@ -81,7 +81,7 @@ static MYSQL_SYSVAR_BOOL(allow_create_integer_latch, g_allow_create_integer_latc
// In the future this needs to be refactactored to live somewhere else // In the future this needs to be refactactored to live somewhere else
struct oqgraph_latch_op_table { const char *key; int latch; }; struct oqgraph_latch_op_table { const char *key; int latch; };
static const oqgraph_latch_op_table latch_ops_table[] = { static const oqgraph_latch_op_table latch_ops_table[] = {
{ "no_search", oqgraph::NO_SEARCH } , { "", oqgraph::NO_SEARCH } , // suggested by Arjen, use empty string instead of no_search
{ "dijkstras", oqgraph::DIJKSTRAS } , { "dijkstras", oqgraph::DIJKSTRAS } ,
{ "breadth_first", oqgraph::BREADTH_FIRST } , { "breadth_first", oqgraph::BREADTH_FIRST } ,
{ NULL, -1 } { NULL, -1 }
...@@ -786,7 +786,7 @@ static int parse_latch_string_to_legacy_int(const String& value, int &latch) ...@@ -786,7 +786,7 @@ static int parse_latch_string_to_legacy_int(const String& value, int &latch)
char *eptr; char *eptr;
unsigned long int v = strtoul( latchValue.c_ptr_safe(), &eptr, 10); unsigned long int v = strtoul( latchValue.c_ptr_safe(), &eptr, 10);
if (!*eptr) { if (!*eptr) {
// we had an unsigned number; remember 0 is valid too (nosearch)) // we had an unsigned number; remember 0 is valid too ('vertices' aka 'no_search'))
if (v >= 0 && v < oqgraph::NUM_SEARCH_OP) { if (v >= 0 && v < oqgraph::NUM_SEARCH_OP) {
latch = v; latch = v;
return true; return true;
...@@ -996,7 +996,7 @@ int ha_oqgraph::rnd_next(byte *buf) ...@@ -996,7 +996,7 @@ int ha_oqgraph::rnd_next(byte *buf)
{ {
int res; int res;
open_query::row row; open_query::row row;
if (!(res= graph->fetch_row(row))) if (!(res= graph->fetch_row(row))) // FIXME - this called after DELETE FROM graph_base; hangs...
res= fill_record(buf, row); res= fill_record(buf, row);
table->status= res ? STATUS_NOT_FOUND: 0; table->status= res ? STATUS_NOT_FOUND: 0;
return error_code(res); return error_code(res);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment