Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IF NOT EXISTS should be handled inside DDL interface #35665

Closed
lance6716 opened this issue Jun 23, 2022 · 0 comments · Fixed by #35819
Closed

IF NOT EXISTS should be handled inside DDL interface #35665

lance6716 opened this issue Jun 23, 2022 · 0 comments · Fixed by #35819
Labels
type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@lance6716
Copy link
Contributor

Feature Request

Is your feature request related to a problem? Please describe:

for CREATE DATABASE, IF NOT EXISTS is handled in DDL executor

tidb/executor/ddl.go

Lines 309 to 314 in 095e323

err = domain.GetDomain(e.ctx).DDL().CreateSchema(e.ctx, model.NewCIStr(s.Name), opt, placementPolicyRef)
if err != nil {
if infoschema.ErrDatabaseExists.Equal(err) && s.IfNotExists {
err = nil
}
}

for CREATE TABLE, it's handled in DDL interface

tidb/ddl/ddl_api.go

Lines 2171 to 2176 in 095e323

onExist := OnExistError
if s.IfNotExists {
onExist = OnExistIgnore
}
return d.CreateTableWithInfo(ctx, schema.Name, tbInfo, onExist)

Describe the feature you'd like:

they should be unified, so another implementation of DDL interface can have a more reasonable behaviour.

I prefer we let DDL interface handle it.

Describe alternatives you've considered:

Teachability, Documentation, Adoption, Migration Strategy:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant