ValidateCopyTo returns an error if the CopyTo node is invalid, for example if it contains columns that are not in the table schema.
(ct *tree.CopyTo, ctx *sql.Context)
| 40 | // ValidateCopyTo returns an error if the CopyTo node is invalid, for example if it contains columns that |
| 41 | // are not in the table schema. |
| 42 | func ValidateCopyTo(ct *tree.CopyTo, ctx *sql.Context) (sql.Table, error) { |
| 43 | if ct.Table.Table() == "" { |
| 44 | if ct.Statement == nil { |
| 45 | return nil, fmt.Errorf("no table specified") |
| 46 | } |
| 47 | return nil, nil |
| 48 | } |
| 49 | table, err := GetSqlTableFromContext(ctx, ct.Table.Schema(), ct.Table.Table()) |
| 50 | if err != nil { |
| 51 | return nil, err |
| 52 | } |
| 53 | if table == nil { |
| 54 | return nil, fmt.Errorf(`relation "%s" does not exist`, ct.Table.Table()) |
| 55 | } |
| 56 | return table, nil |
| 57 | } |
no test coverage detected