On Thu, Nov 7, 2013 at 2:22 AM, Oliver Tonnhofer
<notifications@github.com> wrote:
>
> In conn.go:
>
> > @@ -438,6 +470,9 @@ func (cn *conn) prepareToSimpleStmt(q, stmtName string) (_ *stmt, err error) {
> >  }
> >
> >  func (cn *conn) Prepare(q string) (driver.Stmt, error) {
> > + if len(q) >= 4 && strings.EqualFold(q[:4], "COPY") {
>
> .Exec() returns a Result. .Query() returns *Rows which has .Next() and .Scan(). It could (and IMO should) decode the output and return the right data types. So from the API, similar to a SELECT.

This can only work if you are up for parsing the entire COPY and
supporting every combination of options under the sun, or somehow
restrict the forms of COPY the user is allowed to do.  Consider this
plethora of options:

 FORMAT format_name
    OIDS [ boolean ]
    DELIMITER 'delimiter_character'
    NULL 'null_string'
    HEADER [ boolean ]
    QUOTE 'quote_character'
    ESCAPE 'escape_character'
    FORCE_QUOTE { ( column_name [, ...] ) | * }
    FORCE_NOT_NULL ( column_name [, ...] )
    ENCODING 'encoding_name'

I don't *think* these are echoed back to the client form the server,
even, so one could have a chance of knowing what is going on without
being able to parse COPY, which seems like a bigger yak to shave than
one might want.