mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 14:02:32 +01:00
63 lines
1.9 KiB
Text
63 lines
1.9 KiB
Text
drop table if exists graph;
|
|
Warnings:
|
|
Note 1051 Unknown table 'graph'
|
|
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;
|
|
delete from graph;
|
|
insert into graph(origid, destid) values (1,2), (2,1);
|
|
insert into graph(origid, destid) values (1,3), (3,1);
|
|
insert into graph(origid, destid) values (3,4), (4,3);
|
|
insert into graph(origid, destid) values (3,5), (5,3);
|
|
insert into graph(origid, destid) values (5,6), (6,5);
|
|
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;
|
|
latch origid destid weight seq linkid
|
|
2 1 NULL 2 5 5
|
|
2 1 NULL 2 4 4
|
|
select * from graph
|
|
where latch = 2 and origid = 1 and (weight = 1 or weight = 2);
|
|
latch origid destid weight seq linkid
|
|
2 1 NULL 2 5 5
|
|
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;
|
|
latch origid destid weight seq linkid
|
|
1 1 6 NULL 0 1
|
|
1 1 6 1 1 3
|
|
1 1 6 1 2 5
|
|
1 1 6 1 3 6
|
|
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;
|
|
latch origid destid weight seq linkid
|
|
1 4 1 NULL 0 4
|
|
1 4 1 1 1 3
|
|
1 4 1 1 2 1
|
|
insert into graph (origid,destid) values (4,6);
|
|
delete from graph where origid=5;
|
|
delete from graph where origid=3 and destid=5;
|
|
select * from graph where latch=1 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;
|
|
latch origid destid weight seq linkid
|
|
truncate table graph;
|
|
drop table graph;
|