@@ -85,9 +85,7 @@ func TestIntegration(t *testing.T) {
85
85
`SELECT COUNT(first_commit_year), first_commit_year
86
86
FROM (
87
87
SELECT YEAR(c.commit_author_when) AS first_commit_year
88
- FROM repositories r
89
- INNER JOIN ref_commits rc
90
- ON r.repository_id = rc.repository_id
88
+ FROM ref_commits rc
91
89
INNER JOIN commits c
92
90
ON rc.commit_hash = c.commit_hash
93
91
ORDER BY c.commit_author_when
@@ -101,13 +99,11 @@ func TestIntegration(t *testing.T) {
101
99
FROM (
102
100
SELECT
103
101
MONTH(committer_when) as month,
104
- r .repository_id as repo_id,
102
+ rc .repository_id as repo_id,
105
103
committer_email
106
- FROM repositories r
107
- INNER JOIN ref_commits rc ON rc.repository_id = r.repository_id
108
- AND rc.ref_name = 'refs/heads/master'
104
+ FROM ref_commits rc
109
105
INNER JOIN commits c ON rc.commit_hash = c.commit_hash
110
- WHERE YEAR(committer_when) = 2015
106
+ WHERE YEAR(committer_when) = 2015 AND rc.ref_name = 'refs/heads/master'
111
107
) as t
112
108
GROUP BY committer_email, month, repo_id` ,
113
109
[]sql.Row {
@@ -184,13 +180,13 @@ func TestUastQueries(t *testing.T) {
184
180
FROM tree_entries te
185
181
INNER JOIN blobs b
186
182
ON b.blob_hash = te.blob_hash
187
- WHERE te.tree_entry_name = 'php/ crappy.php'` ,
183
+ WHERE te.tree_entry_name = 'crappy.php'` ,
188
184
)
189
185
require .NoError (err )
190
186
191
187
rows , err := sql .RowIterToRows (iter )
192
188
require .NoError (err )
193
- require .Len (rows , 3 )
189
+ require .Len (rows , 1 )
194
190
}
195
191
196
192
func TestSquashCorrectness (t * testing.T ) {
@@ -226,9 +222,9 @@ func TestSquashCorrectness(t *testing.T) {
226
222
`SELECT * FROM refs r INNER JOIN remotes re ON r.repository_id = re.repository_id` ,
227
223
`SELECT * FROM refs r INNER JOIN commits c ON r.commit_hash = c.commit_hash` ,
228
224
`SELECT * FROM ref_commits r INNER JOIN commits c ON r.commit_hash = c.commit_hash` ,
229
- `SELECT * FROM refs r INNER JOIN tree_entries te ON commit_has_tree( r.commit_hash, te.tree_hash) ` ,
225
+ `SELECT * FROM refs r INNER JOIN commit_trees t ON r.commit_hash = t.commit_hash ` ,
230
226
`SELECT * FROM refs r INNER JOIN blobs b ON commit_has_blob(r.commit_hash, b.blob_hash)` ,
231
- `SELECT * FROM commits c INNER JOIN tree_entries te ON commit_has_tree( c.commit_hash, te .tree_hash) ` ,
227
+ `SELECT * FROM commits c INNER JOIN commit_trees t ON c.commit_hash = t .tree_hash` ,
232
228
`SELECT * FROM commits c INNER JOIN tree_entries te ON c.tree_hash = te.tree_hash` ,
233
229
`SELECT * FROM commits c INNER JOIN blobs b ON commit_has_blob(c.commit_hash, b.blob_hash)` ,
234
230
`SELECT * FROM tree_entries te INNER JOIN blobs b ON te.blob_hash = b.blob_hash` ,
@@ -241,8 +237,10 @@ func TestSquashCorrectness(t *testing.T) {
241
237
WHERE re.ref_name = 'HEAD'` ,
242
238
243
239
`SELECT * FROM commits c
240
+ INNER JOIN commit_trees t
241
+ ON c.commit_hash = t.commit_hash
244
242
INNER JOIN tree_entries te
245
- ON c .tree_hash = te.tree_hash
243
+ ON t .tree_hash = te.tree_hash
246
244
INNER JOIN blobs b
247
245
ON te.blob_hash = b.blob_hash
248
246
WHERE te.tree_entry_name = 'LICENSE'` ,
@@ -323,9 +321,9 @@ func BenchmarkQueries(b *testing.B) {
323
321
{
324
322
"query with commit_has_blob" ,
325
323
`SELECT COUNT(c.commit_hash), c.commit_hash
326
- FROM refs r
324
+ FROM ref_commits r
327
325
INNER JOIN commits c
328
- ON r.ref_name = 'HEAD' AND history_idx( r.commit_hash, c.commit_hash) >= 0
326
+ ON r.ref_name = 'HEAD' AND r.commit_hash = c.commit_hash
329
327
INNER JOIN blobs b
330
328
ON commit_has_blob(c.commit_hash, b.blob_hash)
331
329
GROUP BY c.commit_hash` ,
@@ -335,11 +333,9 @@ func BenchmarkQueries(b *testing.B) {
335
333
`SELECT COUNT(first_commit_year), first_commit_year
336
334
FROM (
337
335
SELECT YEAR(c.commit_author_when) AS first_commit_year
338
- FROM repositories r
339
- INNER JOIN refs
340
- ON r.repository_id = refs.repository_id
336
+ FROM ref_commits r
341
337
INNER JOIN commits c
342
- ON history_idx(refs .commit_hash, c.commit_hash) >= 0
338
+ ON r .commit_hash = c.commit_hash
343
339
ORDER BY c.commit_author_when
344
340
LIMIT 1
345
341
) repo_years
@@ -349,9 +345,9 @@ func BenchmarkQueries(b *testing.B) {
349
345
"query with history_idx" ,
350
346
`SELECT * FROM (
351
347
SELECT COUNT(c.commit_hash) AS num, c.commit_hash
352
- FROM refs r
348
+ FROM ref_commits r
353
349
INNER JOIN commits c
354
- ON history_idx( r.commit_hash, c.commit_hash) >= 0
350
+ ON r.commit_hash = c.commit_hash
355
351
GROUP BY c.commit_hash
356
352
) t WHERE num > 1` ,
357
353
},
0 commit comments