github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/pgwire/pgwirebase/conn.go (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package pgwirebase 12 13 import ( 14 "context" 15 16 "github.com/cockroachdb/cockroach/pkg/sql/sqlbase" 17 ) 18 19 // Conn exposes some functionality of a pgwire network connection to be 20 // used by the Copy-in subprotocol implemented in the sql package. 21 type Conn interface { 22 // Rd returns a reader to be used to consume bytes from the connection. 23 // This reader can be used with a pgwirebase.ReadBuffer for reading messages. 24 // 25 // Note that in the pgwire implementation, this reader encapsulates logic for 26 // updating connection metrics. 27 Rd() BufferedReader 28 29 // BeginCopyIn sends the message server message initiating the Copy-in 30 // subprotocol (COPY ... FROM STDIN). This message informs the client about 31 // the columns that are expected for the rows to be inserted. 32 // 33 // Currently, we only support the "text" format for COPY IN. 34 // See: https://www.postgresql.org/docs/current/static/protocol-flow.html#PROTOCOL-COPY 35 BeginCopyIn(ctx context.Context, columns []sqlbase.ResultColumn) error 36 37 // SendCommandComplete sends a serverMsgCommandComplete with the given 38 // payload. 39 SendCommandComplete(tag []byte) error 40 }