mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-30 10:45:18 -06:00
Merge pull request #8300 from dolthub/nicktobey/show-secondary
Fix nil panic in using `dolt show` to inspect secondary indexes.
This commit is contained in:
@@ -297,10 +297,10 @@ func (sm SerialMessage) HumanReadableStringAtIndentationLevel(level int) string
|
||||
level += 1
|
||||
numSecondaryIndexes := msg.SecondaryIndexesLength()
|
||||
for i := 0; i < numSecondaryIndexes; i++ {
|
||||
var index *serial.Index
|
||||
_, _ = msg.TrySecondaryIndexes(index, i)
|
||||
var index serial.Index
|
||||
_, _ = msg.TrySecondaryIndexes(&index, i)
|
||||
printWithIndendationLevel(level, ret, "{\n")
|
||||
printIndex(level+1, ret, index)
|
||||
printIndex(level+1, ret, &index)
|
||||
printWithIndendationLevel(level, ret, "}\n")
|
||||
}
|
||||
level -= 1
|
||||
|
||||
@@ -316,4 +316,30 @@ EOF
|
||||
[[ "$output" =~ "Comment: " ]] || false
|
||||
[[ "$output" =~ "Checks: [" ]] || false
|
||||
[[ "$output" =~ "Collation: utf8mb4_0900_bin" ]] || false
|
||||
}
|
||||
|
||||
@test "show: secondary index leaf" {
|
||||
dolt sql <<EOF
|
||||
create table test(pk int primary key, v2 int unique);
|
||||
insert into test values (0, 35), (1, 19), (2, 3);
|
||||
EOF
|
||||
run dolt show "#9afhmiubuqjviu4qocn15tqlgigea26l"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "SerialMessage" ]] || false
|
||||
[[ "$output" =~ "{ key: 03000000, 02000000 value: }" ]] || false
|
||||
[[ "$output" =~ "{ key: 13000000, 01000000 value: }" ]] || false
|
||||
[[ "$output" =~ "{ key: 23000000, 00000000 value: }" ]] || false
|
||||
}
|
||||
|
||||
@test "show: secondary index non-leaf" {
|
||||
dolt sql <<EOF
|
||||
create table test(pk int primary key, v1 int, index(v1));
|
||||
insert into test values (1, 0);
|
||||
EOF
|
||||
for i in {1..10}; do dolt sql -q "insert ignore into test select 2*(pk+$i), (pk+$i) from test;"; done
|
||||
run dolt show "#3ir2otqqb8pnu28um6jc1ipv05iamdlk"
|
||||
[ $status -eq 0 ]
|
||||
[[ "$output" =~ "SerialMessage" ]] || false
|
||||
[[ "$output" =~ "{ key: 73000000, e6000000 ref: #pdcuscnfqsusgil1642k5hup1cp5co6t }" ]] || false
|
||||
[[ "$output" =~ "{ key: f4090000, e8130000 ref: #hddhk8djkj275q1so9fs3ag48v7qsfsi }" ]] || false
|
||||
}
|
||||
Reference in New Issue
Block a user