Skip to content

Commit c1d56c3

Browse files
committed
options: don't tolerate invalid KeySchema in MakeWriterOptions
If `KeySchema` isn't found in the map, we silently fall back to the default key schema. We now panic in this case.
1 parent 8273c9c commit c1d56c3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

options.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/cockroachdb/pebble/sstable/colblk"
3333
"github.com/cockroachdb/pebble/vfs"
3434
"github.com/cockroachdb/pebble/wal"
35+
"github.com/cockroachdb/redact"
3536
)
3637

3738
const (
@@ -2125,7 +2126,13 @@ func (o *Options) MakeWriterOptions(level int, format sstable.TableFormat) sstab
21252126
writerOpts.FilterPolicy = levelOpts.FilterPolicy
21262127
writerOpts.FilterType = levelOpts.FilterType
21272128
writerOpts.IndexBlockSize = levelOpts.IndexBlockSize
2128-
writerOpts.KeySchema = o.KeySchemas[o.KeySchema]
2129+
if o.KeySchema != "" {
2130+
var ok bool
2131+
writerOpts.KeySchema, ok = o.KeySchemas[o.KeySchema]
2132+
if !ok {
2133+
panic(fmt.Sprintf("invalid schema %q", redact.Safe(o.KeySchema)))
2134+
}
2135+
}
21292136
writerOpts.AllocatorSizeClasses = o.AllocatorSizeClasses
21302137
writerOpts.NumDeletionsThreshold = o.Experimental.NumDeletionsThreshold
21312138
writerOpts.DeletionSizeRatioThreshold = o.Experimental.DeletionSizeRatioThreshold

0 commit comments

Comments
 (0)