mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
221 lines
4.8 KiB
Text
221 lines
4.8 KiB
Text
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;
|