Skip to content

Commit

Permalink
workload/schemachange: screen for errors in createSchema op
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
jayshrivastava committed Nov 12, 2020
1 parent 26ed047 commit 79046d3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/workload/schemachange/operation_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ var opsWithExecErrorScreening = map[opType]bool{
createTableAs: true,
createView: true,
createEnum: true,
createSchema: true,

dropColumn: true,
dropColumnDefault: true,
Expand Down Expand Up @@ -1432,9 +1433,18 @@ func (og *operationGenerator) createSchema(tx *pgx.Tx) (string, error) {
if err != nil {
return "", err
}
ifNotExists := og.randIntn(2) == 0

schemaExists, err := schemaExists(tx, schemaName)
if err != nil {
return "", err
}
if schemaExists && !ifNotExists {
og.expectedExecErrors.add(pgcode.DuplicateSchema)
}

// TODO(jayshrivastava): Support authorization
stmt := rowenc.MakeSchemaName(og.randIntn(2) == 0, schemaName, security.RootUserName())
stmt := rowenc.MakeSchemaName(ifNotExists, schemaName, security.RootUserName())
return tree.Serialize(stmt), nil
}

Expand Down

0 comments on commit 79046d3

Please sign in to comment.