MCPcopy Create free account
hub / github.com/dolthub/doltgresql / ValidateNewViewName

Method ValidateNewViewName

server/tables/pg_database.go:223–243  ·  view source on GitHub ↗

ValidateNewViewName implements the sql.SchemaObjectNameValidator interface

(ctx *sql.Context, newViewName string, replaceAllowed bool)

Source from the content-addressed store, hash-verified

221
222// ValidateNewViewName implements the sql.SchemaObjectNameValidator interface
223func (d *PgDatabase) ValidateNewViewName(ctx *sql.Context, newViewName string, replaceAllowed bool) error {
224 relationExists, relationType, err := d.doesRelationExist(ctx, newViewName)
225 if err != nil {
226 return err
227 }
228
229 if !relationExists {
230 return nil
231 }
232
233 // When REPLACE is used, Postgres sends a different error message
234 if replaceAllowed {
235 if relationType == "view" {
236 return nil
237 } else {
238 return fmt.Errorf(`"%s" is not a view`, newViewName)
239 }
240 }
241
242 return fmt.Errorf(`relation "%s" already exists`, newViewName)
243}
244
245// ValidateNewTableName implements the sql.SchemaObjectNameValidator interface
246func (d *PgDatabase) ValidateNewTableName(ctx *sql.Context, newTableName string, skipIfExists bool) (nameAlreadyUsed bool, err error) {

Callers

nothing calls this directly

Calls 2

doesRelationExistMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected