Skip to content
Closed
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
8 changes: 6 additions & 2 deletions internal/sql/catalog/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,15 @@ func (c *Catalog) getSchema(name string) (*Schema, error) {
}

func (c *Catalog) createSchema(stmt *ast.CreateSchemaStmt) error {
if stmt.Name == nil {
if *stmt.Name == "" {
return fmt.Errorf("create schema: empty name")
}
if _, err := c.getSchema(*stmt.Name); err == nil {
if !stmt.IfNotExists {
// If the schema is 'public' and IfNotExists is false,
// we want to ignore the error and proceed as if IfNotExists was true.
if *stmt.Name == "public" && !stmt.IfNotExists {
return nil
} else {
return sqlerr.SchemaExists(*stmt.Name)
}
}
Expand Down