Skip to content

Commit

Permalink
mark unscoped commit index as not unique (#8367)
Browse files Browse the repository at this point in the history
  • Loading branch information
jycor authored Sep 18, 2024
1 parent 747985d commit a8dca5b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0
github.com/creasty/defaults v1.6.0
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.18.2-0.20240917161933-32eff493e467
github.com/dolthub/go-mysql-server v0.18.2-0.20240918043246-e3846f5468f5
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
github.com/dolthub/swiss v0.1.0
github.com/goccy/go-json v0.10.2
Expand Down
4 changes: 2 additions & 2 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662 h1:aC17hZD6iwzBwwfO5M+3oBT5E5gGRiQPdn+vzpDXqIA=
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168=
github.com/dolthub/go-mysql-server v0.18.2-0.20240917161933-32eff493e467 h1:Q1VtNuqdXiCDVdCpuOrqxHCAQaHtkHe8HMBejNQz5gc=
github.com/dolthub/go-mysql-server v0.18.2-0.20240917161933-32eff493e467/go.mod h1:m88EMm9OthVVa6qIhbpnRDpj/eYUXuNpvY/+0YWKVwc=
github.com/dolthub/go-mysql-server v0.18.2-0.20240918043246-e3846f5468f5 h1:m12ohMzoZUQExnXqWeTYziQiSwwtzjoEFBSKzBVHin8=
github.com/dolthub/go-mysql-server v0.18.2-0.20240918043246-e3846f5468f5/go.mod h1:m88EMm9OthVVa6qIhbpnRDpj/eYUXuNpvY/+0YWKVwc=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=
Expand Down
2 changes: 1 addition & 1 deletion go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (dt *UnscopedDiffTable) PartitionRows(ctx *sql.Context, partition sql.Parti

// GetIndexes implements sql.IndexAddressable
func (dt *UnscopedDiffTable) GetIndexes(ctx *sql.Context) ([]sql.Index, error) {
return index.DoltCommitIndexes(dt.dbName, dt.Name(), dt.ddb, true)
return index.DoltCommitIndexes(dt.dbName, dt.Name(), dt.ddb, false)
}

// IndexedAccess implements sql.IndexAddressable
Expand Down
18 changes: 18 additions & 0 deletions go/libraries/doltcore/sqle/enginetest/dolt_queries_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,24 @@ var DiffSystemTableScriptTests = []queries.ScriptTest{
},
},
},
{
Name: "duplicate commit_hash",
SetUpScript: []string{
"create table t1 (x int primary key)",
"create table t2 (x int primary key)",
"call dolt_add('.');",
"call dolt_commit_hash_out(@commit1, '-Am', 'commit1');",
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "select table_name from dolt_diff where commit_hash = @commit1",
Expected: []sql.Row{
{"t1"},
{"t2"},
},
},
},
},
}

var Dolt1DiffSystemTableScripts = []queries.ScriptTest{
Expand Down
12 changes: 12 additions & 0 deletions integration-tests/bats/diff.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1954,3 +1954,15 @@ SQL
[[ $output =~ "diff --dolt a/test b/test" ]] || false
[[ $output =~ "deleted table" ]] || false
}

@test "diff: duplicate commit_hash in diff" {
dolt reset --hard
dolt sql -q "create table t1 (i int primary key);"
dolt sql -q "create table t2 (j int primary key);"
dolt add .
dolt commit -m "commit 1"
run dolt sql -q "select table_name from dolt_diff where commit_hash = hashof('HEAD')"
[ $status -eq 0 ]
[[ "$output" =~ "t1" ]] || false
[[ "$output" =~ "t2" ]] || false
}

0 comments on commit a8dca5b

Please sign in to comment.