Skip to content

Commit

Permalink
workload/schemachange: screen for errors in dropSchema 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 79046d3 commit 6ebfb07
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/workload/schemachange/operation_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ var opsWithExecErrorScreening = map[opType]bool{
dropColumn: true,
dropColumnDefault: true,
dropColumnNotNull: true,
dropSchema: true,

renameColumn: true,
renameTable: true,
Expand Down Expand Up @@ -1473,6 +1474,16 @@ func (og *operationGenerator) dropSchema(tx *pgx.Tx) (string, error) {
if err != nil {
return "", err
}

schemaExists, err := schemaExists(tx, schemaName)
if err != nil {
return "", err
}
codesWithConditions{
{pgcode.UndefinedSchema, !schemaExists},
{pgcode.InvalidSchemaName, schemaName == tree.PublicSchema},
}.add(og.expectedExecErrors)

return fmt.Sprintf(`DROP SCHEMA "%s" CASCADE`, schemaName), nil
}

Expand Down

0 comments on commit 6ebfb07

Please sign in to comment.