Commit 7dad8f16 authored by Andrew McDonnell's avatar Andrew McDonnell

Skip deleted records mid table.

parent 62cb9fbe
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;
......@@ -65,6 +65,9 @@ INSERT INTO graph_base (from_id,to_id) VALUES (4,6);
#-- 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;
......@@ -76,6 +79,9 @@ DELETE FROM graph_base WHERE from_id=3 AND to_id=5;
--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;
......
......@@ -286,8 +286,11 @@ int oqgraph3::cursor::seek_next()
if (_index < 0)
{
if (int rc= table.file->ha_rnd_next(table.record[0]))
{
// We need to skip over any deleted records we encounter beyond the start of the table. Bug 796647b
int rc;
while ( ((rc= table.file->ha_rnd_next(table.record[0]))) != 0) {
if (rc == HA_ERR_RECORD_DELETED)
continue;
table.file->ha_rnd_end();
return clear_position(rc);
}
......@@ -513,7 +516,7 @@ int oqgraph3::cursor::seek_to(
if ((rc= table.file->ha_rnd_init(true)))
return clear_position(rc);
// We need to skip over any deleted records we encounter. Bug 796647
// We need to skip over any deleted records we encounter at the start of the table. Bug 796647c
while ( ((rc= table.file->ha_rnd_next(table.record[0]))) != 0) {
if (rc == HA_ERR_RECORD_DELETED)
continue;
......
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