Skip to content

Commit

Permalink
tpccbench: fix existing dataset fast-path
Browse files Browse the repository at this point in the history
This skewed with cockroachdb#24735, which changed the output of information_schema
when connecting to an implicit database.

Release note: None
  • Loading branch information
nvanbenschoten committed May 24, 2018
1 parent 0b90b41 commit 01cb8d4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/cmd/roachtest/tpcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ import (
"strings"
"time"

"github.com/lib/pq"
"github.com/pkg/errors"

"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/util/color"
"github.com/cockroachdb/cockroach/pkg/util/search"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/pkg/errors"
)

func registerTPCC(r *registry) {
Expand Down Expand Up @@ -138,15 +141,9 @@ func loadTPCCBench(

// Check if the dataset already exists and is already large enough to
// accommodate this benchmarking. If so, we can skip the fixture RESTORE.
var tableExists bool
if err := db.QueryRowContext(ctx, `
SELECT COUNT(*) > 0
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_CATALOG = 'tpcc' AND TABLE_NAME = 'warehouse'`,
).Scan(&tableExists); err != nil {
return err
}
if tableExists {
if _, err := db.ExecContext(ctx, `USE tpcc`); err == nil {
c.l.printf("found existing tpcc database\n")

var curWarehouses int
if err := db.QueryRowContext(ctx,
`SELECT COUNT(*) FROM tpcc.warehouse`,
Expand All @@ -162,6 +159,9 @@ func loadTPCCBench(
// before restoring.
c.Wipe(ctx, roachNodes)
c.Start(ctx, roachNodes)
} else if pqErr, ok := err.(*pq.Error); !ok ||
string(pqErr.Code) != pgerror.CodeInvalidCatalogNameError {
return err
}

// Load the corresponding fixture.
Expand Down

0 comments on commit 01cb8d4

Please sign in to comment.