From 1db0278c8b5983616d3df00944c113f41a02c35a Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Tue, 28 May 2013 22:10:27 +0930 Subject: [PATCH] Updated basic test for varchar latch only --- mysql-test/suite/oqgraph/basic.result | 89 +++++++++++--- mysql-test/suite/oqgraph/basic.test | 161 +++++++++----------------- 2 files changed, 125 insertions(+), 125 deletions(-) diff --git a/mysql-test/suite/oqgraph/basic.result b/mysql-test/suite/oqgraph/basic.result index cb8396ae14d..863ff57a26f 100644 --- a/mysql-test/suite/oqgraph/basic.result +++ b/mysql-test/suite/oqgraph/basic.result @@ -1,5 +1,19 @@ 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, @@ -7,7 +21,7 @@ PRIMARY KEY (from_id,to_id), INDEX (to_id) ) ENGINE=MyISAM; CREATE TABLE graph ( -latch SMALLINT UNSIGNED NULL, +latch VARCHAR(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, @@ -20,42 +34,79 @@ 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 = 'breadth_first' AND origid = 1 AND weight = 1; +latch origid destid weight seq linkid +breadth_first 1 NULL 1 3 3 +breadth_first 1 NULL 1 2 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 +# Expect no result, because of autocast and deprecated syntax 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; +# Expect no result between 1,6 because no connection exists +SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6; 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); +SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=6; latch origid destid weight seq linkid -2 1 NULL 2 4 4 -2 1 NULL 1 3 3 -2 1 NULL 1 2 2 -SELECT * FROM graph WHERE latch=1 AND origid=1 AND destid=6; +# Expect result between 4,1 because connection exists via 3 +SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=4; latch origid destid weight seq linkid -SELECT * FROM graph WHERE latch=1 AND origid=1 AND destid=4; +dijkstras 1 4 NULL 0 1 +dijkstras 1 4 1 1 3 +dijkstras 1 4 1 2 4 +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; +# and the reverse direction +SELECT * FROM graph WHERE latch='dijkstras' AND origid=4 AND destid=1; +latch origid destid weight seq linkid +dijkstras 4 1 NULL 0 4 +dijkstras 4 1 1 1 3 +dijkstras 4 1 1 2 1 +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='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 +# Expect no result, because of autocast and deprecated syntax +SELECT * FROM graph WHERE latch=0 and destid=2 and origid=1; +latch origid destid weight seq linkid +# Expect no result, because of NULL latch +SELECT * FROM graph WHERE latch=NULL and destid=2 and origid=1; +latch origid destid weight seq linkid +SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND (weight = 1 OR weight = 2); +latch origid destid weight seq linkid +breadth_first 1 NULL 2 4 4 +breadth_first 1 NULL 1 3 3 +breadth_first 1 NULL 1 2 2 +# Now we add a connection from 4->6 INSERT INTO graph_base (from_id,to_id) VALUES (4,6); +# 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; -SELECT * FROM graph WHERE latch=1 AND origid=1 AND destid=6; +# 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; 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; +dijkstras 1 6 NULL 0 1 +dijkstras 1 6 1 1 3 +dijkstras 1 6 1 2 4 +dijkstras 1 6 1 3 6 +# but not 6>4>3>1 +SELECT * FROM graph WHERE latch='dijkstras' AND origid=6 AND destid=1; latch origid destid weight seq linkid DELETE FROM graph_base; FLUSH TABLES; TRUNCATE TABLE graph_base; -DROP TABLE graph, 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; diff --git a/mysql-test/suite/oqgraph/basic.test b/mysql-test/suite/oqgraph/basic.test index cd0c3e5b7fa..9cc20b5e2c4 100644 --- a/mysql-test/suite/oqgraph/basic.test +++ b/mysql-test/suite/oqgraph/basic.test @@ -4,7 +4,6 @@ DROP TABLE IF EXISTS graph; DROP TABLE IF EXISTS graph2; --enable_warnings - CREATE TABLE graph2 ( latch VARCHAR(32) NULL, origid BIGINT UNSIGNED NULL, @@ -15,12 +14,12 @@ CREATE TABLE graph2 ( 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; --- expect fail as follows: --- ERROR 1146 (42S02): Table 'test.graph_base' doesn't exist --- because base graph is a necessary precondition at this point DROP TABLE graph2; +# Create the backing store CREATE TABLE graph_base ( from_id INT UNSIGNED NOT NULL, to_id INT UNSIGNED NOT NULL, @@ -28,45 +27,8 @@ CREATE TABLE graph_base ( INDEX (to_id) ) ENGINE=MyISAM; --- Backwards compat test - should provide a deprecation warning if we do show warnings -SET GLOBAL oqgraph_allow_create_integer_latch=false; --- We need to expect the following to fail 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'; - --- expected: ---| Warning | 140 | Integer latch is not supported for new tables. | ---| Error | 1005 | Can't create table 'test.graph' (errno: 140 "Wrong create options") | - --- Backwards compat testng - should provide a deprecation warning if we do --- show warnings - and let us create a integer latch so that we can check --- upgrade behaviour -SET GLOBAL oqgraph_allow_create_integer_latch=true; -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'; --- Expected: --- | 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; - - -CREATE TABLE graph2 ( latch VARCHAR(32) NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, @@ -83,87 +45,74 @@ 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 = 'breadth_first' AND origid = 1 AND weight = 1; +# The next works, we allow stringized latch integer to ease migration +SELECT * FROM graph WHERE latch = '2' AND origid = 1 AND weight = 1; +# Expect the next to return no results, due to autocast and use of deprecated syntax... +--echo # Expect no result, because of autocast and deprecated syntax SELECT * FROM graph WHERE latch = 2 AND origid = 1 AND weight = 1; +--echo # Expect no result between 1,6 because no connection exists +SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6; +SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=6; +--echo # Expect result between 4,1 because connection exists via 3 +SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=4; +SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=4; +--echo # and the reverse direction +SELECT * FROM graph WHERE latch='dijkstras' AND origid=4 AND destid=1; +SELECT * FROM graph WHERE latch='1' AND origid=4 AND destid=1; --- expected: --- +-------+--------+--------+--------+------+--------+ --- | latch | origid | destid | weight | seq | linkid | --- +-------+--------+--------+--------+------+--------+ --- | 2 | 1 | NULL | 1 | 3 | 3 | --- | 2 | 1 | NULL | 1 | 2 | 2 | --- +-------+--------+--------+--------+------+--------+ --- reset query cache ; flush query cache; +SELECT * FROM graph WHERE latch='no_search' and destid=2 and origid=1; -SELECT * FROM graph2 WHERE latch = 'breadth_first' AND origid = 1 AND weight = 1; -- works -SELECT * FROM graph2 WHERE latch = '2' AND origid = 1 AND weight = 1; -- as above --- above works, we allow stringized latch integer to ease migration -SELECT * FROM graph2 WHERE latch = 2 AND origid = 1 AND weight = 1; --- Expect the above to fail due to autocast and use of deprecated syntax... +--echo # Expect no result, because of autocast and deprecated syntax +SELECT * FROM graph WHERE latch=0 and destid=2 and origid=1; -SELECT * FROM graph2 WHERE latch='dijkstras' AND origid=1 AND destid=6; -SELECT * FROM graph2 WHERE latch='1' AND origid=1 AND destid=6; -SELECT * FROM graph2 WHERE latch='dijkstras' AND origid=1 AND destid=4; -SELECT * FROM graph2 WHERE latch='1' AND origid=1 AND destid=4; -SELECT * FROM graph2 WHERE latch='dijkstras' AND origid=4 AND destid=1; -SELECT * FROM graph2 WHERE latch='1' AND origid=4 AND destid=1; - -SELECT * FROM graph2 WHERE latch='no_search' and destid=2 and origid=1; -- works - -SELECT * FROM graph2 WHERE latch=0 and destid=2 and origid=1; --- Expect the above to fail due to autocast... - --- FIXME SELECT * FROM graph2 WHERE latch='0' and destid=2 and origid=1; -- causes assertion (at least in debug build, havent tested normal) --- sql/mysqld(my_print_stacktrace+0x35)[0xdbbc02] --- sql/mysqld(handle_fatal_signal+0x355)[0x7dfd05] --- /lib/libpthread.so.0(+0xeff0)[0x7f4810addff0] --- /lib/libc.so.6(gsignal+0x35)[0x7f480feda1b5] --- /lib/libc.so.6(abort+0x180)[0x7f480fedcfc0] --- /lib/libc.so.6(__assert_fail+0xf1)[0x7f480fed3301] --- sql/mysqld(_ZN7handler8ha_resetEv+0x8b)[0x7eb6a9] --- sql/mysqld(_Z18close_thread_tableP3THDPP5TABLE+0x297)[0x5b1207] --- sql/mysqld[0x5b09c4] --- sql/mysqld(_Z19close_thread_tablesP3THD+0x33f)[0x5b0f5d] --- sql/mysqld(_Z21mysql_execute_commandP3THD+0x7fe9)[0x61cc6b] --- sql/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x268)[0x61f9ec] --- sql/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0xc3e)[0x6129ba] --- sql/mysqld(_Z10do_commandP3THD+0x33f)[0x611b35] --- sql/mysqld(_Z24do_handle_one_connectionP3THD+0x1f6)[0x721ba9] --- sql/mysqld(handle_one_connection+0x33)[0x721651] --- /lib/libpthread.so.0(+0x68ca)[0x7f4810ad58ca] --- /lib/libc.so.6(clone+0x6d)[0x7f480ff7792d] - -SELECT * FROM graph2 WHERE latch=NULL and destid=2 and origid=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); -SELECT * FROM graph2 WHERE latch = 'breadth_first' AND origid = 1 AND (weight = 1 OR weight = 2); - -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; +#-- FIXME SELECT * FROM graph2 WHERE latch='0' and destid=2 and origid=1; -- causes assertion (at least in debug build, havent tested normal) +#-- sql/mysqld(my_print_stacktrace+0x35)[0xdbbc02] +#-- sql/mysqld(handle_fatal_signal+0x355)[0x7dfd05] +#-- /lib/libpthread.so.0(+0xeff0)[0x7f4810addff0] +#-- /lib/libc.so.6(gsignal+0x35)[0x7f480feda1b5] +#-- /lib/libc.so.6(abort+0x180)[0x7f480fedcfc0] +#-- /lib/libc.so.6(__assert_fail+0xf1)[0x7f480fed3301] +#-- sql/mysqld(_ZN7handler8ha_resetEv+0x8b)[0x7eb6a9] +#-- sql/mysqld(_Z18close_thread_tableP3THDPP5TABLE+0x297)[0x5b1207] +#-- sql/mysqld[0x5b09c4] +#-- sql/mysqld(_Z19close_thread_tablesP3THD+0x33f)[0x5b0f5d] +#-- sql/mysqld(_Z21mysql_execute_commandP3THD+0x7fe9)[0x61cc6b] +#-- sql/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x268)[0x61f9ec] +#-- sql/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0xc3e)[0x6129ba] +#-- sql/mysqld(_Z10do_commandP3THD+0x33f)[0x611b35] +#-- sql/mysqld(_Z24do_handle_one_connectionP3THD+0x1f6)[0x721ba9] +#-- sql/mysqld(handle_one_connection+0x33)[0x721651] +#-- /lib/libpthread.so.0(+0x68ca)[0x7f4810ad58ca] +#-- /lib/libc.so.6(clone+0x6d)[0x7f480ff7792d] +--echo # Expect no result, because of NULL latch +SELECT * FROM graph WHERE latch=NULL and destid=2 and origid=1; +SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND (weight = 1 OR weight = 2); +--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; -SELECT * FROM graph WHERE latch=1 AND origid=1 AND destid=6; -SELECT * FROM graph WHERE latch=1 AND origid=6 AND destid=1; - -SELECT * FROM graph2 WHERE latch='dijkstras' AND origid=1 AND destid=6; -SELECT * FROM graph2 WHERE latch='dijkstras' AND origid=6 AND destid=1; +--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 +SELECT * FROM graph WHERE latch='dijkstras' AND origid=6 AND destid=1; DELETE FROM graph_base; FLUSH TABLES; TRUNCATE TABLE graph_base; -DROP TABLE graph, graph_base; +DROP TABLE graph_base; + +# Expect error if we pull the table out from under +--error S42S02 +SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6; + +DROP TABLE graph; -SELECT * FROM graph2 WHERE latch='dijkstras' AND origid=1 AND destid=6; --- expect fail as follows: --- ERROR 1146 (42S02): Table 'test.graph_base' doesn't exist --- because base graph is a necessary precondition at this point