@@ -39,10 +39,10 @@ func TestIntegration(t *testing.T) {
39
39
{
40
40
`SELECT COUNT(c.commit_hash), c.commit_hash
41
41
FROM ref_commits r
42
- INNER JOIN commits c
42
+ INNER JOIN commit_blobs c
43
43
ON r.ref_name = 'HEAD' AND r.commit_hash = c.commit_hash
44
44
INNER JOIN blobs b
45
- ON commit_has_blob(c.commit_hash, b.blob_hash)
45
+ ON c.blob_hash = b.blob_hash
46
46
GROUP BY c.commit_hash` ,
47
47
[]sql.Row {
48
48
{int32 (4 ), "1669dce138d9b841a518c64b10914d88f5e488ea" },
@@ -223,10 +223,19 @@ func TestSquashCorrectness(t *testing.T) {
223
223
`SELECT * FROM refs r INNER JOIN commits c ON r.commit_hash = c.commit_hash` ,
224
224
`SELECT * FROM ref_commits r INNER JOIN commits c ON r.commit_hash = c.commit_hash` ,
225
225
`SELECT * FROM refs r INNER JOIN commit_trees t ON r.commit_hash = t.commit_hash` ,
226
- `SELECT * FROM refs r INNER JOIN blobs b ON commit_has_blob(r.commit_hash, b.blob_hash)` ,
226
+ `SELECT * FROM refs r INNER JOIN commit_blobs b ON r.commit_hash = b.commit_hash` ,
227
+ `SELECT * FROM refs r
228
+ INNER JOIN commit_blobs cb
229
+ ON r.commit_hash = cb.commit_hash
230
+ INNER JOIN blobs b
231
+ ON cb.blob_hash = b.blob_hash` ,
227
232
`SELECT * FROM commits c INNER JOIN commit_trees t ON c.commit_hash = t.tree_hash` ,
228
233
`SELECT * FROM commits c INNER JOIN tree_entries te ON c.tree_hash = te.tree_hash` ,
229
- `SELECT * FROM commits c INNER JOIN blobs b ON commit_has_blob(c.commit_hash, b.blob_hash)` ,
234
+ `SELECT * FROM commits c
235
+ INNER JOIN commit_blobs cb
236
+ ON c.commit_hash = cb.commit_hash
237
+ INNER JOIN blobs b
238
+ ON cb.blob_hash = b.blob_hash` ,
230
239
`SELECT * FROM tree_entries te INNER JOIN blobs b ON te.blob_hash = b.blob_hash` ,
231
240
232
241
`SELECT * FROM repositories r
@@ -248,6 +257,17 @@ func TestSquashCorrectness(t *testing.T) {
248
257
`SELECT * FROM repositories,
249
258
commits c INNER JOIN tree_entries te
250
259
ON c.tree_hash = te.tree_hash` ,
260
+
261
+ `SELECT * FROM refs r
262
+ INNER JOIN ref_commits c
263
+ ON r.ref_name = c.ref_name
264
+ AND c.repository_id = r.repository_id` ,
265
+
266
+ `SELECT * FROM refs r
267
+ INNER JOIN ref_commits c
268
+ ON r.commit_hash = c.commit_hash
269
+ AND r.ref_name = c.ref_name
270
+ AND c.repository_id = r.repository_id` ,
251
271
}
252
272
253
273
for _ , q := range queries {
@@ -319,13 +339,13 @@ func BenchmarkQueries(b *testing.B) {
319
339
ON r.repository_id = rr.repository_id` ,
320
340
},
321
341
{
322
- "query with commit_has_blob " ,
342
+ "query with commit_blobs " ,
323
343
`SELECT COUNT(c.commit_hash), c.commit_hash
324
344
FROM ref_commits r
325
- INNER JOIN commits c
345
+ INNER JOIN commit_blobs c
326
346
ON r.ref_name = 'HEAD' AND r.commit_hash = c.commit_hash
327
347
INNER JOIN blobs b
328
- ON commit_has_blob(c.commit_hash, b.blob_hash)
348
+ ON c.blob_hash = b.blob_hash
329
349
GROUP BY c.commit_hash` ,
330
350
},
331
351
{
@@ -367,14 +387,18 @@ func BenchmarkQueries(b *testing.B) {
367
387
{
368
388
"join refs and blobs" ,
369
389
`SELECT * FROM refs r
390
+ INNER JOIN commit_blobs cb
391
+ ON r.commit_hash = cb.commit_hash
370
392
INNER JOIN blobs b
371
- ON commit_has_blob(r.commit_hash, b.blob_hash) ` ,
393
+ ON cb.blob_hash = b.blob_hash` ,
372
394
},
373
395
{
374
396
"join refs and blobs with filters" ,
375
397
`SELECT * FROM refs r
398
+ INNER JOIN commit_blobs cb
399
+ ON r.commit_hash = cb.commit_hash
376
400
INNER JOIN blobs b
377
- ON commit_has_blob(r.commit_hash, b.blob_hash)
401
+ ON cb.blob_hash = b.blob_hash
378
402
WHERE r.ref_name = 'refs/heads/master'` ,
379
403
},
380
404
}
0 commit comments