1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
DROP TABLE IF EXISTS graph2;
call mtr.add_suppression("graph_base is open on delete");
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,
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);
# Expect no result, because of autocast
SELECT * FROM graph WHERE latch=0 ;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and destid=2 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and destid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=0 and origid is NULL;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=1 ;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=1 and destid=2 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=1 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=1 and destid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=1 and origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=1 and origid is NULL;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=2 ;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=2 and destid=2 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=2 and origid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=2 and destid=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=2 and origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch=2 and origid is NULL;
latch origid destid weight seq linkid
# Should this return an error? it seems we treat it as just another bogus latch
SELECT * FROM graph WHERE latch='ThisExceeds32Characters456789012';
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='bogus' and destid=2 and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='bogus' and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='bogus' and destid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='bogus' and origid=666;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='bogus' and origid is NULL;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='666';
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='666' and destid=2 and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='666' and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='666' and destid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='666' and origid=666;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='666' and origid is NULL;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='-1';
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch='-1' and destid=2 and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='-1' and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='-1' and destid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='-1' and origid=666;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='-1' and origid is NULL;
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
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and destid=2 and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and destid=1;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid=666;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
SELECT * FROM graph WHERE latch='Ω Ohms Tennis Ball 〄' and origid is NULL;
latch origid destid weight seq linkid
Warnings:
Warning 1210 Incorrect arguments to OQGRAPH latch
# Return all edges when latch is NULL
SELECT * FROM graph WHERE latch is NULL;
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
SELECT * FROM graph WHERE latch is NULL and destid=2 and origid=1;
latch origid destid weight seq linkid
NULL 1 2 1 3 1
NULL 1 2 1 2 3
NULL 1 2 1 1 2
SELECT * FROM graph WHERE latch is NULL and origid=1;
latch origid destid weight seq linkid
NULL 1 NULL 1 2 3
NULL 1 NULL 1 1 2
SELECT * FROM graph WHERE latch is NULL and destid=1;
latch origid destid weight seq linkid
NULL NULL 1 1 2 3
NULL NULL 1 1 1 2
SELECT * FROM graph WHERE latch is NULL and origid=666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch is NULL and origid is NULL;
latch origid destid weight seq linkid
NULL NULL NULL NULL NULL 1
NULL NULL NULL NULL NULL 2
NULL NULL NULL NULL NULL 3
NULL NULL NULL NULL NULL 4
NULL NULL NULL NULL NULL 5
NULL NULL NULL NULL NULL 6
INSERT INTO graph_base(from_id, to_id) VALUES (1,2);
ERROR 23000: Duplicate entry '1-2' for key 'PRIMARY'
DELETE FROM graph_base;
SELECT * FROM graph;
latch origid destid weight seq linkid
FLUSH TABLES;
TRUNCATE TABLE graph_base;
SELECT * FROM graph;
latch origid destid weight seq linkid
DROP TABLE graph_base;
FLUSH TABLES;
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1 AND destid=6;
ERROR 42S02: Table 'test.graph_base' doesn't exist
DROP TABLE graph;
|