ValidateCopyFrom returns an error if the CopyFrom node is invalid.
(cf *tree.CopyFrom, ctx *sql.Context)
| 23 | |
| 24 | // ValidateCopyFrom returns an error if the CopyFrom node is invalid. |
| 25 | func ValidateCopyFrom(cf *tree.CopyFrom, ctx *sql.Context) (sql.InsertableTable, error) { |
| 26 | table, err := GetSqlTableFromContext(ctx, cf.Table.Schema(), cf.Table.Table()) |
| 27 | if err != nil { |
| 28 | return nil, err |
| 29 | } |
| 30 | if table == nil { |
| 31 | return nil, fmt.Errorf(`relation "%s" does not exist`, cf.Table.Table()) |
| 32 | } |
| 33 | if it, ok := table.(sql.InsertableTable); !ok { |
| 34 | return nil, fmt.Errorf(`table "%s" is read-only`, cf.Table.Table()) |
| 35 | } else { |
| 36 | return it, nil |
| 37 | } |
| 38 | } |
| 39 | |
| 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. |
no test coverage detected