Skip to content

Commit

Permalink
Merge #101861
Browse files Browse the repository at this point in the history
101861: sql: add sqlsmith support to test partial visibility of indexes r=rytaft a=rytaft

Sometimes generate a partially invisible index instead of a fully invisible index.

Informs #82363

Release note: None

Co-authored-by: Rebecca Taft <[email protected]>
  • Loading branch information
craig[bot] and rytaft committed Apr 20, 2023
2 parents 0ffba81 + 7c32d97 commit d9ec744
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkg/internal/sqlsmith/alter.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ func makeCreateIndex(s *Smither) (tree.Statement, bool) {
visibility := 1.0
if notvisible := s.d6() == 1; notvisible {
visibility = 0.0
// TODO(rytaft): sometimes generate a float between (0.0,1.0).
if s.coin() {
visibility = s.rnd.Float64() // [0.0, 1.0)
}
}

return &tree.CreateIndex{
Expand Down
4 changes: 3 additions & 1 deletion pkg/sql/randgen/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ func RandCreateTableWithColumnIndexNumberGeneratorAndName(
indexDef.Invisibility = 0.0
if notvisible := rng.Intn(6) == 0; notvisible {
indexDef.Invisibility = 1.0
// TODO(rytaft): sometimes generate a float between (0.0,1.0).
if rng.Intn(2) == 0 {
indexDef.Invisibility = 1 - rng.Float64()
}
}

defs = append(defs, &indexDef)
Expand Down
4 changes: 3 additions & 1 deletion pkg/workload/schemachange/operation_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,9 @@ func (og *operationGenerator) createIndex(ctx context.Context, tx pgx.Tx) (*opSt
visibility := 1.0
if notvisible := og.randIntn(20) == 0; notvisible {
visibility = 0.0
// TODO(rytaft): sometimes generate a float between (0.0,1.0).
if og.randIntn(2) == 0 {
visibility = og.params.rng.Float64()
}
}

def := &tree.CreateIndex{
Expand Down

0 comments on commit d9ec744

Please sign in to comment.