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

Function ValidateCopyTo

pgserver/validate.go:42–57  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
42func 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}

Callers 1

handleCopyToStdoutMethod · 0.85

Calls 3

GetSqlTableFromContextFunction · 0.85
TableMethod · 0.80
SchemaMethod · 0.45

Tested by

no test coverage detected