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

Method ValidateNewTableName

server/tables/pg_database.go:246–261  ·  view source on GitHub ↗

ValidateNewTableName implements the sql.SchemaObjectNameValidator interface

(ctx *sql.Context, newTableName string, skipIfExists bool)

Source from the content-addressed store, hash-verified

244
245// ValidateNewTableName implements the sql.SchemaObjectNameValidator interface
246func (d *PgDatabase) ValidateNewTableName(ctx *sql.Context, newTableName string, skipIfExists bool) (nameAlreadyUsed bool, err error) {
247 relationExists, _, err := d.doesRelationExist(ctx, newTableName)
248 if err != nil {
249 return false, err
250 }
251
252 if !relationExists {
253 return false, nil
254 }
255
256 if skipIfExists {
257 return true, nil
258 }
259
260 return true, fmt.Errorf(`relation "%s" already exists`, newTableName)
261}
262
263// GenerateIndexName implements the sql.IndexNameGenerator interface with PostgreSQL-compatible naming conventions:
264// - UNIQUE indexes: <table>_<col1>[_col2...]_key

Callers

nothing calls this directly

Calls 2

doesRelationExistMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected