Commit 9459746a authored by Andrew McDonnell's avatar Andrew McDonnell

Fix for assert in debug build, and update test case

parents 83a23f31 1b4164c1
......@@ -77,6 +77,25 @@ 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='0' and destid=2 and origid=1;
latch origid destid weight seq linkid
0 1 2 1 3 1
0 1 2 1 2 3
0 1 2 1 1 2
SELECT * FROM graph WHERE latch = 'breadth_first';
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=666;
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
# 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
# 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
......
......@@ -63,30 +63,23 @@ SELECT * FROM graph WHERE latch='dijkstras' AND origid=4 AND destid=1;
SELECT * FROM graph WHERE latch='1' AND origid=4 AND destid=1;
SELECT * FROM graph WHERE latch='no_search' and destid=2 and origid=1;
SELECT * FROM graph WHERE latch='0' and destid=2 and origid=1;
#--breadth first with no orig id etc
SELECT * FROM graph WHERE latch = 'breadth_first';
--echo # Expect no result, because of invalid latch
SELECT * FROM graph WHERE latch='bogus';
SELECT * FROM graph WHERE latch=666;
SELECT * FROM graph WHERE latch='bogus' and destid=2 and origid=1;
--echo # Make sure we dont crash if someone passed in a UTF string
SELECT * FROM graph WHERE latch='Ohms Ω Tennis Ball 〄';
--echo # Expect no result, because of autocast and deprecated syntax
SELECT * FROM graph WHERE latch=0 and destid=2 and origid=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;
......
......@@ -778,8 +778,8 @@ static int parse_latch_string_to_legacy_int(const String& value, int &latch)
char *eptr;
unsigned long int v = strtoul( latchValue.c_ptr_safe(), &eptr, 10);
if (!*eptr) {
// we had an unsigned number.
if (v > 0 && v < oqgraph::NUM_SEARCH_OP) {
// we had an unsigned number; remember 0 is valid too (nosearch))
if (v >= 0 && v < oqgraph::NUM_SEARCH_OP) {
latch = v;
return true;
}
......@@ -835,6 +835,13 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key,
// Invalid, so warn & fail
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WRONG_ARGUMENTS, ER(ER_WRONG_ARGUMENTS), "OQGRAPH latch");
table->status = STATUS_NOT_FOUND;
if (ptrdiff) /* fixes debug build assert - should be a tidier way to do this */
{
field[0]->move_field_offset(-ptrdiff);
field[1]->move_field_offset(-ptrdiff);
field[2]->move_field_offset(-ptrdiff);
}
dbug_tmp_restore_column_map(table->read_set, old_map);
return error_code(oqgraph::NO_MORE_DATA);
}
}
......
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