(stmt *ast.RenameTableStmt)
| 423 | } |
| 424 | |
| 425 | func (c *Catalog) renameTable(stmt *ast.RenameTableStmt) error { |
| 426 | sch, tbl, err := c.getTable(stmt.Table) |
| 427 | if err != nil { |
| 428 | return checkMissing(err, stmt.MissingOk) |
| 429 | } |
| 430 | if _, _, err := sch.getTable(&ast.TableName{Name: *stmt.NewName}); err == nil { |
| 431 | return sqlerr.RelationExists(*stmt.NewName) |
| 432 | } |
| 433 | if stmt.NewName != nil { |
| 434 | tbl.Rel.Name = *stmt.NewName |
| 435 | } |
| 436 | |
| 437 | for idx := range tbl.Columns { |
| 438 | if tbl.Columns[idx].linkedType { |
| 439 | name := fmt.Sprintf("%s_%s", *stmt.NewName, tbl.Columns[idx].Name) |
| 440 | rename := &ast.RenameTypeStmt{ |
| 441 | Type: &tbl.Columns[idx].Type, |
| 442 | NewName: &name, |
| 443 | } |
| 444 | if err := c.renameType(rename); err != nil { |
| 445 | return err |
| 446 | } |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | return nil |
| 451 | } |
| 452 | |
| 453 | func (c *Catalog) createTableAs(stmt *ast.CreateTableAsStmt, colGen columnGenerator) error { |
| 454 | cols, err := colGen.OutputColumns(stmt.Query) |
no test coverage detected