MCPcopy
hub / github.com/sqlc-dev/sqlc / createSchema

Method createSchema

internal/sql/catalog/schema.go:98–114  ·  view source on GitHub ↗
(stmt *ast.CreateSchemaStmt)

Source from the content-addressed store, hash-verified

96}
97
98func (c *Catalog) createSchema(stmt *ast.CreateSchemaStmt) error {
99 if stmt.Name == nil {
100 return fmt.Errorf("create schema: empty name")
101 }
102 if _, err := c.getSchema(*stmt.Name); err == nil {
103 // If the default schema already exists, treat additional CREATE SCHEMA
104 // statements as no-ops.
105 if *stmt.Name == c.DefaultSchema {
106 return nil
107 }
108 if !stmt.IfNotExists {
109 return sqlerr.SchemaExists(*stmt.Name)
110 }
111 }
112 c.Schemas = append(c.Schemas, &Schema{Name: *stmt.Name})
113 return nil
114}
115
116func (c *Catalog) dropSchema(stmt *ast.DropSchemaStmt) error {
117 // TODO: n^2 in the worst-case

Callers 1

UpdateMethod · 0.95

Calls 2

getSchemaMethod · 0.95
SchemaExistsFunction · 0.92

Tested by

no test coverage detected