MCPcopy Create free account
hub / github.com/apecloud/myduckserver / ValidateCopyFrom

Function ValidateCopyFrom

pgserver/validate.go:25–38  ·  view source on GitHub ↗

ValidateCopyFrom returns an error if the CopyFrom node is invalid.

(cf *tree.CopyFrom, ctx *sql.Context)

Source from the content-addressed store, hash-verified

23
24// ValidateCopyFrom returns an error if the CopyFrom node is invalid.
25func 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.

Callers 1

Calls 3

GetSqlTableFromContextFunction · 0.85
TableMethod · 0.80
SchemaMethod · 0.45

Tested by

no test coverage detected