CreateView implements the DDL interface.
(ctx sessionctx.Context, s *ast.CreateViewStmt)
| 261 | |
| 262 | // CreateView implements the DDL interface. |
| 263 | func (d *SchemaTracker) CreateView(ctx sessionctx.Context, s *ast.CreateViewStmt) error { |
| 264 | viewInfo, err := ddl.BuildViewInfo(s) |
| 265 | if err != nil { |
| 266 | return err |
| 267 | } |
| 268 | |
| 269 | cols := make([]*table.Column, len(s.Cols)) |
| 270 | for i, v := range s.Cols { |
| 271 | cols[i] = table.ToColumn(&model.ColumnInfo{ |
| 272 | Name: v, |
| 273 | ID: int64(i), |
| 274 | Offset: i, |
| 275 | State: model.StatePublic, |
| 276 | }) |
| 277 | } |
| 278 | |
| 279 | tbInfo, err := ddl.BuildTableInfo(ddl.NewMetaBuildContextWithSctx(ctx), s.ViewName.Name, cols, nil, "", "") |
| 280 | if err != nil { |
| 281 | return err |
| 282 | } |
| 283 | tbInfo.View = viewInfo |
| 284 | |
| 285 | onExist := ddl.OnExistError |
| 286 | if s.OrReplace { |
| 287 | onExist = ddl.OnExistReplace |
| 288 | } |
| 289 | |
| 290 | return d.CreateTableWithInfo(ctx, s.ViewName.Schema, tbInfo, nil, ddl.WithOnExist(onExist)) |
| 291 | } |
| 292 | |
| 293 | // DropTable implements the DDL interface. |
| 294 | func (d *SchemaTracker) DropTable(_ sessionctx.Context, stmt *ast.DropTableStmt) (err error) { |
nothing calls this directly
no test coverage detected