Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"sort"
"strconv"
"strings"
"sync/atomic"
"testing"
"text/tabwriter"
"time"
Expand Down Expand Up @@ -1126,7 +1127,7 @@ type logicTest struct {

// allowUnsafe is a variable which controls whether the test can access
// unsafe internals.
allowUnsafe bool
allowUnsafe atomic.Bool
}

func (t *logicTest) t() *testing.T {
Expand Down Expand Up @@ -1501,7 +1502,10 @@ func (t *logicTest) newCluster(
DisableOptimizerRuleProbability: *disableOptRuleProbability,
OptimizerCostPerturbation: *optimizerCostPerturbation,
ForceProductionValues: serverArgs.ForceProductionValues,
UnsafeOverride: func() *bool { return &t.allowUnsafe },
UnsafeOverride: func() *bool {
v := t.allowUnsafe.Load()
return &v
},
}
knobs.SQLExecutor = &sql.ExecutorTestingKnobs{
DeterministicExplain: true,
Expand Down Expand Up @@ -4649,8 +4653,8 @@ func RunLogicTest(
perErrorSummary: make(map[string][]string),
rng: rng,
declarativeCorpusCollector: cc,
allowUnsafe: true,
}
lt.allowUnsafe.Store(true)
if *printErrorSummary {
defer lt.printErrorSummary()
}
Expand Down Expand Up @@ -4940,8 +4944,8 @@ func (t *logicTest) setSafetyGate(sql string, skip bool) func() {
return func() {}
}

t.allowUnsafe = false
t.allowUnsafe.Store(false)
return func() {
t.allowUnsafe = true
t.allowUnsafe.Store(true)
}
}
16 changes: 8 additions & 8 deletions pkg/sql/logictest/parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ func (t *parallelTest) processTestFile(path string, nodeIdx int, db *gosql.DB, c
// Set up a dummy logicTest structure to use that code.
rng, _ := randutil.NewTestRand()
l := &logicTest{
rootT: t.T,
cluster: t.cluster,
nodeIdx: nodeIdx,
db: db,
user: username.RootUser,
verbose: testing.Verbose() || log.V(1),
rng: rng,
allowUnsafe: true,
rootT: t.T,
cluster: t.cluster,
nodeIdx: nodeIdx,
db: db,
user: username.RootUser,
verbose: testing.Verbose() || log.V(1),
rng: rng,
}
l.allowUnsafe.Store(true)
if err := l.processTestFile(path, logictest.TestClusterConfig{}); err != nil {
log.Dev.Errorf(context.Background(), "error processing %s: %s", path, err)
t.Error(err)
Expand Down