RowIter implements the interface sql.ExecSourceRel.
(ctx *sql.Context, r sql.Row)
| 63 | |
| 64 | // RowIter implements the interface sql.ExecSourceRel. |
| 65 | func (c *DropCast) RowIter(ctx *sql.Context, r sql.Row) (sql.RowIter, error) { |
| 66 | castCollection, err := core.GetCastsCollectionFromContext(ctx, "") |
| 67 | if err != nil { |
| 68 | return nil, err |
| 69 | } |
| 70 | castID := id.NewCast(c.Source.ID, c.Target.ID) |
| 71 | if !castCollection.HasCast(ctx, castID) { |
| 72 | if c.IfExists { |
| 73 | // TODO: send notice "cast from type SOURCE_NAME to type TARGET_NAME does not exist, skipping" |
| 74 | return sql.RowsToRowIter(), nil |
| 75 | } |
| 76 | return nil, errors.Errorf("cast from type %s to type %s does not exist", c.Source.Name(), c.Target.Name()) |
| 77 | } |
| 78 | if err = castCollection.DropCast(ctx, castID); err != nil { |
| 79 | return nil, err |
| 80 | } |
| 81 | return sql.RowsToRowIter(), nil |
| 82 | } |
| 83 | |
| 84 | // Schema implements the interface sql.ExecSourceRel. |
| 85 | func (c *DropCast) Schema(ctx *sql.Context) sql.Schema { |